diff options
author | sb5356 <sb5356@att.com> | 2018-05-15 11:58:17 -0400 |
---|---|---|
committer | Timoney, Dan (dt5972) <dt5972@att.com> | 2018-06-06 15:26:06 -0400 |
commit | 7893d08db0ef3fd29d64c9be759325fa18cc21fa (patch) | |
tree | 6f4344818c4089df46c5f19a1ff480ab015ccea4 /resource-assignment/provider/src/test | |
parent | 52a06cedb172a1a446ecfaaaa96bf500a58c8fb5 (diff) |
[CCSDK-245] RA: Refactor RA to make it generic
Resource allocator is cleaned up and refactored so it does not contain
any service specific logic.
Issue-ID: CCSDK-245
Change-Id: Ib948eb813020fbe7dc779148e412de1e074b300b
Signed-off-by: sb5356 <sb5356@att.com>
Diffstat (limited to 'resource-assignment/provider/src/test')
15 files changed, 844 insertions, 2345 deletions
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java index ba57f626..bba8e2b9 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java +++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java @@ -3,14 +3,14 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -21,8 +21,6 @@ package jtest.org.onap.ccsdk.sli.adaptors.ra; -import java.util.Date; - import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestDb; import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable; @@ -30,231 +28,29 @@ public class DataSetup { private TestDb testDb; - private TestTable vpePool = null; - private TestTable vplspePool = null; - private TestTable pserver = null; - private TestTable serviceResource = null; private TestTable resource = null; private TestTable allocationItem = null; - private static final String[] VPE_POOL_COLUMNS = { - "vpe_name", "ipv4_oam_address", "loopback0_ipv4_address", "provisioning_status", "aic_site_id", - "availability_zone", "vlan_id_outer", "vendor", "physical_intf_name", "physical_intf_speed", - "physical_intf_units", "vpe_uuid", "vpe_id", "image_filename" }; - - private static final String[] VPLSPE_POOL_COLUMNS = { - "vplspe_name", "aic_site_id", "availability_zone", "physical_intf_name", "physical_intf_speed", - "physical_intf_units", "loopback0_ipv4_address", "vlan_id_outer", "vplspe_uuid", "image_filename", - "provisioning_status", "vendor" }; - - private static final String[] PSERVER_COLUMNS = { - "hostname", "ptnii_equip_name", "number_of_cpus", "disk_in_gigabytes", "ram_in_megabytes", "equip_type", - "equip_vendor", "equip_model", "fqdn", "pserver_selflink", "ipv4_oam_address", "serial_number", - "pserver_id", "internet_topology", "aic_site_id", "in_maint", "pserver_name2", "purpose" }; - - private static final String[] SERVICE_RESOURCE_COLUMNS = { - "service_instance_id", "service_status", "service_change_number", "resource_set_id", "resource_union_id" }; + private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"}; - 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" }; + 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"}; private void initTables() { - if (vpePool == null) - vpePool = testDb.table("VPE_POOL", "vpe_name", VPE_POOL_COLUMNS); - if (vplspePool == null) - vplspePool = testDb.table("VPLSPE_POOL", "vplspe_name", VPLSPE_POOL_COLUMNS); - if (pserver == null) - pserver = testDb.table("PSERVER", "hostname", PSERVER_COLUMNS); - if (serviceResource == null) - serviceResource = testDb.table("SERVICE_RESOURCE", "service_resource_id", SERVICE_RESOURCE_COLUMNS); - if (resource == null) + if (resource == null) { resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS); - if (allocationItem == null) + } + if (allocationItem == null) { allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS); + } } public void cleanup() { initTables(); - vpePool.delete("true"); - vplspePool.delete("true"); - pserver.delete("true"); - serviceResource.delete("true"); allocationItem.delete("true"); resource.delete("true"); } - public void setupVpePort( - String aicSiteId, - String vpeId, - String interfaceName, - String provStatus, - String imageFileName) { - initTables(); - vpePool.add(vpeId, "127.0.0.1", "107.134.152.139", provStatus, aicSiteId, "mtanj-esx-az01", "3501", - "JUNIPER", interfaceName, "1", "GBPS", "vpe002", "VPESAT-auttx200me6", imageFileName); - } - - public void setupVplspePort( - String aicSiteId, - String vplspeId, - String interfaceName, - String provStatus, - String imageFileName) { - initTables(); - vplspePool.add(vplspeId, aicSiteId, "mtanj-esx-az01", interfaceName, "100", "GBPS", "192.168.119.32", "3501", - "vpls002", imageFileName, provStatus, "JUNIPER"); - } - - public void setupPserver(String hostname, String aicSiteId) { - initTables(); - pserver.add(hostname, hostname + "srv1", 4, 1000, 16000, "equip_type", "equip_vendor", "equip_model", "fqdn", - "pserver_selflink", "123.123.123.123", "serial_number", "pserver_id", "internet_topology", aicSiteId, - "N", hostname, "purpose"); - } - - public void setupService( - String serviceInstanceId, - String status, - int changeNumber, - long speedKbps, - String vpeId, - String vplspeId, - String serverId) { - initTables(); - - String resourceSetId = serviceInstanceId + "/" + changeNumber; - String resourceUnionId = serviceInstanceId; - - serviceResource.add(serviceInstanceId, status, changeNumber, resourceSetId, resourceUnionId); - - Long rid = resource.getId("asset_id = '" + vpeId + "/ae0' AND resource_name = 'Bandwidth'"); - if (rid == null) { - resource.add(vpeId + "/ae0", "Bandwidth", "Limit", 1); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date()); - - rid = resource.getId("asset_id = '" + vplspeId + "' AND resource_name = 'Bandwidth'"); - if (rid == null) { - resource.add(vplspeId, "Bandwidth", "Limit", 1); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date()); - - rid = resource.getId("asset_id = '" + serverId + "' AND resource_name = 'Bandwidth'"); - if (rid == null) { - resource.add(serverId, "Bandwidth", "Limit", 1); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date()); - - rid = resource.getId("asset_id = '" + serverId + "' AND resource_name = 'Connection'"); - if (rid == null) { - resource.add(serverId, "Connection", "Limit", 1); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, 1, new Date()); - } - - public boolean serviceNotInDb(String serviceInstanceId, String status, Integer changeNumber) { - String where = "service_instance_id = '" + serviceInstanceId + "'"; - if (status != null) - where += " AND service_status = '" + status + "'"; - if (changeNumber != null) - where += " AND service_change_number = " + changeNumber; - - if (serviceResource.exists(where)) - return false; - - where = "resource_union_id = '" + serviceInstanceId + "'"; - if (changeNumber != null) - where += " AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "'"; - - if (allocationItem.exists(where)) - return false; - - return true; - } - - public boolean serviceCorrectInDb(String serviceInstanceId, String status, int changeNumber, long speedKbps) { - String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status + - "' AND service_change_number = " + changeNumber; - if (!serviceResource.exists(where)) - return false; - - where = "resource_union_id = '" + serviceInstanceId + "' AND resource_set_id = '" + serviceInstanceId + "/" + - changeNumber + "' AND lt_used = " + speedKbps; - if (!allocationItem.exists(where)) - return false; - - return true; - } - - public boolean serviceCorrectInDb( - String vpeId, - String aicSiteId, - String serviceInstanceId, - String status, - int changeNumber, - long speedKbps) { - - String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status + - "' AND service_change_number = " + changeNumber; - if (!serviceResource.exists(where)) - return false; - - Long vpebwrid = resource.getId("asset_id = '" + vpeId + "/ae0' AND resource_name = 'Bandwidth'"); - if (vpebwrid == null) - return false; - - where = "resource_id = " + vpebwrid + " AND resource_union_id = '" + serviceInstanceId + - "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = " + speedKbps; - if (!allocationItem.exists(where)) - return false; - - Long srvbwrid = resource.getId("asset_id = '" + aicSiteId + "/Server1' AND resource_name = 'Bandwidth'"); - if (srvbwrid == null) - return false; - - where = "resource_id = " + srvbwrid + " AND resource_union_id = '" + serviceInstanceId + - "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = " + speedKbps; - if (!allocationItem.exists(where)) - return false; - - Long srvconrid = resource.getId("asset_id = '" + aicSiteId + "/Server1' AND resource_name = 'Connection'"); - if (srvconrid == null) - return false; - - where = "resource_id = " + srvconrid + " AND resource_union_id = '" + serviceInstanceId + - "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = 1"; - if (!allocationItem.exists(where)) - return false; - - return true; - } - - public boolean serviceCorrectInDb( - String serviceInstanceId, - String endPointPosition, - String status, - int changeNumber, - long speedKbps) { - String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status + - "' AND service_change_number = " + changeNumber; - if (!serviceResource.exists(where)) - return false; - - where = "resource_union_id = '" + serviceInstanceId + "/" + endPointPosition + "' AND resource_set_id = '" + - serviceInstanceId + "/" + endPointPosition + "/" + changeNumber + "' AND lt_used = " + speedKbps; - if (!allocationItem.exists(where)) - return false; - - return true; - } - public void setTestDb(TestDb testDb) { this.testDb = testDb; } diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java deleted file mode 100644 index 4dee2d61..00000000 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java +++ /dev/null @@ -1,405 +0,0 @@ -/*- - * ============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 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.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.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 TestIsAvailable { - - private static final Logger log = LoggerFactory.getLogger(TestIsAvailable.class); - - @Autowired(required = true) - private ResourceAllocator resourceAllocator; - - @Autowired(required = true) - private DataSetup dataSetup; - - @Test - public void test001() throws Exception { - String t = "001"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test successful response - all resources available"); - - String service1 = "isAvailable" + 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.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.isAvailable("NetworkCapacity", null, null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test002() throws Exception { - String t = "002"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - request very big number that is above the limits"); - - String service1 = "isAvailable" + 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.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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("960000")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test003() throws Exception { - String t = "003"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - PROV check for VPE"); - - String service1 = "isAvailable" + t + "/service1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "---", "juniper-vpe-image"); - dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("0")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test004() throws Exception { - String t = "004"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - PROV check for VPLSPE"); - - String service1 = "isAvailable" + t + "/service1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "---", null); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("0")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test005() throws Exception { - String t = "005"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - VPE not found in DB"); - - String service1 = "isAvailable" + t + "/service1"; - - dataSetup.cleanup(); - dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("0")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test006() throws Exception { - String t = "006"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - VPLSPE not found in DB"); - - String service1 = "isAvailable" + t + "/service1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("0")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test007() throws Exception { - String t = "007"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - test max available speed calculation"); - - String service1 = "isAvailable" + t + "/service1"; - String existingService1 = "isAvailable" + t + "/existing-service1"; - String existingService2 = "isAvailable" + t + "/existing-service2"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv127", "ae0", "PROV", "juniper-vpe-image"); - dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null); - dataSetup.setupService(existingService1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", - "MTSNJA4LCP1/Server1"); - dataSetup.setupService(existingService2, "Active", 3, 100000, "mtanjrsv127", "mtsnj303vr1", - "MTSNJA4LCP1/Server1"); - dataSetup.setupService(existingService2, "Pending", 4, 500000, "mtanjrsv127", "mtsnj303vr1", - "MTSNJA4LCP1/Server1"); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("260000")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test008() throws Exception { - String t = "008"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test capacity not found - test server limit depending on number of connections"); - - String service1 = "isAvailable" + t + "/service1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv127", "ae0", "PROV", "juniper-vpe-image"); - dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null); - for (int i = 1; i <= 13; i++) - dataSetup.setupService("isAvailable" + t + "/existing-service" + i, "Active", 2, 20000, "mtanjrsv126", - "mtsnj303vr1", "MTSNJA4LCP1/Server1"); - - SvcLogicContext ctx = new SvcLogicContext(); - 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.isAvailable("NetworkCapacity", null, null, ctx); - - String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"); - String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit"); - - log.info("Result: " + st); - log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed); - log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit); - - Assert.assertTrue(st == QueryStatus.NOT_FOUND); - Assert.assertTrue(maxAvailableSpeed.equals("340000")); - Assert.assertTrue(speedUnit.equals("kbps")); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test009() throws Exception { - String t = "009"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test successful response - no service instance id in input - all resources available"); - - 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.speed", "300"); - ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps"); - ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1"); - - QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", 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); - } - - @Test - public void test010() throws Exception { - String t = "010"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test input validations - no aic-site-id in input"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.speed", "300"); - ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps"); - - try { - resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals( - "tmp.resource-allocator.aic-site-id is required in ResourceAllocator")); - return; - } - Assert.fail("SvcLogicException expected"); - } - - @Test - public void test011() throws Exception { - String t = "011"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test input validations - speed not a number in input"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.speed", "nnnnn"); - ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps"); - ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1"); - - try { - resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals("Invalid tmp.resource-allocator.speed. Must be a number.")); - return; - } - Assert.fail("SvcLogicException expected"); - } - - @Test - public void test012() throws Exception { - String t = "012"; - log.info("============== isAvailable " + t + " ================================"); - log.info("=== Test input validations - speed-unit missing in input"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.speed", "300"); - ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1"); - - try { - resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals( - "tmp.resource-allocator.speed-unit is required in ResourceAllocator")); - return; - } - Assert.fail("SvcLogicException expected"); - } -} diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java new file mode 100644 index 00000000..6564dc3d --- /dev/null +++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java @@ -0,0 +1,59 @@ +package jtest.org.onap.ccsdk.sli.adaptors.ra; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper; +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 TestLockHelper { + + private static final Logger log = LoggerFactory.getLogger(TestLockHelper.class); + + @Autowired + private LockHelper lockHelper; + + @Test + public void test1() throws Exception { + LockThread t1 = new LockThread("req1"); + LockThread t2 = new LockThread("req2"); + LockThread t3 = new LockThread("req3"); + + t1.start(); + t2.start(); + t3.start(); + + t1.join(); + t2.join(); + t3.join(); + } + + private class LockThread extends Thread { + private String requester; + + public LockThread(String requester) { + this.requester = requester; + } + + @Override + public void run() { + lockHelper.lock("resource1", requester, 20); + + try { + Thread.sleep(500); + } catch (InterruptedException e) { + log.warn("Thread interrupted: " + e.getMessage(), e); + } + + lockHelper.unlock("resource1", false); + } + } +} diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java deleted file mode 100644 index 435f4aaa..00000000 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============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 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.core.sli.SvcLogicContext; -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.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 TestQuery { - - private static final Logger log = LoggerFactory.getLogger(TestQuery.class); - - @Autowired(required = true) - private ResourceAllocator resourceAllocator; - - @Autowired(required = true) - private DataSetup dataSetup; - - @Test - public void test001() throws Exception { - String t = "001"; - log.info("============== query " + t + " ================================"); - log.info("=== Test reading assigned resources (subinterface-id, vlan-id-inner)"); - - String service1 = "ICOREPVC" + t + "-1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "New"); - ctx.setAttribute("tmp.resource-allocator.service-model", "L3AVPN-EVC"); - 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"); - ctx.setAttribute("tmp.resource-allocator.vpn-id", "123"); - ctx.setAttribute("tmp.resource-allocator.vrf-required", "false"); - - QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000)); - - st = resourceAllocator.query("NetworkCapacity", true, null, service1, "end-point", null, ctx); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertEquals(ctx.getAttribute("end-point.subinterface-id"), "100"); - Assert.assertEquals(ctx.getAttribute("end-point.vlan-id-inner"), "2"); - Assert.assertEquals(ctx.getAttribute("end-point.vpe-name"), "mtanjrsv126"); - Assert.assertEquals(ctx.getAttribute("end-point.affinity-link"), "1"); - } -} diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java deleted file mode 100644 index 62102254..00000000 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java +++ /dev/null @@ -1,430 +0,0 @@ -/*- - * ============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 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.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.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 TestRelease { - - private static final Logger log = LoggerFactory.getLogger(TestRelease.class); - - @Autowired(required = true) - private ResourceAllocator resourceAllocator; - - @Autowired(required = true) - private DataSetup dataSetup; - - @Test - public void test001() throws Exception { - String t = "001"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - cancel - new start"); - - String service1 = "release" + 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(service1, "Pending", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test002() throws Exception { - String t = "002"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - cancel - change"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3)); - } - - @Test - public void test003() throws Exception { - String t = "003"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - cancel - active there, but no pending - should do nothing and return success"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } - - @Test - public void test004() throws Exception { - String t = "004"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - cancel - nothing in DB - should return success"); - - String service1 = "release" + t + "/service1"; - - dataSetup.cleanup(); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test005() throws Exception { - String t = "005"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - activate - new start"); - - String service1 = "release" + 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(service1, "Pending", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Activate"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } - - @Test - public void test006() throws Exception { - String t = "006"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - actovate - change"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Activate"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 3, 400000)); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2)); - } - - @Test - public void test007() throws Exception { - String t = "007"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - activate - active there, but no pending - should do nothing and return success"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Activate"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } - - @Test - public void test008() throws Exception { - String t = "008"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - activate - nothing in DB - should return success"); - - String service1 = "release" + t + "/service1"; - - dataSetup.cleanup(); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Activate"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test009() throws Exception { - String t = "009"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - disconnect - only pending in DB"); - - String service1 = "release" + 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(service1, "Pending", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test010() throws Exception { - String t = "010"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - disconnect - only active in DB"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test011() throws Exception { - String t = "011"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - disconnect - both active and pending in DB"); - - String service1 = "release" + 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(service1, "Active", 2, 200000)); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000)); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test012() throws Exception { - String t = "012"; - log.info("============== release " + t + " ================================"); - log.info("=== Test release - disconnect - nothing in DB - should return success"); - - String service1 = "release" + t + "/service1"; - - dataSetup.cleanup(); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - - log.info("Result: " + st); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } - - @Test - public void test013() throws Exception { - String t = "013"; - log.info("============== release " + t + " ================================"); - log.info("=== Test input validations - request-type missing in input"); - - String service1 = "release" + t + "/service1"; - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - try { - resourceAllocator.release("NetworkCapacity", null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals( - "tmp.resource-allocator.request-type is required in ResourceAllocator")); - return; - } - Assert.fail("SvcLogicException expected"); - } - - @Test - public void test014() throws Exception { - String t = "014"; - log.info("============== release " + t + " ================================"); - log.info("=== Test input validations - invalid request-type in input"); - - String service1 = "release" + t + "/service1"; - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "xxxxx"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); - - try { - resourceAllocator.release("NetworkCapacity", null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals( - "Invalid tmp.resource-allocator.request-type: xxxxx. Supported values are Cancel, Activate, Disconnect.")); - return; - } - Assert.fail("SvcLogicException expected"); - } - - @Test - public void test015() throws Exception { - String t = "015"; - log.info("============== release " + t + " ================================"); - log.info("=== Test input validations - missing service-instance-id in input"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - - try { - resourceAllocator.release("NetworkCapacity", null, ctx); - } catch (SvcLogicException e) { - Assert.assertTrue(e.getMessage().equals( - "tmp.resource-allocator.service-instance-id is required in ResourceAllocator")); - return; - } - Assert.fail("SvcLogicException expected"); - } -} 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 a4ee5254..c4200751 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 @@ -1,51 +1,58 @@ -/*- - * ============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; @@ -55,627 +62,576 @@ public class TestReserve { 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); + + } } diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java deleted file mode 100644 index 7ae16976..00000000 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============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 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.core.sli.SvcLogicContext; -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.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 TestReserve2 { - - private static final Logger log = LoggerFactory.getLogger(TestReserve2.class); - - @Autowired(required = true) - private ResourceAllocator resourceAllocator; - - @Autowired(required = true) - private DataSetup dataSetup; - - @Test - public void test001() throws Exception { - String t = "001"; - log.info("============== reserve " + t + " ================================"); - log.info("=== Test successful response - new start - all resources available"); - - String service1 = "ICOREPVC" + t + "-1"; - - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "New"); - ctx.setAttribute("tmp.resource-allocator.service-model", "L3AVPN-EVC"); - 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"); - ctx.setAttribute("tmp.resource-allocator.vpn-id", "123"); - ctx.setAttribute("tmp.resource-allocator.vrf-required", "false"); - - QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000)); - } -} diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestDb.java b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestDb.java index 6446240d..6446240d 100644 --- a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestDb.java +++ b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestDb.java diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java new file mode 100644 index 00000000..e2541f39 --- /dev/null +++ b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java @@ -0,0 +1,135 @@ +/*- + * ============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.util.org.onap.ccsdk.sli.adaptors.ra; + +import java.sql.ResultSetMetaData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.rowset.SqlRowSet; + +public class TestTable { + + private String tableName; + private String[] columnList; + private String idName; + + private String insertSql; + + private JdbcTemplate jdbcTemplate; + + private static final Logger log = LoggerFactory.getLogger(TestTable.class); + + public TestTable(JdbcTemplate jdbcTemplate, String tableName, String idName, String... columnList) { + this.jdbcTemplate = jdbcTemplate; + this.tableName = tableName; + this.idName = idName; + this.columnList = columnList; + createInsertSql(); + } + + public TestTable(JdbcTemplate jdbcTemplate, String tableName) { + this.jdbcTemplate = jdbcTemplate; + this.tableName = tableName; + } + + private void createInsertSql() { + StringBuilder ss = new StringBuilder(); + ss.append("INSERT INTO ").append(tableName).append(" ("); + for (String s : columnList) + ss.append(s).append(", "); + ss.setLength(ss.length() - 2); + ss.append(") VALUES ("); + for (int i = 0; i < columnList.length; i++) + ss.append("?, "); + ss.setLength(ss.length() - 2); + ss.append(")"); + insertSql = ss.toString(); + } + + public void add(Object... values) { + jdbcTemplate.update(insertSql, values); + } + + public void update(String updateSql, Object... values) { + jdbcTemplate.update(updateSql, values); + } + + public long getLastId() { + return jdbcTemplate.queryForObject("SELECT max(" + idName + ") FROM " + tableName, Long.class); + } + + public Long getId(String where) { + String selectSql = "SELECT " + idName + " FROM " + tableName + " WHERE " + where; + SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql); + if (rs.first()) + return rs.getLong(idName); + return null; + } + + public Object getColumn(String columnName, String where) { + String selectSql = "SELECT " + columnName + " FROM " + tableName + " WHERE " + where; + SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql); + if (rs.first()) + return rs.getObject(columnName); + return null; + } + + public boolean exists(String where) { + String selectSql = "SELECT * FROM " + tableName + " WHERE " + where; + SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql); + return rs.first(); + } + + public void delete(String where) { + jdbcTemplate.update("DELETE FROM " + tableName + " WHERE " + where); + } + + public void print() { + + jdbcTemplate.query("SELECT * FROM " + tableName, + (rs, rowNum) -> { + String row = "Table Data for " + tableName +"\n"; + String col = ""; + + final ResultSetMetaData meta = rs.getMetaData(); + final int columnCount = meta.getColumnCount(); + + do { + col = ""; + + for (int column = 1; column <= columnCount; ++column) { + Object obj = rs.getObject(column); + if(!rs.wasNull()) { + col = col + obj + ","; + } + } + col = col.trim().length() == 0 ? "" : (col.trim().substring(0, col.trim().length() - 1)); + row = row + col + "\n"; + } while (rs.next()); + + return row; + }).forEach(row -> { + log.info(row); + }); + } +}
\ No newline at end of file diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java b/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java deleted file mode 100644 index cda7302c..00000000 --- a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============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.util.org.onap.ccsdk.sli.adaptors.ra; - -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; - -public class TestTable { - - private String tableName; - private String[] columnList; - private String idName; - - private String insertSql; - - private JdbcTemplate jdbcTemplate; - - public TestTable(JdbcTemplate jdbcTemplate, String tableName, String idName, String... columnList) { - this.jdbcTemplate = jdbcTemplate; - this.tableName = tableName; - this.idName = idName; - this.columnList = columnList; - createInsertSql(); - } - - private void createInsertSql() { - StringBuilder ss = new StringBuilder(); - ss.append("INSERT INTO ").append(tableName).append(" ("); - for (String s : columnList) - ss.append(s).append(", "); - ss.setLength(ss.length() - 2); - ss.append(") VALUES ("); - for (int i = 0; i < columnList.length; i++) - ss.append("?, "); - ss.setLength(ss.length() - 2); - ss.append(")"); - insertSql = ss.toString(); - } - - public void add(Object... values) { - jdbcTemplate.update(insertSql, values); - } - - public long getLastId() { - return jdbcTemplate.queryForObject("SELECT max(" + idName + ") FROM " + tableName, Long.class); - } - - public Long getId(String where) { - String selectSql = "SELECT " + idName + " FROM " + tableName + " WHERE " + where; - SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql); - if (rs.first()) - return rs.getLong(idName); - return null; - } - - public boolean exists(String where) { - String selectSql = "SELECT * FROM " + tableName + " WHERE " + where; - SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql); - return rs.first(); - } - - public void delete(String where) { - jdbcTemplate.update("DELETE FROM " + tableName + " WHERE " + where); - } -} diff --git a/resource-assignment/provider/src/test/resources/homing-req.json b/resource-assignment/provider/src/test/resources/homing-req.json deleted file mode 100644 index 1f061eca..00000000 --- a/resource-assignment/provider/src/test/resources/homing-req.json +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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========================================================= - */ - -{ - "input":{ - "sdnc-homing-header":{ - "svc-request-id":"omx-123", - "svc-action":"homing" - }, - "request-information":{ - "request-id":"mso-1234", - "request-action":"GetAicNodesRequest", - "source":"OMX", - "list-length":1 - }, - "homing-request-information":{ - "service-type":"SDN-ETHERNET-INTERNET", - "global-customer-id":"custid-123", - "customer-location":{ - "lata":332 - } - }, - "homing-other-information":{ - "bandwidth-value":150, - "bandwidth-units":"Mbps" - } - } -} diff --git a/resource-assignment/provider/src/test/resources/param.txt b/resource-assignment/provider/src/test/resources/param.txt deleted file mode 100755 index a20ac909..00000000 --- a/resource-assignment/provider/src/test/resources/param.txt +++ /dev/null @@ -1,44 +0,0 @@ -isAvailable:
- Input in ctx:
- tmp.resource-allocator.aic-site-id
- tmp.resource-allocator.speed
- tmp.resource-allocator.speed-unit
- Output in ctx:
- tmp.resource-allocator.max-available-speed
- tmp.resource-allocator.speed-unit
- Return:
- SUCCESS – capacity available
- NOT_FOUND – capacity not available
- Error message in: error-message, error-code
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-Reserve:
- Input in ctx:
- tmp.resource-allocator.aic-site-id
- tmp.resource-allocator.speed
- tmp.resource-allocator.speed-unit
- tmp.resource-allocator.service-instance-id
- tmp.resource-allocator.request-type { New, Change }
- Output in ctx:
- tmp.resource-allocator-output.max-available-speed
- tmp.resource-allocator-output.speed-unit
- Return:
- SUCCESS – capacity available
- NOT_FOUND – capacity not available
- Error message in: error-message, error-code
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-Release:
- Input in ctx:
- tmp.resource-allocator.service-instance-id
- tmp.resource-allocator.request-type { Activate, Cancel, Disconnect }
- Return:
- SUCCESS – capacity available
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-
-Plugin name: org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator
-Resource: NetworkCapacity
diff --git a/resource-assignment/provider/src/test/resources/sql/data.sql b/resource-assignment/provider/src/test/resources/sql/data.sql index 5fd4c757..681a9c45 100644 --- a/resource-assignment/provider/src/test/resources/sql/data.sql +++ b/resource-assignment/provider/src/test/resources/sql/data.sql @@ -118,3 +118,69 @@ INSERT INTO PARAMETERS (name, value, category, memo) VALUES ('homing.pserver.sparing.ratio', '1:1', 'homing', 'Ratio of primary to backup servers within any of the AIC sites. Used in RA to calculate the max allowed bw in an AIC site.'); +INSERT INTO RESOURCE_RULE ( + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, + allocation_expression, soft_limit_expression, hard_limit_expression) +VALUES ( + 'PortBandwidth', 'ADIG', 'VPE', 'true', 'Port', 'true', + 'service-speed-mbps', 'service-speed-mbps', 'service-speed-mbps'); + +INSERT INTO RESOURCE_RULE ( + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, + allocation_expression, soft_limit_expression, hard_limit_expression) +VALUES ( + 'Bandwidth', 'ADIG', 'VPE', 'true', 'VNF', 'vnf-type = "VPE"', + 'service-speed-mbps', '0.5 * max-vpe-bandwidth-mbps', '0.9 * max-vpe-bandwidth-mbps'); + + +INSERT INTO RESOURCE_RULE ( + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, + allocation_expression, soft_limit_expression, hard_limit_expression) +VALUES ( + 'Bandwidth', 'ADIG', 'VPE', 'true', 'AffinityLink', 'true', + 'service-speed-mbps', '9999999999', '9999999999'); + +INSERT INTO RESOURCE_RULE ( + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, + allocation_expression, soft_limit_expression, hard_limit_expression) +VALUES ( + 'Connection', 'ADIG', 'VPE', 'true', 'VNF', 'true', + '1', '200', '200'); + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'cust-vlan-id', 'ADIG', 'VPE', 'VNF', '2', '1000'); + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'vlan-id-inner', 'ADIG', 'VPE', 'VNF', '1002', '2000'); + + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'vlan-id-outer', 'MY-SERV-MODEL', 'VPE-Cust', 'Site', '2', '1000'); + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core1', 'Site', '1002', '2000'); + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core2', 'Site', '1002', '2000'); + +INSERT INTO RANGE_RULE ( + range_name, service_model, end_point_position, equipment_level, min_value, + max_value) +VALUES ( + 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core3', 'Site', '400', '600'); +
\ No newline at end of file diff --git a/resource-assignment/provider/src/test/resources/svc-topology-req.json b/resource-assignment/provider/src/test/resources/svc-topology-req.json deleted file mode 100644 index ab8afb66..00000000 --- a/resource-assignment/provider/src/test/resources/svc-topology-req.json +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ============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========================================================= - */ - -{ - "input":{ - "sdnc-request-header":{ - "svc-request-id":"omx-123", - "svc-action":"assign" - }, - "sdnc-topology-additional-data":{ - "svc-vnf-type":"vce" - }, - "request-information":{ - "request-id":"mso-1234", - "request-action":"Layer3ServiceActivateRequest", - "source":"OMX" - }, - "service-information":{ - "service-type":"SDN-ETHERNET-INTERNET", - "service-instance-id":"service-instance-123", - "subscriber-name":"ssb-subscriber" - }, - "l2-homing-information":{ - "evc-name":"EVC-123", - "topology":"PointToPoint", - "preferred-aic-clli":"ATLNGATL001" - } - "internet-evc-access-information":{ - "internet-evc-speed-value":"150", - "internet-evc-speed-units":"Mbps", - "ip-version":"v6" - } - "vr-lan":{ - "routing-protocol":"none", - { - "v6-vr-lan-prefix":"string", - "v6-public-lan-prefixes":{ - "t-provided-v6-lan-public-prefixes":[ - { - "v6-lan-public-prefix-length":"integer", - "v6-lan-public-prefix":"string", - "request-index":"integer" - } - ] - }, - "v6-vr-lan-prefix-length":"integer", - "v4-vr-lan-prefix-length":"integer", - "firewall-lite":{ - "v6-firewall-packet-filters":[ - { - "v6-firewall-prefix-length":"integer", - "udp-port-list":[ - { - "port-number":"integer" - } - ], - "tcp-port-list":[ - { - "port-number":"integer" - } - ], - "v6-firewall-prefix":"string" - } - ], - "v4-firewall-packet-filters":[ - { - "v4-firewall-prefix-length":"integer", - "udp-port-list":[ - { - "port-number":"integer" - } - ], - "tcp-port-list":[ - { - "port-number":"integer" - } - ], - "v4-firewall-prefix":"string" - } - ] - }, - "v6-vce-wan-address":"string", - "v4-public-lan-prefixes":{ - "t-provided-v4-lan-public-prefixes":[ - { - "v4-lan-public-prefix":"string", - "v4-lan-public-prefix-length":"integer", - "request-index":"integer" - } - ] - }, - "pat":{ - "v4-pat-default-pool-prefix-length":"integer", - "v4-pat-pools":[ - { - "v4-pat-pool-next-hop-address":"string", - "v4-pat-pool-prefix-length":"integer", - "v4-pat-pool-prefix":"string" - } - ], - "v4-pat-default-pool-prefix":"string" - }, - "v4-vce-loopback-address":"string", - "v4-vr-lan-prefix":"string", - "dhcp":{ - "v4-dhcp-pools":[ - { - "v4-dhcp-relay-next-hop-address":"string", - "excluded-v4-addresses":[ - { - "excluded-v4-address":"string" - } - ], - "v4-dhcp-pool-prefix":"string", - "v4-dhcp-relay-gateway-address":"string", - "v4-dhcp-pool-prefix-length":"integer" - } - ], - "excluded-v4-dhcp-addresses-from-default-pool":[ - { - "excluded-v4-address":"string" - } - ], - "v6-dhcp-pools":[ - { - "v6-dhcp-relay-gateway-address":"string", - "excluded-v6-addresses":[ - { - "excluded-v6-address":"string" - } - ], - "v6-dhcp-pool-prefix-length":"integer", - "v6-dhcp-relay-next-hop-address":"string", - "v6-dhcp-pool-prefix":"string" - } - ], - "v6-dhcp-default-pool-prefix":"string", - "v6-dhcp-default-pool-prefix-length":"integer", - "v4-dhcp-default-pool-prefix":"string", - "excluded-v6-dhcp-addresses-from-default-pool":[ - { - "excluded-v6-address":"string" - } - ], - "v4-dhcp-default-pool-prefix-length":"integer" - }, - "nat":{ - "v4-nat-mapping-entries":[ - { - "v4-nat-external":"string", - "v4-nat-next-hop-address":"string", - "v4-nat-internal":"string" - } - ] - }, - "static-routes":{ - "v6-static-routes":[ - { - "v6-static-route-prefix-length":"integer", - "v6-next-hop-address":"string", - "v6-static-route-prefix":"string" - } - ], - "v4-static-routes":[ - { - "v4-static-route-prefix-length":"integer", - "v4-static-route-prefix":"string", - "v4-next-hop-address":"string" - } - ] - } - } - - } - - } -} diff --git a/resource-assignment/provider/src/test/resources/test-context.xml b/resource-assignment/provider/src/test/resources/test-context.xml index c3b09a1f..32b54e9e 100644 --- a/resource-assignment/provider/src/test/resources/test-context.xml +++ b/resource-assignment/provider/src/test/resources/test-context.xml @@ -4,7 +4,7 @@ openECOMP : SDN-C ================================================================================ Copyright (C) 2017 AT&T Intellectual Property. All rights - reserved. + reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,22 +20,23 @@ ============LICENSE_END========================================================= --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/jdbc - http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.1.xsd - "> + http://www.springframework.org/schema/beans/spring-beans-3.1.xsd + http://www.springframework.org/schema/jdbc + http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.1.xsd + "> <context:annotation-config /> - <!-- JDBC setup --> + <!-- JDBC setup --> - <bean id="test.dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="false"> + <bean id="test.dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" + lazy-init="false" primary="true"> <property name="driverClassName" value="org.h2.Driver" /> <property name="url" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL" /> </bean> @@ -45,10 +46,18 @@ <jdbc:script location="sql/data.sql" /> </jdbc:initialize-database> - <bean id="rm.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> + <bean id="lock.dataSource" class="org.onap.ccsdk.sli.adaptors.util.db.CachedDataSourceWrap"> <property name="dataSource" ref="test.dataSource" /> </bean> + <bean id="rm.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" primary="true"> + <property name="dataSource" ref="test.dataSource" /> + </bean> + + <bean id="lock.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> + <property name="dataSource" ref="lock.dataSource" /> + </bean> + <bean id="testDb" class="jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestDb"> <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> </bean> @@ -57,17 +66,10 @@ <property name="testDb" ref="testDb" /> </bean> - <!-- Utils Configuration --> - - <bean id="speedUtil" class="org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil"> - <property name="unitFactor" value="1000" /> - </bean> - - <!-- Resource Lock Configuration --> + <!-- Resource Lock Configuration --> <bean id="resourceLockDao" class="org.onap.ccsdk.sli.adaptors.lock.dao.ResourceLockDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - <property name="testing" value="true" /> + <property name="jdbcTemplate" ref="lock.jdbcTemplate" /> </bean> <bean id="lockHelper" class="org.onap.ccsdk.sli.adaptors.lock.comp.LockHelperImpl"> @@ -76,7 +78,7 @@ <property name="lockWait" value="5" /> <!-- Seconds --> </bean> - <!-- RM Configuration --> + <!-- RM Configuration --> <bean id="resourceJdbcDao" class="org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.ResourceJdbcDaoImpl"> <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> @@ -99,35 +101,10 @@ <bean id="resourceManager" class="org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManagerImpl"> <property name="lockHelper" ref="lockHelper" /> <property name="resourceDao" ref="resourceDao" /> - <property name="applicationId" value="SDNC" /> <property name="lockTimeout" value="600" /> <!-- Seconds --> </bean> - <!-- Equipment DAO Configuration --> - - <bean id="serverDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.ServerDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <bean id="vpePortDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.VpePortDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <bean id="vplspePortDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.VplspePortDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <!-- Rule DAO Configuration --> - - <bean id="maxPortSpeedDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxPortSpeedDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - <property name="speedUtil" ref="speedUtil" /> - </bean> - - <bean id="maxServerSpeedDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxServerSpeedDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - <property name="speedUtil" ref="speedUtil" /> - </bean> + <!-- Rule DAO Configuration --> <bean id="resourceRuleDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.ResourceRuleDaoImpl"> <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> @@ -137,161 +114,37 @@ <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> </bean> - <bean id="vpeLockDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.VpeLockDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <bean id="parameterDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.ParameterDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <!-- Service DAO Configuration --> - - <bean id="serviceResourceDao" class="org.onap.ccsdk.sli.adaptors.ra.service.dao.ServiceResourceDaoImpl"> - <property name="jdbcTemplate" ref="rm.jdbcTemplate" /> - </bean> - - <!-- ResourceAllocator Configuration --> - - <bean id="allocationRequestBuilder" class="org.onap.ccsdk.sli.adaptors.ra.rule.comp.AllocationRequestBuilderImpl"> - <property name="resourceRuleDao" ref="resourceRuleDao" /> - <property name="rangeRuleDao" ref="rangeRuleDao" /> - </bean> + <!-- ResourceAllocator Configuration --> <bean id="resourceAllocator" class="org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator"> - <property name="speedUtil" ref="speedUtil" /> - <property name="parameterDao" ref="parameterDao" /> - <property name="serverDao" ref="serverDao" /> - <property name="vpePortDao" ref="vpePortDao" /> - <property name="vplspePortDao" ref="vplspePortDao" /> - <property name="maxPortSpeedDao" ref="maxPortSpeedDao" /> - <property name="maxServerSpeedDao" ref="maxServerSpeedDao" /> - <property name="serviceResourceDao" ref="serviceResourceDao" /> - <property name="allocationRequestBuilder" ref="allocationRequestBuilder" /> <property name="resourceManager" ref="resourceManager" /> <property name="endPointAllocator" ref="endPointAllocator" /> + <property name="speedUtil" ref="speedUtil" /> </bean> - <!-- EndPointAllocator Configuration --> + + <bean id="speedUtil" class="org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil" /> + + <!-- EndPointAllocator Configuration --> <bean id="endPointAllocator" class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocatorImpl"> <property name="resourceManager" ref="resourceManager" /> - <property name="endPointAllocationDefinitionMap"> + <property name="allocationRuleMap"> <map> - <entry key="L3AVPN-PORT"> + <entry key="DEFAULT"> <list> - <bean class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocationDefinition"> - <property name="serviceModel" value="L3AVPN-PORT" /> - <property name="endPointPosition" value="VPE-Cust" /> - <property name="equipmentReader" ref="vpePortReader" /> - <property name="equipmentCheckList"> - <list> - <ref bean="provStatusCheck" /> - <ref bean="excludeVpeCheck" /> - <ref bean="anyVrfPresentCheck" /> - </list> - </property> - <property name="preferenceRuleList"> - <list> - <ref bean="affinityLinkPref" /> - </list> - </property> - <property name="allocationRuleList"> - <list> - <ref bean="dbAllocationRule" /> - <ref bean="affinityAllocationRule" /> - </list> - </property> - </bean> - </list> - </entry> - <entry key="L3AVPN-EVC"> - <list> - <bean class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocationDefinition"> - <property name="serviceModel" value="L3AVPN-EVC" /> - <property name="endPointPosition" value="VPE-Cust" /> - <property name="equipmentReader" ref="vpePortReader" /> - <property name="equipmentCheckList"> - <list> - <ref bean="provStatusCheck" /> - <ref bean="excludeVpeCheck" /> - <ref bean="vpeLockCheck" /> - <ref bean="anyVrfPresentCheck" /> - <ref bean="oneMVrfCheck" /> - <ref bean="hubWithRgCheck" /> - </list> - </property> - <property name="preferenceRuleList"> - <list> - <ref bean="affinityLinkPref" /> - </list> - </property> - <property name="allocationRuleList"> - <list> - <ref bean="dbAllocationRule" /> - <ref bean="vrfAllocationRule" /> - <ref bean="servingSiteAllocationRule" /> - <ref bean="affinityAllocationRule" /> - </list> - </property> - </bean> + <ref bean="dbAllocationRule" /> </list> </entry> </map> </property> </bean> - <!-- Equipment Readers Configuration --> - - <bean id="vpePortReader" class="org.onap.ccsdk.sli.adaptors.ra.reader.VpePortReader"> - <property name="vpePortDao" ref="vpePortDao" /> - </bean> - - <!-- Equipment Checks Configuration --> - - <bean id="provStatusCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.ProvStatusCheck"> - </bean> - - <bean id="excludeVpeCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.ExcludeVpeCheck"> - </bean> - - <bean id="vpeLockCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.VpeLockCheck"> - <property name="vpeLockDao" ref="vpeLockDao" /> - <property name="resourceManager" ref="resourceManager" /> - </bean> - - <bean id="anyVrfPresentCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.AnyVrfPresentCheck"> - <property name="resourceManager" ref="resourceManager" /> - </bean> - - <bean id="oneMVrfCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.OneMVrfCheck"> - <property name="resourceManager" ref="resourceManager" /> - </bean> - - <bean id="hubWithRgCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.HubWithRgCheck"> - <property name="resourceManager" ref="resourceManager" /> - </bean> - - <!-- Preference Rule Configuration --> - - <bean id="affinityLinkPref" class="org.onap.ccsdk.sli.adaptors.ra.pref.AffinityLinkPref"> - <property name="resourceManager" ref="resourceManager" /> - </bean> - - <!-- Resource Allocation Rule Configuration --> + <!-- Resource Allocation Rule Configuration --> <bean id="dbAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.DbAllocationRule"> <property name="resourceRuleDao" ref="resourceRuleDao" /> <property name="rangeRuleDao" ref="rangeRuleDao" /> </bean> - <bean id="vrfAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.VrfAllocationRule"> - </bean> - - <bean id="servingSiteAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.ServingSiteAllocationRule"> - </bean> - - <bean id="affinityAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.AffinityAllocationRule"> - </bean> - </beans> |