2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netvirt.elan.l2gw.nodehandlertest;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import com.google.common.collect.Sets;
14 import java.util.ArrayList;
15 import java.util.HashSet;
16 import java.util.List;
18 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
19 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
20 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
21 import org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalMcastCmd;
22 import org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalUcastCmd;
23 import org.opendaylight.netvirt.elan.l2gw.ha.commands.LogicalSwitchesCmd;
24 import org.opendaylight.netvirt.elan.l2gw.ha.commands.RemoteMcastCmd;
25 import org.opendaylight.netvirt.elan.l2gw.ha.commands.RemoteUcastCmd;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacs;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
37 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
38 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
39 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
40 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
41 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
46 * Created by ekvsver on 8/6/2016.
48 public class TestComparators {
49 static Logger LOG = LoggerFactory.getLogger(TestComparators.class);
51 public static void verifySwitches(Node globalOpNode, Node psOpNode) {
52 for (Switches switches : globalOpNode.getAugmentation(HwvtepGlobalAugmentation.class).getSwitches()) {
53 String switchValue = switches.getSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
54 assertEquals("Switch Name should be equal", switchValue, psOpNode.getNodeId().getValue());
58 public static void compareLogicalSwitches(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
59 LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
60 HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
61 HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
63 List<LogicalSwitches> d1Values =
64 d1Aug.getLogicalSwitches() != null ? d1Aug.getLogicalSwitches() : new ArrayList<LogicalSwitches>();
65 List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
66 List<LogicalSwitches> result2 = cmd.transform(nodePath, haAug.getLogicalSwitches());
68 Set<LogicalSwitches> set1 = Sets.newHashSet(result1);
69 Set<LogicalSwitches> set2 = Sets.newHashSet(result2);
70 assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
74 public static void compareLogicalSwitches(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
75 LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
76 HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
77 HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
78 HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
80 List<LogicalSwitches> d1Values =
81 d1Aug.getLogicalSwitches() != null ? d1Aug.getLogicalSwitches() : new ArrayList<LogicalSwitches>();
82 List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
83 List<LogicalSwitches> d2Values =
84 d2Aug.getLogicalSwitches() != null ? d2Aug.getLogicalSwitches() : new ArrayList<LogicalSwitches>();
85 List<LogicalSwitches> result2 = cmd.transform(nodePath, d2Values);
86 //Merge data of both d1 and d2 logical switch info should be same as ha
87 Set<LogicalSwitches> set1 = new HashSet<>();
90 List<LogicalSwitches> result = cmd.transform(nodePath, haAug.getLogicalSwitches());
91 Set<LogicalSwitches> set2 = Sets.newHashSet(result);
92 assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
96 public static void compareRemoteUcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
97 RemoteUcastCmd cmd = new RemoteUcastCmd();
98 HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
99 HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
100 List<RemoteUcastMacs> d1Values =
101 d1Aug.getRemoteUcastMacs() != null ? d1Aug.getRemoteUcastMacs() : new ArrayList<RemoteUcastMacs>();
102 List<RemoteUcastMacs> result1 = cmd.transform(nodePath, d1Values);
103 List<RemoteUcastMacs> result2 = cmd.transform(nodePath, haAug.getRemoteUcastMacs());
105 RemoteUcastMacs mac1 = result1.get(0);
106 RemoteUcastMacs mac2 = result2.get(0);
107 LOG.info("Mac1{} ", mac1);
108 LOG.info("Mac2{}", mac2);
109 Set<RemoteUcastMacs> set1 = Sets.newHashSet(result1);
110 Set<RemoteUcastMacs> set2 = Sets.newHashSet(result2);
111 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
114 public static void compareRemoteUcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
115 RemoteUcastCmd cmd = new RemoteUcastCmd();
116 HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
117 HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
118 HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
120 List<RemoteUcastMacs> d1Values =
121 d1Aug.getRemoteUcastMacs() != null ? d1Aug.getRemoteUcastMacs() : new ArrayList<RemoteUcastMacs>();
122 List<RemoteUcastMacs> result1 = cmd.transform(nodePath, d1Values);
124 List<RemoteUcastMacs> d2Values =
125 d2Aug.getRemoteUcastMacs() != null ? d2Aug.getRemoteUcastMacs() : new ArrayList<RemoteUcastMacs>();
126 List<RemoteUcastMacs> result2 = cmd.transform(nodePath, d2Values);
127 List<RemoteUcastMacs> ruMacList = new ArrayList<RemoteUcastMacs>();
128 ruMacList.addAll(result1);
129 ruMacList.addAll(result2);
130 List<RemoteUcastMacs> result = cmd.transform(nodePath, haAug.getRemoteUcastMacs());
132 Set<RemoteUcastMacs> set1 = Sets.newHashSet(ruMacList);
133 Set<RemoteUcastMacs> set2 = Sets.newHashSet(result);
134 assertEquals("should have equal remote ucast macs ", 0, Sets.difference(set1, set2).size());
138 public static void compareRemoteMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
139 RemoteMcastCmd cmd = new RemoteMcastCmd();
140 HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
141 HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
142 List<RemoteMcastMacs> d1Values =
143 d1Aug.getRemoteMcastMacs() != null ? d1Aug.getRemoteMcastMacs() : new ArrayList<RemoteMcastMacs>();
144 List<RemoteMcastMacs> result1 = cmd.transform(nodePath, d1Values);
145 List<RemoteMcastMacs> result2 = cmd.transform(nodePath, haAug.getRemoteMcastMacs());
147 Set<RemoteMcastMacs> set1 = Sets.newHashSet(result1);
148 Set<RemoteMcastMacs> set2 = Sets.newHashSet(result2);
149 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
153 public static void compareRemoteMcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
154 RemoteMcastCmd cmd = new RemoteMcastCmd();
155 HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
156 HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
157 HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
159 List<RemoteMcastMacs> d1Values =
160 d1Aug.getRemoteMcastMacs() != null ? d1Aug.getRemoteMcastMacs() : new ArrayList<RemoteMcastMacs>();
161 List<RemoteMcastMacs> result1 = cmd.transform(nodePath, d1Values);
163 List<RemoteMcastMacs> d2Values =
164 d2Aug.getRemoteMcastMacs() != null ? d2Aug.getRemoteMcastMacs() : new ArrayList<RemoteMcastMacs>();
165 List<RemoteMcastMacs> result2 = cmd.transform(nodePath, d2Values);
166 List<RemoteMcastMacs> rmMacList = new ArrayList<RemoteMcastMacs>();
167 rmMacList.addAll(result1);
168 rmMacList.addAll(result2);
170 List<RemoteMcastMacs> result = cmd.transform(nodePath, haAug.getRemoteMcastMacs());
172 Set<RemoteMcastMacs> set1 = Sets.newHashSet(rmMacList);
173 Set<RemoteMcastMacs> set2 = Sets.newHashSet(result);
174 assertEquals("should have equal remote Mcast macs ", 0, Sets.symmetricDifference(set1, set2).size());
178 public static void compareLocalUcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
179 LocalUcastCmd cmd = new LocalUcastCmd();
180 HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
181 HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
182 List<LocalUcastMacs> d1Values =
183 d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalUcastMacs() : new ArrayList<LocalUcastMacs>();
184 List<LocalUcastMacs> result1 = cmd.transform(nodePath, d1Values);
185 List<LocalUcastMacs> result2 = cmd.transform(nodePath, haAug.getLocalUcastMacs());
187 Set<LocalUcastMacs> set1 = Sets.newHashSet(result1);
188 Set<LocalUcastMacs> set2 = Sets.newHashSet(result2);
189 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
193 public static void compareLocalUcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
194 LocalUcastCmd cmd = new LocalUcastCmd();
195 HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
196 HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
197 HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
199 List<LocalUcastMacs> d1Values =
200 d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalUcastMacs() : new ArrayList<LocalUcastMacs>();
201 List<LocalUcastMacs> result1 = cmd.transform(nodePath, d1Values);
202 List<LocalUcastMacs> d2Values =
203 d2Aug.getLocalUcastMacs() != null ? d2Aug.getLocalUcastMacs() : new ArrayList<LocalUcastMacs>();
204 List<LocalUcastMacs> result2 = cmd.transform(nodePath, d2Values);
206 List<LocalUcastMacs> result = cmd.transform(nodePath, haAug.getLocalUcastMacs());
208 List<LocalUcastMacs> luMacList = new ArrayList<LocalUcastMacs>();
209 luMacList.addAll(result1);
210 luMacList.addAll(result2);
212 Set<LocalUcastMacs> set1 = Sets.newHashSet(luMacList);
213 Set<LocalUcastMacs> set2 = Sets.newHashSet(result);
214 assertEquals("should have equal Local ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
217 public static void compareLocalMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
218 LocalMcastCmd cmd = new LocalMcastCmd();
219 HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
220 HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
221 List<LocalMcastMacs> d1Values =
222 d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalMcastMacs() : new ArrayList<LocalMcastMacs>();
223 List<LocalMcastMacs> result1 = cmd.transform(nodePath, d1Values);
224 List<LocalMcastMacs> result2 = cmd.transform(nodePath, haAug.getLocalMcastMacs());
226 Set<LocalMcastMacs> set1 = Sets.newHashSet(result1);
227 Set<LocalMcastMacs> set2 = Sets.newHashSet(result2);
228 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
232 public static void compareLocalMcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
233 LocalMcastCmd cmd = new LocalMcastCmd();
234 HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
235 HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
236 HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
237 List<LocalMcastMacs> d1Values =
238 d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalMcastMacs() : new ArrayList<LocalMcastMacs>();
239 List<LocalMcastMacs> result1 = cmd.transform(nodePath, d1Values);
240 List<LocalMcastMacs> d2Values =
241 d2Aug.getLocalUcastMacs() != null ? d2Aug.getLocalMcastMacs() : new ArrayList<LocalMcastMacs>();
242 List<LocalMcastMacs> result2 = cmd.transform(nodePath, d2Values);
244 List<LocalMcastMacs> result = cmd.transform(nodePath, haAug.getLocalMcastMacs());
246 List<LocalMcastMacs> lmMacList = new ArrayList<LocalMcastMacs>();
247 lmMacList.addAll(result1);
248 lmMacList.addAll(result2);
250 Set<LocalMcastMacs> set1 = Sets.newHashSet(lmMacList);
251 Set<LocalMcastMacs> set2 = Sets.newHashSet(result);
252 assertEquals("should have equal Local Mcast macs ", 0, Sets.symmetricDifference(set1, set2).size());
256 public static void comparePhysicalSwitches(Node d1ps, Node d2ps, Node haps, InstanceIdentifier<Node> d1psnodePath,
257 InstanceIdentifier<Node> d2psnodePath,
258 InstanceIdentifier<Node> haPsnodePath,
259 ReadWriteTransaction readWriteTransaction, String switchName,
260 Node d1, Node d2, Node ha) throws ReadFailedException {
261 PhysicalSwitchAugmentation d1PsAug = d1ps.getAugmentation(PhysicalSwitchAugmentation.class);
262 PhysicalSwitchAugmentation d2PsAug = d2ps.getAugmentation(PhysicalSwitchAugmentation.class);
263 PhysicalSwitchAugmentation haPsAug = haps.getAugmentation(PhysicalSwitchAugmentation.class);
265 HwvtepGlobalRef managerd1Ps = d1PsAug.getManagedBy();
266 assertEquals("Hwvtep node name should be same", d1PsAug.getHwvtepNodeName().getValue(),
267 haPsAug.getHwvtepNodeName().getValue());
268 assertEquals("Managers should be equal for d1 ", d1ps.getNodeId().getValue(),
269 managerd1Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
270 HwvtepGlobalRef managerd2Ps = d2PsAug.getManagedBy();
271 assertEquals("Hwvtep node name should be same", d2PsAug.getHwvtepNodeName().getValue(),
272 haPsAug.getHwvtepNodeName().getValue());
273 assertEquals("Managers should be equal for d2 ", d2ps.getNodeId().getValue(),
274 managerd2Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
275 HwvtepGlobalRef managerhaPs = haPsAug.getManagedBy();
276 assertEquals("Managers should be equal for ha ", haps.getNodeId().getValue(),
277 managerhaPs.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
279 assertEquals("Should have equal number TunnelIps",
280 d1PsAug.getTunnelIps().size(), haPsAug.getTunnelIps().size());
281 assertEquals("Should have equal number TunnelIps",
282 d2PsAug.getTunnelIps().size(), haPsAug.getTunnelIps().size());
283 if (d1PsAug.getTunnelIps().size() == haPsAug.getTunnelIps().size()
284 && d2PsAug.getTunnelIps().size() == haPsAug.getTunnelIps().size()) {
285 assertTrue(d1PsAug.getTunnelIps().containsAll(haPsAug.getTunnelIps()));
286 assertTrue(d2PsAug.getTunnelIps().containsAll(haPsAug.getTunnelIps()));
289 //Compare Termination point
290 assertTerminationPoint(DataProvider.getPortNameListD1(),
291 d1psnodePath, haPsnodePath, readWriteTransaction, d1, ha);
292 assertTerminationPoint(DataProvider.getPortNameListD2(),
293 d2psnodePath, haPsnodePath, readWriteTransaction, d2, ha);
296 public static void comparePhysicalSwitches(Node d1ps, Node haps, InstanceIdentifier<Node> d1psnodePath,
297 InstanceIdentifier<Node> haPsnodePath,
298 ReadWriteTransaction readWriteTransaction,
299 String switchName, Node d1, Node ha) throws ReadFailedException {
300 //Compare Physical Augmentation data
301 PhysicalSwitchAugmentation d1PsAug = d1ps.getAugmentation(PhysicalSwitchAugmentation.class);
302 PhysicalSwitchAugmentation haPsAug = haps.getAugmentation(PhysicalSwitchAugmentation.class);
304 HwvtepGlobalRef managerd1Ps = d1PsAug.getManagedBy();
305 assertEquals("Hwvtep node name should be same", d1PsAug.getHwvtepNodeName().getValue(),
306 haPsAug.getHwvtepNodeName().getValue());
307 assertEquals("Managers should be equal for d1 ", d1ps.getNodeId().getValue(),
308 managerd1Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
309 HwvtepGlobalRef managerhaPs = haPsAug.getManagedBy();
310 assertEquals("Managers should be equal for ha ", haps.getNodeId().getValue(),
311 managerhaPs.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
313 assertEquals("Should have equal number TunnelIps", d1PsAug.getTunnelIps().size(),
314 haPsAug.getTunnelIps().size());
315 if (d1PsAug.getTunnelIps().size() == haPsAug.getTunnelIps().size()) {
316 assertTrue(d1PsAug.getTunnelIps().containsAll(haPsAug.getTunnelIps()));
319 //Compare Termination point
320 assertTerminationPoint(DataProvider.getPortNameListD1(), d1psnodePath, haPsnodePath,
321 readWriteTransaction, d1, ha);
324 public static void assertTerminationPoint(List<String> terminationPointNames, InstanceIdentifier<Node> d1ps,
325 InstanceIdentifier<Node> haPsa, ReadWriteTransaction readWriteTransaction,
326 Node nodeD, Node nodeHa) throws ReadFailedException {
327 for (String portName : terminationPointNames) {
328 InstanceIdentifier<TerminationPoint> tpPathd = d1ps.child(TerminationPoint.class,
329 new TerminationPointKey(new TpId(portName)));
330 TerminationPoint tpNoded = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathd)
332 HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationD =
333 tpNoded.getAugmentation(HwvtepPhysicalPortAugmentation.class);
335 InstanceIdentifier<TerminationPoint> tpPathha = haPsa.child(TerminationPoint.class,
336 new TerminationPointKey(new TpId(portName)));
337 TerminationPoint tpNodeha = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathha)
339 HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationHa =
340 tpNodeha.getAugmentation(HwvtepPhysicalPortAugmentation.class);
341 assertEquals("Termination point hwvtep-node-name should be same",
342 hwvtepPhysicalPortAugmentationD.getHwvtepNodeName(),
343 hwvtepPhysicalPortAugmentationHa.getHwvtepNodeName());
345 List<VlanBindings> vlanBindingsesD = hwvtepPhysicalPortAugmentationD.getVlanBindings();
346 List<VlanBindings> vlanBindingsesHa = hwvtepPhysicalPortAugmentationHa.getVlanBindings();
347 assertEquals("Size of VlanBindings should be same", vlanBindingsesD.size(), vlanBindingsesHa.size());
349 List<Integer> vlanKeysD = new ArrayList<>();
350 List<Integer> vlanKeysHa = new ArrayList<>();
351 String logicalSwitchRefD = new String();
352 String logicalSwitchRefHa = new String();
353 List<String> logicalSwitchNameD = new ArrayList<>();
354 List<String> logicalSwitchNameHa = new ArrayList<>();
355 if (vlanBindingsesD.size() == vlanBindingsesHa.size()) {
356 for (int i = 0; i < vlanBindingsesD.size(); i++) {
357 vlanKeysD.add(vlanBindingsesD.get(i).getVlanIdKey().getValue());
358 logicalSwitchRefD = vlanBindingsesD.get(i).getLogicalSwitchRef().getValue()
359 .firstKeyOf(Node.class).getNodeId().getValue();
360 logicalSwitchNameD.add(vlanBindingsesD.get(i).getLogicalSwitchRef().getValue()
361 .firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
363 vlanKeysHa.add(vlanBindingsesHa.get(i).getVlanIdKey().getValue());
364 logicalSwitchRefHa = vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue()
365 .firstKeyOf(Node.class).getNodeId().getValue();
366 logicalSwitchNameHa.add(vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue()
367 .firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
369 assertTrue(vlanKeysD.containsAll(vlanKeysHa));
370 assertTrue(logicalSwitchRefD.equals(nodeD.getNodeId().getValue()));
371 assertTrue(logicalSwitchRefHa.equals(nodeHa.getNodeId().getValue()));
372 assertTrue(logicalSwitchNameD.containsAll(logicalSwitchNameHa));