use of org.onap.aai.serialization.engines.TransactionalGraphEngine 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);
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine 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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine 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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine 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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateForwarderEvcCircuitIdTest method setUp.
@Before
public void setUp() throws Exception {
g = tx.traversal();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
dbEngine = new JanusGraphDBEngine(queryStyle, loader);
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
Vertex pnf1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-1").next();
Vertex pnf2 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-2").next();
Vertex pnf3 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-3").next();
Vertex pnf4 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-4").next();
Vertex pnf5 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-5").next();
Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-1").next();
Vertex pInterface2 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-2").next();
Vertex pInterface3 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-3").next();
Vertex pInterface4 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-4").next();
Vertex pInterface5 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-5").next();
Vertex forwarder1 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
Vertex forwarder2 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
Vertex forwarder3 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
Vertex forwarder4 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
Vertex forwarder5 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
Vertex configuration1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-1").property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex configuration2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-2").property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex configuration3 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-3").property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex configuration4 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-4").property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex configuration5 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-5").property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex forwarderEvc1 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-1").property("circuit-id", "1").property("resource-version", "v13").next();
Vertex forwarderEvc2 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-2").property("circuit-id", "2").property("resource-version", "v13").next();
Vertex forwarderEvc3 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-3").property("resource-version", "v13").next();
Vertex forwarderEvc4 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-4").property("circuit-id", "3").property("resource-version", "v13").next();
Vertex forwarderEvc5 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-5").property("resource-version", "v13").next();
edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
edgeSerializer.addEdge(g, pInterface1, forwarder1);
edgeSerializer.addEdge(g, forwarder1, configuration1);
edgeSerializer.addTreeEdge(g, configuration1, forwarderEvc1);
edgeSerializer.addTreeEdge(g, pnf2, pInterface2);
edgeSerializer.addEdge(g, pInterface2, forwarder2);
edgeSerializer.addEdge(g, forwarder2, configuration2);
edgeSerializer.addTreeEdge(g, configuration2, forwarderEvc2);
edgeSerializer.addTreeEdge(g, pnf3, pInterface3);
edgeSerializer.addEdge(g, pInterface3, forwarder3);
edgeSerializer.addEdge(g, forwarder3, configuration3);
edgeSerializer.addTreeEdge(g, configuration3, forwarderEvc3);
edgeSerializer.addTreeEdge(g, pnf4, pInterface4);
edgeSerializer.addEdge(g, pInterface4, forwarder4);
edgeSerializer.addEdge(g, forwarder4, configuration4);
edgeSerializer.addTreeEdge(g, configuration4, forwarderEvc4);
edgeSerializer.addTreeEdge(g, pnf5, pInterface5);
edgeSerializer.addEdge(g, pInterface5, forwarder5);
edgeSerializer.addEdge(g, forwarder5, configuration5);
edgeSerializer.addTreeEdge(g, configuration5, forwarderEvc5);
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 MigrateForwarderEvcCircuitId(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
Aggregations