aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src/test')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java33
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetByNameResponse.json34
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetCreateResponse.json44
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetDeleteResponse.json8
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetUpdateResponse.json8
5 files changed, 113 insertions, 14 deletions
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 0d8f451a6d..995db522e9 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
@@ -21,9 +21,11 @@
package org.onap.so.openstack.utils;
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 org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -34,7 +36,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Optional;
import org.apache.http.HttpStatus;
-import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -64,38 +65,36 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Mock
private CloudConfig cloudConfigMock;
- private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
+ private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
+ "\"TEST-workload\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}";
private static final String UPDATE_STACK_RESPONSE =
- "{\"template_type\": \"TEST-template\", \"workload_id\": " + "\"TEST-workload\"}";
- private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
- + "\"TEST-workload\", \"workload_status\": \"CREATE_COMPLETE\"}";
- private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
- + "\"TEST-workload\", \"workload_status\": \"UPDATE_COMPLETE\"}";
+ "{\"template_type\": \"heat\", \"workload_id\": " + "\"TEST-workload\"}";
private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload";
private static final String MULTICLOUD_UPDATE_PATH =
"/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
private static final String MULTICLOUD_GET_PATH =
"/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
+ private static final String MULTICLOUD_DELETE_PATH =
+ "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
@Test
public void createStackSuccess() throws MsoException, IOException {
wireMockServer
- .stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
+ .stubFor(post(urlEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_CREATED))
.willSetStateTo("CREATING"));
wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE")
.whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+ .withBodyFile("MulticloudGetCreateResponse.json").withStatus(HttpStatus.SC_OK)));
wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
.inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
.willSetStateTo("UPDATING"));
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE")
- .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+ 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);
@@ -106,7 +105,13 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void deleteStack() throws MsoException {
- StackInfo result = multicloudUtils.deleteStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
+ wireMockServer.stubFor(delete(urlEqualTo(MULTICLOUD_DELETE_PATH)).willReturn(
+ aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NO_CONTENT)));
+ wireMockServer.stubFor(get(urlEqualTo(MULTICLOUD_GET_PATH))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("MulticloudGetDeleteResponse.json").withStatus(HttpStatus.SC_OK)));
+ StackInfo result =
+ multicloudUtils.deleteStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack/TEST-workload");
assertNotNull(result);
assertTrue(HeatStatus.NOTFOUND == result.getStatus());
}
@@ -123,7 +128,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(CREATE_STACK_RESPONSE)
.withStatus(HttpStatus.SC_OK)));
- StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
+ StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceName/instanceId");
assertTrue(HeatStatus.FAILED == result.getStatus());
assertEquals(MULTICLOUD_QUERY_BODY_NULL, result.getStatusMessage());
}
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetByNameResponse.json b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetByNameResponse.json
new file mode 100644
index 0000000000..7e671d005a
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetByNameResponse.json
@@ -0,0 +1,34 @@
+{
+ "template_type": "heat",
+ "workload_id": "TEST-workload",
+ "workload_status": "GET_COMPLETE",
+ "workload_status_reason": {
+ "stacks": [
+ {
+ "id": "TEST-workload",
+ "links" : [
+ {
+ "href" : "port",
+ "rel" : "self"
+ }
+ ],
+ "stack_name": "TEST-stack",
+ "stack_status": "CREATE_COMPLETE",
+ "creation_time": "2019-03-21T03:17:32Z",
+ "description": "Sample stack response",
+ "stack_owner": "stack_Owner",
+ "capabilities": [],
+ "parameters": {
+ "OS::project_id": "0e148b76ee8c42f78d37013bf6b7b1ae",
+ "apt_proxy": "10.12.5.2:8000",
+ "etcd_vm_flavor": "m1.medium",
+ "docker_version": "17.03.2",
+ "portal_hostname": "portal.api.simpledemo.onap.org",
+ "docker_proxy": "10.12.5.2:5000",
+ "kubectl_version": "1.11.5",
+ "use_ramdisk": "false"
+ }
+ }
+ ]
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetCreateResponse.json b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetCreateResponse.json
new file mode 100644
index 0000000000..8feb3e085e
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetCreateResponse.json
@@ -0,0 +1,44 @@
+{
+ "template_type": "heat",
+ "workload_id": "TEST-workload",
+ "workload_status": "CREATE_COMPLETE",
+ "workload_status_reason": {
+ "stack": {
+ "id": "TEST-workload",
+ "links" : [
+ {
+ "href" : "port",
+ "rel" : "self"
+ }
+ ],
+ "stack_name": "TEST-stack",
+ "stack_status": "CREATE_COMPLETE",
+ "creation_time": "2019-03-21T03:17:32Z",
+ "description": "Sample stack response",
+ "stack_owner": "stack_Owner",
+ "capabilities": [],
+ "parameters": {
+ "OS::project_id": "0e148b76ee8c42f78d37013bf6b7b1ae",
+ "apt_proxy": "10.12.5.2:8000",
+ "etcd_vm_flavor": "m1.medium",
+ "docker_version": "17.03.2",
+ "portal_hostname": "portal.api.simpledemo.onap.org",
+ "docker_proxy": "10.12.5.2:5000",
+ "kubectl_version": "1.11.5",
+ "use_ramdisk": "false"
+ },
+ "outputs": [
+ {
+ "output_value": "10.12.6.20",
+ "output_key": "k8s_12_vm_ip",
+ "description": "The IP address of the k8s_12 instance"
+ },
+ {
+ "output_value": "10.12.5.241",
+ "output_key": "k8s_01_vm_ip",
+ "description": "The IP address of the k8s_01 instance"
+ }
+ ]
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetDeleteResponse.json b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetDeleteResponse.json
new file mode 100644
index 0000000000..9efaf7b265
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetDeleteResponse.json
@@ -0,0 +1,8 @@
+{
+ "template_type": "heat",
+ "workload_id": "TEST-workload",
+ "workload_status": "DELETE_COMPLETE",
+ "workload_status_reason": {
+ "stack": {}
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetUpdateResponse.json b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetUpdateResponse.json
new file mode 100644
index 0000000000..84d7db82ba
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/__files/MulticloudGetUpdateResponse.json
@@ -0,0 +1,8 @@
+{
+ "template_type": "heat",
+ "workload_id": "TEST-workload",
+ "workload_status": "UPDATE_COMPLETE",
+ "workload_status_reason": {
+ "stack": {}
+ }
+}