aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/aai/migration/MigrationControllerInternal.java12
-rw-r--r--src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java35
2 files changed, 39 insertions, 8 deletions
diff --git a/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java b/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
index b94460a..55b03fb 100644
--- a/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
+++ b/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
@@ -317,7 +317,9 @@ public class MigrationControllerInternal {
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 ??
@@ -353,15 +355,17 @@ public class MigrationControllerInternal {
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;
}
diff --git a/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java b/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java
index 8e9f88f..215dd55 100644
--- a/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java
+++ b/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java
@@ -242,7 +242,29 @@ public class MigrationControllerInternalTest extends AAISetup {
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"
@@ -250,7 +272,9 @@ public class MigrationControllerInternalTest extends AAISetup {
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);
}
@@ -262,8 +286,10 @@ public class MigrationControllerInternalTest extends AAISetup {
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();
@@ -282,7 +308,8 @@ public class MigrationControllerInternalTest extends AAISetup {
"-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
"--commit",
"--runDisabled","RebuildAllEdges",
- "-e","RebuildAllEdges"
+ "-e","RebuildAllEdges",
+ "-f"
};
migrationControllerInternal.run(args);
String content = myOut.toString();