diff options
-rw-r--r-- | src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java | 17 | ||||
-rw-r--r-- | src/test/java/org/onap/aai/datasnapshot/DataSnapshot4HistInitTest.java (renamed from src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java) | 45 | ||||
-rw-r--r-- | src/test/java/org/onap/aai/dbgen/DupeToolTest.java | 64 |
3 files changed, 86 insertions, 40 deletions
diff --git a/src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java b/src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java index 03ff51a..8d250d7 100644 --- a/src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java +++ b/src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java @@ -109,14 +109,6 @@ public class DataSnapshot4HistInit { */ public static void main(String[] args) { - // Set the logging file properties to be used by EELFManager - System.setProperty("aai.service.name", DataSnapshot4HistInit.class.getSimpleName()); - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_LOGBACK_PROPS); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_BUNDLECONFIG); - LOGGER = LoggerFactory.getLogger(DataSnapshot4HistInit.class); - - AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration(); initializer.initialize(ctx); @@ -157,6 +149,13 @@ public class DataSnapshot4HistInit { public boolean executeCommand(String[] args) { + // Set the logging file properties to be used by EELFManager + System.setProperty("aai.service.name", DataSnapshot4HistInit.class.getSimpleName()); + Properties props = System.getProperties(); + props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_LOGBACK_PROPS); + props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_BUNDLECONFIG); + LOGGER = LoggerFactory.getLogger(DataSnapshot4HistInit.class); + Boolean dbClearFlag = false; JanusGraph graph = null; String command = "UNKNOWN"; @@ -1076,4 +1075,4 @@ public class DataSnapshot4HistInit { } -}
\ No newline at end of file +} diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshot4HistInitTest.java index adcde4e..c297f78 100644 --- a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java +++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshot4HistInitTest.java @@ -33,28 +33,20 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.onap.aai.AAISetup; -import org.onap.aai.datagrooming.DataGrooming; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; - -import org.onap.aai.logging.LogFormatTools; -import org.onap.aai.util.AAISystemExitUtil; import org.springframework.boot.test.rule.OutputCapture; - -import com.beust.jcommander.ParameterException; - -import java.lang.NumberFormatException; import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.stream.Collectors; import static org.hamcrest.CoreMatchers.is; @@ -62,7 +54,8 @@ import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.*; -public class DataSnapshotTest4HistInit extends AAISetup { + +public class DataSnapshot4HistInitTest extends AAISetup { private GraphTraversalSource g; @@ -77,7 +70,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Before public void setup() throws AAIException { - dataSnapshot4HistInit = new DataSnapshot4HistInit(loaderFactory, schemaVersions); + dataSnapshot4HistInit = new DataSnapshot4HistInit(loaderFactory, schemaVersions); JanusGraph graph = AAIGraph.getInstance().getGraph(); currentTransaction = graph.newTransaction(); @@ -174,7 +167,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiAndItShouldCreateMultipleSnapshotFiles() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2"}; @@ -189,7 +182,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithDebugAndItShouldCreateMultipleSnapshotFiles() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2", "-debugFlag","DEBUG"}; @@ -204,8 +197,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithDebugAndInvalidNumberAndItShouldFail() throws IOException { - boolean thrown = false; - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","foo","-debugFlag", "DEBUG"}; @@ -219,7 +211,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithDebugAndTimeDelayAndInvalidNumberAndItShouldFail() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo", "-debugFlag","DEBUG","-debugAddDelayTime", "100"}; @@ -233,7 +225,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithDebugAndTimeDelayAndZeroThreadsAndItShouldFail() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0", "-debugFlag","DEBUG", "-debugAddDelayTime","100"}; @@ -247,7 +239,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithDebugAndTimeDelayIsInvalidNumberAndItShouldFail() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "0","-debugFlag","DEBUG", "-debugAddDelayTime","foo"}; @@ -261,7 +253,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { // @Test public void testTakeSnapshotMultiWithMoreParametersThanAllowedAndItShouldFail() throws IOException { - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount", "0", "-debugFlag","DEBUG", "-debugAddDelayTime","foo", "bar"}; @@ -275,9 +267,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithZeroThreadsAndItShouldFail(){ - // For this test if there is only one vertex in the graph, not sure if it will create multiple files - // would need to add more data to the janusgraph - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0"}; @@ -288,9 +278,7 @@ public class DataSnapshotTest4HistInit extends AAISetup { @Test public void testTakeSnapshotMultiWithInvalidNumberForThreadsAndItShouldFail(){ - // For this test if there is only one vertex in the graph, not sure if it will create multiple files - // would need to add more data to the janusgraph - String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/"; + System.getProperty("AJSC_HOME"); // Run the clear dataSnapshot and this time it should fail String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo"}; @@ -386,13 +374,12 @@ public class DataSnapshotTest4HistInit extends AAISetup { String nodeType = (String)entry.getKey(); ArrayList<String> keyNames = (ArrayList<String>)entry.getValue(); keyNamesHash.put(nodeType,keyNames); - System.out.println("DEBUGjojo === for nType " + nodeType + ", got keys = [" + keyNames + "]"); } assertTrue(keyNamesHash != null ); assertFalse(keyNamesHash.isEmpty()); } - + private void showVertProperties(String propKey, String propVal) { diff --git a/src/test/java/org/onap/aai/dbgen/DupeToolTest.java b/src/test/java/org/onap/aai/dbgen/DupeToolTest.java index ac7a82d..bd95bcb 100644 --- a/src/test/java/org/onap/aai/dbgen/DupeToolTest.java +++ b/src/test/java/org/onap/aai/dbgen/DupeToolTest.java @@ -114,6 +114,30 @@ public class DupeToolTest extends AAISetup { .property("source-of-truth", "JUNIT") .next(); edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex6); + + + Vertex pInterfaceVertex7 = g.addV() + .property("aai-node-type", "p-interface") + .property("interface-name", "p-interface-name3") + .property("in-maint", false) + .property("source-of-truth", "JUNIT") + .next(); + edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex7); + + // Now add a few more pservers - they won't be dupes because the db won't let us + Vertex pserverVertexX = g.addV() + .property("aai-node-type", "pserver") + .property("hostname", "test-pserverX") + .property("in-maint", false) + .property("source-of-truth", "JUNIT") + .next(); + + Vertex pserverVertexY = g.addV() + .property("aai-node-type", "pserver") + .property("hostname", "test-pserverY") + .property("in-maint", false) + .property("source-of-truth", "JUNIT") + .next(); } catch(Exception ex){ @@ -130,7 +154,7 @@ public class DupeToolTest extends AAISetup { } - @Test + @Test public void testDupeToolForPInterface(){ String[] args = { @@ -146,6 +170,42 @@ public class DupeToolTest extends AAISetup { } + + @Test + public void testDupeToolForPInterfaceWithAutoFixOn(){ + + String[] args = { + "-userId", "testuser", + "-nodeType", "p-interface", + "-timeWindowMinutes", "30", + "-maxFix", "30", + "-sleepMinutes", "5", + "-autoFix" + }; + + dupeTool.execute(args); + assertThat(dupeTool.getDupeGroupCount(), is(3)); + + } + + + @Test + public void testDupeToolForPServer(){ + + String[] args = { + "-userId", "testuser", + "-nodeType", "pserver", + "-timeWindowMinutes", "30", + "-maxFix", "30", + "-sleepMinutes", "0" + }; + + dupeTool.execute(args); + assertThat(dupeTool.getDupeGroupCount(), is(0)); + + } + + @After public void tearDown(){ @@ -173,4 +233,4 @@ public class DupeToolTest extends AAISetup { } } -}
\ No newline at end of file +} |