-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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 jtest.org.onap.ccsdk.sli.adaptors.ra;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
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.adaptors.ra.comp.ResourceEntity;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
+import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
+import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:test-context.xml" })
+@ContextConfiguration(locations = {"classpath:test-context.xml"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestReserve {
private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
+ private JdbcTemplate jdbcTemplate;
+
+ private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"};
+
+ private static final String[] ALLOCATION_ITEM_COLUMNS = {"resource_id", "application_id", "resource_set_id",
+ "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time"};
+
+
+ @Autowired
+ public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+
@Autowired(required = true)
private ResourceAllocator resourceAllocator;
+ /*
+ * @Autowired(required = true) private ResourceAllocatorApi resourceAllocatorApi;
+ */
+
@Autowired(required = true)
private DataSetup dataSetup;
log.info("============== reserve " + t + " ================================");
log.info("=== Test successful response - new start - all resources available");
- String service1 = "reserve" + t + "/service1";
+ // String service1 = "reserve" + t + "/service1";
dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
+ TestTable allocationItem =
+ new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 300000));
- }
-
- @Test
- public void test002() throws Exception {
- String t = "002";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - new start supp - all resources available");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
SvcLogicContext ctx = new SvcLogicContext();
- // ctx.setAttribute("tmp.resource-allocator.request-type", "New"); - Default is New
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "400");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
+ ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-type", "VNF");
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
- }
-
- @Test
- public void test003() throws Exception {
- String t = "003";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change - all resources available");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "400");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- }
- @Test
- public void test004() throws Exception {
- String t = "004";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change supp - all resources available");
-
- String service1 = "reserve" + t + "/service1";
+ resource.print();
+ allocationItem.print();
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "500");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ ctx.setAttribute("ra-input.reservation-target-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-target-data.service-speed-unit", "Mbps");
+ ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
+ ctx.setAttribute("ra-input.reservation-target-type", "Port");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 500000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
- @Test
- public void test005() throws Exception {
- String t = "005";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change - check that hard limits are applied, not soft for change");
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- String service1 = "reserve" + t + "/service1";
+ ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
+ ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-type", "AffinityLink");
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1200000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "kbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 1200000));
- }
-
- @Test
- public void test006() throws Exception {
- String t = "006";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - new start");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test007() throws Exception {
- String t = "007";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - new start supp");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test008() throws Exception {
- String t = "008";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - change");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test009() throws Exception {
- String t = "009";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - change supp");
-
- String service1 = "reserve" + t + "/service1";
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 4));
- }
-
- @Test
- public void test010() throws Exception {
- String t = "010";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test border condition - connection limit - new start - adding connection " +
- "when we are on the limit should fail");
-
- String service1 = "reserve" + t + "/service1";
+ resource.print();
+ allocationItem.print();
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 40; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 40; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test011() throws Exception {
- String t = "011";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - new start supp should succeed as no new connection being added");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ /* Query Using ReservationEntityId using ServiceLogicContext */
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
- dataSetup.setupService(service1, "Pending", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 1000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "5");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
- }
-
- @Test
- public void test012() throws Exception {
- String t = "012";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - change should succeed as no new connection being added");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "5");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
+ /* Query Using ReservationTargetId using ServiceLogicContext */
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
+ ctx.setAttribute("ra-input.reservation-target-type", "Port");
+ ctx.setAttribute("ra-input.resource-name", "Bandwidth");
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
- }
- @Test
- public void test013() throws Exception {
- String t = "013";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - change supp should succeed as no new connection being added");
+ log.info("======================== Query Using ResourceEntity==============================");
+ /* Query Using ResourceEntity bean */
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "ICOREPVCID-123456";
+ sd.resourceEntityType = "SI";
- String service1 = "reserve" + t + "/service1";
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ ResourceRequest rr = new ResourceRequest();
+ rr.serviceModel = "ADIG";
+ rr.resourceName = "cust-vlan-id";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
- dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 5000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ List<ResourceResponse> rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, null, rsList);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "10");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ log.info("======================== release Using ResourceEntity==============================");
+ rsList = new ArrayList<>();
+ AllocationStatus status = resourceAllocator.release(sd);
+ Assert.assertTrue(status == AllocationStatus.Success);
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
+ log.info("======================== Query Using ResourceEntity==============================");
+ rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, null, rsList);
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 10000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test014() throws Exception {
- String t = "014";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test input validations - invalid request-type in input");
- String service1 = "reserve" + t + "/service1";
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "xxxxx");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "10");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- try {
- resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "Invalid tmp.resource-allocator.request-type: xxxxx. Supported values are New, Change."));
- return;
- }
- Assert.fail("SvcLogicException expected");
}
@Test
- public void test015() throws Exception {
- String t = "015";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test server bw limit depends on number of servers - limit is 960Mbps for 1 server, 1920 for 2");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1200");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1200000));
- }
-
- @Test
- public void test016() throws Exception {
- String t = "016";
+ public void test002() throws Exception {
+ String t = "002";
log.info("============== reserve " + t + " ================================");
- log.info("=== Test resource threshold output");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1605");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ log.info("=== Test successful response - new start - all resources available");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ Map<String, String> data = new HashMap<>();
+ data.put("service-speed", "100");
+ data.put("service-speed-unit", "Mbps");
- log.info("Result: " + st);
- for (String key : ctx.getAttributeKeySet())
- if (key.startsWith("tmp.resource-allocator-output"))
- log.info(" " + key + ": " + ctx.getAttribute(key));
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "ICOREPVCID-123456";
+ sd.resourceEntityType = "SI";
+ sd.data = data;
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1605000));
- }
+ data = new HashMap<>();
+ data.put("vnf-type", "VPE");
+ data.put("vpe-name", "mdt300vpe54");
+ data.put("max-vpe-bandwidth-mbps", "5000");
- @Test
- public void test017() throws Exception {
- String t = "017";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
- log.info("=== For 10 existing EVC, it should take the first row, not the second (see data.sql).");
- log.info("=== Applied limit should be 1920Mbps, not 1680Mbps.");
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "mdt300vpe54";
+ rt.resourceTargetType = "VNF";
+ rt.data = data;
- String service1 = "reserve" + t + "/service1";
+ ResourceRequest rr = new ResourceRequest();
+ rr.serviceModel = "ADIG";
+ // rr.resourceName = "cust-vlan-id";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
+ List<ResourceResponse> rsList = new ArrayList<>();
- for (int i = 1; i <= 10; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ resourceAllocator.reserve(sd, rt, rr, rsList);
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "800"); // 10*100Mbps existing + 800 = 1800
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, rr, rsList);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 800000));
}
-
+
+
@Test
- public void test018() throws Exception {
- String t = "018";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
- log.info("=== For 11 existing EVC, it should take the second row (see data.sql).");
- log.info("=== Applied limit should be 1680Mbps. We have 11*100 + 700, so this should fail.");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- for (int i = 1; i <= 11; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "700"); // 11*100Mbps existing + 700 = 1800
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
+ public void test003() throws Exception {
+ String t = "003";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Cust";
+ //rr.requestType = "New";
+ //rr.rangeMaxOverride = 5;
+ //rr.rangeMinOverride = 5;
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+
+
+
+ @Test
+ public void test004() throws Exception {
+ String t = "004";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+ List<ResourceRequest> rrs = new ArrayList<ResourceRequest>();
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Cust";
+ rrs.add(rr);
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Core1";
+ rrs.add(rr);
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Core2";
+ rrs.add(rr);
+
+
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ //resourceAllocator.reserve(sd, rt, rrs, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+
+ @Test
+ public void test005() throws Exception {
+ String t = "005";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ //String service1 = "reserve" + t + "/service1";
+
+ dataSetup.cleanup();
+
+ TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
+
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Cust");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
+
+
+ QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ resource.print();
+ allocationItem.print();
+
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
+
+
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ resource.print();
+ allocationItem.print();
+
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core2");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
+ ctx.setAttribute("ra-input.replace", "false");
+
+
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ resource.print();
+ allocationItem.print();
+
+
+ /*Query Using ReservationEntityId using ServiceLogicContext*/
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
+
+
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+
+ /*Query Using ReservationTargetId using ServiceLogicContext*/
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+ ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
+
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ log.info("======================== Query Using ResourceEntity==============================");
+ /*Query Using ResourceEntity bean*/
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE-Core1";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL-1";
+ rr.resourceName = "vlan-id-inner";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.query(sd, null, null, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ /*log.info("======================== release Using ResourceEntity==============================");
+ rsList = new ArrayList<ResourceResponse>();
+ AllocationStatus status = resourceAllocator.release(sd);
+ Assert.assertTrue(status == AllocationStatus.Success);
+
+
+ log.info("======================== Query Using ResourceEntity==============================");
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.query(sd, null, null, rsList);
+
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });*/
+
+ }
+
+
+
+ @Test
+ public void test006() throws Exception {
+ String t = "006";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE-Cust";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL-1";
+ rr.resourceName = "cust-vlan-id";
+
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+ @Test
+ public void test007() throws Exception {
+ String t = "007";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ dataSetup.cleanup();
+
+ TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
+
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-outer";
+ rr.endPointPosition="VPE-Cust";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ //VPE-Core1
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core1";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+
+ //VPE-Core2
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core2";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+
+ //VPE-Core3
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core3";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ resource.print();
+ allocationItem.print();
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE");
+
+
+ QueryStatus st = resourceAllocator.release("NetworkCapacity", "gblond2003me6", ctx);
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ }
}