aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test
diff options
context:
space:
mode:
authorMax Benjamin <max.benjamin@att.com>2021-03-09 19:18:11 +0000
committerGerrit Code Review <gerrit@onap.org>2021-03-09 19:18:11 +0000
commit85d6591d7fa102bf755bd9b025264586ebe15190 (patch)
tree2de1da70ab0b2b67ea9d9aeeff783f9ebf961e47 /adapters/mso-openstack-adapters/src/test
parent845a6badbe9316bacea207d122e33c97bf38b355 (diff)
parent9f6c9c74c5f10794cdbe6de2ed6d0539ce7d0d84 (diff)
Merge "Added volume creation to heatbridge"
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java26
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/stack-resources.json22
2 files changed, 47 insertions, 1 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index fab7df5345..cf3e1c5ee1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -106,6 +106,8 @@ import org.openstack4j.model.network.Network;
import org.openstack4j.model.network.NetworkType;
import org.openstack4j.model.network.Port;
import org.openstack4j.model.network.Subnet;
+import org.openstack4j.model.storage.block.Volume;
+import org.openstack4j.model.storage.block.VolumeAttachment;
import org.openstack4j.openstack.heat.domain.HeatResource;
import org.openstack4j.openstack.heat.domain.HeatResource.Resources;
import org.slf4j.Logger;
@@ -118,7 +120,6 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
-
@RunWith(MockitoJUnitRunner.Silent.class)
public class HeatBridgeImplTest {
@@ -808,6 +809,28 @@ public class HeatBridgeImplTest {
assertEquals(1, images.size());
}
+ @Test
+ public void testBuildAddVolumes() throws HeatBridgeException {
+ List<Resource> stackResources = (List<Resource>) extractTestStackResources();
+ Volume volume = mock(Volume.class);
+ List<VolumeAttachment> attachments = new ArrayList<>();
+ VolumeAttachment server = mock(VolumeAttachment.class);
+ attachments.add(server);
+ when(volume.getAttachments()).thenAnswer(x -> attachments);
+ when(server.getServerId()).thenReturn("vserverIdTest");
+
+ when(osClient.getVolumeById("5ad95036-8daf-4379-a59c-865f35976ca3")).thenReturn(volume);
+
+ heatbridge.buildAddVolumes(stackResources);
+
+ verify(transaction, times(1)).createIfNotExists(
+ eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion("CloudOwner", "RegionOne").tenant("7320ec4a5b9d4589ba7c4412ccfd290f")
+ .vserver("vserverIdTest").volume("5ad95036-8daf-4379-a59c-865f35976ca3"))),
+ any(Optional.class));
+ verify(osClient, times(1)).getVolumeById(eq("5ad95036-8daf-4379-a59c-865f35976ca3"));
+ }
+
private List<? extends Resource> extractTestStackResources() {
List<HeatResource> stackResources = null;
try {
@@ -838,4 +861,5 @@ public class HeatBridgeImplTest {
}
+
}
diff --git a/adapters/mso-openstack-adapters/src/test/resources/stack-resources.json b/adapters/mso-openstack-adapters/src/test/resources/stack-resources.json
index 6b63895a33..159c6665f2 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/stack-resources.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/stack-resources.json
@@ -436,6 +436,28 @@
"resource_status_reason": "state changed",
"physical_resource_id": "5ad95036-8daf-4379-a59c-865f35976cd4",
"resource_type": "OS::Neutron::Net"
+ },
+ {
+ "resource_name": "volume",
+ "links": [
+ {
+ "href": "http://10.10.10.10:8004/v1/7320ec4a5b9d4589ba7c4412ccfd290f/stacks/ClosedLoop_vFW_VfModule-vfw_instance-tw3i5ile2nam-re_pfe_network-2wmjvgzrhtvs/290fc2fd-cd1d-47d0-90eb-2ece7c009b29/resources/bridge_network",
+ "rel": "self"
+ },
+ {
+ "href": "http://10.10.10.10:8004/v1/7320ec4a5b9d4589ba7c4412ccfd290f/stacks/ClosedLoop_vFW_VfModule-vfw_instance-tw3i5ile2nam-re_pfe_network-2wmjvgzrhtvs/290fc2fd-cd1d-47d0-90eb-2ece7c009b29",
+ "rel": "stack"
+ }
+ ],
+ "logical_resource_id": "some_id",
+ "resource_status": "CREATE_COMPLETE",
+ "updated_time": "2018-04-09T21:09:55Z",
+ "required_by": [
+ "bridge_network_subnet"
+ ],
+ "resource_status_reason": "state changed",
+ "physical_resource_id": "5ad95036-8daf-4379-a59c-865f35976ca3",
+ "resource_type": "OS::Cinder::Volume"
}
]
}