use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateRadcomChangesTest 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 genericVnf1 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-1").property("vnf-name", "name-1").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf2 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-2").property("vnf-name", "name-2").property("vnf-type", "test").property("model-invariant-id-local", "change").property("model-version-id-local", "change").property("model-customization-id", "change").next();
Vertex genericVnf3 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-3").property("vnf-name", "no-service").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf4 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-4").property("vnf-name", "no-invariant").property("vnf-type", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf5 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-5").property("vnf-name", "no-version").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf6 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-6").property("vnf-name", "no-customization").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex genericVnf7 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-7").property("vnf-name", "no ids").property("vnf-type", "test").next();
Vertex genericVnf8 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-8").property("vnf-name", "many-service-1").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf9 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-9").property("vnf-name", "many-service-2").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf10 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-10").property("vnf-name", "multi-name").property("vnf-type", "test").next();
Vertex genericVnf11 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-11").property("vnf-name", "multi-name").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex genericVnf12 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-12").property("vnf-name", "wrong-type").property("vnf-type", "none").next();
Vertex genericVnf13 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-13").property("vnf-name", "wrong-name").property("vnf-type", "test").property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
Vertex serviceInstance1 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "service-1").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex serviceInstance2 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "service-2").property("model-invariant-id-local", "diff").property("model-version-id-local", "diff").next();
Vertex serviceInstance3 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "no-invariant").property("model-version-id-local", "test").next();
Vertex serviceInstance4 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "no-version").property("model-invariant-id-local", "test").next();
Vertex serviceInstance5 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "no ids").next();
Vertex serviceInstance6 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "service-many").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex serviceInstance7 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "wrong").next();
Vertex serviceInstance8 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "connected-wrong").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex serviceModel = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-service-inv").property("model-type", "Service").next();
Vertex serviceModelVer = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-service-ver").property("model-name", "test-service").property("version", "test").next();
Vertex resourceModel = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-resource-inv").property("model-type", "VNF-resource").next();
Vertex resourceModelVer = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-resource-ver").property("model-name", "test-resource").property("version", "test").next();
Vertex resourceModelElement1 = g.addV().property("aai-node-type", "model-element").property("model-element-uuid", "resource-element-start").property("new-data-del-flag", "T").property("cardinality", "unbounded").next();
Vertex newVfModuleModelVer2 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-vf-module-ver-2").property("model-name", "model-2").property("version", "test").next();
Vertex newVfModuleModel2 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-vf-module-inv-2").property("model-type", "2").next();
Vertex resourceModelElement2 = g.addV().property("aai-node-type", "model-element").property("model-element-uuid", "resource-element-depth-1").property("new-data-del-flag", "T").property("cardinality", "unbounded").next();
Vertex newVfModuleModelVer3 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-vf-module-ver-3").property("model-name", "model-3").property("version", "test").next();
Vertex newVfModuleModel3 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-vf-module-inv-3").property("model-type", "3").next();
Vertex resourceModelElement3 = g.addV().property("aai-node-type", "model-element").property("model-element-uuid", "resource-element-depth-2-1").property("new-data-del-flag", "T").property("cardinality", "unbounded").next();
Vertex newVfModuleModelVer4 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-vf-module-ver-4").property("model-name", "model-4").property("version", "test").next();
Vertex newVfModuleModel4 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-vf-module-inv-4").property("model-type", "4").next();
Vertex resourceModelElement4 = g.addV().property("aai-node-type", "model-element").property("model-element-uuid", "resource-element-depth-2-2").property("new-data-del-flag", "T").property("cardinality", "unbounded").next();
Vertex newVfModuleModelVer5 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-vf-module-ver-5").property("model-name", "model-5").property("version", "test").next();
Vertex newVfModuleModel5 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-vf-module-inv-5").property("model-type", "5").next();
Vertex resourceModelElement5 = g.addV().property("aai-node-type", "model-element").property("model-element-uuid", "resource-element-depth-2-3").property("new-data-del-flag", "T").property("cardinality", "unbounded").next();
Vertex newVfModuleModelVer1 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "new-vf-module-ver-1").property("model-name", "model-1").property("version", "test").next();
Vertex newVfModuleModel1 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "new-vf-module-inv-1").property("model-type", "1").next();
Vertex vfModule1 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "vf-module-1").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex vfModule2 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "vf-module-2").property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
Vertex vfModule3 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "no-invariant").property("model-version-id-local", "test").next();
Vertex vfModule4 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "no-ver").property("model-invariant-id-local", "test").next();
Vertex vfModule5 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "no-ids").next();
Vertex badVfModule = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "bad").next();
Vertex vserver1 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver-1").property("vserver-name", "vname-1").next();
Vertex vserver2 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver-2").property("vserver-name", "vname-2").next();
Vertex unchangedVserver = g.addV().property("aai-node-type", "vserver").property("vserver-id", "unchanged").property("vserver-name", "unchanged").next();
Vertex image1 = g.addV().property("aai-node-type", "image").property("image-id", "image-id-1").property("image-name", "image-1").next();
Vertex image2 = g.addV().property("aai-node-type", "image").property("image-id", "image-id-2").property("image-name", "image-2").next();
Vertex oldImage = g.addV().property("aai-node-type", "image").property("image-id", "image-old").property("image-name", "image-old-name").next();
Vertex badImage = g.addV().property("aai-node-type", "image").property("image-id", "image-bad").property("image-name", "image-bad").next();
Vertex tenant1 = g.addV().property("aai-node-type", "tenant").property("tenant-id", "tenant-id-1").property("tenant-name", "tenant-1").next();
Vertex tenant2 = g.addV().property("aai-node-type", "tenant").property("tenant-id", "tenant-id-2").property("tenant-name", "tenant-2").next();
Vertex cloudRegion1 = g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "region-1").property("cloud-owner", "owner-1").next();
Vertex cloudRegion2 = g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "region-2").property("cloud-owner", "owner-2").next();
edgeSerializer.addEdge(g, genericVnf1, serviceInstance1);
edgeSerializer.addEdge(g, genericVnf2, serviceInstance2);
edgeSerializer.addEdge(g, genericVnf4, serviceInstance3);
edgeSerializer.addEdge(g, genericVnf5, serviceInstance4);
edgeSerializer.addEdge(g, genericVnf6, serviceInstance5);
edgeSerializer.addEdge(g, genericVnf8, serviceInstance6);
edgeSerializer.addEdge(g, genericVnf9, serviceInstance6);
edgeSerializer.addEdge(g, genericVnf12, serviceInstance8);
edgeSerializer.addTreeEdge(g, genericVnf2, vfModule1);
edgeSerializer.addTreeEdge(g, genericVnf4, vfModule2);
edgeSerializer.addTreeEdge(g, genericVnf5, vfModule3);
edgeSerializer.addTreeEdge(g, genericVnf6, vfModule4);
edgeSerializer.addTreeEdge(g, genericVnf7, vfModule5);
edgeSerializer.addTreeEdge(g, genericVnf12, badVfModule);
edgeSerializer.addTreeEdge(g, serviceModel, serviceModelVer);
edgeSerializer.addTreeEdge(g, resourceModel, resourceModelVer);
edgeSerializer.addTreeEdge(g, resourceModelVer, resourceModelElement1);
edgeSerializer.addEdge(g, resourceModelElement1, newVfModuleModelVer2);
edgeSerializer.addTreeEdge(g, newVfModuleModelVer2, newVfModuleModel2);
edgeSerializer.addTreeEdge(g, resourceModelElement1, resourceModelElement2);
edgeSerializer.addEdge(g, resourceModelElement2, newVfModuleModelVer3);
edgeSerializer.addTreeEdge(g, newVfModuleModelVer3, newVfModuleModel3);
edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement3);
edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement4);
edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement5);
edgeSerializer.addEdge(g, resourceModelElement3, newVfModuleModelVer4);
edgeSerializer.addTreeEdge(g, newVfModuleModelVer4, newVfModuleModel4);
edgeSerializer.addEdge(g, resourceModelElement4, newVfModuleModelVer5);
edgeSerializer.addTreeEdge(g, newVfModuleModelVer5, newVfModuleModel5);
edgeSerializer.addEdge(g, resourceModelElement5, newVfModuleModelVer1);
edgeSerializer.addTreeEdge(g, newVfModuleModelVer1, newVfModuleModel1);
edgeSerializer.addEdge(g, vfModule1, vserver1);
edgeSerializer.addEdge(g, vfModule2, vserver2);
edgeSerializer.addEdge(g, vfModule4, unchangedVserver);
edgeSerializer.addEdge(g, vserver2, oldImage);
edgeSerializer.addEdge(g, unchangedVserver, badImage);
edgeSerializer.addTreeEdge(g, image1, cloudRegion1);
edgeSerializer.addTreeEdge(g, tenant1, cloudRegion1);
edgeSerializer.addTreeEdge(g, tenant1, vserver1);
edgeSerializer.addTreeEdge(g, image2, cloudRegion2);
edgeSerializer.addTreeEdge(g, tenant2, cloudRegion2);
edgeSerializer.addTreeEdge(g, tenant2, vserver2);
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 MigrateRadcomChanges(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateBooleanDefaultsToFalseTest method setup.
@Before
public void setup() throws Exception {
g = tx.traversal();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
dbEngine = new JanusGraphDBEngine(queryStyle, loader);
// cloud-region
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region0").next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region1").property("orchestration-disabled", "").next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region2").property("orchestration-disabled", true).next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region3").property("orchestration-disabled", 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 BooleanDefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateL2DefaultToFalseTest method setup.
@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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class RebuildAllEdgesTest method setUp.
@Before
public void setUp() {
graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
JanusGraphManagement janusgraphManagement = graph.openManagement();
tx = graph.newTransaction();
g = tx.traversal();
Loader loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
TransactionalGraphEngine dbEngine = new JanusGraphDBEngine(queryStyle, loader);
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();
RebuildAllEdges rebuildAllEdges = new RebuildAllEdges(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
spyRebuildAllEdges = spy(rebuildAllEdges);
doNothing().when((EdgeMigrator) spyRebuildAllEdges).rebuildEdges(g.E().toSet());
spyRebuildAllEdges.run();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine 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();
}
Aggregations