diff options
author | Boslet, Cory <cory.boslet@att.com> | 2020-03-08 10:43:59 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-03-08 10:43:59 -0400 |
commit | 7b42dee721e03ee3f0a52dda92010e09d748cf72 (patch) | |
tree | 3012b8bcf094713b10e1aade41046e7a74414ead /adapters/mso-openstack-adapters/src/test/java/org/onap | |
parent | 4d1e251ebcde26583cc85abef7b6909e9808771c (diff) |
false positive on network creates
Added a new resourceStatusMessage field to the GET orch request API
added new column to infra active request table
updated openstack adapter to record the resource status
added support of v8 on GET orch request API.
Issue-ID: SO-2718
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I73b35f1562de4df477bf7e5cef01de13440ba98a
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test/java/org/onap')
6 files changed, 75 insertions, 10 deletions
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); |