return engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE).has(name, true).hasNext();
}
private Set<Class<? extends Migrator>> findClasses(Reflections reflections) {
- Set<Class<? extends Migrator>> migratorClasses = reflections.getSubTypesOf(Migrator.class);
+ Set<Class<? extends Migrator>> migratorClasses = reflections.getSubTypesOf(Migrator.class).stream()
+ .filter(clazz -> clazz.isAnnotationPresent(MigrationPriority.class))
+ .collect(Collectors.toSet());
/*
* TODO- Change this to make sure only classes in the specific $release are added in the runList
* Or add a annotation like exclude which folks again need to remember to add ??
private List<Class<? extends Migrator>> createMigratorList(CommandLineArgs cArgs,
List<Class<? extends Migrator>> migratorClasses) {
List<Class<? extends Migrator>> migratorClassesToRun = new ArrayList<>();
- if (cArgs.scripts.isEmpty() && cArgs.runDisabled.isEmpty()) {
+ if (cArgs.scripts.isEmpty()) {
return migratorClasses;
-
}
+
for (Class<? extends Migrator> migratorClass : migratorClasses) {
- if (migratorExplicitlySpecified(cArgs, migratorClass.getSimpleName()) || migratorToRunWhenDisabled(cArgs, migratorClass.getSimpleName())) {
+ if (migratorExplicitlySpecified(cArgs, migratorClass.getSimpleName())
+ || migratorToRunWhenDisabled(cArgs, migratorClass.getSimpleName())) {
migratorClassesToRun.add(migratorClass);
}
}
+
return migratorClassesToRun;
}
System.setOut(new PrintStream(myOut));
String [] args = {
"-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
- "-m", "SDWANSpeedChangeMigration",
+ "-m", "MigrateBooleanDefaultsToFalse",
+ " --skipPreMigrationSnapShot",
+ "--commit",
+ "--runDisabled","RebuildAllEdges",
+ "-f"
+ };
+ migrationControllerInternal.run(args);
+ String content = myOut.toString();
+ assertThat("RebuildAllEdges didn't run", content.contains("igration RebuildAllEdges Succeeded."));
+ assertThat("MigrateBooleanDefaultsToFalse didn't run", content.contains("igration MigrateBooleanDefaultsToFalse Succeeded."));
+ System.setOut(oldOutputStream);
+ }
+
+ @Test
+ public void testSkipSpecificMigrationWithRunDisabledAndCommit() throws Exception {
+ assertThat("rebuildAllEdges shouldn't have enabled annotation", !RebuildAllEdges.class.isAnnotationPresent(Enabled.class));
+ PrintStream oldOutputStream = System.out;
+ final ByteArrayOutputStream myOut = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(myOut));
+ String [] args = {
+ "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
+ "-e", "MigrateRadcomChanges",
+ "--skipPreMigrationSnapShot",
"--commit",
"--runDisabled","RebuildAllEdges",
"-f"
migrationControllerInternal.run(args);
String content = myOut.toString();
assertThat("RebuildAllEdges didn't run", content.contains("igration RebuildAllEdges Succeeded."));
- assertThat("SDWANSpeedChangeMigration shouldn't run", !content.contains("igration SDWANSpeedChangeMigration Succeeded."));
+ //all other mirgrators should run along with rebuild edges.
+ assertThat("MigrateBooleanDefaultsToFalse didn't run", content.contains("igration MigrateBooleanDefaultsToFalse Succeeded."));
+ assertThat("MigrateRadcomChanges shouldn't run", !content.contains("igration MigrateRadcomChanges Succeeded."));
System.setOut(oldOutputStream);
}
System.setOut(new PrintStream(myOut));
String [] args = {
"-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
+ "--skipPreMigrationSnapShot",
"--commit",
- "--runDisabled","RebuildAllEdges"
+ "--runDisabled","RebuildAllEdges",
+ "-f"
};
migrationControllerInternal.run(args);
String content = myOut.toString();
"-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
"--commit",
"--runDisabled","RebuildAllEdges",
- "-e","RebuildAllEdges"
+ "-e","RebuildAllEdges",
+ "-f"
};
migrationControllerInternal.run(args);
String content = myOut.toString();