aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-06-12 16:53:33 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-06-13 15:28:10 +0200
commit023e0b5018247f02e05dbed3f91c495161fde814 (patch)
tree9fed7ae6e82ea9389c27896a0b66962aa1a242f7 /src/test
parent1647fc01e2dd11a56770cf6b1dd6d2c1f11392f5 (diff)
Support exporting to the kryo format in the dataSnapshot script
- add support for the kryo format when creating a database snapshot Issue-ID: AAI-3872 Change-Id: Iba085f7227bbfcb928370443c2e0eac95e49bb9c Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java62
1 files changed, 46 insertions, 16 deletions
diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
index 9d74651..cc61e99 100644
--- a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
+++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
@@ -56,7 +56,7 @@ public class DataSnapshotTest extends AAISetup {
private JanusGraphTransaction currentTransaction;
private List<Vertex> vertexes;
-
+
private static final int DELAYSINGLETHREADTEST = 90;
@Rule
@@ -126,15 +126,13 @@ public class DataSnapshotTest extends AAISetup {
assertThat(outputCapture.toString(), containsString("graphson had no data."));
}
-
- @Ignore("Unit test failing temporarily ignore")
@Test
public void testTakeSnapshotAndItShouldCreateASnapshotFileWithOneVertex() throws IOException, InterruptedException {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
Set<Path> preSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
-
+
// previous test may have the same generated file name, this wait will ensure a new name is used for this test
System.out.println("delay generation, seconds " + DELAYSINGLETHREADTEST);
Thread.sleep(DELAYSINGLETHREADTEST*1000);
@@ -149,7 +147,7 @@ public class DataSnapshotTest extends AAISetup {
Set<Path> postSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
- assertThat(postSnapshotFiles.size(), is(37));
+ assertThat(postSnapshotFiles.size(), is(preSnapshotFiles.size() +1));
postSnapshotFiles.removeAll(preSnapshotFiles);
List<Path> snapshotPathList = postSnapshotFiles.stream().collect(Collectors.toList());
@@ -158,7 +156,39 @@ public class DataSnapshotTest extends AAISetup {
List<String> fileContents = Files.readAllLines(snapshotPathList.get(0));
assertThat(fileContents.get(0), containsString("id"));
}
-
+
+ @Test
+ public void testTakeKryoSnapshotAndItShouldCreateASnapshotFileWithOneVertex() throws IOException, InterruptedException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ Set<Path> preSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
+
+ // previous test may have the same generated file name, this wait will ensure a new name is used for this test
+ System.out.println("delay generation, seconds " + DELAYSINGLETHREADTEST);
+ Thread.sleep(DELAYSINGLETHREADTEST*100);
+ // Run the clear dataSnapshot and this time it should fail
+ //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", "-snapshotType" , "gryo"};
+
+ DataSnapshot.main(args);
+
+ // Add sleep so the file actually gets created with the data
+
+ Set<Path> postSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
+
+ assertThat(postSnapshotFiles.size(), is(preSnapshotFiles.size() +1));
+ boolean gryoSnapshotExists = postSnapshotFiles.stream()
+ .map(Path::toString)
+ .anyMatch(name -> name.endsWith("gryo"));
+ assertTrue(gryoSnapshotExists);
+ postSnapshotFiles.removeAll(preSnapshotFiles);
+ List<Path> snapshotPathList = postSnapshotFiles.stream().collect(Collectors.toList());
+
+ assertThat(snapshotPathList.size(), is(1));
+ }
+
@Test
public void testTakeSnapshotMultiAndItShouldCreateMultipleSnapshotFiles() throws IOException {
@@ -180,27 +210,27 @@ public class DataSnapshotTest extends AAISetup {
long totalVerts = 5000;
int threadCt = 15;
long maxNodesPerFile = 120000;
-
- int fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
+
+ int fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
maxNodesPerFile );
assertThat( fileCt, is(15));
-
+
totalVerts = 5000;
threadCt = 15;
maxNodesPerFile = 100;
- fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
+ fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
maxNodesPerFile );
assertThat( fileCt, is(60));
-
+
totalVerts = 1500;
threadCt = 15;
maxNodesPerFile = 100;
- fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
+ fileCt = DataSnapshot.figureOutFileCount( totalVerts, threadCt,
maxNodesPerFile );
- assertThat( fileCt, is(15));
-
+ assertThat( fileCt, is(15));
+
}
-
+
@Test
public void testTakeSnapshotMultiWithDebugAndItShouldCreateMultipleSnapshotFiles() throws IOException {
@@ -224,7 +254,7 @@ public class DataSnapshotTest extends AAISetup {
// Run the clear dataSnapshot and this time it should fail
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