summaryrefslogtreecommitdiffstats
path: root/resource-assignment/provider
diff options
context:
space:
mode:
authorstan-sb <67116470+stan-sb@users.noreply.github.com>2020-06-23 10:21:23 -0400
committerstanbonev <sb5356@att.com>2020-06-23 10:31:24 -0400
commit7b790e614732183db8be972a168a60d564a86d60 (patch)
treeb163e1340dac899f33f6ed670ad9068c8f7fe930 /resource-assignment/provider
parentdde59cf2ebddb71d36a7a9b1ae6a1ecf4a6d2167 (diff)
RA: Add option for sequential number assignment from a range
Fix case, when no previous numbers have been allocated Change-Id: Iead3cb4fe4a8ed3f6de363d31677eb389e9f1329 Issue-ID: CCSDK-2416 Signed-off-by: Stan Bonev <sb5356@att.com>
Diffstat (limited to 'resource-assignment/provider')
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java4
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java35
2 files changed, 36 insertions, 3 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
index 5ec7c26ba..485010656 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
@@ -359,9 +359,7 @@ class AllocationFunction extends SynchronizedFunction {
break;
}
}
- if (foundAllocated) {
- n++;
- }
+ n++;
for (; foundCount < req.requestedCount && n <= range.max; n++) {
foundNumbers.add(n);
foundCount++;
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
index af9508a66..ab2d936cf 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
@@ -918,4 +918,39 @@ public class TestReserve {
Assert.assertTrue(st == QueryStatus.SUCCESS);
Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "2222"));
}
+
+ @Test
+ public void test014() throws Exception {
+ String t = "014";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test range-next-in-sequence = true - no previously reserved numbers");
+
+ String entityId = "reserve" + t;
+ String targetId = "port-id-1";
+ String resourceName = "vlan-id-filter";
+
+ String assetId = "Site::" + targetId;
+
+ dataSetup.cleanup();
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
+ ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
+ ctx.setAttribute("ra-input.check-only", "false");
+
+ ctx.setAttribute("ra-input.resource-name", resourceName);
+ ctx.setAttribute("ra-input.range-next-in-sequence", "true");
+
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
+ ctx.setAttribute("ra-input.reservation-entity-version", "1");
+
+ ctx.setAttribute("ra-input.reservation-target-id", targetId);
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+ Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1002"));
+ }
}