Search in sources :

Example 21 with TransactionalGraphEngine

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

the class EdgeSwingMigratorTest method setUp.

@Before
public void setUp() throws Exception {
    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 MockEdgeSwingMigrator(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)

Example 22 with TransactionalGraphEngine

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

the class MigrateSAREvcInventoryTest 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", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd").property("subscriber-type", "CUST").next();
    Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "SAREA").next();
    Vertex servInst1 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "evc-name-1").next();
    Vertex customer2 = g.addV().property("aai-node-type", "customer").property("global-customer-id", "cust-1").property("subscriber-type", "CUST").next();
    Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "SAREA").next();
    Vertex servInst2 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "evc-name-1").next();
    Vertex collectorPnf = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name-collector-1").next();
    Vertex bearerPnf = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-name-bearer-1").next();
    Vertex collectorPort = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-int-collector-1").next();
    Vertex bearerPort = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-int-bearer-1").next();
    Vertex servInst4 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "evc-name-4").next();
    // graph 1
    edgeSerializer.addTreeEdge(g, customer1, servSub1);
    // edgeSerializer.addTreeEdge(g, servSub1, servInst1);
    edgeSerializer.addTreeEdge(g, customer2, servSub2);
    edgeSerializer.addTreeEdge(g, servSub2, servInst2);
    // evc-name-4 exists in graph as a child of SAREA serv-sub
    edgeSerializer.addTreeEdge(g, servSub1, servInst4);
    edgeSerializer.addTreeEdge(g, collectorPnf, collectorPort);
    edgeSerializer.addTreeEdge(g, bearerPnf, bearerPort);
    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 MigrateSAREvcInventory(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 23 with TransactionalGraphEngine

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

the class SDWANSpeedChangeMigrationTest 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);
    Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "DHV").next();
    Vertex servinst1 = g.addV().property("aai-node-type", "service-instance").property("service-type", "DHV").next();
    Vertex allotedRsrc1 = g.addV().property("aai-node-type", "allotted-resource").property("id", "rsrc1").next();
    Vertex servinst2 = g.addV().property("aai-node-type", "service-instance").property("service-type", "VVIG").next();
    Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "VVIG").next();
    Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnfId1").next();
    Vertex vServer1 = g.addV().property("aai-node-type", "vserver").next();
    Vertex pServer1 = g.addV().property("aai-node-type", "pserver").next();
    Vertex pInterfaceWan1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "ge-0/0/10").next();
    Vertex tunnelXConnectAll_Wan1 = g.addV().property("aai-node-type", "tunnel-xconnect").property("id", "txc1").property("bandwidth-up-wan1", "300 Mbps").property("bandwidth-down-wan1", "400 Mbps").property("bandwidth-up-wan2", "500 Mbps").property("bandwidth-down-wan2", "600 Mbps").next();
    pLinkWan1 = g.addV().property("aai-node-type", "physical-link").property("link-name", "pLinkWan1").property("service-provider-bandwidth-up-value", "empty").property("service-provider-bandwidth-up-units", "empty").property("service-provider-bandwidth-down-value", "empty").property("service-provider-bandwidth-down-units", "empty").next();
    Vertex servSub3 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "DHV").next();
    Vertex servinst3 = g.addV().property("aai-node-type", "service-instance").property("service-type", "DHV").next();
    Vertex allotedRsrc3 = g.addV().property("aai-node-type", "allotted-resource").property("id", "rsrc1").next();
    Vertex servinst4 = g.addV().property("aai-node-type", "service-instance").property("service-type", "VVIG").next();
    Vertex servSub4 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "VVIG").next();
    Vertex genericvnf3 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnfId1").next();
    Vertex vServer3 = g.addV().property("aai-node-type", "vserver").next();
    Vertex pServer3 = g.addV().property("aai-node-type", "pserver").next();
    Vertex pInterfaceWan3 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "ge-0/0/11").next();
    Vertex tunnelXConnectAll_Wan3 = g.addV().property("aai-node-type", "tunnel-xconnect").property("id", "txc3").property("bandwidth-up-wan1", "300 Mbps").property("bandwidth-down-wan1", "400 Mbps").property("bandwidth-up-wan2", "500 Mbps").property("bandwidth-down-wan2", "600 Mbps").next();
    pLinkWan3 = g.addV().property("aai-node-type", "physical-link").property("link-name", "pLinkWan3").property("service-provider-bandwidth-up-value", "empty").property("service-provider-bandwidth-up-units", "empty").property("service-provider-bandwidth-down-value", "empty").property("service-provider-bandwidth-down-units", "empty").next();
    Vertex servSub5 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "DHV").next();
    Vertex servinst5 = g.addV().property("aai-node-type", "service-instance").property("service-type", "DHV").next();
    Vertex allotedRsrc5 = g.addV().property("aai-node-type", "allotted-resource").property("id", "rsrc1").next();
    Vertex servinst6 = g.addV().property("aai-node-type", "service-instance").property("service-type", "VVIG").next();
    Vertex servSub6 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "VVIG").next();
    Vertex genericvnf5 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnfId1").next();
    Vertex vServer5 = g.addV().property("aai-node-type", "vserver").next();
    Vertex pServer5 = g.addV().property("aai-node-type", "pserver").next();
    Vertex pInterfaceWan5 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "ge-0/0/10").next();
    Vertex tunnelXConnectAll_Wan5 = g.addV().property("aai-node-type", "tunnel-xconnect").property("id", "txc5").property("bandwidth-up-wan1", "").property("bandwidth-down-wan1", "").property("bandwidth-up-wan2", "500 Mbps").property("bandwidth-down-wan2", "600 Mbps").next();
    pLinkWan5 = g.addV().property("aai-node-type", "physical-link").property("link-name", "pLinkWan5").property("service-provider-bandwidth-up-value", "").property("service-provider-bandwidth-up-units", "").property("service-provider-bandwidth-down-value", "").property("service-provider-bandwidth-down-units", "").next();
    Vertex servSub7 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "DHV").next();
    Vertex servinst7 = g.addV().property("aai-node-type", "service-instance").property("service-type", "DHV").next();
    Vertex allotedRsrc7 = g.addV().property("aai-node-type", "allotted-resource").property("id", "rsrc1").next();
    Vertex servinst9 = g.addV().property("aai-node-type", "service-instance").property("service-type", "VVIG").next();
    Vertex servSub9 = g.addV().property("aai-node-type", "service-subscription").property("service-type", "VVIG").next();
    Vertex genericvnf7 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnfId1").next();
    Vertex vServer7 = g.addV().property("aai-node-type", "vserver").next();
    Vertex pServer7 = g.addV().property("aai-node-type", "pserver").next();
    Vertex pInterfaceWan7 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "ge-0/0/11").next();
    Vertex tunnelXConnectAll_Wan7 = g.addV().property("aai-node-type", "tunnel-xconnect").property("id", "txc7").property("bandwidth-up-wan1", "300 Mbps").property("bandwidth-down-wan1", "400 Mbps").property("bandwidth-up-wan2", "").property("bandwidth-down-wan2", "").next();
    pLinkWan7 = g.addV().property("aai-node-type", "physical-link").property("link-name", "pLinkWan5").property("service-provider-bandwidth-up-value", "").property("service-provider-bandwidth-up-units", "").property("service-provider-bandwidth-down-value", "").property("service-provider-bandwidth-down-units", "").next();
    edgeSerializer.addTreeEdge(g, servSub1, servinst1);
    edgeSerializer.addEdge(g, servinst1, allotedRsrc1);
    edgeSerializer.addTreeEdge(g, servinst2, servSub2);
    edgeSerializer.addTreeEdge(g, allotedRsrc1, servinst2);
    edgeSerializer.addTreeEdge(g, allotedRsrc1, tunnelXConnectAll_Wan1);
    edgeSerializer.addEdge(g, servinst1, genericvnf1);
    edgeSerializer.addEdge(g, genericvnf1, vServer1);
    edgeSerializer.addEdge(g, vServer1, pServer1);
    edgeSerializer.addTreeEdge(g, pServer1, pInterfaceWan1);
    edgeSerializer.addEdge(g, pInterfaceWan1, pLinkWan1);
    edgeSerializer.addTreeEdge(g, servSub3, servinst3);
    edgeSerializer.addEdge(g, servinst3, allotedRsrc3);
    edgeSerializer.addTreeEdge(g, servinst4, servSub4);
    edgeSerializer.addTreeEdge(g, allotedRsrc3, servinst4);
    edgeSerializer.addTreeEdge(g, allotedRsrc3, tunnelXConnectAll_Wan3);
    edgeSerializer.addEdge(g, servinst3, genericvnf3);
    edgeSerializer.addEdge(g, genericvnf3, vServer3);
    edgeSerializer.addEdge(g, vServer3, pServer3);
    edgeSerializer.addTreeEdge(g, pServer3, pInterfaceWan3);
    edgeSerializer.addEdge(g, pInterfaceWan3, pLinkWan3);
    edgeSerializer.addTreeEdge(g, servSub5, servinst5);
    edgeSerializer.addEdge(g, servinst5, allotedRsrc5);
    edgeSerializer.addTreeEdge(g, servinst6, servSub6);
    edgeSerializer.addTreeEdge(g, allotedRsrc5, servinst6);
    edgeSerializer.addTreeEdge(g, allotedRsrc5, tunnelXConnectAll_Wan5);
    edgeSerializer.addEdge(g, servinst5, genericvnf5);
    edgeSerializer.addEdge(g, genericvnf5, vServer5);
    edgeSerializer.addEdge(g, vServer5, pServer5);
    edgeSerializer.addTreeEdge(g, pServer5, pInterfaceWan5);
    edgeSerializer.addEdge(g, pInterfaceWan5, pLinkWan5);
    edgeSerializer.addTreeEdge(g, servSub7, servinst7);
    edgeSerializer.addEdge(g, servinst7, allotedRsrc7);
    edgeSerializer.addTreeEdge(g, servinst9, servSub9);
    edgeSerializer.addTreeEdge(g, allotedRsrc7, servinst9);
    edgeSerializer.addTreeEdge(g, allotedRsrc7, tunnelXConnectAll_Wan7);
    edgeSerializer.addEdge(g, servinst7, genericvnf7);
    edgeSerializer.addEdge(g, genericvnf7, vServer7);
    edgeSerializer.addEdge(g, vServer7, pServer7);
    edgeSerializer.addTreeEdge(g, pServer7, pInterfaceWan7);
    edgeSerializer.addEdge(g, pInterfaceWan7, pLinkWan7);
    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 SDWANSpeedChangeMigration(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 24 with TransactionalGraphEngine

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

the class MigratePServerAndPnfEquipTypeTest 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);
    pserver1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Server").next();
    pserver2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server").next();
    pnf1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch").next();
    pnf22 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "switch").next();
    pserver3 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server1").next();
    pnf2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE).property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch1").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 MigratePserverAndPnfEquipType(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) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 25 with TransactionalGraphEngine

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

