From e96bde2aaf8a134ce07660c024fc5699e4bdc872 Mon Sep 17 00:00:00 2001 From: "Threefoot, Jane (jt6620)" Date: Fri, 1 Sep 2017 13:31:50 -0400 Subject: added new queries for vce resiliency automation Issue-ID: AAI-258 Change-Id: I648dc6f51e8801a29324d6e56e357bdefc957ae3 Signed-off-by: Threefoot, Jane (jt6620) --- .../search/LinkedDevices_ComplicatedGVtoGV.java | 78 +++++++++++++++++++ .../search/LinkedDevices_NewvceVserverTest.java | 91 ++++++++++++++++++++++ .../LinkedDevices_SimpleGVtoGVQueryTest.java | 66 ++++++++++++++++ .../aai/rest/search/VnfsFromPserverQueryTest.java | 90 +++++++++++++++++++++ 4 files changed, 325 insertions(+) create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java (limited to 'aai-traversal/src/test/java') diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java new file mode 100644 index 0000000..656cd44 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java @@ -0,0 +1,78 @@ +package org.openecomp.aai.rest.search; + +import java.util.Map; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Test; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public class LinkedDevices_ComplicatedGVtoGV extends QueryTest { + + public LinkedDevices_ComplicatedGVtoGV() throws AAIException, NoEdgeRuleFoundException { + super(); + } + + @Test + public void run() { + super.run(); + } + + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { + Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf", + "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type"); + + Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", + "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + + Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link", + "link-name", "loglink1", "in-maint", "false", "link-type", "sausage"); + + Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", + "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + + Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "30", "aai-node-type", "vlan", + "vlan-interface", "vlan1"); + + Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link", + "link-name", "loglink2", "in-maint", "false", "link-type", "sausage"); + + Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "40", "aai-node-type", "lag-interface", + "interface-name", "lagint1"); + + Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf", + "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type"); + + GraphTraversalSource g = graph.traversal(); + rules.addTreeEdge(g, gvnf1, lint1); + rules.addEdge(g, lint1, loglink1); + rules.addEdge(g, lint2, loglink1); + rules.addTreeEdge(g, lint2, vlan); + rules.addEdge(g, vlan, loglink2); + rules.addEdge(g, loglink2, lagint); + rules.addTreeEdge(g, gvnf2, lagint); + + expectedResult.add(gvnf1); + expectedResult.add(gvnf2); + } + + @Override + protected String getQueryName() { + return "linked-devices"; + } + + @Override + protected void addStartNode(GraphTraversal g) { + g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvnf1"); + } + + @Override + protected void addParam(Map params) { + // n/a for this query + } + +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java new file mode 100644 index 0000000..e37bb5a --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java @@ -0,0 +1,91 @@ +package org.openecomp.aai.rest.search; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Map; +import java.util.List; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Test; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public class LinkedDevices_NewvceVserverTest extends QueryTest { + + public LinkedDevices_NewvceVserverTest() throws AAIException, NoEdgeRuleFoundException { + super(); + } + + @Test + public void run() { + super.run(); + } + + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { + //Note: I don't know if this topology is realistic, but it doesn't really matter bc we're just testing functionality + Vertex newvce1 = graph.addVertex(T.label, "newvce", T.id, "00", "aai-node-type", "newvce", + "vnf-id2", "newvce1", "vnf-name", "bob", "vnf-type", "new"); + + Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", + "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link", + "link-name", "loglink1", "in-maint", "false", "link-type", "sausage"); + Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", + "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "40", "aai-node-type", "vlan", + "vlan-interface", "vlan1"); + + Vertex newvce2 = graph.addVertex(T.label, "newvce", T.id, "01", "aai-node-type", "newvce", + "vnf-id2", "newvce2", "vnf-name", "bob", "vnf-type", "new"); + + Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link", + "link-name", "loglink2", "in-maint", "false", "link-type", "sausage"); + Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", + "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + + Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region", + "cloud-owner", "att", "cloud-region-id", "crId"); + Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant", + "tenant-id", "tenId", "tenant-name", "verity"); + Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver", + "vserver-id", "vserv1", "vserver-name", "frank"); + + GraphTraversalSource g = graph.traversal(); + rules.addTreeEdge(g, newvce1, lint1); + rules.addTreeEdge(g, lint1, vlan); + rules.addEdge(g, lint1, loglink1); + rules.addEdge(g, lint2, loglink1); + + rules.addTreeEdge(g, cloudregion, tenant); + rules.addTreeEdge(g, tenant, vserver); + rules.addTreeEdge(g, vserver, lint2); + + rules.addEdge(g, vlan, loglink2); + rules.addTreeEdge(g, newvce2, lint3); + rules.addEdge(g, loglink2, lint3); + + expectedResult.add(newvce1); + expectedResult.add(newvce2); + expectedResult.add(vserver); + } + + @Override + protected String getQueryName() { + return "linked-devices"; + } + + @Override + protected void addStartNode(GraphTraversal g) { + g.has("aai-node-type", "newvce").has("vnf-id2", "newvce1"); + } + + @Override + protected void addParam(Map params) { + // n/a for this query + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java new file mode 100644 index 0000000..435878e --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java @@ -0,0 +1,66 @@ +package org.openecomp.aai.rest.search; + +import java.util.Map; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Test; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public class LinkedDevices_SimpleGVtoGVQueryTest extends QueryTest { + + public LinkedDevices_SimpleGVtoGVQueryTest() throws AAIException, NoEdgeRuleFoundException { + super(); + } + + @Test + public void run() { + super.run(); + } + + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { + Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf", + "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type"); + + Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", + "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + + Vertex loglink = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link", + "link-name", "loglink1", "in-maint", "false", "link-type", "sausage"); + + Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", + "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false"); + + Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf", + "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type"); + + GraphTraversalSource g = graph.traversal(); + rules.addTreeEdge(g, gvnf1, lint1); + rules.addTreeEdge(g, gvnf2, lint2); + rules.addEdge(g, lint1, loglink); + rules.addEdge(g, lint2, loglink); + + expectedResult.add(gvnf1); + expectedResult.add(gvnf2); + } + + @Override + protected String getQueryName() { + return "linked-devices"; + } + + @Override + protected void addStartNode(GraphTraversal g) { + g.has("aai-node-type","generic-vnf").has("vnf-id","gvnf1"); + } + + @Override + protected void addParam(Map params) { + // n/a for this test + } + +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java new file mode 100644 index 0000000..fde3729 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.rest.search; + +import java.util.Map; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Test; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public class VnfsFromPserverQueryTest extends QueryTest { + public VnfsFromPserverQueryTest() throws AAIException, NoEdgeRuleFoundException { + super(); + } + + @Test + public void run() { + super.run(); + } + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { + //Set up the test graph + + Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "sample"); + Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername1"); + + Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2"); + Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername2"); + + Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername3"); + Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-name", "vservername"); + Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "7", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname"); + Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "8", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername"); + + Vertex vnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid3", "vnf-name", "sample"); + + GraphTraversalSource g = graph.traversal(); + + rules.addEdge(g, pserver1, vnf1); + rules.addEdge(g, pserver1, vnf2); + rules.addEdge(g, pserver1, vnf3); + + rules.addTreeEdge(g, tenant, cloudregion); + rules.addTreeEdge(g, vserver, tenant); + rules.addEdge(g, vserver, pserver3); + rules.addEdge(g, vserver, vnf2); + + //expectedResult.add(vnf2); + expectedResult.add(vnf1); + //expectedResult.add(vnf3); + + } + @Override + protected String getQueryName() { + return "vnfs-fromPserver"; + } + @Override + protected void addStartNode(GraphTraversal g) { + //g.has("vnf-id", "vnfid2"); + g.has("aai-node-type","generic-vnf").has("vnf-id", "vnfid1").has("vnf-name", "sample"); + } + + @Override + protected void addParam(Map params) { + params.put("hostname", "pservername1"); + } +} -- cgit 1.2.3-korg