Bug 7922 - Use counter to keep track of duplicate flow entries
[netvirt.git] / openstack / net-virt / src / test / java / org / opendaylight / netvirt / openstack / netvirt / impl / SecurityServicesImplTest.java
index 9db9e571444967c36bbbbcf7ba43368a68b07780..37b533c1b46770817037c9ec1832dfdf1b13afe0 100644 (file)
@@ -481,9 +481,8 @@ public class SecurityServicesImplTest {
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(nodeCacheManager.getNode(nodeId_1)).thenReturn(node);
         when(neutronPort_Vm1.getMacAddress()).thenReturn("attached-mac");
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, true);
-        verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(true));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, true);
+        verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(true));
     }
 
     /**
@@ -495,9 +494,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, true);
-        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(true));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, true);
+        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(true));
     }
 
     /**
@@ -509,9 +507,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     /**
@@ -523,9 +520,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     /**
@@ -537,9 +533,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(null, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(null, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     /**
@@ -552,9 +547,8 @@ public class SecurityServicesImplTest {
         when(neutronPort_Vm1.getSecurityGroups()).thenReturn(null);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     /**
@@ -567,9 +561,8 @@ public class SecurityServicesImplTest {
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(southbound.getInterfaceExternalIdsValue(any(OvsdbTerminationPointAugmentation.class),eq("attached-mac"))).thenReturn(null);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
 
@@ -582,9 +575,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV6);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     /**
@@ -596,9 +588,8 @@ public class SecurityServicesImplTest {
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("outgress");
         when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
-        when(neutronSecurityGroup_1.getSecurityGroupName()).thenReturn(SECURITY_GROUP_ID_1);
-        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, neutronSecurityGroup_1, false);
-        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutronSecurityGroup_1), eq(neutron_ip_1), eq(false));
+        securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, nodeId_1, false);
+        verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
 
     @Test