*/
package org.opendaylight.netvirt.elanmanager.tests;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
+import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import com.google.common.collect.Sets;
-
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.stream.Collectors;
-
import org.awaitility.core.ConditionFactory;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
import org.opendaylight.genius.testutils.interfacemanager.TunnelInterfaceDetails;
import org.opendaylight.mdsal.binding.testutils.AssertDataObjects;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class Verifications {
private static final boolean CHECK_FOR_EXISTS = true;
private static final boolean CHECK_FOR_DELETED = false;
- private static final Function<BigInteger, NodeId> GET_OPENFLOW_NODE_ID = (dpnId) -> new NodeId("openflow:" + dpnId);
+ private static final Function<Uint64, NodeId> GET_OPENFLOW_NODE_ID = (dpnId) -> new NodeId("openflow:" + dpnId);
private static final InstanceIdentifier<ElanInstance> ELAN_IID = InstanceIdentifier
.builder(ElanInstances.class)
.child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1))
}
}
boolean remoteMcastFoundFlag = false;
- for (RemoteMcastMacs remoteMcastMacs : augmentation.getRemoteMcastMacs()) {
+ for (RemoteMcastMacs remoteMcastMacs : augmentation.getRemoteMcastMacs().values()) {
for (LocatorSet locatorSet : remoteMcastMacs.getLocatorSet()) {
TpId tpId = locatorSet.getLocatorRef().getValue().firstKeyOf(TerminationPoint.class).getTpId();
if (tpId.getValue().contains(tepIp)) {
}
}
if (checkForExists) {
- return (remoteMcastFoundFlag == true);
+ return remoteMcastFoundFlag == true;
} else {
- return (remoteMcastFoundFlag == false);
+ return remoteMcastFoundFlag == false;
}
} catch (ReadFailedException e) {
return false;
}
}
boolean remoteUcastFoundFlag = false;
- for (RemoteUcastMacs remoteUcastMacs : augmentation.getRemoteUcastMacs()) {
+ for (RemoteUcastMacs remoteUcastMacs : augmentation.getRemoteUcastMacs().values()) {
String mac = remoteUcastMacs.getMacEntryKey().getValue();
if (mac.equals(dpnMac)) {
remoteUcastFoundFlag = true;
}
}
if (checkForExists) {
- return (remoteUcastFoundFlag == true);
+ return remoteUcastFoundFlag == true;
} else {
- return (remoteUcastFoundFlag == false);
+ return remoteUcastFoundFlag == false;
}
} catch (ReadFailedException e) {
return false;
}
private List<Bucket> buildRemoteBcGroupBuckets(ElanInstance elanInfo,
- List<BigInteger> otherDpns,
+ List<Uint64> otherDpns,
List<String> otherTors,
- BigInteger dpnId,
+ Uint64 dpnId,
int bucketId)
throws ExecutionException, InterruptedException {
List<Bucket> listBucketInfo = new ArrayList<>();
if (otherDpns != null) {
- for (BigInteger otherDpn : otherDpns) {
+ for (Uint64 otherDpn : otherDpns) {
GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder()
.setIntfName(extnIntfs.get(dpnId + ":" + otherDpn).getInterfaceInfo().getInterfaceName())
- .setTunnelKey(elanInfo.getElanTag()).build();
+ .setTunnelKey(elanInfo.getElanTag().longValue() + ElanConstants.ELAN_TAG_ADDEND).build();
List<Action> actionsList =
- odlInterfaceRpcService.getEgressActionsForInterface(getEgressActInput).get().getResult()
- .getAction();
+ new ArrayList<Action>(odlInterfaceRpcService.getEgressActionsForInterface(getEgressActInput)
+ .get().getResult().getAction().values());
listBucketInfo.add(MDSALUtil.buildBucket(actionsList, MDSALUtil.GROUP_WEIGHT, bucketId,
MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
.setIntfName(extnIntfs.get(dpnId + ":" + otherTor).getInterfaceInfo().getInterfaceName())
.setTunnelKey(elanInfo.getSegmentationId()).build();
List<Action> actionsList =
- odlInterfaceRpcService.getEgressActionsForInterface(getEgressActInput).get().getResult()
- .getAction();
+ new ArrayList<Action>(odlInterfaceRpcService.getEgressActionsForInterface(getEgressActInput)
+ .get().getResult().getAction().values());
listBucketInfo.add(MDSALUtil.buildBucket(actionsList, MDSALUtil.GROUP_WEIGHT, bucketId,
MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
return listBucketInfo;
}
- private Group buildStandardElanBroadcastGroups(ElanInstance elanInfo, BigInteger dpnId, List<BigInteger> otherdpns,
+ private Group buildStandardElanBroadcastGroups(ElanInstance elanInfo, Uint64 dpnId, List<Uint64> otherdpns,
List<String> tepIps)
throws ExecutionException, InterruptedException {
List<Bucket> listBucket = new ArrayList<>();
int bucketId = 0;
int actionKey = 0;
- Long elanTag = elanInfo.getElanTag();
+ Uint32 elanTag = elanInfo.getElanTag();
List<Action> listAction = new ArrayList<>();
- listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
+ listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag.longValue())).buildAction(++actionKey));
listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT,
MDSALUtil.WATCH_GROUP));
bucketId++;
listBucket.addAll(buildRemoteBcGroupBuckets(elanInfo, otherdpns, tepIps, dpnId, bucketId));
- long groupId = ElanUtils.getElanRemoteBCGId(elanTag);
+ long groupId = ElanUtils.getElanRemoteBCGId(elanTag.longValue());
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll,
MDSALUtil.buildBucketLists(listBucket));
return group;
}
private boolean validateGroup(ElanInstance actualElanInstances,
- BigInteger dpnId,
- List<BigInteger> otherdpns,
+ Uint64 dpnId,
+ List<Uint64> otherdpns,
List<String> torips)
throws ExecutionException, InterruptedException, ReadFailedException, TransactionCommitFailedException {
Group expected = buildStandardElanBroadcastGroups(actualElanInstances, dpnId, otherdpns, torips);
AssertDataObjects.assertEqualBeans(expected, actual);
}
- Set<Bucket> actualBuckets = modifyBucketId(actual.getBuckets().getBucket());
- Set<Bucket> expectedBuckets = modifyBucketId(expected.getBuckets().getBucket());
+ Set<Bucket> actualBuckets = modifyBucketId(new ArrayList<Bucket>(actual.getBuckets().getBucket().values()));
+ Set<Bucket> expectedBuckets = modifyBucketId(new ArrayList<Bucket>(expected.getBuckets().getBucket().values()));
Set<Bucket> diff = Sets.difference(actualBuckets, expectedBuckets);
if (diff != null && !diff.isEmpty()) {
AssertDataObjects.assertEqualBeans(expected, actual);
return true;
}
- private Set<Bucket> modifyBucketId(List<Bucket> input) {
+ private static Set<Bucket> modifyBucketId(List<Bucket> input) {
return input.stream()
.map(bucket -> new BucketBuilder(bucket).setBucketId(new BucketId(1L))
.withKey(new BucketKey(new BucketId(1L))).build())
.collect(Collectors.toSet());
}
- public void verifyThatDpnGroupUpdated(BigInteger dpnId, List<BigInteger> otherdpns, List<String> othertors)
+ public void verifyThatDpnGroupUpdated(Uint64 dpnId, List<Uint64> otherdpns, List<String> othertors)
throws ReadFailedException, TransactionCommitFailedException, ExecutionException, InterruptedException {
verifyDPNGroup(dpnId, otherdpns, othertors, CHECK_FOR_EXISTS);
}
- public void verifyThatDpnGroupDeleted(BigInteger dpnId)
+ public void verifyThatDpnGroupDeleted(Uint64 dpnId)
throws ReadFailedException, TransactionCommitFailedException, ExecutionException, InterruptedException {
verifyDPNGroup(dpnId, Collections.emptyList(), Collections.emptyList(), CHECK_FOR_DELETED);
}
- public void verifyLocalBcGroup(BigInteger dpnId, int expectedNoBuckets)
+ public void verifyLocalBcGroup(Uint64 dpnId, int expectedNoBuckets)
throws ReadFailedException, TransactionCommitFailedException, ExecutionException, InterruptedException {
awaiter.until(() -> {
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, ELAN_IID);
});
}
- public void verifyThatLocalBcGroupDeleted(BigInteger dpnId)
+ public void verifyThatLocalBcGroupDeleted(Uint64 dpnId)
throws ReadFailedException, TransactionCommitFailedException, ExecutionException, InterruptedException {
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, ELAN_IID);
InstanceIdentifier<Group> grpIid = buildLocalGroupIid(actualElanInstances, dpnId);
awaitForDataDelete(CONFIGURATION, grpIid);
}
- public void verifyDPNGroup(BigInteger dpnId,
- List<BigInteger> otherdpns,
+ public void verifyDPNGroup(Uint64 dpnId,
+ List<Uint64> otherdpns,
List<String> othertors,
boolean checkForExists)
throws ReadFailedException, TransactionCommitFailedException, ExecutionException, InterruptedException {
}
}
- public void verifyThatDmacFlowOfTORCreated(List<BigInteger> dpns,
+ public void verifyThatDmacFlowOfTORCreated(List<Uint64> dpns,
InstanceIdentifier<Node> torNodeId,
List<String> macs) throws ReadFailedException {
for (String mac : macs) {
- for (BigInteger srcDpnId : dpns) {
+ for (Uint64 srcDpnId : dpns) {
verifyDmacFlowOfTOR(srcDpnId, torNodeId, mac, CHECK_FOR_EXISTS);
}
}
}
- public void verifyThatDmacFlowOfTORDeleted(List<BigInteger> dpns,
+ public void verifyThatDmacFlowOfTORDeleted(List<Uint64> dpns,
InstanceIdentifier<Node> torNodeId,
List<String> macs) throws ReadFailedException {
for (String mac : macs) {
- for (BigInteger srcDpnId : dpns) {
+ for (Uint64 srcDpnId : dpns) {
verifyDmacFlowOfTOR(srcDpnId, torNodeId, mac, CHECK_FOR_DELETED);
}
}
}
- public void verifyDmacFlowOfTOR(BigInteger srcDpnId,
+ public void verifyDmacFlowOfTOR(Uint64 srcDpnId,
InstanceIdentifier<Node> torNodeIid,
String mac,
boolean checkForExists) throws ReadFailedException {
srcDpnId,
torNodeId,
mac,
- actualElanInstances.getElanTag(),
+ actualElanInstances.getElanTag().toJava(),
false));
InstanceIdentifier<Flow> flowIid = getFlowIid(NwConstants.ELAN_DMAC_TABLE, flowId, srcDpnId);
}
}
- public void verifyThatDmacOfOtherDpnCreated(BigInteger srcDpnId, BigInteger dpnId, List<String> dpnMacs)
+ public void verifyThatDmacOfOtherDpnCreated(Uint64 srcDpnId, Uint64 dpnId, List<String> dpnMacs)
throws ReadFailedException, InterruptedException {
for (String dpnMac : dpnMacs) {
verifyDmacFlowOfOtherDPN(srcDpnId, dpnId, dpnMac, CHECK_FOR_EXISTS);
}
}
- public void verifyThatDmacOfOtherDPNDeleted(BigInteger srcDpnId, BigInteger dpnId, List<String> dpnMacs)
+ public void verifyThatDmacOfOtherDPNDeleted(Uint64 srcDpnId, Uint64 dpnId, List<String> dpnMacs)
throws ReadFailedException, InterruptedException {
for (String dpnMac : dpnMacs) {
verifyDmacFlowOfOtherDPN(srcDpnId, dpnId, dpnMac, CHECK_FOR_DELETED);
}
}
- private void verifyDmacFlowOfOtherDPN(BigInteger srcDpnId, BigInteger dpnId, String dpnMac, boolean createFlag)
+ private void verifyDmacFlowOfOtherDPN(Uint64 srcDpnId, Uint64 dpnId, String dpnMac, boolean createFlag)
throws ReadFailedException, InterruptedException {
InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class)
.child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
FlowId flowId = new FlowId(
- ElanUtils.getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE,
- srcDpnId,
- dpnId,
- dpnMac,
- actualElanInstances.getElanTag()));
+ ElanUtils.getKnownDynamicmacFlowRef(actualElanInstances.getElanTag(), dpnMac));
InstanceIdentifier<Flow> flowInstanceIidDst = getFlowIid(NwConstants.ELAN_DMAC_TABLE, flowId, srcDpnId);
if (createFlag) {
awaitForData(LogicalDatastoreType.CONFIGURATION, flowInstanceIidDst);
}
}
- private InstanceIdentifier<Flow> getFlowIid(short tableId, FlowId flowid, BigInteger dpnId) {
+ private static InstanceIdentifier<Flow> getFlowIid(short tableId, FlowId flowid, Uint64 dpnId) {
FlowKey flowKey = new FlowKey(new FlowId(flowid));
NodeId nodeId = GET_OPENFLOW_NODE_ID.apply(dpnId);
.child(Table.class, new TableKey(tableId)).child(Flow.class, flowKey).build();
}
- private InstanceIdentifier<Group> buildGroupIid(ElanInstance actualElanInstances, BigInteger dpnId) {
+ private static InstanceIdentifier<Group> buildGroupIid(ElanInstance actualElanInstances, Uint64 dpnId) {
return DpnNodeBuilders.buildGroupInstanceIdentifier(
- ElanUtils.getElanRemoteBCGId(actualElanInstances.getElanTag()), DpnNodeBuilders.buildDpnNode(dpnId));
+ ElanUtils.getElanRemoteBCGId(actualElanInstances.getElanTag().toJava()),
+ DpnNodeBuilders.buildDpnNode(dpnId));
}
- private InstanceIdentifier<Group> buildLocalGroupIid(ElanInstance actualElanInstances, BigInteger dpnId) {
+ private static InstanceIdentifier<Group> buildLocalGroupIid(ElanInstance actualElanInstances, Uint64 dpnId) {
return DpnNodeBuilders.buildGroupInstanceIdentifier(
- ElanUtils.getElanLocalBCGId(actualElanInstances.getElanTag()), DpnNodeBuilders.buildDpnNode(dpnId));
+ ElanUtils.getElanLocalBCGId(actualElanInstances.getElanTag().toJava()),
+ DpnNodeBuilders.buildDpnNode(dpnId));
}
}