From 7b790e614732183db8be972a168a60d564a86d60 Mon Sep 17 00:00:00 2001 From: stan-sb <67116470+stan-sb@users.noreply.github.com> Date: Tue, 23 Jun 2020 10:21:23 -0400 Subject: 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 --- .../sli/adaptors/rm/comp/AllocationFunction.java | 4 +-- .../onap/ccsdk/sli/adaptors/ra/TestReserve.java | 35 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'resource-assignment/provider') 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")); + } } -- cgit 1.2.3-korg