the class MigrateVnfcModelInvariantIdTest 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);
    Vertex vnfc1 = g.addV().property("aai-node-type", "vnfc").property("model-invariant-id", "vnfc-invariant-id-1").property("vnfcName", "vnfc-name-1").property("nfcNamingCode", "naming-code-1").property("nfcFunction", "function-1").property("model-version-id", "vnfc-variant-id-1").next();
    Vertex vnfc2 = g.addV().property("aai-node-type", "vnfc").property("model-invariant-id-local", "vnfc-invariant-id-2").property("vnfcName", "vnfc-name-2").property("nfcNamingCode", "naming-code-2").property("nfcFunction", "function-2").property("model-version-id-local", "vnfc-version-id-2").next();
    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 MigrateVnfcModelInvariantId(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)

Aggregations

TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)86 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)60 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)45 Loader (org.onap.aai.introspection.Loader)42 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)33 Before (org.junit.Before)31 Test (org.junit.Test)24 Introspector (org.onap.aai.introspection.Introspector)23 Graph (org.apache.tinkerpop.gremlin.structure.Graph)18 Matchers.containsString (org.hamcrest.Matchers.containsString)18 JanusGraph (org.janusgraph.core.JanusGraph)18 DBSerializer (org.onap.aai.serialization.db.DBSerializer)18 AAIException (org.onap.aai.exceptions.AAIException)9 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)8 SchemaVersion (org.onap.aai.setup.SchemaVersion)8 URI (java.net.URI)6 QueryParser (org.onap.aai.parsers.query.QueryParser)6 JsonObject (com.google.gson.JsonObject)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 URIToObject (org.onap.aai.parsers.uri.URIToObject)4