From e71c86c428806b55076c1687bb180176f87e6a23 Mon Sep 17 00:00:00 2001 From: "Cheung, Pat (kc1472)" Date: Mon, 11 Jan 2021 22:37:56 +0000 Subject: sdnc-apps update Fixing delete operation issue and add junit config and operation tests Issue-ID: SDNC-1429 Signed-off-by: Cheung, Pat (kc1472) Change-Id: I2e72db0db899ca52cbfd7910d8fb55be4cf05749 --- .../ConfigApiServicesControllerTest.java | 345 ++++++++++++++++- .../controllers/OperationsApiControllerTest.java | 109 +++++- .../src/test/resources/allotted-resource-item.json | 29 ++ .../contrail-route-allotted-resource-1.json | 33 ++ .../test/resources/policy-update-notify-rpc.json | 7 + .../src/test/resources/port-mirror-assign-rpc.json | 46 +++ .../resources/port-mirror-configuration-1.json | 120 ++++++ .../resources/port-mirror-configuration-item.json | 116 ++++++ .../src/test/resources/service1-vfmodule-item.json | 422 +++++++++++++++++++++ .../src/test/resources/service9.json | 268 +++++++++++++ .../src/test/resources/vf-module-assign-rpc.json | 57 +++ .../vnf-get-resource-request-expected.json | 1 + .../resources/vnf-get-resource-request-rpc.json | 15 + 13 files changed, 1562 insertions(+), 6 deletions(-) create mode 100644 ms/generic-resource-api/src/test/resources/allotted-resource-item.json create mode 100644 ms/generic-resource-api/src/test/resources/contrail-route-allotted-resource-1.json create mode 100644 ms/generic-resource-api/src/test/resources/policy-update-notify-rpc.json create mode 100644 ms/generic-resource-api/src/test/resources/port-mirror-assign-rpc.json create mode 100644 ms/generic-resource-api/src/test/resources/port-mirror-configuration-1.json create mode 100644 ms/generic-resource-api/src/test/resources/port-mirror-configuration-item.json create mode 100644 ms/generic-resource-api/src/test/resources/service1-vfmodule-item.json create mode 100644 ms/generic-resource-api/src/test/resources/service9.json create mode 100644 ms/generic-resource-api/src/test/resources/vf-module-assign-rpc.json create mode 100644 ms/generic-resource-api/src/test/resources/vnf-get-resource-request-expected.json create mode 100644 ms/generic-resource-api/src/test/resources/vnf-get-resource-request-rpc.json (limited to 'ms/generic-resource-api/src/test') diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java index b9ec3de..75e1a31 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java @@ -16,8 +16,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; -import org.onap.sdnc.apps.ms.gra.data.ConfigServices; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; +import org.onap.sdnc.apps.ms.gra.data.*; import org.onap.sdnc.apps.ms.gra.swagger.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -37,6 +36,8 @@ public class ConfigApiServicesControllerTest { private final static String CONFIG_SERVICES_URL = "/config/GENERIC-RESOURCE-API:services/"; private final static String CONFIG_SERVICES_SERVICE_URL = "/config/GENERIC-RESOURCE-API:services/service/"; + private final static String CONFIG_CR_ARS_CR_AR_URL = "/config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/"; + private final static String CONFIG_PM_CONFIGS_PM_CONFIG_URL = "/config/GENERIC-RESOURCE-API:port-mirror-configurations/port-mirror-configuration/"; @Autowired private MockMvc mvc; @@ -44,6 +45,12 @@ public class ConfigApiServicesControllerTest { @Autowired ConfigServicesRepository configServicesRepository; + @Autowired + ConfigContrailRouteAllottedResourcesRepository configContrailRouteAllottedResourcesRepository; + + @Autowired + ConfigPortMirrorConfigurationsRepository configPortMirrorConfigurationsRepository; + @BeforeClass public static void setUp() throws Exception { System.out.println("ConfigApiServicesControllerTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir"); @@ -669,6 +676,312 @@ public class ConfigApiServicesControllerTest { assertEquals(1, configServicesRepository.count()); } + @Test + public void configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdPut() throws Exception { + // Clean up data + configPortMirrorConfigurationsRepository.deleteAll(); + + String content = readFileContent("src/test/resources/port-mirror-configuration-item.json"); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-2/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(201, mvcResult.getResponse().getStatus()); + + // Test with existing port-mirror-configuration + // Load data + loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json"); + assertEquals(2, configPortMirrorConfigurationsRepository.count()); + + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-2/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(204, mvcResult.getResponse().getStatus()); + assertEquals(2, configPortMirrorConfigurationsRepository.count()); + + // Clean up data + configPortMirrorConfigurationsRepository.deleteAll(); + } + + @Test + public void configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdDelete() throws Exception { + // Clean up data + configPortMirrorConfigurationsRepository.deleteAll(); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(204, mvcResult.getResponse().getStatus()); + assertEquals(0, configPortMirrorConfigurationsRepository.count()); + + // Load data + loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json"); + assertEquals(1, configPortMirrorConfigurationsRepository.count()); + + // Test with data + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(204, mvcResult.getResponse().getStatus()); + assertEquals(0, configPortMirrorConfigurationsRepository.count()); + } + + @Test + public void configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdGet() throws Exception { + // Clean up data + configPortMirrorConfigurationsRepository.deleteAll(); + + // Test with data + loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json"); + assert(configPortMirrorConfigurationsRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with bad allotted-resource-id in input + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"dummy/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configPortMirrorConfigurationsRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdConfigurationDataPortMirrorConfigurationTopologyGet() throws Exception { + // Clean up data + configPortMirrorConfigurationsRepository.deleteAll(); + + // Test with data + loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json"); + assert(configPortMirrorConfigurationsRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/configuration-data/port-mirror-configuration-topology/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with dummy allotted-resource-id + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"dummy/configuration-data/port-mirror-configuration-topology/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configPortMirrorConfigurationsRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_PM_CONFIG_URL+"pm-config-1/configuration-data/port-mirror-configuration-topology/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdPut() throws Exception { + // Clean up data + configContrailRouteAllottedResourcesRepository.deleteAll(); + + String content = readFileContent("src/test/resources/allotted-resource-item.json"); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_CR_ARS_CR_AR_URL+"ar2/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(201, mvcResult.getResponse().getStatus()); + + // Test with existing allotted-resource + // Load data + configContrailRouteAllottedResourcesRepository.deleteAll(); + loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json"); + assertEquals(1, configContrailRouteAllottedResourcesRepository.count()); + + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_CR_ARS_CR_AR_URL+"ar2/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(201, mvcResult.getResponse().getStatus()); + assertEquals(2, configContrailRouteAllottedResourcesRepository.count()); + + // Clean up data + configContrailRouteAllottedResourcesRepository.deleteAll(); + } + + @Test + public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdDelete() throws Exception { + // Clean up data + configContrailRouteAllottedResourcesRepository.deleteAll(); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_CR_ARS_CR_AR_URL+"ar1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(204, mvcResult.getResponse().getStatus()); + assertEquals(0, configContrailRouteAllottedResourcesRepository.count()); + + // Load data + loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json"); + assertEquals(1, configContrailRouteAllottedResourcesRepository.count()); + + // Test with data + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_CR_ARS_CR_AR_URL+"ar1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(204, mvcResult.getResponse().getStatus()); + assertEquals(0, configContrailRouteAllottedResourcesRepository.count()); + } + + @Test + public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdGet() throws Exception { + // Clean up data + configContrailRouteAllottedResourcesRepository.deleteAll(); + + // Test with data + loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json"); + assert(configContrailRouteAllottedResourcesRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"ar1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with bad allotted-resource-id in input + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"dummy/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configContrailRouteAllottedResourcesRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"ar1/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdAllottedResourceDataContrailRouteTopologyGet() throws Exception { + // Clean up data + configContrailRouteAllottedResourcesRepository.deleteAll(); + + // Test with data + loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json"); + assert(configContrailRouteAllottedResourcesRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"ar1/allotted-resource-data/contrail-route-topology/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with dummy allotted-resource-id + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"dummy/allotted-resource-data/contrail-route-topology/").contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configContrailRouteAllottedResourcesRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_CR_AR_URL+"ar1/allotted-resource-data/contrail-route-topology/").contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdPut() throws Exception { + // Clean up data + configServicesRepository.deleteAll(); + + String content = readFileContent("src/test/resources/service1-vfmodule-item.json"); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/vf-1/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(400, mvcResult.getResponse().getStatus()); + + // Test with existing service and vnf + // Load data + loadServicesData("src/test/resources/service1.json"); + assertEquals(1, configServicesRepository.count()); + + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/vf-1/") + .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + assertEquals(1, configServicesRepository.count()); + + // Clean up data + configServicesRepository.deleteAll(); + } + + @Test + public void configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdDelete() throws Exception { + // Clean up data + configServicesRepository.deleteAll(); + + // Test with no data + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(400, mvcResult.getResponse().getStatus()); + assertEquals(0, configServicesRepository.count()); + + // Load data + loadServicesData("src/test/resources/service1.json"); + assertEquals(1, configServicesRepository.count()); + + // Test with data + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdGet() throws Exception { + // Clean up data + configServicesRepository.deleteAll(); + + // Test with data + loadServicesData("src/test/resources/service1.json"); + assert(configServicesRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with bad vf-module-id in input + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/dummyid/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configServicesRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/") + .contentType(MediaType.APPLICATION_JSON).content("")).andReturn(); + + assertEquals(404, mvcResult.getResponse().getStatus()); + } + + @Test + public void configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdVfModuleDataVfModuleTopologyGet() throws Exception { + // Clean up data + configServicesRepository.deleteAll(); + + // Test with data + loadServicesData("src/test/resources/service1.json"); + assert(configServicesRepository.count() > 0); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/vf-module-data/vf-module-topology/").contentType(MediaType.APPLICATION_JSON) + .content("")).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Test with existing service and vnf but with dummy vf-module-id in input + configServicesRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/dummy/vf-module-data/vf-module-topology/").contentType(MediaType.APPLICATION_JSON) + .content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + + // Test with no data + configServicesRepository.deleteAll(); + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/vnfs/vnf/fae319cc-68d6-496f-be1e-a09e133c71d4/vnf-data/vf-modules/vf-module/269bda16-f40c-41a9-baef-e8905ab2b70e/vf-module-data/vf-module-topology/").contentType(MediaType.APPLICATION_JSON) + .content("")).andReturn(); + assertEquals(404, mvcResult.getResponse().getStatus()); + } + private String readFileContent(String path) throws IOException { String content = new String(Files.readAllBytes(Paths.get(path))); return content; @@ -725,4 +1038,32 @@ public class ConfigApiServicesControllerTest { configServicesRepository.save(newService); } + private void loadContrailRouteAllottedResourceData(String path) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + String content = readFileContent(path); + GenericResourceApiContrailRouteAllottedResources allottedResources = objectMapper.readValue(content, GenericResourceApiContrailRouteAllottedResources.class); + + for (GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource allottedResource : allottedResources.getContrailRouteAllottedResource()) { + ConfigContrailRouteAllottedResources newContrailRouteAllottedResource = new ConfigContrailRouteAllottedResources(); + newContrailRouteAllottedResource.setAllottedResourceId(allottedResource.getAllottedResourceId()); + newContrailRouteAllottedResource.setArData(objectMapper.writeValueAsString(allottedResource.getAllottedResourceData())); + newContrailRouteAllottedResource.setAllottedResourceStatus(allottedResource.getAllottedResourceStatus()); + configContrailRouteAllottedResourcesRepository.save(newContrailRouteAllottedResource); + } + } + + private void loadPortMirrorConfigurationData(String path) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + String content = readFileContent(path); + GenericResourceApiPortMirrorConfigurations pmConfigurations = objectMapper.readValue(content, GenericResourceApiPortMirrorConfigurations.class); + + for (GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration pmConfig : pmConfigurations.getPortMirrorConfiguration()) { + ConfigPortMirrorConfigurations newPmConfig = new ConfigPortMirrorConfigurations(); + newPmConfig.setConfigureationId(pmConfig.getConfigurationId()); + newPmConfig.setPmcData(objectMapper.writeValueAsString(pmConfig.getConfigurationData())); + newPmConfig.setPortMirrorConfigurationStatus(pmConfig.getConfigurationStatus()); + configPortMirrorConfigurationsRepository.save(newPmConfig); + } + } + } \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java index 60dc811..3d24b22 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java @@ -13,10 +13,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigServices; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; -import org.onap.sdnc.apps.ms.gra.data.OperationalServicesRepository; +import org.onap.sdnc.apps.ms.gra.data.*; import org.onap.sdnc.apps.ms.gra.swagger.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -39,6 +36,10 @@ public class OperationsApiControllerTest { private final static String SERVICE_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:service-topology-operation/"; private final static String NETWORK_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:network-topology-operation/"; private final static String VNF_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:vnf-topology-operation/"; + private final static String VF_MODULE_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:vf-module-topology-operation/"; + private final static String PORT_MIRROR_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:port-mirror-topology-operation/"; + private final static String VNF_GET_RESOURCE_REQUEST_URL = "/operations/GENERIC-RESOURCE-API:vnf-get-resource-request/"; + private final static String POLICY_UPDATE_NOTIFY_URL = "/operations/GENERIC-RESOURCE-API:policy-update-notify-operation/"; @Autowired @@ -56,6 +57,12 @@ public class OperationsApiControllerTest { @Autowired OperationsApiController operationsApiController; + @Autowired + ConfigPortMirrorConfigurationsRepository configPortMirrorConfigurationsRepository; + + @Autowired + OperationalPortMirrorConfigurationsRepository operationalPortMirrorConfigurationsRepository; + @BeforeClass public static void setUp() throws Exception { System.out.println("OperationsApiControllerTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir"); @@ -206,6 +213,86 @@ public class OperationsApiControllerTest { } + @Test + public void operationsGENERICRESOURCEAPIvfModuleTopologyOperationAssignPost() throws Exception { + + // Remove any existing service data + configServicesRepository.deleteAll(); + operationalServicesRepository.deleteAll(); + + // Load services data + loadServicesData("src/test/resources/service1.json"); + + // Add invalid content + String content = readFileContent("src/test/resources/preload1-rpc-vfmodule.json"); + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(VF_MODULE_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Add valid content + content = readFileContent("src/test/resources/vf-module-assign-rpc.json"); + mvcResult = mvc.perform(MockMvcRequestBuilders.post(VF_MODULE_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + } + + @Test + public void operationsGENERICRESOURCEAPIportMirrorConfigurationTopologyOperationAssignPost() throws Exception { + + // Remove any existing service data + configPortMirrorConfigurationsRepository.deleteAll(); + operationalPortMirrorConfigurationsRepository.deleteAll(); + + // Load port-mirror-configuration data + loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json"); + + // Load services data + loadServicesData("src/test/resources/service1.json"); + + // Add invalid content for request input + String content = readFileContent("src/test/resources/preload1-rpc-vfmodule.json"); + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(PORT_MIRROR_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + // Add valid content + content = readFileContent("src/test/resources/port-mirror-assign-rpc.json"); + mvcResult = mvc.perform(MockMvcRequestBuilders.post(PORT_MIRROR_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + + } + + @Test + public void operationsGENERICRESOURCEAPIvnfGetResourceRequestPost() throws Exception { + + // Remove any existing service data + configServicesRepository.deleteAll(); + operationalServicesRepository.deleteAll(); + + // Load services data + loadServicesData("src/test/resources/service9.json"); + + // Add valid content + String content = readFileContent("src/test/resources/vnf-get-resource-request-rpc.json"); + String expected = readFileContent("src/test/resources/vnf-get-resource-request-expected.json"); + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(VNF_GET_RESOURCE_REQUEST_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + assertEquals(expected, mvcResult.getResponse().getContentAsString()); + + } + @Test + public void operationsGENERICRESOURCEAPIpolicyUpdateNotifyOperationPost() throws Exception { + + // Add valid content + String content = readFileContent("src/test/resources/policy-update-notify-rpc.json"); + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(POLICY_UPDATE_NOTIFY_URL).contentType(MediaType.APPLICATION_JSON).content(content)) + .andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + } + private void loadServicesData(String path) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); @@ -221,6 +308,20 @@ public class OperationsApiControllerTest { } } + private void loadPortMirrorConfigurationData(String path) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + String content = readFileContent(path); + GenericResourceApiPortMirrorConfigurations pmConfigurations = objectMapper.readValue(content, GenericResourceApiPortMirrorConfigurations.class); + + for (GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration pmConfig : pmConfigurations.getPortMirrorConfiguration()) { + ConfigPortMirrorConfigurations newPmConfig = new ConfigPortMirrorConfigurations(); + newPmConfig.setConfigureationId(pmConfig.getConfigurationId()); + newPmConfig.setPmcData(objectMapper.writeValueAsString(pmConfig.getConfigurationData())); + newPmConfig.setPortMirrorConfigurationStatus(pmConfig.getConfigurationStatus()); + configPortMirrorConfigurationsRepository.save(newPmConfig); + } + } + private String readFileContent(String path) throws IOException { String content = new String(Files.readAllBytes(Paths.get(path))); return content; diff --git a/ms/generic-resource-api/src/test/resources/allotted-resource-item.json b/ms/generic-resource-api/src/test/resources/allotted-resource-item.json new file mode 100644 index 0000000..5aa3371 --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/allotted-resource-item.json @@ -0,0 +1,29 @@ +{ + "allotted-resource-id": "ar2", + "allotted-resource-data": { + "allotted-resource-oper-status": { + "create-timestamp": "2020-11-24T12:41:01.796Z", + "order-status": "Active" + }, + "contrail-route-topology": { + "contrail-route-assignments": { + "contrail-id": "cr2", + "dest-network": { + "network-id": "19cdfce4-9124-4bbf-83bd-5140931bb519", + "network-role": "pktmirror" + }, + "fq-name": "default-domain.GRP-27529-T-IST-13C.GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "source-network": { + "network-id": "1610d17a-fb91-48ac-9d4c-43f739fdbe54", + "network-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP" + } + }, + "allotted-resource-identifiers": { + "allotted-resource-id": "ar2", + "allotted-resource-type": "contrail-route", + "allotted-resource-name": "GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "parent-service-instance-id": "service1" + } + } + } +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/contrail-route-allotted-resource-1.json b/ms/generic-resource-api/src/test/resources/contrail-route-allotted-resource-1.json new file mode 100644 index 0000000..193002a --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/contrail-route-allotted-resource-1.json @@ -0,0 +1,33 @@ +{ + "contrail-route-allotted-resource" : [ + { + "allotted-resource-id": "ar1", + "allotted-resource-data": { + "allotted-resource-oper-status": { + "create-timestamp": "2020-11-24T12:41:01.796Z", + "order-status": "Active" + }, + "contrail-route-topology": { + "contrail-route-assignments": { + "contrail-id": "cr1", + "dest-network": { + "network-id": "19cdfce4-9124-4bbf-83bd-5140931bb519", + "network-role": "pktmirror" + }, + "fq-name": "default-domain.GRP-27529-T-IST-13C.GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "source-network": { + "network-id": "1610d17a-fb91-48ac-9d4c-43f739fdbe54", + "network-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP" + } + }, + "allotted-resource-identifiers": { + "allotted-resource-id": "ar1", + "allotted-resource-type": "contrail-route", + "allotted-resource-name": "GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "parent-service-instance-id": "service1" + } + } + } + } + ] +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/policy-update-notify-rpc.json b/ms/generic-resource-api/src/test/resources/policy-update-notify-rpc.json new file mode 100644 index 0000000..6e1c101 --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/policy-update-notify-rpc.json @@ -0,0 +1,7 @@ +{ + "input": { + "policy-name": "name", + "update-type": "Update", + "version-id": "1.0" + } +} diff --git a/ms/generic-resource-api/src/test/resources/port-mirror-assign-rpc.json b/ms/generic-resource-api/src/test/resources/port-mirror-assign-rpc.json new file mode 100644 index 0000000..0b9b0b3 --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/port-mirror-assign-rpc.json @@ -0,0 +1,46 @@ +{ + "input": { + "request-information": { + "request-action": "CreatePortMirrorConfigurationInstance", + "source": "MSO", + "request-id": "pm-request-1" + }, + "sdnc-request-header": { + "svc-request-id": "767f2d08-e022-4000-97c2-61c002ebc740", + "svc-notification-url": "https://mso-bpmn-url", + "svc-action": "assign" + }, + "service-information": { + "subscription-service-type": "viprsvc", + "service-instance-id": "service1" + }, + "configuration-information": { + "onap-model-information": { + "model-name": "SmsfNc2578..smsf_base..module-0", + "model-version": "3", + "model-customization-uuid": "cfg-customization-uuid-1", + "model-uuid": "795f1014-7fe5-4c4f-a0ca-dc6ebd2185ab", + "model-invariant-uuid": "6265446b-58a6-4689-860f-78bada0faf2c" + }, + "configuration-id": "cfg-1", + "configuration-type": "PORT-MIRROR", + "configuration-sub-type": "vprobe" + }, + "port-mirror-configuration-request-input": { + "source-port": { + "source-port-id": "1", + "vnf-information": { + "vnf-id": "mob-vnf-1" + } + }, + "dest-port": { + "dest-port-id": "1", + "vnf-information": { + "vnf-id": "mob-vnf-2" + } + } + }, + "aic-cloud-region": "mtn6", + "tenant": "4714fe06cc24414c914c51ca0aa1bf84" + } +} diff --git a/ms/generic-resource-api/src/test/resources/port-mirror-configuration-1.json b/ms/generic-resource-api/src/test/resources/port-mirror-configuration-1.json new file mode 100644 index 0000000..446235d --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/port-mirror-configuration-1.json @@ -0,0 +1,120 @@ +{ + "port-mirror-configuration": [ + { + "configuration-data": { + "configuration-oper-status": { + "last-action": "CreatePortMirrorConfigurationInstance", + "last-rpc-action": "activate", + "order-status": "Active" + }, + "configuration-operation-information": { + "configuration-information": { + "configuration-id": "pm-config-1", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "onap-model-information": { + "model-customization-uuid": "770c991a-47fb-4225-8d72-4790847f8307", + "model-invariant-uuid": "a81abec0-222e-4fb2-b1c6-c4162359b2b3", + "model-name": "Port Mirroring Configuration", + "model-uuid": "18af239e-5397-4224-816f-d2850f3fab38", + "model-version": "23.0" + } + }, + "port-mirror-configuration-request-input": { + "dest-port": { + "vnf-information": { + "vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5" + } + }, + "source-port": { + "vnf-information": { + "vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d" + } + } + }, + "request-information": { + "request-action": "CreatePortMirrorConfigurationInstance", + "request-id": "61fe8925-fb53-4968-b9de-74be4acd06cc", + "source": "MSO" + }, + "sdnc-request-header": { + "svc-action": "activate", + "svc-notification-url": "https://mso-sdnc-s3.ecomp.idns.aic.cip.att.com:30254/adapters/rest/SDNCNotify", + "svc-request-id": "ba937e51-6baf-486c-9851-3c6a646c9256" + }, + "service-information": { + "global-customer-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5", + "subscription-service-type": "Mobility" + } + }, + "port-mirror-configuration-topology": { + "configuration-identifiers": { + "configuration-id": "pm-config-1", + "configuration-name": "vMME02_VLC_Port_Mirroring_DYH2B_SCTPA", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "parent-service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "port-mirror-configuration-assignments": { + "cloud-owner": "att-aic", + "cloud-region-id": "dyh2b", + "dest-network-fqdn": "default-domain:GRP-27529-T-SIL-13B:GRP-27529-T-SIL-13B_vprobe_int_pkmirror1", + "dest-vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5", + "dest-vnfc-instance-group-id": { + "configuration-id": "pm-config-1", + "instance-group-role": "pktmirror", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "owning-entity": "10c645f5-9924-4b89-bec0-b17cf49d3cad", + "probe-type": "vprobe", + "route-allotted-resource-id": "286d41ea-d644-46b2-98fc-643ea1b591d1", + "source-capacity": 100000, + "source-network-fqdn": "default-domain:GRP-27529-T-IST-13C:GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12", + "source-to-dest-maps": { + "source-to-dest-map": [ + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.4" + } + }, + "dest-port-id": "b91beeda-fae3-4a99-9354-06c965db83f7", + "dest-port-name": "zdyh2bprbvlba_module04-vlbagent_eph_aff_0_int_pktmirror_port_0-m5ylyrybbmmb", + "dest-vserver-id": "9e2fc5ea-a88f-4955-bda8-10e75c173a8e", + "source-port-id": "7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-port-name": "default-virtual-machine-interface-7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-vserver-id": "2e3a8bb2-75ff-4e97-a888-961bfc624caa" + }, + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.3" + } + }, + "dest-port-id": "7cf3fda3-3153-4655-ae47-36fcf4439073", + "dest-port-name": "zdyh2bprbvlba_base_5-vlbagentbase_eph_aff_0_int_pktmirror_port_0-vkvey3eyoqk2", + "dest-vserver-id": "165db140-c09f-411a-bfdc-b8e6c7dbbda4", + "source-port-id": "0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-port-name": "default-virtual-machine-interface-0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-vserver-id": "b5bf2e1f-9f90-445c-be00-2c882e82d1d7" + } + ] + }, + "source-vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d", + "source-vnfc-instance-group-id": { + "configuration-id": "pm-config-1", + "instance-group-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "tenant": "GRP-27529-T-IST-13C", + "tenant-context": "Test", + "tenant-id": "077445458306425499337c98bafc8c47", + "vnics-group-id": "97" + } + } + }, + "configuration-id": "pm-config-1" + } + ] +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/port-mirror-configuration-item.json b/ms/generic-resource-api/src/test/resources/port-mirror-configuration-item.json new file mode 100644 index 0000000..780d079 --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/port-mirror-configuration-item.json @@ -0,0 +1,116 @@ +{ + "configuration-data": { + "configuration-oper-status": { + "last-action": "CreatePortMirrorConfigurationInstance", + "last-rpc-action": "activate", + "order-status": "Active" + }, + "configuration-operation-information": { + "configuration-information": { + "configuration-id": "pm-config-2", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "onap-model-information": { + "model-customization-uuid": "770c991a-47fb-4225-8d72-4790847f8307", + "model-invariant-uuid": "a81abec0-222e-4fb2-b1c6-c4162359b2b3", + "model-name": "Port Mirroring Configuration", + "model-uuid": "18af239e-5397-4224-816f-d2850f3fab38", + "model-version": "23.0" + } + }, + "port-mirror-configuration-request-input": { + "dest-port": { + "vnf-information": { + "vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5" + } + }, + "source-port": { + "vnf-information": { + "vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d" + } + } + }, + "request-information": { + "request-action": "CreatePortMirrorConfigurationInstance", + "request-id": "61fe8925-fb53-4968-b9de-74be4acd06cc", + "source": "MSO" + }, + "sdnc-request-header": { + "svc-action": "activate", + "svc-notification-url": "https://mso-sdnc-s3.ecomp.idns.aic.cip.att.com:30254/adapters/rest/SDNCNotify", + "svc-request-id": "ba937e51-6baf-486c-9851-3c6a646c9256" + }, + "service-information": { + "global-customer-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5", + "subscription-service-type": "Mobility" + } + }, + "port-mirror-configuration-topology": { + "configuration-identifiers": { + "configuration-id": "pm-config-2", + "configuration-name": "vMME02_VLC_Port_Mirroring_DYH2B_SCTPA", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "parent-service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "port-mirror-configuration-assignments": { + "cloud-owner": "att-aic", + "cloud-region-id": "dyh2b", + "dest-network-fqdn": "default-domain:GRP-27529-T-SIL-13B:GRP-27529-T-SIL-13B_vprobe_int_pkmirror1", + "dest-vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5", + "dest-vnfc-instance-group-id": { + "configuration-id": "pm-config-2", + "instance-group-role": "pktmirror", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "owning-entity": "10c645f5-9924-4b89-bec0-b17cf49d3cad", + "probe-type": "vprobe", + "route-allotted-resource-id": "286d41ea-d644-46b2-98fc-643ea1b591d1", + "source-capacity": 100000, + "source-network-fqdn": "default-domain:GRP-27529-T-IST-13C:GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12", + "source-to-dest-maps": { + "source-to-dest-map": [ + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.4" + } + }, + "dest-port-id": "b91beeda-fae3-4a99-9354-06c965db83f7", + "dest-port-name": "zdyh2bprbvlba_module04-vlbagent_eph_aff_0_int_pktmirror_port_0-m5ylyrybbmmb", + "dest-vserver-id": "9e2fc5ea-a88f-4955-bda8-10e75c173a8e", + "source-port-id": "7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-port-name": "default-virtual-machine-interface-7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-vserver-id": "2e3a8bb2-75ff-4e97-a888-961bfc624caa" + }, + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.3" + } + }, + "dest-port-id": "7cf3fda3-3153-4655-ae47-36fcf4439073", + "dest-port-name": "zdyh2bprbvlba_base_5-vlbagentbase_eph_aff_0_int_pktmirror_port_0-vkvey3eyoqk2", + "dest-vserver-id": "165db140-c09f-411a-bfdc-b8e6c7dbbda4", + "source-port-id": "0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-port-name": "default-virtual-machine-interface-0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-vserver-id": "b5bf2e1f-9f90-445c-be00-2c882e82d1d7" + } + ] + }, + "source-vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d", + "source-vnfc-instance-group-id": { + "configuration-id": "pm-config-2", + "instance-group-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "tenant": "GRP-27529-T-IST-13C", + "tenant-context": "Test", + "tenant-id": "077445458306425499337c98bafc8c47", + "vnics-group-id": "97" + } + } + }, + "configuration-id": "pm-config-2" +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/service1-vfmodule-item.json b/ms/generic-resource-api/src/test/resources/service1-vfmodule-item.json new file mode 100644 index 0000000..10f707f --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/service1-vfmodule-item.json @@ -0,0 +1,422 @@ +{ + "vf-module-data": { + "request-information": { + "notification-url": "string", + "order-number": "string", + "order-version": "string", + "request-action": "CreateNetworkInstance", + "request-id": "string", + "source": "string" + }, + "sdnc-request-header": { + "svc-action": "assign", + "svc-notification-url": "string", + "svc-request-id": "string" + }, + "service-information": { + "global-customer-id": "string", + "onap-model-information": { + "model-customization-uuid": "string", + "model-invariant-uuid": "string", + "model-name": "string", + "model-uuid": "string", + "model-version": "string" + }, + "service-id": "string", + "service-instance-id": "string", + "subscriber-name": "string", + "subscription-service-type": "string" + }, + "vf-module-information": { + "from-preload": true, + "onap-model-information": { + "model-customization-uuid": "string", + "model-invariant-uuid": "string", + "model-name": "string", + "model-uuid": "string", + "model-version": "string" + }, + "vf-module-id": "vf-1", + "vf-module-type": "string" + }, + "vf-module-level-oper-status": { + "create-timestamp": "string", + "last-action": "CreateNetworkInstance", + "last-order-status": "Active", + "last-rpc-action": "assign", + "last-svc-request-id": "string", + "modify-timestamp": "string", + "order-status": "Active" + }, + "vf-module-request-input": { + "aic-clli": "string", + "aic-cloud-region": "string", + "cloud-owner": "string", + "request-version": "string", + "tenant": "string", + "vf-module-input-parameters": { + "param": [ + { + "name": "string", + "resource-resolution-data": { + "capability-name": "string", + "payload": "string", + "resource-key": [ + { + "name": "string", + "value": "string" + } + ], + "status": "string" + }, + "value": "string" + } + ] + }, + "vf-module-name": "vf-name-1" + }, + "vf-module-topology": { + "aic-clli": "string", + "aic-cloud-region": "string", + "cloud-owner": "string", + "onap-model-information": { + "model-customization-uuid": "string", + "model-invariant-uuid": "string", + "model-name": "string", + "model-uuid": "string", + "model-version": "string" + }, + "sdnc-generated-cloud-resources": true, + "tenant": "string", + "vf-module-assignments": { + "dhcp-subnet-assignments": { + "dhcp-subnet-assignment": [ + { + "ip-version": "string", + "network-role": "string", + "neutron-subnet-id": "string" + } + ] + }, + "vf-module-status": "string", + "vlan-vnfc-instance-groups": { + "vlan-vnfc-instance-group": [ + { + "instance-group-function": "string", + "instance-group-id": "string", + "vnf-id": "fae319cc-68d6-496f-be1e-a09e133c71d4", + "vnfcs": { + "vnfc": [ + { + "vnfc-name": "string", + "vnic-groups": { + "vnic-group": [ + { + "network-instance-group-function": "string", + "vlan-assignment-policy-name": "string", + "vlan-common-ip-addresses": { + "ip-addresses": { + "ipv4-address": "string", + "ipv6-address": "string", + "vipv4-address": "string", + "vipv6-address": "string" + } + }, + "vlan-tag-index-next": 0, + "vlan-vnics": { + "vlan-vnic": [ + { + "vnic-port-id": "string", + "vnic-sub-interfaces": { + "sub-interface-network-data": [ + { + "floating-ips": { + "floating-ip-v4": [ + "string" + ], + "floating-ip-v6": [ + "string" + ] + }, + "network-id": "string", + "network-information-items": { + "network-information-item": [ + { + "ip-count": 0, + "ip-version": "string", + "network-ips": { + "network-ip": [ + "string" + ] + }, + "use-dhcp": "Y" + } + ] + }, + "network-name": 0, + "network-role": "string", + "network-role-tag": "string", + "neutron-network-id": "string", + "vlan-tag-id": 0 + } + ] + } + } + ] + }, + "vnic-interface-role": "string" + } + ] + } + } + ] + } + } + ] + }, + "vms": { + "vm": [ + { + "nfc-naming-code": "string", + "onap-model-information": { + "model-customization-uuid": "string", + "model-invariant-uuid": "string", + "model-name": "string", + "model-uuid": "string", + "model-version": "string" + }, + "vm-count": 0, + "vm-names": { + "vm-name": [ + "string" + ], + "vnfc-names": [ + { + "vnfc-name": "string", + "vnfc-networks": { + "vnfc-network-data": [ + { + "connection-point": { + "connection-point-id": "string", + "port-id": "string", + "vlan-data": [ + { + "vlan-role": "string", + "vlan-tag-description": "string", + "vlan-tag-id": "string", + "vlan-uuid": "string" + } + ] + }, + "vnfc-network-role": "string", + "vnfc-ports": { + "vnfc-port": [ + { + "common-sub-interface-role": "string", + "vnfc-port-id": "string", + "vnic-sub-interfaces": { + "sub-interface-network-data": [ + { + "floating-ips": { + "floating-ip-v4": [ + "string" + ], + "floating-ip-v6": [ + "string" + ] + }, + "network-id": "string", + "network-information-items": { + "network-information-item": [ + { + "ip-count": 0, + "ip-version": "string", + "network-ips": { + "network-ip": [ + "string" + ] + }, + "use-dhcp": "Y" + } + ] + }, + "network-name": 0, + "network-role": "string", + "network-role-tag": "string", + "neutron-network-id": "string", + "vlan-tag-id": 0 + } + ] + } + } + ] + }, + "vnfc-subnet": [ + { + "vnfc-ip-assignments": [ + { + "vnfc-address-family": "ipv4", + "vnfc-subnet-dhcp": "Y", + "vnfc-subnet-ip": [ + { + "ip-type": "FIXED", + "vnfc-client-key": "string", + "vnfc-ip-address": "string" + } + ], + "vnfc-subnet-ip-count": 0 + } + ], + "vnfc-subnet-role": "string" + } + ], + "vnfc-type": "string" + } + ] + } + } + ] + }, + "vm-networks": { + "vm-network": [ + { + "floating-ips": { + "floating-ip-v4": [ + "string" + ], + "floating-ip-v6": [ + "string" + ] + }, + "interface-route-prefixes": { + "interface-route-prefix": [ + "string" + ] + }, + "is-trunked": true, + "mac-addresses": { + "mac-address": [ + "string" + ] + }, + "network-information-items": { + "network-information-item": [ + { + "ip-count": 0, + "ip-version": "string", + "network-ips": { + "network-ip": [ + "string" + ] + }, + "use-dhcp": "Y" + } + ] + }, + "network-role": "string", + "network-role-tag": "string", + "related-networks": { + "related-network": [ + { + "network-id": "string", + "network-role": "string", + "vlan-tags": { + "is-private": true, + "lower-tag-id": 0, + "upper-tag-id": 0, + "vlan-interface": "string" + } + } + ] + }, + "segmentation-id": "string", + "sriov-parameters": { + "application-tags": { + "c-tags": { + "c-tag": [ + "string" + ], + "ctag": [ + "string" + ] + }, + "ctags": { + "c-tag": [ + "string" + ], + "ctag": [ + "string" + ] + }, + "s-tags": { + "s-tag": [ + "string" + ], + "stag": [ + "string" + ] + }, + "stags": { + "s-tag": [ + "string" + ], + "stag": [ + "string" + ] + } + }, + "heat-vlan-filters": { + "heat-vlan-filter": [ + "string" + ] + } + } + } + ] + }, + "vm-type": "string", + "vm-type-tag": "string" + } + ] + } + }, + "vf-module-parameters": { + "param": [ + { + "name": "string", + "resource-resolution-data": { + "capability-name": "string", + "payload": "string", + "resource-key": [ + { + "name": "string", + "value": "string" + } + ], + "status": "string" + }, + "value": "string" + } + ] + }, + "vf-module-topology-identifier": { + "vf-module-id": "vf-1", + "vf-module-name": "vf-name-1", + "vf-module-type": "string" + } + }, + "vnf-information": { + "onap-model-information": { + "model-customization-uuid": "string", + "model-invariant-uuid": "string", + "model-name": "string", + "model-uuid": "string", + "model-version": "string" + }, + "vnf-id": "fae319cc-68d6-496f-be1e-a09e133c71d4", + "vnf-name": "Python_ONAP_SDK_vnf_instance_2aff902a-4714-4d08-942d-d97b3a3b87c2", + "vnf-type": "service-nginx-ingress-1/nginx-ingress-1 0" + } + }, + "vf-module-id": "vf-1" +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/service9.json b/ms/generic-resource-api/src/test/resources/service9.json new file mode 100644 index 0000000..aef12ab --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/service9.json @@ -0,0 +1,268 @@ +{ + "service": [ + { + "service-instance-id": "service9", + "service-data": { + "request-information": { + "request-id": "id-2006-2", + "source": "local-vm", + "request-action": "CreateServiceInstance" + }, + "service-request-input": { + "service-instance-name": "service-name-9" + }, + "service-information": { + "service-id": "service-id-0002", + "onap-model-information": { + "model-invariant-uuid": "service-model-invariant-uuid", + "model-name": "service-model-name", + "model-version": "service-model-version", + "model-uuid": "service-uuid-2006" + }, + "service-instance-id": "service9", + "global-customer-id": "MCBH-2006", + "subscription-service-type": "viprsvc" + }, + "service-topology": { + "service-topology-identifier": { + "service-instance-id": "service9", + "service-instance-name": "service-name-9", + "service-type": "viprsvc", + "global-customer-id": "MCBH-2006" + }, + "onap-model-information": { + "model-invariant-uuid": "service-model-invariant-uuid", + "model-name": "service-model-name", + "model-version": "service-model-version", + "model-uuid": "service-uuid-2006" + } + }, + "service-level-oper-status": { + "order-status": "Created", + "last-rpc-action": "assign", + "last-action": "CreateServiceInstance" + }, + "sdnc-request-header": { + "svc-action": "assign", + "svc-request-id": "id-0002" + }, + "vnfs": { + "vnf": [ + { + "vnf-id": "vnf-9", + "vnf-data": { + "vnf-level-oper-status": { + "order-status": "PendingCreate", + "last-rpc-action": "assign", + "last-action": "CreateVnfInstance" + }, + "service-information": { + "service-instance-id": "service9", + "global-customer-id": "MCBH-2006" + }, + "sdnc-request-header": { + "svc-action": "assign", + "svc-request-id": "vnf-9", + "svc-notification-url": "http://dummy.att.com" + }, + "vnf-information": { + "vnf-id": "vnf-9", + "vnf-name": "vnf-name-9", + "vnf-type": "vdns", + "onap-model-information": { + "model-invariant-uuid": "bgb-model", + "model-name": "model-name-vnf-9", + "model-version": "4.0", + "model-customization-uuid": "cust-uuid-vnf-9", + "model-uuid": "bgb-model-ver-id" + } + }, + "request-information": { + "request-id": "vnf-0002", + "source": "local-vm", + "request-action": "CreateVnfInstance" + }, + "vnf-request-input": { + "vnf-name": "vnf-name-9", + "tenant": "pc-tenant-1", + "cloud-owner": "att-aic", + "aic-cloud-region": "mtn6" + }, + "vnf-topology": { + "onap-model-information": { + "model-invariant-uuid": "bgb-model", + "model-name": "model-name-vnf-9", + "model-version": "4.0", + "model-customization-uuid": "cust-uuid-vnf-200", + "model-uuid": "bgb-model-ver-id" + }, + "vnf-parameters-data": { + "param": [ + { + "name": "vnf_param_1", + "value": "vnf_value_1", + "resource-resolution-data": { + "status": "SUCCESS", + "payload": "vnfpayload", + "capability-name": "param-capability" + } + }, + { + "name": "vnf_param_2", + "value": "vnf_value_2" + } + ] + }, + "tenant": "pc-tenant-1", + "vnf-topology-identifier-structure": { + "vnf-id": "vnf-200", + "vnf-type": "vdns", + "nf-type": "NAT", + "nf-role": "vdns", + "nf-code": "vn2", + "nf-function": "AVPNvdns" + }, + "aic-clli": "AUSTTXGR", + "aic-cloud-region": "mtn6" + }, + "vf-modules": { + "vf-module": [ + { + "vf-module-id": "vf-module-9", + "vf-module-data": { + "service-information": { + "service-id": "service-id-0002", + "onap-model-information": { + "model-invariant-uuid": "service-model-invariant-uuid", + "model-name": "service-model-name", + "model-version": "service-model-version", + "model-uuid": "service-uuid-2006" + }, + "service-instance-id": "service9", + "global-customer-id": "MCBH-2006", + "subscription-service-type": "viprsvc" + }, + "vf-module-topology": { + "onap-model-information": { + "model-invariant-uuid": "bgb-model", + "model-name": "vSAMP10aDEV::base::module-0", + "model-version": "1.0", + "model-customization-uuid": "cust-uuid-vf-module-9", + "model-uuid": "bgb-model-ver-id" + }, + "vf-module-parameters": { + "param": [ + { + "name": "param1", + "value": "param_value_1" + }, + { + "name": "param2", + "value": "param_value_2", + "resource-resolution-data": { + "resource-key": [ + { + "name": "key1", + "value": "key_value_1" + }, + { + "name": "key2", + "value": "key_value_2" + } + ], + "payload": "12", + "capability-name": "walkingmachine", + "status": "SUCCESS" + } + }, + { + "name": "param3", + "value": "param_value3", + "resource-resolution-data": { + "payload": "12", + "capability-name": "walkingmachine", + "status": "SUCCESS" + } + }, + { + "name": "mob1_names", + "value": "", + "resource-resolution-data": { + "payload": "", + "capability-name": "None", + "status": "FAILED" + } + }, + { + "name": "mob1_role1_public_vlans", + "value": "4000" + } + ] + }, + "tenant": "pc-tenant-1", + "sdnc-generated-cloud-resources": true, + "aic-clli": "rxutest201901", + "vf-module-topology-identifier": { + "vf-module-type": "vSAMP10aDEV::base::module-0", + "vf-module-id": "vf-module-9", + "vf-module-name": "vf-module-name-9" + }, + "aic-cloud-region": "mtn6" + }, + "vf-module-request-input": { + "tenant": "pc-tenant-1", + "vf-module-name": "vf-module-name-1", + "aic-cloud-region": "mtn6" + }, + "sdnc-request-header": { + "svc-action": "assign", + "svc-request-id": "vf-id-0001", + "svc-notification-url": "http://dummy.att.com" + }, + "vnf-information": { + "vnf-id": "vnf-100", + "vnf-type": "vdns", + "vnf-name": "vnf-name-1", + "onap-model-information": { + "model-invariant-uuid": "bgb-model", + "model-name": "model-name-vnf-100", + "model-version": "4.0", + "model-customization-uuid": "cust-uuid-vnf-100", + "model-uuid": "bgb-model-ver-id" + } + }, + "vf-module-information": { + "onap-model-information": { + "model-invariant-uuid": "bgb-model", + "model-name": "vSAMP10aDEV::base::module-0", + "model-version": "1.0", + "model-customization-uuid": "cust-uuid-vf-module-100", + "model-uuid": "bgb-model-ver-id" + }, + "vf-module-id": "vf-module-100", + "vf-module-type": "ss-vf-module-type", + "from-preload": true + }, + "request-information": { + "notification-url": "http://some.url.com", + "request-id": "request-0001", + "request-action": "CreateVfModuleInstance", + "source": "VID" + }, + "vf-module-level-oper-status": { + "order-status": "PendingCreate", + "last-rpc-action": "assign", + "last-action": "CreateVfModuleInstance" + } + } + } + ] + } + } + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/vf-module-assign-rpc.json b/ms/generic-resource-api/src/test/resources/vf-module-assign-rpc.json new file mode 100644 index 0000000..78b3289 --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/vf-module-assign-rpc.json @@ -0,0 +1,57 @@ +{ + "input":{ + "request-information" : { + "request-action" : "CreateVfModuleInstance", + "source" : "MSO", + "request-id" : "fa988b60-ebd5-4d0b-9b7c-3073c365a9ed" + }, + "sdnc-request-header" : { + "svc-request-id" : "767f2d08-e022-4000-97c2-61c002ebc740", + "svc-notification-url" : "https://mso-bpmn-s1.ecomp.idns.aic.cip.att.com:30252/mso/WorkflowMessage/SDNCCallback/25200c7f-e966-4a0d-8c6c-e345e97089a4", + "svc-action" : "assign" + }, + "service-information" : { + "onap-model-information" : { + "model-name" : "SMSF-NC2-578-SVC", + "model-version" : "3.0", + "model-uuid" : "20b35ef0-956f-4e1b-bf75-f51a2e7c53db", + "model-invariant-uuid" : "5c905067-7b5a-457a-9f25-7a83a04b2a6d" + }, + "subscription-service-type" : "Mobility", + "service-id" : "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "global-customer-id" : "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "service-instance-id" : "mob-service-9" + }, + "vf-module-information" : { + "onap-model-information" : { + "model-name" : "SmsfNc2578..smsf_base..module-0", + "model-version" : "3", + "model-customization-uuid" : "79198077-e742-4d9f-8ef5-4bdc10c90def", + "model-uuid" : "795f1014-7fe5-4c4f-a0ca-dc6ebd2185ab", + "model-invariant-uuid" : "6265446b-58a6-4689-860f-78bada0faf2c" + }, + "vf-module-id" : "45841173-3729-4a1d-a811-a3bde399e22d", + "from-preload" : true, + "vf-module-type" : "SmsfNc2578..smsf_base..module-0" + }, + "vf-module-request-input" : { + "aic-cloud-region" : "rdm61a", + "cloud-owner" : "att-nc", + "tenant" : "4714fe06cc24414c914c51ca0aa1bf84", + "vf-module-name" : "zrdm61asmsf01_base", + "vf-module-input-parameters" : { } + }, + "vnf-information" : { + "onap-model-information" : { + "model-name" : "SMSF-NC2-578", + "model-version" : "3.0", + "model-customization-uuid" : "0f229dd7-36ba-44ff-b7fb-327721dcb8d2", + "model-uuid" : "7b44be32-b39f-4a3b-8650-ece4e75fd094", + "model-invariant-uuid" : "0017cd47-7f1b-49fb-874d-6add86ececb1" + }, + "vnf-id" : "mob-vnf-9", + "vnf-name" : "zrdm61asmsf01", + "vnf-type" : "SMSF-NC2-578-SVC/SMSF-NC2-578" + } + } +} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-expected.json b/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-expected.json new file mode 100644 index 0000000..719c4dc --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-expected.json @@ -0,0 +1 @@ +{"output":{"vnf-get-resource-response-information":{"service-instance-id":"service9","service-instance-name":"service-name-9","vnf":[{"param":[{"name":"vnf_param_1","resource-resolution-data":{"capability-name":"param-capability","status":"SUCCESS"},"value":"vnf_value_1"},{"name":"vnf_param_2","resource-resolution-data":{"capability-name":"","status":""},"value":"vnf_value_2"}],"vnf-id":"vnf-9","vf-module":[{"param":[{"name":"param1","resource-resolution-data":{},"value":"param_value_1"},{"name":"param2","resource-resolution-data":{"resource-key":[{"name":"key1","value":"key_value_1"},{"name":"key2","value":"key_value_2"}]},"value":"param_value_2"},{"name":"param3","resource-resolution-data":{},"value":"param_value3"},{"name":"mob1_names","resource-resolution-data":{},"value":""},{"name":"mob1_role1_public_vlans","resource-resolution-data":{},"value":"4000"}],"vf-module-id":"vf-module-9"}],"vnf-name":""}]}}} \ No newline at end of file diff --git a/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-rpc.json b/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-rpc.json new file mode 100644 index 0000000..7438deb --- /dev/null +++ b/ms/generic-resource-api/src/test/resources/vnf-get-resource-request-rpc.json @@ -0,0 +1,15 @@ +{ + "input": { + "sdnc-request-header": { + "svc-request-id": "id-0002", + "svc-action": "assign" + }, + "request-information": { + "request-id": "id-2006-2", + "source": "local-vm" + }, + "service-information": { + "service-instance-id": "service9" + } + } +} \ No newline at end of file -- cgit 1.2.3-korg