summaryrefslogtreecommitdiffstats
path: root/resource-assignment/provider/src/test
diff options
context:
space:
mode:
authorStan Bonev <sb5356@att.com>2018-11-01 09:43:40 -0400
committerStan Bonev <sb5356@att.com>2018-11-01 09:43:40 -0400
commit10431fbfe6e8f99f04cdb7a19cd7341467e998c5 (patch)
treef552e16766c8cfb8313840f0a7c3287fa5b7e6a7 /resource-assignment/provider/src/test
parent3474fad00e780e279976921d60376d8d86b953c0 (diff)
RA: Enhance query for allocated resources
Change-Id: I97d724910d1caac8d7b16455296a41fef1669310 Issue-ID: CCSDK-644 Signed-off-by: Stan Bonev <sb5356@att.com>
Diffstat (limited to 'resource-assignment/provider/src/test')
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java37
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java115
2 files changed, 115 insertions, 37 deletions
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
index 45889137..a968c3fb 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestGetResource.java
@@ -6,8 +6,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
import org.slf4j.Logger;
@@ -86,13 +84,6 @@ public class TestGetResource {
setupResourceData();
- ResourceTarget rt = new ResourceTarget();
- rt.resourceTargetId = "GBLOND2025MG2";
- rt.resourceTargetType = "Device";
-
- ResourceRequest rr = new ResourceRequest();
- rr.resourceName = "internal-vlan";
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
ctx.setAttribute("ra-input.resource-target-type", "Device");
@@ -120,13 +111,6 @@ public class TestGetResource {
setupResourceData();
- ResourceTarget rt = new ResourceTarget();
- rt.resourceTargetId = "GBLOND2025MG2";
- rt.resourceTargetType = "Device";
-
- ResourceRequest rr = new ResourceRequest();
- rr.resourceName = "internal-vlan";
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
ctx.setAttribute("ra-input.resource-target-type", "Device");
@@ -157,13 +141,6 @@ public class TestGetResource {
setupResourceData();
- ResourceTarget rt = new ResourceTarget();
- rt.resourceTargetId = "GBLOND2025MG2";
- rt.resourceTargetType = "Device";
-
- ResourceRequest rr = new ResourceRequest();
- rr.resourceName = "internal-vlan";
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
ctx.setAttribute("ra-input.resource-target-type", "Device");
@@ -193,13 +170,6 @@ public class TestGetResource {
setupResourceData();
- ResourceTarget rt = new ResourceTarget();
- rt.resourceTargetId = "GBLOND2025MG2";
- rt.resourceTargetType = "Device";
-
- ResourceRequest rr = new ResourceRequest();
- rr.resourceName = "internal-vlan";
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
ctx.setAttribute("ra-input.resource-target-type", "Device");
@@ -229,13 +199,6 @@ public class TestGetResource {
setupResourceData();
- ResourceTarget rt = new ResourceTarget();
- rt.resourceTargetId = "GBLOND2025MG2";
- rt.resourceTargetType = "Device";
-
- ResourceRequest rr = new ResourceRequest();
- rr.resourceName = "internal-vlan";
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.resource-target-id", "GBLOND2025MG2");
ctx.setAttribute("ra-input.resource-target-type", "Device");
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java
new file mode 100644
index 00000000..4be985b2
--- /dev/null
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java
@@ -0,0 +1,115 @@
+package jtest.org.onap.ccsdk.sli.adaptors.ra;
+
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:test-context.xml"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestQueryResource {
+
+ private static final Logger log = LoggerFactory.getLogger(TestQueryResource.class);
+
+ @Autowired(required = true)
+ private ResourceAllocator resourceAllocator;
+
+ @Autowired(required = true)
+ private DataSetup dataSetup;
+
+ private void setupResourceData() {
+ dataSetup.cleanup();
+
+ for (int k = 0; k < 6; k++) {
+ String assetId = "Port::TESTPORT-" + (k / 2 + 1) + "-" + (k + 1);
+
+ for (int i = 0; i < 5; i++) {
+ String entityId = "TEST-" + i + "-" + (k / 2 + 1);
+
+ String resourceUnion = "EVC::" + entityId;
+ String resourceSet = resourceUnion + "::1";
+
+ dataSetup.setupRangeItem("test-range-1", assetId, resourceSet, resourceUnion, String.valueOf(i));
+ }
+ }
+
+ for (int k = 0; k < 6; k++) {
+ String assetId = "Port::TESTPORT-" + (k / 2 + 1) + "-" + (k + 1);
+
+ for (int i = 0; i < 5; i++) {
+ String entityId = "TEST-" + i + "-" + (k / 2 + 1);
+
+ String resourceUnion = "EVC::" + entityId;
+ String resourceSet = resourceUnion + "::1";
+
+ dataSetup.setupLimitItem("test-limit-1", assetId, resourceSet, resourceUnion, (i + 1) * 100);
+ }
+ }
+ }
+
+ @Test
+ public void test001() throws Exception {
+
+ String t = "001";
+ log.info("============== query node " + t + " ================================");
+ log.info("=== Test query for resources - with resource target condition - range");
+
+ setupResourceData();
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-target-id-filter", "TESTPORT-1-%");
+ ctx.setAttribute("ra-input.resource-target-type-filter", "Port");
+
+ ctx.setAttribute("ra-input.resource-name", "test-range-1");
+
+ QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "2");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "test-range-1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Port");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "TESTPORT-1-1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"), "0, 1, 2, 3, 4");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].resource-name"), "test-range-1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].resource-target-type"), "Port");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].resource-target-id"), "TESTPORT-1-2");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocated"), "0, 1, 2, 3, 4");
+ }
+
+ @Test
+ public void test002() throws Exception {
+
+ String t = "002";
+ log.info("============== query node " + t + " ================================");
+ log.info("=== Test query for resources - with resource target condition - limit");
+
+ setupResourceData();
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.resource-target-id-filter", "TESTPORT-%-1");
+ ctx.setAttribute("ra-input.resource-target-type-filter", "Port");
+
+ ctx.setAttribute("ra-input.resource-name", "test-limit-1");
+
+ QueryStatus st = resourceAllocator.query("NetworkCapacity", false, null, null, "ra-output", null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list_length"), "1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-name"), "test-limit-1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Port");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "TESTPORT-1-1");
+ Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"), "1500");
+ }
+}