aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/AAIGremlinQueryTest.java2
-rw-r--r--src/test/java/org/onap/aai/audit/AuditGraphson2SqlTest.java287
-rw-r--r--src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java10
-rw-r--r--src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java471
-rw-r--r--src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java209
-rw-r--r--src/test/java/org/onap/aai/migration/v20/MigrateL2DefaultToFalseTest.java135
-rw-r--r--src/test/resources/logback.xml111
7 files changed, 1009 insertions, 216 deletions
diff --git a/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
index ec40b90..3115b87 100644
--- a/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
+++ b/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
@@ -23,7 +23,7 @@ import com.jayway.jsonpath.JsonPath;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.*;
-import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.util.AAIConfig;
diff --git a/src/test/java/org/onap/aai/audit/AuditGraphson2SqlTest.java b/src/test/java/org/onap/aai/audit/AuditGraphson2SqlTest.java
new file mode 100644
index 0000000..2bc6250
--- /dev/null
+++ b/src/test/java/org/onap/aai/audit/AuditGraphson2SqlTest.java
@@ -0,0 +1,287 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.audit;
+
+import com.google.gson.JsonObject;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.mockito.Mock;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.onap.aai.AAISetup;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.rest.client.ApertureService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.TestPropertySource;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import static org.junit.Assert.*;
+
+public class AuditGraphson2SqlTest extends AAISetup {
+
+
+ private AuditGraphson2Sql auditG2S;
+
+ @Autowired
+ private EdgeIngestor ei;
+
+ @Mock
+ private ApertureService apertureServiceMock;
+
+ @Before
+ public void setUp() {
+
+ auditG2S = new AuditGraphson2Sql(ei, schemaVersions, loaderFactory, apertureServiceMock);
+
+ }
+
+ @Test
+ public void testCompareGood() throws IOException, EdgeRuleNotFoundException {
+ String outDir = "logs/data/audit";
+ Boolean resultOk = true;
+ HashMap <String,Integer> gHash = new HashMap <String,Integer> ();
+ gHash.put("tbl2", 5);
+ gHash.put("tbl-x", 6);
+ gHash.put("edge__tbly__tblX", 7);
+ gHash.put("edge__tblZ__tblX", 8);
+ gHash.put("tbl-only-in-g", 88);
+
+ HashMap <String,Integer> sEdgeHash = new HashMap <String,Integer> ();
+ sEdgeHash.put("edge__tbly__tblX", 7);
+ sEdgeHash.put("edge__tblZ__tblX", 8);
+
+ HashMap <String,Integer> sNodeHash = new HashMap <String,Integer> ();
+ sNodeHash.put("tbl2", 5);
+ sNodeHash.put("tbl-x", 6);
+ sNodeHash.put("tbl-only-in-sql", 89);
+
+ String titleInfo = "Comparing data from GraphSon file: " +
+ "fileXYZ.202001223344, and Aperture data using timeStamp = [987654321]";
+
+ try {
+ auditG2S.compareResults(gHash,sNodeHash,sEdgeHash,outDir,titleInfo);
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ resultOk = false;
+ }
+ assertTrue(resultOk);
+ }
+
+ @Test
+ public void testCompareResMissingRecords() throws IOException, EdgeRuleNotFoundException {
+
+ String outDir = "logs/data/audit";
+ Boolean resultOk = true;
+ HashMap <String,Integer> gHash = new HashMap <String,Integer> ();
+ gHash.put("tbl2", 5);
+ gHash.put("tbl-x", 6);
+ gHash.put("edge__tblZ__tblX", 7);
+ gHash.put("edge__tblZ__tblX", 8);
+ gHash.put("tbl-only-in-g", 88);
+ HashMap <String,Integer> sNodeHash = new HashMap <String,Integer> ();
+ HashMap <String,Integer> sEdgeHash = new HashMap <String,Integer> ();
+
+ String titleInfo = "Comparing data from GraphSon file: " +
+ "fileXYZ.202001223344, and Aperture data using timeStamp = [987654321]";
+
+ try {
+ auditG2S.compareResults(gHash,sNodeHash,sEdgeHash,outDir,titleInfo);
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ resultOk = false;
+ }
+
+ assertTrue(resultOk);
+ }
+
+ @Ignore
+ @Test
+ public void testGetDateTimeStamp() {
+ long dts = 0;
+ String fName = "xxxxx.yyyy.202003220000";
+ try {
+ dts = auditG2S.getTimestampFromFileName(fName);
+ } catch (Exception e) {
+ System.out.println(" threw Exception e = " + e.getMessage());
+ }
+
+ assertEquals(1577595600000L, dts);
+ }
+
+ @Test
+ public void testTimePieceGood() {
+ String dtPiece = "";
+ String fName = "xxxxx.yyyy.222233445566";
+ try {
+ dtPiece = auditG2S.getDateTimePieceOfFileName(fName);
+ } catch (Exception e) {
+ System.out.println(" threw Exception e = " + e.getMessage());
+ }
+ assertEquals( "222233445566", dtPiece);
+ }
+
+ @Test
+ public void testTimePieceGoodStill() {
+ String dtPiece = "";
+ String fName = "x.222233445566";
+ try {
+ dtPiece = auditG2S.getDateTimePieceOfFileName(fName);
+ } catch (Exception e) {
+ System.out.println(" threw Exception e = " + e.getMessage());
+ }
+ assertEquals(dtPiece, "222233445566");
+ }
+
+ @Test
+ public void testTimePieceNotime() {
+ String fName = "xxxxx.yyyy";
+ Boolean resultOk = true;
+ try {
+ auditG2S.getDateTimePieceOfFileName(fName);
+ } catch (Exception e) {
+ System.out.println(" threw Exception e = " + e.getMessage());
+ resultOk = false;
+ }
+ assertFalse(resultOk);
+ }
+
+ @Test
+ public void testTimePieceTooShort() {
+ String fName = "xxxxx.yyyy.22223";
+ Boolean resultOk = true;
+ try {
+ auditG2S.getDateTimePieceOfFileName(fName);
+ } catch (Exception e) {
+ System.out.println(" threw Exception e = " + e.getMessage());
+ resultOk = false;
+ }
+ assertFalse(resultOk);
+ }
+
+
+ @Ignore
+ @Test
+ public void testGetCounts() throws IOException, EdgeRuleNotFoundException {
+ Boolean resultOk = true;
+ String dbName = "aai";
+ String fileNamePart = "dataSnapshot.graphSON.201908151845";
+ String srcDir = "src/test/resources/audit/";
+ HashMap <String,Integer> resHash = new HashMap <String,Integer> ();
+ try {
+ resHash = auditG2S.getCountsFromGraphsonSnapshot(dbName, fileNamePart, srcDir);
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ resultOk = false;
+ }
+
+ assertTrue(resultOk);
+ }
+
+
+ @Ignore
+ @Test
+ public void testGoodRun() throws IOException, EdgeRuleNotFoundException {
+
+ String [] argVals = {};
+
+ // this is the tStamp that would go
+ // with this file name: "dataSnapshot.graphSON.201908151845"
+ Long tStamp = 1565842725000L;
+
+
+ JsonObject jVal = new JsonObject();
+ jVal.addProperty("autonomous-system",5);
+ jVal.addProperty("pnf",7);
+
+
+ String dbn = "aai_relational";
+ String resStr = "";
+ try {
+ when(apertureServiceMock.runAudit(anyLong(), anyString())).thenReturn(jVal);
+ resStr = auditG2S.runAudit("aai",
+ "dataSnapshot.graphSON.201908151845",
+ "src/test/resources/audit/");
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ resStr = "Error";
+ }
+
+ assertTrue( resStr.startsWith("Audit ran and logged") );
+
+ }
+
+ @Test
+ public void testRunWithBadParam() throws IOException, EdgeRuleNotFoundException {
+
+ String resStr = "";
+ try {
+ resStr = auditG2S.runAudit("aai",
+ "bogusFileName",
+ "src/test/resources/audit/");
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ resStr = "Error";
+ }
+
+ assertTrue( resStr.equals("Error") );
+ }
+
+
+ @Test
+ public void testGetCountsFromJson() throws IOException, EdgeRuleNotFoundException {
+
+ JsonObject sqlJsonData = new JsonObject ();
+ sqlJsonData.addProperty("tableName1", 4);
+ sqlJsonData.addProperty("tableName2", 5);
+ sqlJsonData.addProperty("tableName3", 6);
+ sqlJsonData.addProperty("tableName4", 7);
+
+ HashMap <String,Integer> results1 = new HashMap <String,Integer> ();
+ HashMap <String,Integer> results2 = new HashMap <String,Integer> ();
+ try {
+ results1 = auditG2S.getNodeCountsFromSQLRes(sqlJsonData);
+ results2 = auditG2S.getNodeCountsFromSQLRes(sqlJsonData);
+ }
+ catch ( Exception e ) {
+ System.out.println("ERROR - got this exception: " + e.getMessage());
+ }
+
+ assertEquals(4, results1.size());
+ assertTrue( results1.containsKey("tableName3") );
+ assertTrue( results1.get("tableName4") == 7);
+ assertEquals(4, results2.size());
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
index ad27188..ef57aaf 100644
--- a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
+++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
@@ -32,6 +32,9 @@ import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.FormatDate;
+import org.onap.aai.util.GraphAdminDBUtils;
import org.springframework.boot.test.rule.OutputCapture;
import com.beust.jcommander.ParameterException;
@@ -58,6 +61,8 @@ public class DataSnapshotTest extends AAISetup {
private JanusGraphTransaction currentTransaction;
private List<Vertex> vertexes;
+
+ private static final int DELAYSINGLETHREADTEST = 90;
@Rule
public OutputCapture outputCapture = new OutputCapture();
@@ -133,7 +138,10 @@ public class DataSnapshotTest extends AAISetup {
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);
// 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.
diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java
new file mode 100644
index 0000000..adcde4e
--- /dev/null
+++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest4HistInit.java
@@ -0,0 +1,471 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.datasnapshot;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.After;
+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.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.*;
+
+
+public class DataSnapshotTest4HistInit extends AAISetup {
+
+ private GraphTraversalSource g;
+
+ private JanusGraphTransaction currentTransaction;
+
+ private List<Vertex> vertexes;
+
+ private DataSnapshot4HistInit dataSnapshot4HistInit;
+
+ @Rule
+ public OutputCapture outputCapture = new OutputCapture();
+
+ @Before
+ public void setup() throws AAIException {
+ dataSnapshot4HistInit = new DataSnapshot4HistInit(loaderFactory, schemaVersions);
+
+ JanusGraph graph = AAIGraph.getInstance().getGraph();
+ currentTransaction = graph.newTransaction();
+ g = currentTransaction.traversal();
+
+ // Setup the graph so it has one pserver vertex
+ vertexes = setupPserverData(g);
+ currentTransaction.commit();
+ }
+
+ @After
+ public void tearDown(){
+
+ JanusGraph graph = AAIGraph.getInstance().getGraph();
+ currentTransaction = graph.newTransaction();
+ g = currentTransaction.traversal();
+
+ vertexes.stream().forEach((v) -> g.V(v).next().remove());
+ currentTransaction.commit();
+ }
+
+ @Test
+ public void testClearEntireDatabaseAndVerifyDataIsRemoved() throws IOException {
+
+ // Copy the pserver.graphson file from src/test/resoures to ${AJSC_HOME}/logs/data/dataSnapshots/ folder
+ String sourceFileName = "src/test/resources/pserver.graphson";
+ String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver.graphson";
+ copySnapshotFile(sourceFileName,destFileName);
+
+
+ // Run the dataSnapshot to clear the graph
+ String [] args = {"-c", "CLEAR_ENTIRE_DATABASE", "-f", "pserver.graphson"};
+ dataSnapshot4HistInit.executeCommand(args);
+
+ // Since the code doesn't clear the graph using AAIGraph.getInstance().getGraph(), its creating a second inmemory graph
+ // so we can't verify this with by counting the vertexes and edges in the graph
+ // In the future we could do that but for now we will depend on the following string "All done clearing DB"
+
+ // Capture the standard output and see if the following text is there
+ assertThat(outputCapture.toString(), containsString("All done clearing DB"));
+ }
+
+
+ @Test
+ public void testClearEntireDatabaseWithEmptyGraphSONFileAndItShouldNotClearDatabase() throws IOException {
+
+ // Create a empty file called empty.graphson in src/test/resources/
+
+ // Copy that file to ${AJSC_HOME}/logs/data/dataSnapshots/
+ String sourceFileName = "src/test/resources/empty.graphson";
+ String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/empty.graphson";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","CLEAR_ENTIRE_DATABASE", "-f","empty.graphson"};
+ dataSnapshot4HistInit.executeCommand(args);
+
+ // Capture the standard output and see if the following text had no data is there
+ // Since the graphson is empty it should output that and not clear the graph
+ // Uncomment the following line after the test changes are done
+ assertThat(outputCapture.toString(), containsString("graphson had no data."));
+ }
+
+
+ @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());
+
+ // 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"};
+
+ dataSnapshot4HistInit.executeCommand(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));
+ postSnapshotFiles.removeAll(preSnapshotFiles);
+ List<Path> snapshotPathList = postSnapshotFiles.stream().collect(Collectors.toList());
+
+ assertThat(snapshotPathList.size(), is(1));
+
+ List<String> fileContents = Files.readAllLines(snapshotPathList.get(0));
+ assertThat(fileContents.get(0), containsString("id"));
+ }
+
+
+ @Test
+ public void testTakeSnapshotMultiAndItShouldCreateMultipleSnapshotFiles() throws IOException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+
+ @Test
+ public void testTakeSnapshotMultiWithDebugAndItShouldCreateMultipleSnapshotFiles() throws IOException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2", "-debugFlag","DEBUG"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+
+ @Test
+ public void testTakeSnapshotMultiWithDebugAndInvalidNumberAndItShouldFail() throws IOException {
+
+ boolean thrown = false;
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","foo","-debugFlag", "DEBUG"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+ @Test
+ public void testTakeSnapshotMultiWithDebugAndTimeDelayAndInvalidNumberAndItShouldFail() throws IOException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo", "-debugFlag","DEBUG","-debugAddDelayTime", "100"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+ @Test
+ public void testTakeSnapshotMultiWithDebugAndTimeDelayAndZeroThreadsAndItShouldFail() throws IOException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0", "-debugFlag","DEBUG", "-debugAddDelayTime","100"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+ @Test
+ public void testTakeSnapshotMultiWithDebugAndTimeDelayIsInvalidNumberAndItShouldFail() throws IOException {
+
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "0","-debugFlag","DEBUG", "-debugAddDelayTime","foo"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+// @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 = {"-c","THREADED_SNAPSHOT", "-threadCount", "0", "-debugFlag","DEBUG", "-debugAddDelayTime","foo", "bar"};
+
+ dataSnapshot4HistInit.executeCommand(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
+ }
+
+ @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/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0"};
+
+ dataSnapshot4HistInit.executeCommand(args);
+ }
+
+ @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/";
+
+ // Run the clear dataSnapshot and this time it should fail
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo"};
+
+ dataSnapshot4HistInit.executeCommand(args);
+ }
+
+
+ @Test
+ public void testReloadDataAndVerifyDataInGraphMatchesGraphson() throws IOException {
+
+ // Create a graphson file that contains a couple of vertexes in src/test/resources
+ // Copy that file to ${AJSC_HOME}/logs/data/dataSnasphots/
+ // Run the reload arguments and ensure that the graph was recreated by checking vertexes in graph
+
+ // 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 sourceFileName = "src/test/resources/pserver.graphson";
+ String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver.graphson";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ String [] args = {"-c","RELOAD_DATA", "-f","pserver.graphson"};
+
+ dataSnapshot4HistInit.executeCommand(args);
+ }
+
+
+ @Test
+ public void testMultiReloadDataAndVerifyDataInGraphMatchesGraphson() throws IOException, AAIException {
+
+ // Create multiple graphson files that contains a couple of vertexes in src/test/resources
+ // Copy those files to ${AJSC_HOME}/logs/data/dataSnasphots/
+ // Run the reload arguments and ensure that the graph was recreated by checking vertexes in graph
+ String sourceFileName = "src/test/resources/pserver2.graphson.P0";
+ String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver2.graphson.P0";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ sourceFileName = "src/test/resources/pserver2.graphson.P1";
+ destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver2.graphson.P1";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ // 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 = {"-c","MULTITHREAD_RELOAD","-f", "pserver2.graphson"};
+ dataSnapshot4HistInit.executeCommand(args);
+
+ }
+
+ @Test
+ public void testMultiReloadDataWithNonExistentFilesAndItShouldFail() throws IOException {
+
+ // 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 = {"-c","MULTITHREAD_RELOAD", "-f","emptyfoo2.graphson"};
+
+ dataSnapshot4HistInit.executeCommand(args);
+ }
+
+ @Test
+ public void testReloadMultiDataAndVerifyDataInGraphMatchesGraphson() throws IOException {
+
+ // Create multiple graphson files that contains a couple of vertexes in src/test/resources
+ // Copy those files to ${AJSC_HOME}/logs/data/dataSnasphots/
+ // Run the reload arguments and ensure that the graph was recreated by checking vertexes in graph
+ String sourceFileName = "src/test/resources/pserver2.graphson.P0";
+ String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver2.graphson.P0";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ sourceFileName = "src/test/resources/pserver2.graphson.P1";
+ destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver2.graphson.P1";
+ copySnapshotFile(sourceFileName,destFileName);
+
+ // 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 = {"-c","RELOAD_DATA_MULTI","-f", "pserver2.graphson"};
+
+ dataSnapshot4HistInit.executeCommand(args);
+ }
+
+ @Test
+ public void testCanRetrieveNamesOfKeyProps() throws IOException {
+
+ // Make sure we can get the key names without failing
+ HashMap <String,ArrayList<String>> keyNamesHash = dataSnapshot4HistInit.getNodeKeyNames();
+ Iterator keyItr = keyNamesHash.entrySet().iterator();
+ while( keyItr.hasNext() ) {
+ Map.Entry entry = (Map.Entry) keyItr.next();
+ 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) {
+
+ Vertex v1 = g.V().has(propKey, propVal).next();
+ Iterator<VertexProperty<Object>> pI = v1.properties();
+ while( pI.hasNext() ){
+ VertexProperty<Object> tp = pI.next();
+ String infStr = " [" + tp.key() + "][" + tp.value() + "] ";
+ System.out.println("Regular ole properties are: " + infStr );
+ Iterator<Property<Object>> fullPropI = tp.properties();
+ while( fullPropI.hasNext() ){
+ // Note - the 'real' key/value of a property are not part of this list, just the
+ // extra stuff beyond those two.
+ Property<Object> propOfProp = fullPropI.next();
+ String infStr2 = " [" + propOfProp.key() + "][" + propOfProp.value() + "] ";
+ System.out.println("For " + infStr + ", got sub-property:" + infStr2 );
+ }
+ }
+ }
+
+
+ private List<Vertex> setupOneHistoryNode(GraphTraversalSource g) throws AAIException {
+
+ Vertex v1 = g.addV().property("aai-node-type", "pserver","start-ts", 9988707,"source-of-truth","N/A")
+ .property("hostname", "historyHOstGuy--8","start-ts", 9988707,"source-of-truth","N/A")
+ .property("equip-vendor", "historyVendor","start-ts", 9988707,"source-of-truth","N/A")
+ .property("role", "historyRole","start-ts", 9988707,"source-of-truth","N/A")
+ .next();
+ List<Vertex> list = new ArrayList<>();
+ list.add(v1);
+
+ Iterator<VertexProperty<Object>> pI = v1.properties();
+ while( pI.hasNext() ){
+ VertexProperty<Object> tp = pI.next();
+ String infStr = " [" + tp.key() + "|" + tp.value() + "] ";
+ System.out.println("Regular ole properties are: " + infStr );
+ Iterator<Property<Object>> fullPropI = tp.properties();
+ while( fullPropI.hasNext() ){
+ // Note - the 'real' key/value of a property are not part of this list, just the
+ // extra stuff beyond those two.
+ Property<Object> propOfProp = fullPropI.next();
+ String infStr2 = " [" + propOfProp.key() + "|" + propOfProp.value() + "] ";
+ System.out.println("For " + infStr + ", got sub-property:" + infStr2 );
+ }
+ }
+ return list;
+ }
+
+ private List<Vertex> setupPserverData(GraphTraversalSource g) throws AAIException {
+ Vertex v1 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname", "somerandomhostname")
+ .next();
+ List<Vertex> list = new ArrayList<>();
+ list.add(v1);
+ Vertex v2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname", "somerandomhostname2")
+ .next();
+ Vertex pinterface = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .next();
+ edgeSerializer.addTreeEdge(g, v2, pinterface);
+ list.add(v2);
+ return list;
+ }
+
+ private void copySnapshotFile(String sourceFileName, String destFileName) throws IOException {
+
+ File inputFile = new File(sourceFileName);
+ File outputFile = new File(destFileName);
+
+ FileUtils.copyFile(inputFile, outputFile);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java b/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
index 7dacfe6..0ca8481 100644
--- a/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
+++ b/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
@@ -21,7 +21,6 @@ package org.onap.aai.dbgen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.test.rule.OutputCapture;
import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -29,7 +28,6 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.aai.AAISetup;
@@ -39,8 +37,6 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -51,9 +47,6 @@ public class ForceDeleteToolTest extends AAISetup {
private ForceDeleteTool deleteTool;
private Vertex cloudRegionVertex;
-
- @Rule
- public OutputCapture outputCapture = new OutputCapture();
@Before
public void setup(){
@@ -124,12 +117,10 @@ public class ForceDeleteToolTest extends AAISetup {
@Test
public void testDeleteNode(){
- InputStream systemInputStream = System.in;
- ByteArrayInputStream in = new ByteArrayInputStream("y".getBytes());
- System.setIn(in);
String id = cloudRegionVertex.id().toString();
String [] args = {
+
"-action",
"DELETE_NODE",
"-userId",
@@ -139,7 +130,6 @@ public class ForceDeleteToolTest extends AAISetup {
};
deleteTool.main(args);
- System.setIn(systemInputStream);
}
@Test
@@ -151,6 +141,7 @@ public class ForceDeleteToolTest extends AAISetup {
String cloudRegionToPserverId = edges.get(0).id().toString();
String [] args = {
+
"-action",
"COLLECT_DATA",
"-userId",
@@ -160,7 +151,6 @@ public class ForceDeleteToolTest extends AAISetup {
};
deleteTool.main(args);
-
}
@Test
@@ -175,6 +165,7 @@ public class ForceDeleteToolTest extends AAISetup {
String cloudRegionToPserverId = edges.get(0).id().toString();
String [] args = {
+
"-action",
"DELETE_EDGE",
"-userId",
@@ -186,200 +177,6 @@ public class ForceDeleteToolTest extends AAISetup {
deleteTool.main(args);
System.setIn(systemInputStream);
}
-
- //------------------------------ Adding some new tests --------------
-
-
- @Test
- public void testCollectDataForVertexId(){
- String id = cloudRegionVertex.id().toString();
-
- String [] args = {
- "-action",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-vertexId",
- id
- };
-
- deleteTool.main(args);
- }
-
-
- @Test
- public void testInputParamsBadAction(){
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
- List<Edge> edges = g.E().toList();
- String cloudRegionToPserverId = edges.get(0).id().toString();
-
- String [] args = {
- "-action",
- "JUNK-ACTION",
- "-userId",
- "someuser",
- "-edgeId",
- cloudRegionToPserverId
- };
-
- deleteTool.main(args);
- // Capture the standard output and see if the following text is there
- assertThat(outputCapture.toString(), containsString("Bad action parameter"));
-
- }
-
-
- @Test
- public void testMissingInputs(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- String [] args = {
- "-action"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-vertexId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-edgeId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
-
- args = new String []{
- "-params4Collect"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
- }
-
-
-
- @Test
- public void testInvalidUserIds(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
- List<Edge> edges = g.E().toList();
- String cloudRegionToPserverId = edges.get(0).id().toString();
-
- String [] args = {
- "-userId"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("No value passed with"));
-
- args = new String []{
- "-userId",
- "bad"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad userId parameter"));
-
- args = new String []{
- "-userId",
- "AAIADMIN"
- };
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad userId parameter"));
- }
-
-
- @Test
- public void testBadInputs2(){
-
- // pass in a bad/unknown argument (-junkParam)
- String [] args = {
- "-junkParam",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-edgeId",
- "999"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Unrecognized argument"));
- }
-
- @Test
- public void testBadInputs3(){
-
- // pass in a nonExistant edgeId for DELETE EDGE
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- String [] args = {
- "-action",
- "DELETE_EDGE",
- "-userId",
- "someuser",
- "-edgeId",
- "NotRealId"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Edge with edgeId = NotRealId not found"));
-
- }
-
- @Test
- public void testBadInputs4(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- // pass in a bad vertex Id when collecting data
-
- String [] args = {
- "-action",
- "COLLECT_DATA",
- "-userId",
- "someuser",
- "-vertexId",
- "NotANumber"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Bad value passed"));
-
- }
-
-
- @Test
- public void testBadInputs5(){
-
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
-
- // pass in a bad vertex Id when collecting data
-
- String [] args = {
- "-action",
- "DELETE_NODE",
- "-userId",
- "someuser",
- "-vertexId",
- "555"
- };
-
- deleteTool.main(args);
- assertThat(outputCapture.toString(), containsString("Vertex with vertexId = 555 not found"));
-
- }
-
@After
public void tearDown(){
diff --git a/src/test/java/org/onap/aai/migration/v20/MigrateL2DefaultToFalseTest.java b/src/test/java/org/onap/aai/migration/v20/MigrateL2DefaultToFalseTest.java
new file mode 100644
index 0000000..cba5c45
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v20/MigrateL2DefaultToFalseTest.java
@@ -0,0 +1,135 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v20;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersions;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class MigrateL2DefaultToFalseTest extends
+ AAISetup {
+
+ protected static final String L_INTERFACE_NODE_TYPE = "l-interface";
+ protected static final String L2_MULTI_PROPERTY = "l2-multicasting";
+
+ public static class L2DefaultMigrator extends MigrateL2DefaultToFalse {
+ public L2DefaultMigrator(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+ }
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private L2DefaultMigrator migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setup() throws Exception{
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ loader);
+
+ g.addV().property("aai-node-type", L_INTERFACE_NODE_TYPE)
+ .property("interface-name", "no-value")
+ .property("interface-id", "1")
+ .next();
+ g.addV().property("aai-node-type", L_INTERFACE_NODE_TYPE)
+ .property("interface-name", "empty-value")
+ .property("interface-id", "2")
+ .property(L2_MULTI_PROPERTY, "")
+ .next();
+ g.addV().property("aai-node-type", L_INTERFACE_NODE_TYPE)
+ .property("interface-name", "true-value")
+ .property("interface-id", "3")
+ .property(L2_MULTI_PROPERTY, "true")
+ .next();
+ g.addV().property("aai-node-type", L_INTERFACE_NODE_TYPE)
+ .property("interface-name", "false-value")
+ .property("interface-id", "4")
+ .property(L2_MULTI_PROPERTY, "false")
+ .next();
+ g.addV().property("aai-node-type", L_INTERFACE_NODE_TYPE)
+ .property("interface-name", "extra")
+ .property("interface-id", "5")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new L2DefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testAllValuesSet() {
+ assertTrue("Value of node 1 \"no-value\" should have " + L2_MULTI_PROPERTY + " of false ",
+ g.V().has("aai-node-type", L_INTERFACE_NODE_TYPE).has("interface-name", "no-value")
+ .has(L2_MULTI_PROPERTY,false).hasNext());
+
+ assertTrue("Value of node 2 \"empty-value\" should have " + L2_MULTI_PROPERTY + " of false ",
+ g.V().has("aai-node-type", L_INTERFACE_NODE_TYPE).has("interface-name", "empty-value")
+ .has(L2_MULTI_PROPERTY,false).hasNext());
+
+ assertTrue("Value of node 3 \"true-value\" should have " + L2_MULTI_PROPERTY + " of true ",
+ g.V().has("aai-node-type", L_INTERFACE_NODE_TYPE).has("interface-name", "true-value")
+ .has(L2_MULTI_PROPERTY,true).hasNext());
+
+ assertTrue("Value of node 4 \"false-value\" should have " + L2_MULTI_PROPERTY + " of false ",
+ g.V().has("aai-node-type", L_INTERFACE_NODE_TYPE).has("interface-name", "false-value")
+ .has(L2_MULTI_PROPERTY,false).hasNext());
+
+ assertTrue("Value of node 5 \"extra\" should have " + L2_MULTI_PROPERTY + " of false ",
+ g.V().has("aai-node-type", L_INTERFACE_NODE_TYPE).has("interface-name", "extra")
+ .has(L2_MULTI_PROPERTY,false).hasNext());
+ }
+
+ @Test
+ public void testOtherMethods() {
+ assertTrue("getStatus function works", migration.getStatus().toString().contains("SUCCESS"));
+
+ assertTrue("getAffectedNodeTypes returns " + L_INTERFACE_NODE_TYPE,
+ Arrays.asList(migration.getAffectedNodeTypes().get()).contains(L_INTERFACE_NODE_TYPE));
+
+ assertTrue("getMigrationName returns MigrateL2DefaultToFalse",
+ migration.getMigrationName().equals("MigrateL2DefaultToFalse"));
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
index 2b45d8c..f634010 100644
--- a/src/test/resources/logback.xml
+++ b/src/test/resources/logback.xml
@@ -195,7 +195,7 @@
</fileNamePattern>
</rollingPolicy>
<encoder>
- <pattern>${"errorPattern"}</pattern>
+ <pattern>${errorPattern}</pattern>
</encoder>
</appender>
<appender name="dmaapAAIEventConsumerInfo"
@@ -353,7 +353,56 @@
</appender>
<!-- DataSnapshot logs ended -->
-
+
+
+ <!-- AuditGraphson2SQL logs started -->
+ <appender name="auditGraphson2Sql" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <File>${logDirectory}/auditGraphson2Sql/error.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/auditGraphson2Sql/error.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="auditGraphson2Sqldebug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>DEBUG</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <File>${logDirectory}/auditGraphson2Sql/debug.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/auditGraphson2Sql/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="auditGraphson2Sqlaudit" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <File>${logDirectory}/auditGraphson2Sql/audit.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/auditGraphson2Sql/audit.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!-- AuditGraphson2Sql logs ended -->
+
+
+
<!-- HistoryTruncate logs started -->
<appender name="historyTruncate" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
@@ -410,7 +459,7 @@
<fileNamePattern>${logDirectory}/createDBSchema/error.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
<encoder>
- <pattern>${"errorPattern"}</pattern>
+ <pattern>${errorPattern}</pattern>
</encoder>
</appender>
@@ -455,7 +504,7 @@
<fileNamePattern>${logDirectory}/misc/error.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
<encoder>
- <pattern>${"errorPattern"}</pattern>
+ <pattern>${errorPattern}</pattern>
</encoder>
</appender>
@@ -497,9 +546,9 @@
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
- <File>${logDirectory}/dupetool/debug.log</File>
+ <File>${logDirectory}/dupeTool/debug.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/dupetool/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
+ <fileNamePattern>${logDirectory}/dupeTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>${debugPattern}</pattern>
@@ -600,7 +649,7 @@
</appender>
<!-- forceDelete logs ended -->
- <!-- migration logs started -->
+ <!-- default migration logs started -->
<appender name="migrationdebug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
@@ -630,7 +679,38 @@
<pattern>${errorPattern}</pattern>
</encoder>
</appender>
- <!-- migration logs ended -->
+ <!-- default migration logs ended -->
+
+ <!-- other migration logs started -->
+ <appender name="migrationlog" class="ch.qos.logback.classic.sift.SiftingAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <!-- This is MDC value -->
+ <!-- We will assign a value to 'logFilenameAppender' via Java code -->
+ <discriminator>
+ <key>logFilenameAppender</key>
+ <defaultValue>undefined</defaultValue>
+ </discriminator>
+ <sift>
+ <!-- A standard RollingFileAppender, the log file is based on 'logFileName'
+ at runtime -->
+ <appender name="FILE-${logFilenameAppender}"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/migration/${logFilenameAppender}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/migration/${logFilenameAppender}.log.%d{yyyy-MM-dd}
+ </fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
+ </encoder>
+ </appender>
+ </sift>
+ </appender>
+ <!-- other migration logs ended -->
<!-- DataGrooming logs started -->
<appender name="dataExportError" class="ch.qos.logback.core.rolling.RollingFileAppender">
@@ -971,6 +1051,13 @@
<appender-ref ref="STDOUT"/>
</logger>
+ <logger name="org.onap.aai.audit.AuditGraphson2Sql" level="DEBUG" additivity="false">
+ <appender-ref ref="auditGraphson2Sql"/>
+ <appender-ref ref="auditGraphson2Sqldebug"/>
+ <appender-ref ref="auditGraphson2Sqlaudit"/>
+ <appender-ref ref="STDOUT"/>
+ </logger>
+
<logger name="org.onap.aai.historytruncate" level="DEBUG" additivity="false">
<appender-ref ref="historyTruncate"/>
<appender-ref ref="historyTruncatedebug"/>
@@ -1028,6 +1115,14 @@
<appender-ref ref="migrationdebug" />
<appender-ref ref="migrationerror" />
</logger>
+
+ <logger name="org.onap.aai.migration" level="ERROR" additivity="false">
+ <appender-ref ref="migrationlog" />
+ </logger>
+
+ <logger name="org.onap.aai.migration" level="INFO" additivity="false">
+ <appender-ref ref="migrationlog" />
+ </logger>
<logger name="org.onap.aai.dataexport" level="DEBUG" additivity="false">
<appender-ref ref="dataExportError"/>