Search in sources :

Example 26 with JanusGraphDBEngine

use of org.onap.aai.serialization.engines.JanusGraphDBEngine 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)

Example 27 with JanusGraphDBEngine

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

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

Example 28 with JanusGraphDBEngine

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

the class MigrateMissingFqdnOnPserversTest 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", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE).property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname1.com").property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO").next();
    pserver2 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE).property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname2.com").property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "").next();
    pserver3 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE).property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "akr1").property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO").property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "akr1").next();
    pserver4 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE).property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname1").property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO").property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "").next();
    pserver5 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE).property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname2").property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO").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 MigrateMissingFqdnOnPservers(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 29 with JanusGraphDBEngine

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

the class MigrateSdnaIvlanDataTest 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");
    // PNF -  pnf1
    Vertex pnf1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf1").next();
    // P-INTERFACE - "11111.1"
    Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "11111.1").next();
    // LAG-INTERFACE - lag-interface1
    Vertex lagInterface1 = g.addV().property("aai-node-type", "lag-interface").property("interface-name", "lag-interface1").next();
    // CONFIGURATION - "test/evc/one"
    Vertex configuration1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "test/evc/one").next();
    // CONFIGURATION - "test/evc/one-1"
    Vertex configuration1_1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "test/evc/one-1").next();
    // CONFIGURATION - "test/evc/one-2"
    Vertex configuration1_2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "test/evc/one-2").next();
    // FORWARDER - "test/evc/one" sequence 1
    Vertex forwarder1_1 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1).property("forwarder-role", "ingress").next();
    // FORWARDER - "test/evc/one"  sequence 2
    Vertex forwarder1_2 = g.addV().property("aai-node-type", "forwarder").property("sequence", 2).property("forwarder-role", "ingress").next();
    // FORWARDING-PATH - "test/evc/one"
    Vertex forwardingPath1 = g.addV().property("aai-node-type", "forwarding-path").property("forwarding-path-id", "test/evc/one").property("forwarding-path-name", "test/evc/one").next();
    // EVC - "test/evc/one"
    Vertex evc = g.addV().property("aai-node-type", "evc").property("evc-id", "test/evc/one").next();
    // FORWARDER-EVC - "test/evc/one-1"
    Vertex fwdEvc1_1 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "test/evc/one-1").next();
    // FORWARDER-EVC - "test/evc/one-2"
    Vertex fwdEvc1_2 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "test/evc/one-2").next();
    // pnf -> p-interface -> forwarder -> configuration -> forwarder-evc
    // pnf1 -> pInterface1 -> forwarder1_1 -> configuration1_1 -> fwdEvc1_1
    edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
    edgeSerializer.addEdge(g, pInterface1, forwarder1_1);
    edgeSerializer.addEdge(g, forwarder1_1, configuration1_1);
    edgeSerializer.addEdge(g, forwardingPath1, configuration1);
    edgeSerializer.addTreeEdge(g, forwarder1_1, forwardingPath1);
    edgeSerializer.addTreeEdge(g, forwarder1_2, forwardingPath1);
    edgeSerializer.addTreeEdge(g, configuration1_1, fwdEvc1_1);
    // pnf -> lag-interface -> forwarder -> configuration -> forwarder-evc
    // pnf1 -> lagInterface1 -> forwarder1_2 -> configuration1_2 -> fwdEvc1_2
    edgeSerializer.addTreeEdge(g, pnf1, lagInterface1);
    edgeSerializer.addEdge(g, forwarder1_2, configuration1_2);
    edgeSerializer.addEdge(g, lagInterface1, forwarder1_2);
    edgeSerializer.addTreeEdge(g, configuration1_2, fwdEvc1_2);
    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 MigrateSdnaIvlanData(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 30 with JanusGraphDBEngine

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

the class SendMigrationNotifications method initFields.

private void initFields() {
    this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
    this.engine = new JanusGraphDBEngine(queryStyle, loader);
    try {
        this.serializer = new DBSerializer(version, this.engine, introspectorFactoryType, this.eventSource);
    } catch (AAIException e) {
        throw new RuntimeException("could not create serializer", e);
    }
    this.notificationHelper = new NotificationHelper(loader, serializer, loaderFactory, schemaVersions, engine, requestId, this.eventSource);
}
Also used : DBSerializer(org.onap.aai.serialization.db.DBSerializer) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) NotificationHelper(org.onap.aai.migration.NotificationHelper) AAIException(org.onap.aai.exceptions.AAIException)

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