summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test
diff options
context:
space:
mode:
authorMunir Ahmad <munir.ahmad@bell.ca>2020-07-30 10:24:50 -0400
committerMunir Ahmad <munir.ahmad@bell.ca>2020-08-04 11:19:24 -0400
commitd9c694b4c4123bbd3e62f8a64484c27c6be1b100 (patch)
tree31754d1b6f4303fad8ce08e7e5fa2fe9018097b6 /adapters/mso-openstack-adapters/src/test
parent4e81b212f66800fffbb06a1f6c55b5733a98c122 (diff)
[SO] heatbridge implemention to populate AAI with openstack provider network/subnet
Issue-ID: SO-3109 Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca> Change-Id: Ibb8f5b994072b797783dba7ce412baecb9b64174
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java66
1 files changed, 66 insertions, 0 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 643dd4cd9a..8c21e3f7f7 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
@@ -85,9 +85,11 @@ import org.openstack4j.model.compute.Server;
import org.openstack4j.model.compute.Server.Status;
import org.openstack4j.model.heat.Resource;
import org.openstack4j.model.network.IP;
+import org.openstack4j.model.network.IPVersionType;
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.openstack.heat.domain.HeatResource;
import org.openstack4j.openstack.heat.domain.HeatResource.Resources;
import org.springframework.core.env.Environment;
@@ -450,6 +452,70 @@ public class HeatBridgeImplTest {
}
@Test
+ public void testUpdateNetworksToAai() throws HeatBridgeException {
+
+ Subnet subnet1 = mock(Subnet.class);
+ when(subnet1.getId()).thenReturn("test-subnet1-id");
+ when(subnet1.getName()).thenReturn("test-subnet1-name");
+ when(subnet1.isDHCPEnabled()).thenReturn(true);
+ when(subnet1.getGateway()).thenReturn("test-subnet1-gateway");
+ when(subnet1.getCidr()).thenReturn("test-subnet1-gateway");
+ when(subnet1.getIpVersion()).thenReturn(IPVersionType.V4);
+
+ Subnet subnet2 = mock(Subnet.class);
+ when(subnet2.getId()).thenReturn("test-subnet2-id");
+ when(subnet2.getName()).thenReturn("test-subnet2-name");
+ when(subnet2.isDHCPEnabled()).thenReturn(true);
+ when(subnet2.getGateway()).thenReturn("test-subnet1-gateway");
+ when(subnet2.getCidr()).thenReturn("test-subnet1-gateway");
+ when(subnet2.getIpVersion()).thenReturn(IPVersionType.V6);
+
+ when(osClient.getSubnetById(subnet1.getId())).thenReturn(subnet1);
+ when(osClient.getSubnetById(subnet2.getId())).thenReturn(subnet2);
+
+ List<String> subnetIds = Arrays.asList(subnet1.getId(), subnet2.getId());
+
+ // Arrange
+ Network network1 = mock(Network.class);
+ when(network1.getId()).thenReturn("test-network1-id");
+ when(network1.isShared()).thenReturn(true);
+ when(network1.isRouterExternal()).thenReturn(true);
+ when(network1.isAdminStateUp()).thenReturn(true);
+ when(network1.getProviderPhyNet()).thenReturn("sriov-network1");
+ when(network1.getName()).thenReturn("network1");
+ when(network1.getSubnets()).thenReturn(subnetIds);
+
+ Network network2 = mock(Network.class);
+ when(network2.getId()).thenReturn("test-network2-id");
+ when(network2.isShared()).thenReturn(true);
+ when(network2.isRouterExternal()).thenReturn(true);
+ when(network2.isAdminStateUp()).thenReturn(true);
+ when(network2.getProviderPhyNet()).thenReturn("sriov-network2");
+ when(network2.getName()).thenReturn("network2");
+ when(network2.getSubnets()).thenReturn(subnetIds);
+
+ String vnfId = "some-uuiid-of-the-vnf";
+ String vfModuleId = "some-uuiid-of-the-vf-module";
+
+ Subnet subnet = mock(Subnet.class);
+
+ List<Network> networks = Arrays.asList(network1, network2);
+
+ // Act #1
+ heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks);
+
+ // Assert #1
+ verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+
+ // Act #2
+ heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks);
+
+ // Assert #2
+ verify(transaction, times(4)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+
+ }
+
+ @Test
public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException {
// Arrange
List<Resource> stackResources = (List<Resource>) extractTestStackResources();