diff options
Diffstat (limited to 'adapters/mso-openstack-adapters')
9 files changed, 114 insertions, 15 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index ef04ee9c13..2e562bd74e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -92,6 +92,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static final String NEUTRON_MODE = "NEUTRON"; private static final String CLOUD_OWNER = "CloudOwner"; private static final String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}"; + private static final String NETWORK_EXIST_STATUS_MESSAGE = + "The network was found to already exist, thus no new network was created in the cloud via this request"; + private static final String NETWORK_CREATED_STATUS_MESSAGE = + "The new network was successfully created in the cloud"; + private static final String NETWORK_NOT_EXIST_STATUS_MESSAGE = + "The network as not found, thus no network was deleted in the cloud via this request"; + private static final String NETWORK_DELETED_STATUS_MESSAGE = "The network was successfully deleted in the cloud"; private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class); @@ -225,7 +232,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // See if the Network already exists (by name) NetworkInfo netInfo = null; - long queryNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId); } catch (MsoException me) { @@ -254,10 +260,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { logger.warn("{} {} Found Existing network, status={} for Neutron mode ", MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), netInfo.getStatus()); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } - long createNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.createNetwork(cloudSiteId, tenantId, neutronNetworkType, networkName, physicalNetworkName, vlans); @@ -360,6 +366,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(), networkName, cloudSiteId, tenantId); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } @@ -473,6 +480,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNetworkCreated(true); networkRollback.setNetworkType(networkType); + try { + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } + logger.debug("Network {} successfully created via HEAT", networkName); } @@ -1055,8 +1068,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } else { try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); - networkDeleted.value = true; + StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); + networkDeleted.value = stack.isOperationPerformed(); } catch (MsoException me) { me.addContext("DeleteNetwork"); logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, @@ -1064,6 +1077,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException(me); } } + try { + heat.updateResourceStatus(msoRequest.getRequestId(), + networkDeleted.value ? NETWORK_DELETED_STATUS_MESSAGE : NETWORK_NOT_EXIST_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } } /** diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 65d5523709..12736697ba 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -109,6 +109,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final String USER_ERROR = "USER ERROR"; private static final String VERSION_MIN = "VersionMin"; private static final String VERSION_MAX = "VersionMax"; + private static final String VF_EXIST_STATUS_MESSAGE = + "The vf module was found to already exist, thus no new vf module was created in the cloud via this request"; + private static final String VF_CREATED_STATUS_MESSAGE = "The new vf module was successfully created in the cloud"; + private static final String VF_NOT_EXIST_STATUS_MESSAGE = + "The vf module was not, thus no vf module was deleted in the cloud via this request"; + private static final String VF_DELETED_STATUS_MESSAGE = "The vf module was successfully deleted in the cloud"; @Autowired private VFModuleCustomizationRepository vfModuleCustomRepo; @@ -1046,6 +1052,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null, template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString, nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(), failIfExists); + + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + heatStack.isOperationPerformed() ? VF_EXIST_STATUS_MESSAGE : VF_CREATED_STATUS_MESSAGE); } else { throw new MsoHeatNotFoundException(); } @@ -1125,7 +1134,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } try { - msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + StackInfo stackInfo = + msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + stackInfo.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE); } catch (MsoException me) { me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java index add1918748..284067a766 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,9 @@ package org.onap.so.adapters.network; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteNeutronNetwork; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStack_200; @@ -52,6 +55,7 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.github.tomakehurst.wiremock.WireMockServer; public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @@ -112,6 +116,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json"); @@ -140,6 +146,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStack_404(wireMockServer, "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"); @@ -158,6 +166,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json"); @@ -236,6 +246,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkHeatModeSuccess() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json"); @@ -292,6 +304,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkNeureonMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); @@ -506,4 +520,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { String input = new String(Files.readAllBytes(Paths.get(JsonInput))); return input; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java index 727f18902a..00961a16b9 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ package org.onap.so.adapters.network; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile; @@ -41,6 +42,7 @@ import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.Subnet; import org.springframework.beans.factory.annotation.Autowired; +import com.github.tomakehurst.wiremock.WireMockServer; public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { @Autowired @@ -263,4 +265,5 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { false, new ArrayList<>(), new HashMap<String, String>(), "messageId", new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index a058378425..9fc2aba948 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vnf; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.mockito.Mockito.when; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; @@ -30,6 +31,7 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse; +import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -53,6 +55,7 @@ import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.utils.MsoHeatUtils; import org.springframework.beans.factory.annotation.Autowired; +import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.stubbing.Scenario; @@ -73,6 +76,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -88,6 +92,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_NullFailIfExists() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -117,6 +122,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { .inScenario("HeatStatusFailure").whenScenarioStateIs("HeatStackFailed") .willSetStateTo("HeatStackSuccess")); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); @@ -133,6 +140,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_HeatStatusCreated() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); @@ -516,5 +525,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { return vfModuleCustomization; } + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java index 5a8524fd73..9655e90e46 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,8 @@ package org.onap.so.adapters.vnf; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.github.tomakehurst.wiremock.WireMockServer; +import org.apache.http.HttpStatus; import org.json.JSONException; import org.junit.Ignore; import org.junit.Test; @@ -49,6 +51,9 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -112,6 +117,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -208,6 +215,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -342,6 +351,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers); @@ -539,4 +549,9 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { return request; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java index 523a6903cc..c2e2b567f1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -50,6 +54,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon { @Test public void testCreateVNFVolumes() throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java index fb4bec69ed..6fd9f02cfe 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -52,6 +56,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 6171e7a624..42955c35c9 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -61,6 +61,9 @@ ssl-enable: false tomcat: max-threads: 50 mso: + adapters: + requestDb: + endpoint: http://localhost:${wiremock.server.port} audit: lock-time: 240000 logPath: logs |