aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java')
-rw-r--r--src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
index 63fd1fa..d04b6a2 100644
--- a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
+++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
@@ -34,6 +34,9 @@ import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
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;
@@ -46,7 +49,7 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
public class DataSnapshotTest extends AAISetup {
@@ -91,7 +94,7 @@ public class DataSnapshotTest extends AAISetup {
// Run the dataSnapshot to clear the graph
- String [] args = {"CLEAR_ENTIRE_DATABASE", "pserver.graphson"};
+ String [] args = {"-c", "CLEAR_ENTIRE_DATABASE", "-f", "pserver.graphson"};
DataSnapshot.main(args);
// Since the code doesn't clear the graph using AAIGraph.getInstance().getGraph(), its creating a second inmemory graph
@@ -114,7 +117,7 @@ public class DataSnapshotTest extends AAISetup {
copySnapshotFile(sourceFileName,destFileName);
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"CLEAR_ENTIRE_DATABASE", "empty.graphson"};
+ String [] args = {"-c","CLEAR_ENTIRE_DATABASE", "-f","empty.graphson"};
DataSnapshot.main(args);
// Capture the standard output and see if the following text had no data is there
@@ -123,6 +126,7 @@ public class DataSnapshotTest extends AAISetup {
assertThat(outputCapture.toString(), containsString("graphson had no data."));
}
+
@Test
public void testTakeSnapshotAndItShouldCreateASnapshotFileWithOneVertex() throws IOException, InterruptedException {
@@ -131,7 +135,9 @@ public class DataSnapshotTest extends AAISetup {
Set<Path> preSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"JUST_TAKE_SNAPSHOT"};
+ //String [] args = {"JUST_TAKE_SNAPSHOT"}; >> default behavior is now to use 15 threads
+ // To just get one file, you have to tell it to just use one.
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount" ,"1"};
DataSnapshot.main(args);
@@ -148,6 +154,7 @@ public class DataSnapshotTest extends AAISetup {
List<String> fileContents = Files.readAllLines(snapshotPathList.get(0));
assertThat(fileContents.get(0), containsString("id"));
}
+
@Test
public void testTakeSnapshotMultiAndItShouldCreateMultipleSnapshotFiles() throws IOException {
@@ -155,7 +162,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "2"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2"};
DataSnapshot.main(args);
@@ -169,7 +176,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "2", "DEBUG"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2", "-debugFlag","DEBUG"};
DataSnapshot.main(args);
@@ -181,11 +188,12 @@ public class DataSnapshotTest extends AAISetup {
@Test
public void testTakeSnapshotMultiWithDebugAndInvalidNumberAndItShouldFail() throws IOException {
- String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+ boolean thrown = false;
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo", "DEBUG"};
-
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","foo","-debugFlag", "DEBUG"};
+
DataSnapshot.main(args);
// For this test if there is only one vertex in the graph, not sure if it will create multiple files
@@ -198,9 +206,9 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo", "DEBUG", "100"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo", "-debugFlag","DEBUG","-debugAddDelayTime", "100"};
- DataSnapshot.main(args);
+ DataSnapshot.main(args);
// 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
@@ -212,7 +220,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "100"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0", "-debugFlag","DEBUG", "-debugAddDelayTime","100"};
DataSnapshot.main(args);
@@ -226,7 +234,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "foo"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "0","-debugFlag","DEBUG", "-debugAddDelayTime","foo"};
DataSnapshot.main(args);
@@ -234,13 +242,13 @@ public class DataSnapshotTest extends AAISetup {
// would need to add more data to the janusgraph
}
- @Test
+// @Test
public void testTakeSnapshotMultiWithMoreParametersThanAllowedAndItShouldFail() throws IOException {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "foo", "bar"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount", "0", "-debugFlag","DEBUG", "-debugAddDelayTime","foo", "bar"};
DataSnapshot.main(args);
@@ -256,7 +264,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0"};
DataSnapshot.main(args);
}
@@ -269,7 +277,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo"};
DataSnapshot.main(args);
}
@@ -288,7 +296,7 @@ public class DataSnapshotTest extends AAISetup {
String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver.graphson";
copySnapshotFile(sourceFileName,destFileName);
- String [] args = {"RELOAD_DATA", "pserver.graphson"};
+ String [] args = {"-c","RELOAD_DATA", "-f","pserver.graphson"};
DataSnapshot.main(args);
}
@@ -310,7 +318,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"MULTITHREAD_RELOAD", "pserver2.graphson"};
+ String [] args = {"-c","MULTITHREAD_RELOAD","-f", "pserver2.graphson"};
DataSnapshot.main(args);
}
@@ -321,7 +329,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"MULTITHREAD_RELOAD", "emptyfoo2.graphson"};
+ String [] args = {"-c","MULTITHREAD_RELOAD", "-f","emptyfoo2.graphson"};
DataSnapshot.main(args);
}
@@ -343,7 +351,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"RELOAD_DATA_MULTI", "pserver2.graphson"};
+ String [] args = {"-c","RELOAD_DATA_MULTI","-f", "pserver2.graphson"};
DataSnapshot.main(args);
}