From 806052bf4df8bd023cfb391794bc5937f2624716 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 2 Aug 2017 15:09:24 -0700 Subject: Convert tabs to spaces Per Java Code Style Guide: https://wiki.onap.org/display/DW/Java+code+style Converting tabs to 4 spaces. Issue-Id: SDNC-25 Change-Id: I99ce6c244df72f805b52d0d66403d8b76d9929ae Signed-off-by: Marcus G K Williams --- .../jtest/org/openecomp/sdnc/ra/DataSetup.java | 462 +++---- .../org/openecomp/sdnc/ra/TestIsAvailable.java | 708 +++++------ .../jtest/org/openecomp/sdnc/ra/TestQuery.java | 66 +- .../jtest/org/openecomp/sdnc/ra/TestRelease.java | 574 ++++----- .../jtest/org/openecomp/sdnc/ra/TestReserve.java | 1272 ++++++++++---------- .../jtest/org/openecomp/sdnc/ra/TestReserve2.java | 54 +- .../jtest/org/openecomp/sdnc/rm/DataSetup.java | 152 +-- .../jtest/util/org/openecomp/sdnc/ra/TestDb.java | 16 +- .../util/org/openecomp/sdnc/ra/TestTable.java | 94 +- .../provider/src/test/resources/homing-req.json | 48 +- .../provider/src/test/resources/log4j.properties | 2 +- .../provider/src/test/resources/sql/data.sql | 40 +- .../provider/src/test/resources/sql/schema.sql | 192 +-- .../provider/src/test/resources/test-context.xml | 546 ++++----- 14 files changed, 2113 insertions(+), 2113 deletions(-) (limited to 'resource-assignment/provider/src/test') diff --git a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/DataSetup.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/DataSetup.java index f74eeee5..46ac760a 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/DataSetup.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/DataSetup.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -28,234 +28,234 @@ import jtest.util.org.openecomp.sdnc.ra.TestTable; 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[] 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) - resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS); - 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; - } + 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[] 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) + resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS); + 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/openecomp/sdnc/ra/TestIsAvailable.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestIsAvailable.java index 7d57eba3..2c25c3e1 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestIsAvailable.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestIsAvailable.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -41,384 +41,384 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestIsAvailable { - private static final Logger log = LoggerFactory.getLogger(TestIsAvailable.class); + private static final Logger log = LoggerFactory.getLogger(TestIsAvailable.class); - @Autowired(required = true) - private ResourceAllocator resourceAllocator; + @Autowired(required = true) + private ResourceAllocator resourceAllocator; - @Autowired(required = true) - private DataSetup dataSetup; + @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"); + @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"; + 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); + 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"); + 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); + QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + 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); + 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"); + 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); + 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"); + 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); + 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)); - } + 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"); + @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"; + 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); + 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"); + 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); + 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"); + 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); + 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)); - } + 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"; + @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 - no speed in input"); - - SvcLogicContext ctx = new SvcLogicContext(); - 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("tmp.resource-allocator.speed is required in ResourceAllocator")); - return; - } - Assert.fail("SvcLogicException expected"); - } - - @Test - public void test012() throws Exception { - String t = "012"; - 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 test013() throws Exception { - String t = "013"; - 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"); - } + 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 - no speed in input"); + + SvcLogicContext ctx = new SvcLogicContext(); + 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("tmp.resource-allocator.speed is required in ResourceAllocator")); + return; + } + Assert.fail("SvcLogicException expected"); + } + + @Test + public void test012() throws Exception { + String t = "012"; + 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 test013() throws Exception { + String t = "013"; + 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/openecomp/sdnc/ra/TestQuery.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestQuery.java index e69003a3..0d287f2b 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestQuery.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestQuery.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -40,46 +40,46 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestQuery { - private static final Logger log = LoggerFactory.getLogger(TestQuery.class); + private static final Logger log = LoggerFactory.getLogger(TestQuery.class); - @Autowired(required = true) - private ResourceAllocator resourceAllocator; + @Autowired(required = true) + private ResourceAllocator resourceAllocator; - @Autowired(required = true) - private DataSetup dataSetup; + @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)"); + @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"; + String service1 = "ICOREPVC" + t + "-1"; - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); + 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"); + 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); + QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000)); + 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); + 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"); - } + 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/openecomp/sdnc/ra/TestRelease.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestRelease.java index f2ee50fc..45bd047a 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestRelease.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestRelease.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -41,390 +41,390 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestRelease { - private static final Logger log = LoggerFactory.getLogger(TestRelease.class); + private static final Logger log = LoggerFactory.getLogger(TestRelease.class); - @Autowired(required = true) - private ResourceAllocator resourceAllocator; + @Autowired(required = true) + private ResourceAllocator resourceAllocator; - @Autowired(required = true) - private DataSetup dataSetup; + @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"); + @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"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @Test + public void test002() throws Exception { + String t = "002"; + log.info("============== release " + t + " ================================"); + log.info("=== Test release - cancel - change"); - String service1 = "release" + t + "/service1"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3)); - } + 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"); + @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"; + 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.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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } + 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"); + @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"; + String service1 = "release" + t + "/service1"; - dataSetup.cleanup(); + dataSetup.cleanup(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } + 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"); + @Test + public void test006() throws Exception { + String t = "006"; + log.info("============== release " + t + " ================================"); + log.info("=== Test release - actovate - change"); - String service1 = "release" + t + "/service1"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 3, 400000)); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2)); - } + 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"); + @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"; + 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.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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000)); - } + 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"); + @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"; + String service1 = "release" + t + "/service1"; - dataSetup.cleanup(); + dataSetup.cleanup(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Activate"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + 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.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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + 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"); + 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)); + 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); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + String service1 = "release" + t + "/service1"; - dataSetup.cleanup(); + dataSetup.cleanup(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect"); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1); + 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); + QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx); - log.info("Result: " + st); + log.info("Result: " + st); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null)); - } + 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"); + @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"; + String service1 = "release" + t + "/service1"; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.resource-allocator.service-instance-id", 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"); + 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"); - } + 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/openecomp/sdnc/ra/TestReserve.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve.java index 08c67358..1dff3589 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -41,641 +41,641 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestReserve { - private static final Logger log = LoggerFactory.getLogger(TestReserve.class); + private static final Logger log = LoggerFactory.getLogger(TestReserve.class); - @Autowired(required = true) - private ResourceAllocator resourceAllocator; + @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 = "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")); - - 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"); - - 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", 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"; - - 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", "500"); - 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", 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"); - - 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", "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")); - - 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"; - - 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"); - - 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); - - 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); - - 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"); - - 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"); - dataSetup.setupService(service1, "Pending", 3, 5000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1"); - - Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000)); - Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000)); - - 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"); - - QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - - log.info("Result: " + st); - - 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"; - - 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"; - 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"); - - QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - - log.info("Result: " + st); - for (String key : ctx.getAttributeKeySet()) - if (key.startsWith("tmp.resource-allocator-output")) - log.info(" " + key + ": " + ctx.getAttribute(key)); - - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1605000)); - } - - @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."); - - 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 <= 10; 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", "800"); // 10*100Mbps existing + 800 = 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")); - - 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)); - } + @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 = "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")); + + 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"); + + 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", 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"; + + 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", "500"); + 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", 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"); + + 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", "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")); + + 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"; + + 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"); + + 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); + + 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); + + 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"); + + 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"); + dataSetup.setupService(service1, "Pending", 3, 5000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1"); + + Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000)); + Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000)); + + 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"); + + QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); + + log.info("Result: " + st); + + 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"; + + 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"; + 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"); + + QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); + + log.info("Result: " + st); + for (String key : ctx.getAttributeKeySet()) + if (key.startsWith("tmp.resource-allocator-output")) + log.info(" " + key + ": " + ctx.getAttribute(key)); + + Assert.assertTrue(st == QueryStatus.SUCCESS); + Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1605000)); + } + + @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."); + + 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 <= 10; 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", "800"); // 10*100Mbps existing + 800 = 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")); + + 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)); + } } diff --git a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve2.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve2.java index a92cbc5a..1442f3ca 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve2.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/ra/TestReserve2.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -40,38 +40,38 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestReserve2 { - private static final Logger log = LoggerFactory.getLogger(TestReserve2.class); + private static final Logger log = LoggerFactory.getLogger(TestReserve2.class); - @Autowired(required = true) - private ResourceAllocator resourceAllocator; + @Autowired(required = true) + private ResourceAllocator resourceAllocator; - @Autowired(required = true) - private DataSetup dataSetup; + @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"); + @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"; + String service1 = "ICOREPVC" + t + "-1"; - dataSetup.cleanup(); - dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image"); + 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"); + 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); + QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx); - Assert.assertTrue(st == QueryStatus.SUCCESS); - Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000)); - } + 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/org/openecomp/sdnc/rm/DataSetup.java b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/rm/DataSetup.java index 55824b00..4ff5bec7 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/rm/DataSetup.java +++ b/resource-assignment/provider/src/test/java/jtest/org/openecomp/sdnc/rm/DataSetup.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -28,79 +28,79 @@ import jtest.util.org.openecomp.sdnc.ra.TestTable; public class DataSetup { - private TestDb testDb; - - private TestTable resource = null; - private TestTable allocationItem = null; - - private static final String[] RESOURCE_COLUMNS = - { "asset_id", "resource_name", "resource_type", "lt_used", "ll_label", "ll_reference_count", "rr_used" }; - - private static final String[] ALLOCATION_ITEM_COLUMNS = { - "resource_id", "application_id", "resource_set_id", "resource_union_id", "resource_share_group_list", - "lt_used", "ll_label", "rr_used", "allocation_time" }; - - private void initTables() { - if (resource == null) - resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS); - if (allocationItem == null) - allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS); - } - - public void cleanup() { - allocationItem.delete("true"); - resource.delete("true"); - } - - public void setupLimitItem( - String resourceName, - String assetId, - String resourceSetId, - String resourceUnionId, - long used) { - initTables(); - - Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); - if (rid == null) { - resource.add(assetId, resourceName, "Limit", 1, null, null, null); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, used, null, null, new Date()); - } - - public void setupRangeItem( - String resourceName, - String assetId, - String resourceSetId, - String resourceUnionId, - String used) { - initTables(); - - Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); - if (rid == null) { - resource.add(assetId, resourceName, "Range", null, null, null, used); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, null, used, new Date()); - } - - public void setupLabelItem( - String resourceName, - String assetId, - String resourceSetId, - String resourceUnionId, - String label) { - initTables(); - - Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); - if (rid == null) { - resource.add(assetId, resourceName, "Label", null, label, 1, null); - rid = resource.getLastId(); - } - allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, label, null, new Date()); - } - - public void setTestDb(TestDb testDb) { - this.testDb = testDb; - } + private TestDb testDb; + + private TestTable resource = null; + private TestTable allocationItem = null; + + private static final String[] RESOURCE_COLUMNS = + { "asset_id", "resource_name", "resource_type", "lt_used", "ll_label", "ll_reference_count", "rr_used" }; + + private static final String[] ALLOCATION_ITEM_COLUMNS = { + "resource_id", "application_id", "resource_set_id", "resource_union_id", "resource_share_group_list", + "lt_used", "ll_label", "rr_used", "allocation_time" }; + + private void initTables() { + if (resource == null) + resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS); + if (allocationItem == null) + allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS); + } + + public void cleanup() { + allocationItem.delete("true"); + resource.delete("true"); + } + + public void setupLimitItem( + String resourceName, + String assetId, + String resourceSetId, + String resourceUnionId, + long used) { + initTables(); + + Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); + if (rid == null) { + resource.add(assetId, resourceName, "Limit", 1, null, null, null); + rid = resource.getLastId(); + } + allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, used, null, null, new Date()); + } + + public void setupRangeItem( + String resourceName, + String assetId, + String resourceSetId, + String resourceUnionId, + String used) { + initTables(); + + Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); + if (rid == null) { + resource.add(assetId, resourceName, "Range", null, null, null, used); + rid = resource.getLastId(); + } + allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, null, used, new Date()); + } + + public void setupLabelItem( + String resourceName, + String assetId, + String resourceSetId, + String resourceUnionId, + String label) { + initTables(); + + Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'"); + if (rid == null) { + resource.add(assetId, resourceName, "Label", null, label, 1, null); + rid = resource.getLastId(); + } + allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, label, null, new Date()); + } + + public void setTestDb(TestDb testDb) { + this.testDb = testDb; + } } 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/openecomp/sdnc/ra/TestDb.java index ec7c2abf..ba890c72 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/openecomp/sdnc/ra/TestDb.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -25,13 +25,13 @@ import org.springframework.jdbc.core.JdbcTemplate; public class TestDb { - private JdbcTemplate jdbcTemplate; + private JdbcTemplate jdbcTemplate; - public TestTable table(String tableName, String idName, String... columnList) { - return new TestTable(jdbcTemplate, tableName, idName, columnList); - } + public TestTable table(String tableName, String idName, String... columnList) { + return new TestTable(jdbcTemplate, tableName, idName, columnList); + } - public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } } 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 index 64288d96..a57ab4fc 100644 --- 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 @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 ONAP 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. @@ -26,59 +26,59 @@ import org.springframework.jdbc.support.rowset.SqlRowSet; public class TestTable { - private String tableName; - private String[] columnList; - private String idName; + private String tableName; + private String[] columnList; + private String idName; - private String insertSql; + private String insertSql; - private JdbcTemplate jdbcTemplate; + 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(); - } + 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(); - } + 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 add(Object... values) { + jdbcTemplate.update(insertSql, values); + } - public long getLastId() { - return jdbcTemplate.queryForObject("SELECT max(" + idName + ") FROM " + tableName, Long.class); - } + 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 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 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 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 index 48ec701a..1f061eca 100644 --- a/resource-assignment/provider/src/test/resources/homing-req.json +++ b/resource-assignment/provider/src/test/resources/homing-req.json @@ -3,7 +3,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,27 +20,27 @@ */ { - "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" - } - } + "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/log4j.properties b/resource-assignment/provider/src/test/resources/log4j.properties index 6d6e30ff..b36b7674 100644 --- a/resource-assignment/provider/src/test/resources/log4j.properties +++ b/resource-assignment/provider/src/test/resources/log4j.properties @@ -3,7 +3,7 @@ # openECOMP : SDN-C # ================================================================================ # Copyright (C) 2017 ONAP 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. diff --git a/resource-assignment/provider/src/test/resources/sql/data.sql b/resource-assignment/provider/src/test/resources/sql/data.sql index 2214bce7..f840a232 100644 --- a/resource-assignment/provider/src/test/resources/sql/data.sql +++ b/resource-assignment/provider/src/test/resources/sql/data.sql @@ -3,7 +3,7 @@ -- openECOMP : SDN-C -- ================================================================================ -- Copyright (C) 2017 ONAP 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. @@ -34,10 +34,10 @@ VALUES ( 'service-speed-kbps', '0.6 * max-server-speed * number-primary-servers', 'max-server-speed * number-primary-servers'); INSERT INTO RESOURCE_RULE ( - resource_name, service_model, end_point_position, service_expression, equipment_level, + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, allocation_expression, soft_limit_expression, hard_limit_expression) VALUES ( - 'Connection', 'L3SDN', 'VCE-Cust', 'true', 'Server', + 'Connection', 'L3SDN', 'VCE-Cust', 'true', 'Server', 'true', '1', '40', '40'); INSERT INTO RESOURCE_RULE ( @@ -48,51 +48,51 @@ VALUES ( 'service-speed-kbps', '0.5 * max-port-speed', '0.9 * max-port-speed'); INSERT INTO RESOURCE_RULE ( - resource_name, service_model, end_point_position, service_expression, + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, allocation_expression, soft_limit_expression, hard_limit_expression) VALUES ( - 'Bandwidth', 'L3AVPN-EVC', 'VPE-Cust', 'true', 'Port', 'true', 'service-speed-kbps', '8000000', '8000000'); + 'Bandwidth', 'L3AVPN-EVC', 'VPE-Cust', 'true', 'Port', 'true', 'service-speed-kbps', '8000000', '8000000'); INSERT INTO RESOURCE_RULE ( - resource_name, service_model, end_point_position, service_expression, + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, allocation_expression, soft_limit_expression, hard_limit_expression) VALUES ( - 'Connection', 'L3AVPN-EVC', 'VPE-Cust', 'true', 'Port', 'true', '1', '200', '200'); + 'Connection', 'L3AVPN-EVC', 'VPE-Cust', 'true', 'Port', 'true', '1', '200', '200'); INSERT INTO RESOURCE_RULE ( - resource_name, service_model, end_point_position, service_expression, + resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression, allocation_expression, soft_limit_expression, hard_limit_expression) VALUES ( - 'Bandwidth', 'L3AVPN-PORT', 'VPE-Cust', 'true', 'Port', 'true', 'service-speed-kbps', '8000000', '8000000'); + 'Bandwidth', 'L3AVPN-PORT', 'VPE-Cust', 'true', 'Port', 'true', 'service-speed-kbps', '8000000', '8000000'); insert into RESOURCE_THRESHOLD ( - resource_rule_id, threshold_expression, threshold_message) + resource_rule_id, threshold_expression, threshold_message) values ( - (select resource_rule_id from RESOURCE_RULE where resource_name = 'Bandwidth' and equipment_level = 'Server'), + (select resource_rule_id from RESOURCE_RULE where resource_name = 'Bandwidth' and equipment_level = 'Server'), '0.5 * max-server-speed * number-primary-servers', 'The provisioned access bandwidth is at or exceeds 50% of the total server capacity.'); insert into RESOURCE_THRESHOLD ( - resource_rule_id, threshold_expression, threshold_message) + resource_rule_id, threshold_expression, threshold_message) values ( - (select resource_rule_id from RESOURCE_RULE where resource_name = 'Bandwidth' and equipment_level = 'Server'), + (select resource_rule_id from RESOURCE_RULE where resource_name = 'Bandwidth' and equipment_level = 'Server'), '0.7 * max-server-speed * number-primary-servers', 'The provisioned access bandwidth is at or exceeds 70% of the total server capacity.'); INSERT INTO RANGE_RULE ( - range_name, service_model, end_point_position, equipment_level, min_value, max_value) + range_name, service_model, end_point_position, equipment_level, min_value, max_value) VALUES ( - 'subinterface-id', 'L3AVPN-EVC', 'VPE-Cust', 'Port', 100, 3999); + 'subinterface-id', 'L3AVPN-EVC', 'VPE-Cust', 'Port', 100, 3999); INSERT INTO RANGE_RULE ( - range_name, service_model, end_point_position, equipment_level, min_value, max_value) + range_name, service_model, end_point_position, equipment_level, min_value, max_value) VALUES ( - 'vlan-id-inner', 'L3AVPN-EVC', 'VPE-Cust', 'Port', 2, 4091); + 'vlan-id-inner', 'L3AVPN-EVC', 'VPE-Cust', 'Port', 2, 4091); INSERT INTO RANGE_RULE ( - range_name, service_model, end_point_position, equipment_level, min_value, max_value) + range_name, service_model, end_point_position, equipment_level, min_value, max_value) VALUES ( - 'bundle-id', 'L3AVPN-PORT', 'VPE-Cust', 'Port', 1, 99999); + 'bundle-id', 'L3AVPN-PORT', 'VPE-Cust', 'Port', 1, 99999); INSERT INTO MAX_PORT_SPEED ( image_file_name, end_point_position, interface_name, max_speed, unit) @@ -116,5 +116,5 @@ VALUES ('ALL', 10000, 500, 'Mbps', 'Max speed, when there are 21 or more EVC on 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.'); + '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.'); diff --git a/resource-assignment/provider/src/test/resources/sql/schema.sql b/resource-assignment/provider/src/test/resources/sql/schema.sql index e650337e..03b5bfa7 100644 --- a/resource-assignment/provider/src/test/resources/sql/schema.sql +++ b/resource-assignment/provider/src/test/resources/sql/schema.sql @@ -3,7 +3,7 @@ -- openECOMP : SDN-C -- ================================================================================ -- Copyright (C) 2017 ONAP 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,12 +20,12 @@ --- CREATE TABLE RESOURCE_LOCK ( - resource_lock_id SERIAL PRIMARY KEY, - resource_name VARCHAR(50) NOT NULL UNIQUE, - lock_holder VARCHAR(100) NOT NULL, - lock_count SMALLINT NOT NULL, - lock_time DATETIME NOT NULL, - expiration_time DATETIME NOT NULL + resource_lock_id SERIAL PRIMARY KEY, + resource_name VARCHAR(50) NOT NULL UNIQUE, + lock_holder VARCHAR(100) NOT NULL, + lock_count SMALLINT NOT NULL, + lock_time DATETIME NOT NULL, + expiration_time DATETIME NOT NULL ); CREATE TABLE RESOURCE ( @@ -70,59 +70,59 @@ CREATE INDEX i1_allocation_item ON allocation_item (resource_id); CREATE UNIQUE INDEX ak1_allocation_item ON allocation_item (resource_id, resource_set_id); CREATE TABLE RESOURCE_RULE ( - resource_rule_id SERIAL PRIMARY KEY, - resource_name VARCHAR(50) NOT NULL, - service_model VARCHAR(50) NOT NULL, - end_point_position VARCHAR(50) NOT NULL, - service_expression VARCHAR(2000) NOT NULL, - equipment_level VARCHAR(50) NOT NULL, - equipment_expression VARCHAR(2000) NOT NULL, - allocation_expression VARCHAR(2000) NOT NULL, - soft_limit_expression VARCHAR(2000) NOT NULL, - hard_limit_expression VARCHAR(2000) NOT NULL + resource_rule_id SERIAL PRIMARY KEY, + resource_name VARCHAR(50) NOT NULL, + service_model VARCHAR(50) NOT NULL, + end_point_position VARCHAR(50) NOT NULL, + service_expression VARCHAR(2000) NOT NULL, + equipment_level VARCHAR(50) NOT NULL, + equipment_expression VARCHAR(2000) NOT NULL, + allocation_expression VARCHAR(2000) NOT NULL, + soft_limit_expression VARCHAR(2000) NOT NULL, + hard_limit_expression VARCHAR(2000) NOT NULL ); CREATE TABLE RESOURCE_THRESHOLD ( - resource_threshold_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, - resource_rule_id bigint(20) NOT NULL, - threshold_expression varchar(2000) NOT NULL, - threshold_message varchar(2000) NOT NULL, - PRIMARY KEY (resource_threshold_id) + resource_threshold_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, + resource_rule_id bigint(20) NOT NULL, + threshold_expression varchar(2000) NOT NULL, + threshold_message varchar(2000) NOT NULL, + PRIMARY KEY (resource_threshold_id) ); CREATE TABLE RANGE_RULE ( - range_rule_id SERIAL PRIMARY KEY, - range_name VARCHAR(50) NOT NULL, - service_model VARCHAR(50) NOT NULL, - end_point_position VARCHAR(50) NOT NULL, - equipment_level VARCHAR(50) NOT NULL, - min_value INT NOT NULL, - max_value INT NOT NULL + range_rule_id SERIAL PRIMARY KEY, + range_name VARCHAR(50) NOT NULL, + service_model VARCHAR(50) NOT NULL, + end_point_position VARCHAR(50) NOT NULL, + equipment_level VARCHAR(50) NOT NULL, + min_value INT NOT NULL, + max_value INT NOT NULL ); CREATE TABLE MAX_PORT_SPEED ( - max_port_speed_id SERIAL PRIMARY KEY, - image_file_name VARCHAR(50) NOT NULL, - end_point_position VARCHAR(50) NOT NULL, - interface_name VARCHAR(100) NOT NULL, - max_speed BIGINT NOT NULL, - unit VARCHAR(10) NOT NULL + max_port_speed_id SERIAL PRIMARY KEY, + image_file_name VARCHAR(50) NOT NULL, + end_point_position VARCHAR(50) NOT NULL, + interface_name VARCHAR(100) NOT NULL, + max_speed BIGINT NOT NULL, + unit VARCHAR(10) NOT NULL ); CREATE TABLE MAX_SERVER_SPEED ( - max_server_speed_id SERIAL PRIMARY KEY, - server_model VARCHAR(50) NOT NULL, - evc_count SMALLINT NOT NULL, - max_speed BIGINT NOT NULL, - unit VARCHAR(10) NOT NULL, - description VARCHAR(500) + max_server_speed_id SERIAL PRIMARY KEY, + server_model VARCHAR(50) NOT NULL, + evc_count SMALLINT NOT NULL, + max_speed BIGINT NOT NULL, + unit VARCHAR(10) NOT NULL, + description VARCHAR(500) ); CREATE TABLE SERVICE_RESOURCE ( - service_resource_id SERIAL PRIMARY KEY, - service_instance_id VARCHAR(80) NOT NULL, - service_status VARCHAR(10) NOT NULL, - service_change_number SMALLINT NOT NULL, + service_resource_id SERIAL PRIMARY KEY, + service_instance_id VARCHAR(80) NOT NULL, + service_status VARCHAR(10) NOT NULL, + service_change_number SMALLINT NOT NULL, resource_set_id VARCHAR(100) NOT NULL, resource_union_id VARCHAR(100) NOT NULL, ); @@ -132,37 +132,37 @@ CREATE INDEX i1_service_resource ON SERVICE_RESOURCE (service_instance_id); CREATE UNIQUE INDEX ak1_service_resource ON SERVICE_RESOURCE (service_instance_id, service_change_number); CREATE TABLE VPE_POOL ( - vpe_name VARCHAR(20) NOT NULL, - ipv4_oam_address VARCHAR(20) NOT NULL, - loopback0_ipv4_address VARCHAR(20) NOT NULL, - provisioning_status VARCHAR(10) NOT NULL, - aic_site_id VARCHAR(100) NOT NULL, - availability_zone VARCHAR(100) NOT NULL, - vlan_id_outer VARCHAR(20) NOT NULL, - vendor VARCHAR(20) NOT NULL, - physical_intf_name VARCHAR(40) NOT NULL, - physical_intf_speed VARCHAR(20) NOT NULL, - physical_intf_units VARCHAR(20) NOT NULL, - vpe_uuid VARCHAR(80) DEFAULT NULL, - vpe_id VARCHAR(80) DEFAULT NULL, - image_filename VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (aic_site_id, vpe_name, availability_zone) + vpe_name VARCHAR(20) NOT NULL, + ipv4_oam_address VARCHAR(20) NOT NULL, + loopback0_ipv4_address VARCHAR(20) NOT NULL, + provisioning_status VARCHAR(10) NOT NULL, + aic_site_id VARCHAR(100) NOT NULL, + availability_zone VARCHAR(100) NOT NULL, + vlan_id_outer VARCHAR(20) NOT NULL, + vendor VARCHAR(20) NOT NULL, + physical_intf_name VARCHAR(40) NOT NULL, + physical_intf_speed VARCHAR(20) NOT NULL, + physical_intf_units VARCHAR(20) NOT NULL, + vpe_uuid VARCHAR(80) DEFAULT NULL, + vpe_id VARCHAR(80) DEFAULT NULL, + image_filename VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (aic_site_id, vpe_name, availability_zone) ); CREATE TABLE VPLSPE_POOL ( - vplspe_name varchar(20) NOT NULL, - aic_site_id varchar(100) NOT NULL, - availability_zone varchar(100) NOT NULL, - physical_intf_name varchar(40) NOT NULL, - physical_intf_speed varchar(20) NOT NULL, - physical_intf_units varchar(20) NOT NULL, - loopback0_ipv4_address varchar(20) NOT NULL, - vlan_id_outer varchar(20) NOT NULL, - vplspe_uuid varchar(80) DEFAULT NULL, - image_filename varchar(100) DEFAULT NULL, - provisioning_status varchar(10) DEFAULT NULL, - vendor varchar(20) DEFAULT NULL, - PRIMARY KEY (vplspe_name, aic_site_id, availability_zone, physical_intf_name) + vplspe_name varchar(20) NOT NULL, + aic_site_id varchar(100) NOT NULL, + availability_zone varchar(100) NOT NULL, + physical_intf_name varchar(40) NOT NULL, + physical_intf_speed varchar(20) NOT NULL, + physical_intf_units varchar(20) NOT NULL, + loopback0_ipv4_address varchar(20) NOT NULL, + vlan_id_outer varchar(20) NOT NULL, + vplspe_uuid varchar(80) DEFAULT NULL, + image_filename varchar(100) DEFAULT NULL, + provisioning_status varchar(10) DEFAULT NULL, + vendor varchar(20) DEFAULT NULL, + PRIMARY KEY (vplspe_name, aic_site_id, availability_zone, physical_intf_name) ); CREATE TABLE VPE_LOCK ( @@ -172,30 +172,30 @@ CREATE TABLE VPE_LOCK ( ); CREATE TABLE PARAMETERS ( - name varchar(100) PRIMARY KEY, - value varchar(24) NOT NULL, - category varchar(24) NOT NULL, - memo varchar(128) + name varchar(100) PRIMARY KEY, + value varchar(24) NOT NULL, + category varchar(24) NOT NULL, + memo varchar(128) ); CREATE TABLE PSERVER ( - hostname varchar(255) NOT NULL, - ptnii_equip_name varchar(255), - number_of_cpus varchar(255), - disk_in_gigabytes varchar(255), - ram_in_megabytes varchar(255), - equip_type varchar(255), - equip_vendor varchar(255), - equip_model varchar(255), - fqdn varchar(255), - pserver_selflink varchar(255), - ipv4_oam_address varchar(15), - serial_number varchar(255), - pserver_id varchar(255), - internet_topology varchar(40), - aic_site_id varchar(100), - in_maint varchar(5), - pserver_name2 varchar(255), - purpose varchar(255), - PRIMARY KEY (hostname) + hostname varchar(255) NOT NULL, + ptnii_equip_name varchar(255), + number_of_cpus varchar(255), + disk_in_gigabytes varchar(255), + ram_in_megabytes varchar(255), + equip_type varchar(255), + equip_vendor varchar(255), + equip_model varchar(255), + fqdn varchar(255), + pserver_selflink varchar(255), + ipv4_oam_address varchar(15), + serial_number varchar(255), + pserver_id varchar(255), + internet_topology varchar(40), + aic_site_id varchar(100), + in_maint varchar(5), + pserver_name2 varchar(255), + purpose varchar(255), + PRIMARY KEY (hostname) ); diff --git a/resource-assignment/provider/src/test/resources/test-context.xml b/resource-assignment/provider/src/test/resources/test-context.xml index 89aea439..1d21fa4f 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 ONAP 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. @@ -21,277 +21,277 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 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 + "> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg