Search in sources :

Example 11 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-graphadmin by onap.

the class ValueMigratorTest method setup.

@Before
public void setup() throws Exception {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    tx = graph.newTransaction();
    g = tx.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    Map<String, Map> map = new HashMap<>();
    Map<String, Boolean> pair = new HashMap<>();
    pair.put("in-maint", true);
    map.put("pserver", pair);
    map.put("pnf", pair);
    g.addV().property("aai-node-type", "pserver").property("pserver-id", "pserver0").next();
    g.addV().property("aai-node-type", "pserver").property("pserver-id", "pserver1").property("in-maint", "").next();
    g.addV().property("aai-node-type", "pserver").property("pserver-id", "pserver2").property("in-maint", false).next();
    g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf1").property("in-maint", false).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 SampleValueMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, map, false);
    migration.run();
    map = new HashMap<>();
    pair = new HashMap<>();
    pair.put("in-maint", true);
    map.put("pnf", pair);
    existingValuesMigration = new SampleValueMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, map, true);
    existingValuesMigration.run();
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) HashMap(java.util.HashMap) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) HashMap(java.util.HashMap) Map(java.util.Map) Before(org.junit.Before)

Example 12 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-graphadmin by onap.

the class VertexMergeTest method setUp.

@Before
public void setUp() throws Exception {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    tx = graph.newTransaction();
    g = tx.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    JanusGraphManagement mgmt = graph.openManagement();
    mgmt.makePropertyKey("test-list").dataType(String.class).cardinality(Cardinality.SET).make();
    mgmt.commit();
    Vertex pserverSkeleton = g.addV().property("aai-node-type", "pserver").property("hostname", "TEST1").property("source-of-truth", "AAI-EXTENSIONS").property("fqdn", "test1.com").property("test-list", "value1").next();
    Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface1").property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface1").next();
    Vertex pInterface2 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface2").property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2").next();
    Vertex pInterface2Secondary = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface2").property("special-prop", "value").property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2").next();
    Vertex lInterface1 = g.addV().property("aai-node-type", "l-interface").property("interface-name", "l-interface1").property("special-prop", "value").property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2/l-interfaces/l-interface/l-interface1").next();
    Vertex lInterface1Canopi = g.addV().property("aai-node-type", "l-interface").property("interface-name", "l-interface1").property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2/l-interfaces/l-interface/l-interface1").next();
    Vertex logicalLink = g.addV().property("aai-node-type", "logical-link").property("link-name", "logical-link1").property(AAIProperties.AAI_URI, "/network/logical-links/logical-link/logical-link1").next();
    Vertex pserverCanopi = g.addV().property("aai-node-type", "pserver").property("hostname", "TEST1").property("source-of-truth", "CANOPI-WS").property("fqdn", "test2.com").property("test-list", "value2").next();
    Vertex complex1 = g.addV().property("aai-node-type", "complex").property("physical-location-id", "complex1").property("source-of-truth", "RO").next();
    Vertex complex2 = g.addV().property("aai-node-type", "complex").property("physical-location-id", "complex2").property("source-of-truth", "RCT").next();
    Vertex vserver1 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver1").property("source-of-truth", "RO").next();
    Vertex vserver2 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver2").property("source-of-truth", "RCT").next();
    Vertex vserver3 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver3").property("source-of-truth", "RCT").next();
    Vertex vserver4 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver4").property("source-of-truth", "RCT").next();
    Vertex vserver5 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver5").property("source-of-truth", "RCT").next();
    edgeSerializer.addEdge(g, pserverSkeleton, complex1);
    edgeSerializer.addEdge(g, pserverSkeleton, vserver1);
    edgeSerializer.addEdge(g, pserverSkeleton, vserver2);
    edgeSerializer.addTreeEdge(g, pserverSkeleton, pInterface1);
    edgeSerializer.addTreeEdge(g, pserverSkeleton, pInterface2Secondary);
    edgeSerializer.addTreeEdge(g, pInterface2Secondary, lInterface1);
    edgeSerializer.addEdge(g, lInterface1, logicalLink);
    edgeSerializer.addEdge(g, pserverCanopi, complex2);
    edgeSerializer.addEdge(g, pserverCanopi, vserver3);
    edgeSerializer.addEdge(g, pserverCanopi, vserver4);
    edgeSerializer.addEdge(g, pserverCanopi, vserver5);
    edgeSerializer.addTreeEdge(g, pserverCanopi, pInterface2);
    edgeSerializer.addTreeEdge(g, pInterface2, lInterface1Canopi);
    Map<String, Set<String>> forceCopy = new HashMap<>();
    Set<String> forceSet = new HashSet<>();
    forceSet.add("fqdn");
    forceCopy.put("pserver", forceSet);
    TransactionalGraphEngine spy = spy(dbEngine);
    TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
    GraphTraversalSource traversal = g;
    GraphTraversalSource readOnly = g;
    when(spy.asAdmin()).thenReturn(adminSpy);
    when(adminSpy.getTraversalSource()).thenReturn(traversal);
    when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
    DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "Merge test");
    VertexMerge merge = new VertexMerge.Builder(loader, spy, serializer).edgeSerializer(edgeSerializer).build();
    merge.performMerge(pserverCanopi, pserverSkeleton, forceCopy, basePath);
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DBSerializer(org.onap.aai.serialization.db.DBSerializer) TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 13 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-graphadmin by onap.

