*/
package org.opendaylight.netvirt.aclservice.tests;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
+import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.netvirt.aclservice.tests.StateInterfaceBuilderHelper.putNewStateInterface;
import java.math.BigInteger;
import javax.inject.Inject;
import org.eclipse.xtext.xbase.lib.Pair;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.datastoreutils.testutils.AsyncEventsWaiter;
import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorEventsWaiter;
import org.opendaylight.genius.testutils.TestInterfaceManager;
import org.opendaylight.infrautils.testutils.LogCaptureRule;
import org.opendaylight.infrautils.testutils.LogRule;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.netvirt.aclservice.tests.infra.DataBrokerPairsUtil;
import org.opendaylight.netvirt.aclservice.utils.AclConstants;
import org.opendaylight.netvirt.aclservice.utils.AclServiceUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
private InterfaceInfo newInterfaceInfo(String testInterfaceName) {
- InterfaceInfo interfaceInfo = new InterfaceInfo(BigInteger.valueOf(789), "port1");
+ InterfaceInfo interfaceInfo = new InterfaceInfo(Uint64.valueOf(BigInteger.valueOf(789)), "port1");
interfaceInfo.setInterfaceName(testInterfaceName);
return interfaceInfo;
}
abstract void newInterfaceCheck();
@Test
+ @Ignore
public void newInterfaceWithEtherTypeAcl() throws Exception {
LOG.info("newInterfaceWithEtherTypeAcl - start");
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) -1);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_UNSPECIFIED, AclConstants.DEST_UPPER_PORT_UNSPECIFIED,
AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
dataBrokerUtil.put(
new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2).newMatches(matches)
.newDirection(DirectionIngress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) -1);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_UNSPECIFIED, AclConstants.DEST_UPPER_PORT_UNSPECIFIED,
AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
dataBrokerUtil.put(
new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2).newMatches(matches)
.newDirection(DirectionIngress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_2).newRuleName(SR_UUID_2_1)
.newMatches(matches).newDirection(DirectionEgress.class).newRemoteGroupId(new Uuid(SG_UUID_2)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_HTTP, AclConstants.DEST_UPPER_PORT_HTTP,
AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_2).newRuleName(SR_UUID_2_2)
.newMatches(matches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
List<String> sgList = new ArrayList<>();
sgList.add(SG_UUID_1);
sgList.add(SG_UUID_2);
newAllowedAddressPair(PORT_1, sgList, Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, sgList, Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newInterfaceWithMultipleAclCheck();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_HTTP, AclConstants.DEST_UPPER_PORT_HTTP,
AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2)
.newMatches(matches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_UDP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_HTTP, AclConstants.DEST_UPPER_PORT_HTTP,
dataBrokerUtil.put(
new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2).newMatches(matches)
.newDirection(DirectionIngress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
prepareInterfaceWithIcmpAcl();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 333, 777, AclConstants.SOURCE_REMOTE_IP_PREFIX_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 2000,
2003, AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
(short) NwConstants.IP_PROT_UDP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2)
.newMatches(matches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
abstract void newInterfaceWithDstPortRangeCheck();
@Test
+ @Ignore
public void newInterfaceWithDstAllPorts() throws Exception {
LOG.info("newInterfaceWithDstAllPorts - start");
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 1, 65535, AclConstants.SOURCE_REMOTE_IP_PREFIX_UNSPECIFIED,
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 1,
65535, AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED,
(short) NwConstants.IP_PROT_UDP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2)
.newMatches(matches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_3, Arrays.asList(SG_UUID_1, SG_UUID_2), Collections.singletonList(AAP_PORT_3),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
Matches icmpEgressMatches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_2,
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(icmpEgressMatches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2)
.newMatches(icmpIngressMatches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_2).newRuleName(SR_UUID_2_1)
.newMatches(icmpEgressMatches).newDirection(DirectionEgress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_2).newRuleName(SR_UUID_2_2)
.newMatches(icmpIngressMatches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
// When
putNewStateInterface(dataBroker, PORT_3, PORT_MAC_3);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
public void newInterfaceWithIcmpAclHavingOverlappingMac() throws Exception {
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
// Given
prepareInterfaceWithIcmpAcl();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
LOG.info("newInterfaceWithAapIpv4All test - start");
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
List<AllowedAddressPairs> aapList = new ArrayList<>();
aapList.add(AAP_PORT_2);
aapList.add(buildAap("0.0.0.0/0", PORT_MAC_2));
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), aapList,
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
prepareInterfaceWithIcmpAcl();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1),
Arrays.asList(AAP_PORT_2, AAP_PORT_100, AAP_PORT_101), Collections.singletonList(SUBNET_INFO_1));
+ asyncEventsWaiter.awaitEventsConsumption();
prepareInterfaceWithIcmpAcl();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
+ asyncEventsWaiter.awaitEventsConsumption();
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
+ asyncEventsWaiter.awaitEventsConsumption();
asyncEventsWaiter.awaitEventsConsumption();
AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_ICMP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1)
.newMatches(matches).newDirection(DirectionEgress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
+ asyncEventsWaiter.awaitEventsConsumption();
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED,
AclConstants.DEST_LOWER_PORT_2, AclConstants.DEST_UPPER_PORT_3,
(short) NwConstants.IP_PROT_ICMP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2)
.newMatches(matches).newDirection(DirectionIngress.class).build());
+ asyncEventsWaiter.awaitEventsConsumption();
}
protected void newAllowedAddressPair(String portName, List<String> sgUuidList, List<AllowedAddressPairs> aapList,