X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openstack%2Fnet-virt-providers%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fopenstack%2Fnetvirt%2Fproviders%2Fopenflow13%2Fservices%2FIngressAclServiceTest.java;h=5e42ba72f2f025219d19847c1e7698d7098aa720;hb=591572ba0834aac01e135ba00c44caca70b39885;hp=c4e19b8d3dc1cb1a32cae0cf408952dd630029e7;hpb=72f03b2fe8c579872ca058236c61265e864e152f;p=netvirt.git diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java index c4e19b8d3d..5e42ba72f2 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java @@ -37,10 +37,11 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.neutron.spi.NeutronSecurityGroup; -import org.opendaylight.neutron.spi.NeutronSecurityRule; -import org.opendaylight.neutron.spi.Neutron_IPs; +import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup; +import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule; +import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs; import org.opendaylight.ovsdb.openstack.netvirt.api.Constants; +import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger; import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; @@ -77,6 +78,7 @@ public class IngressAclServiceTest { @Mock private NeutronSecurityGroup securityGroup; @Mock private NeutronSecurityRule portSecurityRule; @Mock private SecurityServicesManager securityServices; + @Mock private SecurityGroupCacheManger securityGroupCacheManger; private List neutronSrcIpList = new ArrayList(); private List neutronDestIpList = new ArrayList(); @@ -92,6 +94,7 @@ public class IngressAclServiceTest { private static final String DEST_IP_1 = "192.169.0.1"; private static final String DEST_IP_2 = "192.169.0.2"; private static final String SECURITY_GROUP_UUID = "85cc3048-abc3-43cc-89b3-377341426ac5"; + private static final String PORT_UUID = "95cc3048-abc3-43cc-89b3-377341426ac5"; private static final String SEGMENT_ID = "2"; private static final Long DP_ID_LONG = (long) 1554; private static final Long LOCAL_PORT = (long) 124; @@ -144,7 +147,7 @@ public class IngressAclServiceTest { when(securityGroup.getSecurityRules()).thenReturn(portSecurityList); when(securityServices.getVmListForSecurityGroup - (neutronSrcIpList, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList); + (PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList); } /* *//** @@ -283,7 +286,7 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null); when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null); - ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true); + ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,true); verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true)); verify(writeTransaction, times(1)).submit(); @@ -300,7 +303,7 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRulePortMin()).thenReturn(null); when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn(null); - ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false); + ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false); verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); verify(writeTransaction, times(1)).submit(); @@ -319,8 +322,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -346,8 +349,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -373,8 +376,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -409,8 +412,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -445,8 +448,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -469,8 +472,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -492,8 +495,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -524,8 +527,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -557,8 +560,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -584,8 +587,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -611,8 +614,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -646,8 +649,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -681,8 +684,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -705,8 +708,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -729,8 +732,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, true); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -761,8 +764,8 @@ public class IngressAclServiceTest { when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5"); PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, - neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroup, + PORT_UUID, false); Match match = flowBuilder.getMatch(); EthernetMatch ethMatch = match.getEthernetMatch(); @@ -793,8 +796,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, - MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, + MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, true); Match match = flowBuilder.getMatch(); Icmpv4Match icmpv4Match = match.getIcmpv4Match(); Assert.assertEquals(10, icmpv4Match.getIcmpv4Type().shortValue()); @@ -820,8 +823,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, - MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, + MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, false); Match match = flowBuilder.getMatch(); Icmpv4Match icmpv4Match = match.getIcmpv4Match(); Assert.assertEquals(20, icmpv4Match.getIcmpv4Type().shortValue()); @@ -847,8 +850,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, - MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, true); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, + MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, true); Match match = flowBuilder.getMatch(); Icmpv4Match icmpv4Match =match.getIcmpv4Match(); Assert.assertEquals(30, icmpv4Match.getIcmpv4Type().shortValue()); @@ -881,8 +884,8 @@ public class IngressAclServiceTest { PowerMockito.doAnswer(answer()) .when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class)); - ingressAclServiceSpy.programPortSecurityAcl(DP_ID_LONG, SEGMENT_ID, - MAC_ADDRESS, LOCAL_PORT, securityGroup, neutronSrcIpList, false); + ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, + MAC_ADDRESS, LOCAL_PORT, securityGroup, PORT_UUID, false); Match match = flowBuilder.getMatch(); Icmpv4Match icmpv4Match = match.getIcmpv4Match(); Assert.assertEquals(40, icmpv4Match.getIcmpv4Type().shortValue()); @@ -910,7 +913,7 @@ public class IngressAclServiceTest { public void testProgramPortSecurityACLRuleInvalidEther() throws Exception { when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPV6"); - ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false); + ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false); verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); verify(writeTransaction, times(0)).submit(); @@ -924,7 +927,7 @@ public class IngressAclServiceTest { public void testProgramPortSecurityACLRuleInvalidDirection() throws Exception { when(portSecurityRule.getSecurityRuleDirection()).thenReturn("edgress"); - ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false); + ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false); verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); verify(writeTransaction, times(0)).submit(); @@ -936,7 +939,7 @@ public class IngressAclServiceTest { */ @Test public void testProgramFixedSecurityACLAdd1() throws Exception { - ingressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, true); + ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, true); verify(writeTransaction, times(0)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true)); verify(writeTransaction, times(0)).submit(); @@ -948,7 +951,7 @@ public class IngressAclServiceTest { @Test public void testProgramFixedSecurityACLRemove1() throws Exception { - ingressAclServiceSpy.programFixedSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, false); + ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, false, false, false); verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); verify(writeTransaction, times(0)).submit();