diff options
author | 2019-05-20 12:11:54 +0530 | |
---|---|---|
committer | 2019-06-12 08:05:21 +0000 | |
commit | 2623c8402a57e2035db69a9d92d2851050916801 (patch) | |
tree | f7311f32a5566702921a2e650b476f1ff6bf0de1 /test-apis-ci/src/main/java/org/openecomp | |
parent | 799bc7e3c75de762dea7448c6f8f5d6e5f3f9671 (diff) |
Upgrade SDC from Titan to Janus Graph
Upgrade SDC from Titan to Janus Graph
Change-Id: I67fb8b8e60cc6751697bc5ff2f06754c92803786
Issue-ID: SDC-2296
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp')
5 files changed, 76 insertions, 76 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java index 4f74345182..8f6d9db4c2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java @@ -24,7 +24,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.Status; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraph; import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; import org.junit.rules.TestName; @@ -67,7 +67,7 @@ public abstract class ComponentBaseTest { protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator; private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html"; - protected static TitanGraph titanGraph; + protected static JanusGraph janusGraph; public static Config config; protected static ITestContext myContext; @@ -151,7 +151,7 @@ public abstract class ComponentBaseTest { } @AfterSuite(alwaysRun = true) - public static void shutdownTitan() throws Exception { + public static void shutdownJanusGraph() throws Exception { performClean(); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java index c44c029c76..ffdf2fd02a 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java @@ -68,7 +68,7 @@ public class Config { private String neoDBusername; private String neoDBpassword; - private String titanPropertiesFile; + private String januGraphPropertiesFile; private List<String> packages; private List<String> bugs; private List<String> resourcesNotToDelete; @@ -498,12 +498,12 @@ public class Config { this.neoDBpassword = neoDBpassword; } - public String getTitanPropertiesFile() { - return titanPropertiesFile; + public String getjanuGraphPropertiesFile() { + return januGraphPropertiesFile; } - public void setTitanPropertiesFile(String titanPropertiesFile) { - this.titanPropertiesFile = titanPropertiesFile; + public void setjanuGraphPropertiesFile(String januGraphPropertiesFile) { + this.januGraphPropertiesFile = januGraphPropertiesFile; } public List<String> getPackages() { @@ -640,7 +640,7 @@ public class Config { + ", importTypesConfigDir=" + importTypesConfigDir + ", testSuites=" + testSuites + ", catalogFeHost=" + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword=" - + neoDBpassword + ", titanPropertiesFile=" + titanPropertiesFile + ", packages=" + packages + ", bugs=" + + neoDBpassword + ", januGraphPropertiesFile=" + januGraphPropertiesFile + ", packages=" + packages + ", bugs=" + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete=" + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName=" diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java index fc0e33d3a8..bcd00a10b7 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java @@ -31,7 +31,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.sdc.ci.tests.api.Urls; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.utils.DbUtils; -import org.openecomp.sdc.ci.tests.utils.DbUtils.TitanState; +import org.openecomp.sdc.ci.tests.utils.DbUtils.JanusGraphState; import org.openecomp.sdc.ci.tests.utils.Utils; import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; @@ -45,7 +45,7 @@ public class ImportCapabilityTypeCITest { @AfterClass public static void afterClass() { - DbUtils.shutDowntitan(); + DbUtils.shutDownJanusGraph(); } static Config config = Config.instance(); @@ -55,7 +55,7 @@ public class ImportCapabilityTypeCITest { @Test public void testAddingCapabilityTypes() throws IOException { - TitanState originalState = DbUtils.getCurrentTitanState(); + JanusGraphState originalState = DbUtils.getCurrentJanusGraphState(); String importResourceDir = config.getImportResourceConfigDir(); @@ -64,20 +64,20 @@ public class ImportCapabilityTypeCITest { importCapabilityType(capabilityTypes); Either<Vertex, Boolean> eitherVertex = DbUtils.getVertexByUId("tosca.capabilities.Test.Ci"); AssertJUnit.assertTrue(eitherVertex.isLeft()); - DbUtils.restoreToTitanState(originalState); + DbUtils.restoreToJanusGraphState(originalState); eitherVertex = DbUtils.getVertexByUId("tosca.capabilities.Test.Ci"); AssertJUnit.assertTrue(eitherVertex.isRight()); } @Test public void AddingCapabilityNotFound() throws IOException { - TitanState originalState = DbUtils.getCurrentTitanState(); + JanusGraphState originalState = DbUtils.getCurrentJanusGraphState(); String importResourceTestsDir = config.getImportResourceTestsConfigDir(); String capabilitiesTests = importResourceTestsDir + File.separator + "capabilityTypesCi.zip"; importCapabilityType(capabilitiesTests); Either<Vertex, Boolean> eitherVertex = DbUtils.getVertexByUId("tosca.capabilities.NonExsitingCapability"); AssertJUnit.assertTrue(eitherVertex.isRight()); - DbUtils.restoreToTitanState(originalState); + DbUtils.restoreToJanusGraphState(originalState); } public static Integer importAllCapabilityTypes() throws IOException { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java index dea9084149..5ba7062f3b 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java @@ -21,10 +21,10 @@ package org.openecomp.sdc.ci.tests.utils; import com.google.gson.*; -import com.thinkaurelius.titan.core.TitanEdge; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanVertex; +import org.janusgraph.core.JanusGraphEdge; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Element; @@ -43,8 +43,8 @@ import java.util.Map.Entry; public class DbUtils { - private static String titanConfigFilePath; - private static TitanGraph titanGraph; + private static String janusGraphConfigFilePath; + private static JanusGraph janusGraph; public static void cleanAllAudits() throws IOException { @@ -74,11 +74,11 @@ public class DbUtils { } public Either<Vertex, Boolean> getVertexByUId(String uid) { - TitanGraph titanGraph = getTitanGraph(); + JanusGraph janusGraph = getJanusGraph(); Either<Vertex, Boolean> result = Either.right(false); - // Iterator<Vertex> vertexItr = titanGraph.getVertices().iterator(); + // Iterator<Vertex> vertexItr = janusGraph.getVertices().iterator(); - Iterator<TitanVertex> vertexItr = titanGraph.query().vertices().iterator(); + Iterator<JanusGraphVertex> vertexItr = janusGraph.query().vertices().iterator(); while (vertexItr.hasNext()) { Vertex vertex = vertexItr.next(); // String uidFoundVal = vertex.getProperty("uid"); @@ -90,14 +90,14 @@ public class DbUtils { return result; } - public static TitanState getCurrentTitanState() { - TitanGraph titanGraph = getTitanGraph(); + public static JanusGraphState getCurrentJanusGraphState() { + JanusGraph janusGraph = getJanusGraph(); List<Vertex> vertices = new ArrayList<>(); List<Edge> edges = new ArrayList<>(); - // Iterator<Edge> edgesItr = titanGraph.getEdges().iterator(); - Iterator<TitanEdge> edgesItr = titanGraph.query().edges().iterator(); - // Iterator<Vertex> verticesItr = titanGraph.getVertices().iterator(); - Iterator<TitanVertex> verticesItr = titanGraph.query().vertices().iterator(); + // Iterator<Edge> edgesItr = janusGraph.getEdges().iterator(); + Iterator<JanusGraphEdge> edgesItr = janusGraph.query().edges().iterator(); + // Iterator<Vertex> verticesItr = janusGraph.getVertices().iterator(); + Iterator<JanusGraphVertex> verticesItr = janusGraph.query().vertices().iterator(); while (edgesItr.hasNext()) { edges.add(edgesItr.next()); } @@ -105,43 +105,43 @@ public class DbUtils { vertices.add(verticesItr.next()); } - TitanState currState = new TitanState(edges, vertices); + JanusGraphState currState = new JanusGraphState(edges, vertices); return currState; } // - private static TitanGraph getTitanGraph() { - if (titanGraph == null) { - titanGraph = TitanFactory.open(titanConfigFilePath); + private static JanusGraph getJanusGraph() { + if (janusGraph == null) { + janusGraph = JanusGraphFactory.open(janusGraphConfigFilePath); } - return titanGraph; + return janusGraph; } - public void restoreToTitanState(TitanState titanStateToRestoreTo) { + public void restoreToJanusGraphState(JanusGraphState janusGraphStateToRestoreTo) { List<Vertex> verticesToRemove = new ArrayList<>(), verticesToAdd = new ArrayList<>(); List<Edge> edgesToRemove = new ArrayList<>(), edgesToAdd = new ArrayList<>(); - TitanState currentTitanState = getCurrentTitanState(); + JanusGraphState currentJanusGraphState = getCurrentJanusGraphState(); List<Edge> joinedEdges = new ArrayList<>(); - joinedEdges.addAll(titanStateToRestoreTo.edges); - joinedEdges.retainAll(currentTitanState.edges); + joinedEdges.addAll(janusGraphStateToRestoreTo.edges); + joinedEdges.retainAll(currentJanusGraphState.edges); List<Vertex> joinedVertices = new ArrayList<>(); - joinedVertices.addAll(titanStateToRestoreTo.vertices); - joinedVertices.retainAll(currentTitanState.vertices); + joinedVertices.addAll(janusGraphStateToRestoreTo.vertices); + joinedVertices.retainAll(currentJanusGraphState.vertices); - edgesToRemove.addAll(currentTitanState.edges); + edgesToRemove.addAll(currentJanusGraphState.edges); edgesToRemove.removeAll(joinedEdges); - verticesToRemove.addAll(currentTitanState.vertices); + verticesToRemove.addAll(currentJanusGraphState.vertices); verticesToRemove.removeAll(joinedVertices); - edgesToAdd.addAll(titanStateToRestoreTo.edges); + edgesToAdd.addAll(janusGraphStateToRestoreTo.edges); edgesToAdd.removeAll(joinedEdges); - verticesToAdd.addAll(titanStateToRestoreTo.vertices); + verticesToAdd.addAll(janusGraphStateToRestoreTo.vertices); verticesToAdd.removeAll(joinedVertices); modifyGraphAccordingToDelta(verticesToRemove, verticesToAdd, edgesToRemove, edgesToAdd); @@ -151,24 +151,24 @@ public class DbUtils { private void modifyGraphAccordingToDelta(List<Vertex> verticesToRemove, List<Vertex> verticesToAdd, List<Edge> edgesToRemove, List<Edge> edgesToAdd) { - TitanGraph titanGraph = getTitanGraph(); + JanusGraph janusGraph = getJanusGraph(); for (Vertex vertex : verticesToRemove) { - // titanGraph.removeVertex(vertex); + // janusGraph.removeVertex(vertex); vertex.remove(); } for (Vertex vertex : verticesToAdd) { - TitanVertex titanVertex = titanGraph.addVertex(); - copyProperties(vertex, titanVertex); + JanusGraphVertex janusGraphVertex = janusGraph.addVertex(); + copyProperties(vertex, janusGraphVertex); } for (Edge edge : edgesToRemove) { - // titanGraph.removeEdge(edge); + // janusGraph.removeEdge(edge); edge.remove(); } for (Edge edge : edgesToAdd) { - // Element addedEdge = titanGraph.addEdge(edge.getId(), + // Element addedEdge = janusGraph.addEdge(edge.getId(), // edge.getVertex(Direction.OUT), edge.getVertex(Direction.IN), // edge.getLabel()); @@ -181,8 +181,8 @@ public class DbUtils { } - // titanGraph.commit(); - titanGraph.tx().commit(); + // janusGraph.commit(); + janusGraph.tx().commit(); } @@ -197,26 +197,26 @@ public class DbUtils { } - public static class TitanState { + public static class JanusGraphState { private List<Edge> edges; private List<Vertex> vertices; - private TitanState(List<Edge> edges, List<Vertex> vertices) { + private JanusGraphState(List<Edge> edges, List<Vertex> vertices) { this.edges = edges; this.vertices = vertices; } @Override public String toString() { - return "TitanState [edges=" + edges.size() + ", vertices=" + vertices.size() + "]"; + return "JanusGraphState [edges=" + edges.size() + ", vertices=" + vertices.size() + "]"; } } - public void shutDowntitan() { - if (titanGraph != null) { - // titanGraph.shutdown(); - titanGraph.close(); + public void shutDownJanusGraph() { + if (janusGraph != null) { + // janusGraph.shutdown(); + janusGraph.close(); } } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java b/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java index 803e190b59..322a3171ad 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java @@ -20,9 +20,9 @@ package org.openecomp.sdc.post; -import org.openecomp.sdc.be.dao.DAOTitanStrategy; -import org.openecomp.sdc.be.dao.titan.TitanGraphClient; -import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import java.io.File; @@ -30,39 +30,39 @@ public class Install { public static void main(String[] args) { if (args == null || args.length == 0) { - System.out.println("Usage: org.openecomp.sdc.post.Install path_to_titan.properties"); + System.out.println("Usage: org.openecomp.sdc.post.Install path_to_janusgraph.properties"); System.exit(1); } - String titanPropsFile = args[0]; + String janusGraphPropsFile = args[0]; - if (!isFileExists(titanPropsFile)) { + if (!isFileExists(janusGraphPropsFile)) { System.exit(2); } - if (!createTitanSchema(titanPropsFile)) { + if (!createJanusGraphSchema(janusGraphPropsFile)) { System.exit(3); } System.exit(0); } - private static boolean createTitanSchema(String titanPropsFile) { - TitanGraphClient titanGraphClient = new TitanGraphClient(new DAOTitanStrategy()); - TitanOperationStatus status = titanGraphClient.createGraph(titanPropsFile); - if (TitanOperationStatus.OK == status) { - System.out.println("Titan schema ,indexes and default values created successfully."); + private static boolean createJanusGraphSchema(String janusGraphPropsFile) { + JanusGraphClient janusGraphClient = new JanusGraphClient(new DAOJanusGraphStrategy()); + JanusGraphOperationStatus status = janusGraphClient.createGraph(janusGraphPropsFile); + if (JanusGraphOperationStatus.OK == status) { + System.out.println("JanusGraph schema ,indexes and default values created successfully."); return true; } else { System.out.println( - "Problem while creating titan schema ,indexes and default values. (" + status.name() + ")"); + "Problem while creating janusgraph schema ,indexes and default values. (" + status.name() + ")"); return false; } } - private static boolean isFileExists(String titanPropsFile) { - File f = new File(titanPropsFile); + private static boolean isFileExists(String janusGraphPropsFile) { + File f = new File(janusGraphPropsFile); if (!f.exists()) { - System.out.println(titanPropsFile + " not found"); + System.out.println(janusGraphPropsFile + " not found"); return false; } return true; |