summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org
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-adapter-utils/src/test/java/org
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-adapter-utils/src/test/java/org')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsITTest.java6
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java24
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java20
3 files changed, 28 insertions, 22 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsITTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsITTest.java
index 7e783aa7a4..86b1413291 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsITTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsITTest.java
@@ -133,7 +133,7 @@ public class MsoHeatUtilsITTest extends BaseTest {
@Test
public void deleteVduTest() throws Exception {
VduInstance expected = new VduInstance();
- expected.setVduInstanceId("instanceId");
+ expected.setVduInstanceId("name/stackId");
expected.setVduInstanceName("instanceId");
VduStatus status = new VduStatus();
status.setState(VduStateType.DELETED);
@@ -209,8 +209,8 @@ public class MsoHeatUtilsITTest extends BaseTest {
StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
StubOpenStack.mockOpenStackGet(wireMockServer, "TEST-stack/stackId");
- StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack",
- "TEST-heat", new HashMap<>(), false, 1, "TEST-env", new HashMap<>(), new HashMap<>());
+ StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", null,
+ "TEST-heat", new HashMap<>(), false, 1, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
assertNotNull(stackInfo);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index e68364eab8..92cf96ed16 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -124,7 +124,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
latestStack.setStackStatusReason("Stack Finished");
doReturn(latestStack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
- Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(latestStack);
Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
assertEquals(true, actual != null);
@@ -141,7 +141,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
doNothing().when(stackStatusHandler).updateStackStatus(stack);
doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
- Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(stack);
Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
assertEquals(true, actual != null);
@@ -259,11 +259,12 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
doReturn(stackResource).when(heatClient).getStacks();
doReturn(mockDeleteStack).when(stackResource).deleteByName("stackName/id");
doReturn(deletedStack).when(heatUtils).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId,
- tenantId);
+ tenantId, true);
heatUtils.handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
Mockito.verify(heatUtils, times(1)).executeAndRecordOpenstackRequest(mockDeleteStack);
- Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId);
+ Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId,
+ true);
Mockito.verify(heatUtils, times(1)).postProcessStackDelete(deletedStack);
}
@@ -357,12 +358,13 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
createStackParam.setStackName("stackName");
doReturn(createdStack).when(heatUtils).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId,
- tenantId);
+ tenantId, false);
doReturn(createdStack).when(heatUtils).postProcessStackCreate(createdStack, true, 120, true, cloudSiteId,
tenantId, createStackParam);
heatUtils.processCreateStack(cloudSiteId, tenantId, 120, true, stack, createStackParam, true);
- Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId,
+ false);
Mockito.verify(heatUtils, times(1)).postProcessStackCreate(createdStack, true, 120, true, cloudSiteId, tenantId,
createStackParam);
}
@@ -387,11 +389,12 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
createStackParam.setStackName("stackName");
doThrow(new StackCreationException("Error")).when(heatUtils).pollStackForStatus(120, stack,
- "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
exceptionRule.expect(MsoException.class);
exceptionRule.expectMessage("Error");
heatUtils.processCreateStack(cloudSiteId, tenantId, 120, true, stack, createStackParam, true);
- Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId,
+ false);
Mockito.verify(heatUtils, times(1)).postProcessStackCreate(stack, true, 120, true, cloudSiteId, tenantId,
createStackParam);
}
@@ -527,12 +530,13 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
createStackParam.setStackName("stackName");
doThrow(new StackCreationException("Error")).when(heatUtils).pollStackForStatus(120, stack,
- "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
exceptionRule.expect(MsoException.class);
exceptionRule.expectMessage("Error");
heatUtils.processCreateStack(cloudSiteId, tenantId, 120, false, stack, createStackParam, true);
- Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
+ Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId,
+ false);
Mockito.verify(heatUtils, times(0)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
index 995db522e9..44a9bc3e10 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
@@ -24,8 +24,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -95,9 +95,9 @@ public class MsoMulticloudUtilsTest extends BaseTest {
wireMockServer.stubFor(get(urlEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE").whenScenarioStateIs("UPDATING")
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("MulticloudGetUpdateResponse.json").withStatus(HttpStatus.SC_OK)));
- StackInfo result =
- multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
- "TEST-heat", new HashMap<>(), true, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
+ StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack",
+ new VduModelInfo(), "TEST-heat", new HashMap<>(), true, 200, "TEST-env", new HashMap<>(),
+ new HashMap<>(), false, false);
wireMockServer.resetScenarios();
assertNotNull(result);
assertEquals("TEST-stack", result.getName());
@@ -155,7 +155,8 @@ public class MsoMulticloudUtilsTest extends BaseTest {
cloudSite.setIdentityService(new CloudIdentity());
when(cloudConfigMock.getCloudSite("MTN13")).thenReturn(Optional.of(cloudSite));
multicloudUtilsMock.createStack("MNT14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
- "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
+ "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false,
+ false);
} catch (MsoException e) {
assertEquals("0 : Multicloud client could not be initialized", e.toString());
return;
@@ -169,7 +170,8 @@ public class MsoMulticloudUtilsTest extends BaseTest {
wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).willReturn(
aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_BAD_REQUEST)));
multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
- "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
+ "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false,
+ false);
} catch (MsoException e) {
assertEquals("0 : Bad Request", e.toString());
return;
@@ -181,9 +183,9 @@ public class MsoMulticloudUtilsTest extends BaseTest {
public void createStackEmptyResponseEntity() throws MsoException {
wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).willReturn(
aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_CREATED)));
- StackInfo result =
- multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
- "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
+ StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack",
+ new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(),
+ new HashMap<>(), false, false);
assertNotNull(result);
assertEquals("TEST-stack/", result.getName());
}