aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-10-01 09:40:18 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-10-01 10:13:16 -0400
commit73936e41eceeba4e40e2c2c7f84a3d266a9a076e (patch)
tree9e95db93563202f594058ebb9950555831023f71 /adapters/mso-openstack-adapters/src/test
parent4e944d4149bfcf7196691c57f3ae6659ffd05960 (diff)
Improve fall out case handling
Update Openstack adapter to handle fall out cases with greater stability Issue-ID: SO-2376 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I20116cbd3b63bb29c9bf4ed99e92bd5f2b691da5
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java99
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-test.yaml4
3 files changed, 21 insertions, 84 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
index 1f4c205e7a..412abeab3b 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
@@ -194,9 +194,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
public void testRollbackNetwork() throws IOException {
RollbackNetworkRequest request = new RollbackNetworkRequest();
-
MsoRequest msoReq = new MsoRequest();
-
msoReq.setRequestId(MSO_REQUEST_ID);
msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
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 651e2c9a73..0d972bb4d2 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
@@ -40,7 +40,6 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnf.exceptions.VnfNotFound;
import org.onap.so.db.catalog.beans.HeatEnvironment;
@@ -50,15 +49,15 @@ import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.HeatStatus;
-import org.onap.so.openstack.beans.StackInfo;
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.stubbing.Scenario;
public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -71,17 +70,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
@Test
- @Ignore
- public void healthCheckVNFTest() {
- MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
- instance.healthCheck();
- }
-
- @Test
public void createVnfTest() throws Exception {
- StackInfo info = new StackInfo();
- info.setStatus(HeatStatus.CREATED);
-
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStackVfModule_200(wireMockServer);
@@ -90,105 +79,57 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
+ "VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.TRUE, Boolean.TRUE,
+ Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
+ new Holder<VnfRollback>());
}
@Test
- public void createVnfTest_HeatStatusUpdating() throws Exception {
- expectedException.expect(VnfAlreadyExists.class);
+ public void createVnfTest_HeatStatusFailed() throws Exception {
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
wireMockServer.stubFor(get(
urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Updating_VfModule.json")
- .withStatus(HttpStatus.SC_OK)));
-
- MsoRequest msoRequest = getMsoRequest();
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVnfTest_HeatStatusUpdated() throws Exception {
- expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ .withBodyFile("OpenstackResponse_Stack_Failed_VfModule.json")
+ .withStatus(HttpStatus.SC_OK))
+ .inScenario("HeatStatusFailure").whenScenarioStateIs(Scenario.STARTED)
+ .willSetStateTo("HeatStackFailed"));
wireMockServer.stubFor(get(
urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
+ .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
+ .withStatus(HttpStatus.SC_OK))
+ .inScenario("HeatStatusFailure").whenScenarioStateIs("HeatStackFailed")
+ .willSetStateTo("HeatStackSuccess"));
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
+ "VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.FALSE, Boolean.TRUE,
+ Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
+ new Holder<VnfRollback>());
}
- @Test
- public void createVnfTest_HeatStatusFailed() throws Exception {
- expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- wireMockServer.stubFor(get(
- urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Failed_VfModule.json")
- .withStatus(HttpStatus.SC_OK)));
-
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
@Test
public void createVnfTest_HeatStatusCreated() throws Exception {
- expectedException.expect(VnfAlreadyExists.class);
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
mockOpenStackGetStackVfModule_200(wireMockServer);
-
MsoRequest msoRequest = getMsoRequest();
-
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
+ "VFMOD", null, null, "b4ea86b4-253f-11e7-93ae-92361f002671", map, Boolean.TRUE, Boolean.TRUE,
+ Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
+ new Holder<VnfRollback>());
}
@Test
- public void createVnfTest_ExceptionInGettingHeat() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
public void createVnfTest_NestedHeatStatusNotFound() throws Exception {
expectedException.expect(VnfException.class);
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
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 7cc7697129..20fd812ab9 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -1,5 +1,3 @@
-# will be used as entry in DB to say SITE OFF/ON for healthcheck
-# MSO Properties go here
org:
onap:
so:
@@ -41,7 +39,7 @@ org:
default_keystone_reg_ex: "/[vV][0-9]"
default_tenant_description: ECOMP Tenant
default_region_type: single
- default_user_role: admin
+ default_user_role: adminev
default_success_status_string: Success
default_no_regions_status_string: no regions
default_orm_request_path: /v1/orm/customers/