the class DeletePInterfaceTest method setUp.

@Before
public void setUp() throws Exception {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    tx = graph.newTransaction();
    g = tx.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    System.setProperty("AJSC_HOME", ".");
    System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    Vertex pnf1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name1").next();
    Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "interface-name1").property("source-of-truth", "AAI-CSVP-INSTARAMS").next();
    edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
    Vertex pnf2 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name2").next();
    Vertex pInterface2 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "interface-name2").property("source-of-truth", "AAI-CSVP-INSTARAMS").next();
    Vertex pLink = g.addV().property("aai-node-type", "physical-link").property("interface-name", "interface-name1").next();
    edgeSerializer.addTreeEdge(g, pnf2, pInterface2);
    edgeSerializer.addEdge(g, pInterface2, pLink);
    Vertex pnf3 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name3").next();
    Vertex pInterface3 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "interface-name3").property("source-of-truth", "AAI-CSVP-INSTARAMS").next();
    Vertex lInterface = g.addV().property("aai-node-type", "l-interface").property("interface-name", "interface-name3").next();
    edgeSerializer.addTreeEdge(g, pnf3, pInterface3);
    edgeSerializer.addTreeEdge(g, pInterface3, lInterface);
    Vertex pnf4 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name4").next();
    Vertex pInterface4 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "interface-name4").next();
    edgeSerializer.addTreeEdge(g, pnf4, pInterface4);
    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 DeletePInterface(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
    migration.run();
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 14 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-graphadmin by onap.

the class MigrateHUBEvcInventoryTest method setUp.

@Before
public void setUp() throws Exception {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    tx = graph.newTransaction();
    g = tx.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
    Vertex customer1 = g.addV().property("aai-node-type", "customer").property("global-customer-id", "customer-id-1").property("subscriber-type", "CUST").next();
    Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "SAREA").next();
    Vertex servInstance1 = g.addV().property("aai-node-type", "service-instance").property("service-type", "SAREA").property("service-instance-id", "evc-name-1").next();
    Vertex servInstance3 = g.addV().property("aai-node-type", "service-instance").property("service-type", "SAREA").property("service-instance-id", "evc-name-3").next();
    Vertex servInstance2 = g.addV().property("aai-node-type", "service-instance").property("service-type", "SAREA").property("service-instance-id", "evc-name-2").next();
    Vertex evc1 = g.addV().property("aai-node-type", "evc").property("evc-id", "evc-name-1").next();
    Vertex config1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-1").next();
    Vertex fp1 = g.addV().property("aai-node-type", "forwarding-path").property("forwarding-path-id", "evc-name-1").next();
    Vertex for11 = g.addV().property("aai-node-type", "forwarder").property("sequence", "1").property("forwarder-role", "ingress").next();
    Vertex for12 = g.addV().property("aai-node-type", "forwarder").property("sequence", "2").property("forwarder-role", "egress").next();
    Vertex config11 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-1-1").next();
    Vertex config12 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-1-2").next();
    Vertex fevc11 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-1-1").property("svlan", "6").next();
    Vertex fevc12 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-1-2").property("svlan", "16").next();
    Vertex evc2 = g.addV().property("aai-node-type", "evc").property("evc-id", "evc-name-2").next();
    Vertex config2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-2").next();
    Vertex fp2 = g.addV().property("aai-node-type", "forwarding-path").property("forwarding-path-id", "evc-name-2").next();
    Vertex for21 = g.addV().property("aai-node-type", "forwarder").property("sequence", "1").property("forwarder-role", "ingress").next();
    Vertex for22 = g.addV().property("aai-node-type", "forwarder").property("sequence", "2").property("forwarder-role", "ingress").next();
    Vertex for23 = g.addV().property("aai-node-type", "forwarder").property("sequence", "3").property("forwarder-role", "egress").next();
    Vertex for24 = g.addV().property("aai-node-type", "forwarder").property("sequence", "4").property("forwarder-role", "egress").next();
    Vertex config21 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-2-1").next();
    Vertex config22 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-2-2").next();
    Vertex config23 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-2-3").next();
    Vertex config24 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-2-4").next();
    Vertex fevc21 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-2-1").property("svlan", "6").next();
    Vertex fevc22 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-2-2").property("svlan", "16").next();
    Vertex fevc23 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-2-3").property("svlan", "12").property("ivlan", "600").next();
    Vertex fevc24 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-2-4").property("svlan", "16").property("ivlan", "600").next();
    Vertex evc3 = g.addV().property("aai-node-type", "evc").property("evc-id", "evc-name-3").next();
    Vertex config3 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-3").next();
    Vertex fp3 = g.addV().property("aai-node-type", "forwarding-path").property("forwarding-path-id", "evc-name-3").next();
    Vertex for31 = g.addV().property("aai-node-type", "forwarder").property("sequence", "1").property("forwarder-role", "ingress").next();
    Vertex for32 = g.addV().property("aai-node-type", "forwarder").property("sequence", "2").property("forwarder-role", "egress").next();
    Vertex config31 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-3-1").next();
    Vertex config32 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "evc-name-3-2").next();
    Vertex fevc31 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-3-1").property("svlan", "6").next();
    Vertex fevc32 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-name-3-2").next();
    // graph 1
    edgeSerializer.addTreeEdge(g, customer1, servSub1);
    edgeSerializer.addTreeEdge(g, servSub1, servInstance1);
    edgeSerializer.addTreeEdge(g, servSub1, servInstance2);
    edgeSerializer.addTreeEdge(g, servSub1, servInstance3);
    edgeSerializer.addEdge(g, servInstance1, fp1);
    edgeSerializer.addEdge(g, servInstance2, fp2);
    edgeSerializer.addEdge(g, fp1, config1);
    edgeSerializer.addEdge(g, fp2, config2);
    edgeSerializer.addEdge(g, fp3, config3);
    edgeSerializer.addTreeEdge(g, evc1, config1);
    edgeSerializer.addTreeEdge(g, evc2, config2);
    edgeSerializer.addTreeEdge(g, evc3, config3);
    edgeSerializer.addTreeEdge(g, fp1, for11);
    edgeSerializer.addTreeEdge(g, fp1, for12);
    edgeSerializer.addTreeEdge(g, fp2, for21);
    edgeSerializer.addTreeEdge(g, fp2, for22);
    edgeSerializer.addTreeEdge(g, fp2, for23);
    edgeSerializer.addTreeEdge(g, fp2, for24);
    edgeSerializer.addTreeEdge(g, fp3, for31);
    edgeSerializer.addTreeEdge(g, fp3, for32);
    edgeSerializer.addEdge(g, for11, config11);
    edgeSerializer.addEdge(g, for12, config12);
    edgeSerializer.addEdge(g, for21, config21);
    edgeSerializer.addEdge(g, for22, config22);
    edgeSerializer.addEdge(g, for23, config23);
    edgeSerializer.addEdge(g, for24, config24);
    edgeSerializer.addEdge(g, for31, config31);
    edgeSerializer.addEdge(g, for32, config32);
    edgeSerializer.addTreeEdge(g, config11, fevc11);
    edgeSerializer.addTreeEdge(g, config12, fevc12);
    edgeSerializer.addTreeEdge(g, config21, fevc21);
    edgeSerializer.addTreeEdge(g, config22, fevc22);
    edgeSerializer.addTreeEdge(g, config23, fevc23);
    edgeSerializer.addTreeEdge(g, config24, fevc24);
    edgeSerializer.addTreeEdge(g, config31, fevc31);
    edgeSerializer.addTreeEdge(g, config32, fevc32);
    TransactionalGraphEngine spy = spy(dbEngine);
    TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
    GraphTraversalSource traversal = g;
    GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
    when(spy.tx()).thenReturn(tx);
    when(spy.asAdmin()).thenReturn(adminSpy);
    when(adminSpy.getTraversalSource()).thenReturn(traversal);
    when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
    migration = new MigrateHUBEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
    migration.run();
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 15 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine in project aai-graphadmin by onap.

the class MigrateBadWidgetModelsPartTwoTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
    JanusGraphManagement janusgraphManagement = graph.openManagement();
    g = graph.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    createFirstVertexAndRelatedVertexes();
    TransactionalGraphEngine spy = spy(dbEngine);
    TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
    GraphTraversalSource traversal = g;
    when(spy.asAdmin()).thenReturn(adminSpy);
    when(adminSpy.getTraversalSource()).thenReturn(traversal);
    Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
    migration = new MockMigrateBadWidgetModelsPartTwo(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
    migration.run();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Aggregations

JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)78 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)51 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)45 Before (org.junit.Before)40 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)27 DBSerializer (org.onap.aai.serialization.db.DBSerializer)10 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)8 SchemaVersion (org.onap.aai.setup.SchemaVersion)8 Loader (org.onap.aai.introspection.Loader)7 AAIException (org.onap.aai.exceptions.AAIException)5 ModelType (org.onap.aai.introspection.ModelType)3 QueryStyle (org.onap.aai.serialization.engines.QueryStyle)3 UrlBuilder (org.onap.aai.serialization.queryformats.utils.UrlBuilder)3 Properties (java.util.Properties)2 Test (org.junit.Test)2 NotificationHelper (org.onap.aai.migration.NotificationHelper)2 UEBNotification (org.onap.aai.rest.ueb.UEBNotification)2 JCommander (com.beust.jcommander.JCommander)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1