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 java.util.concurrent.ExecutionException;
19 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
20 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
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._switch.attributes.TunnelIps;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
38 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
39 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
40 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
41 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
42 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
47 * Created by ekvsver on 8/6/2016.
49 public final class TestComparators {
50 static Logger LOG = LoggerFactory.getLogger(TestComparators.class);
52 private TestComparators() {
56 public static void verifySwitches(Node globalOpNode, Node psOpNode) {
57 for (Switches switches : globalOpNode.augmentation(HwvtepGlobalAugmentation.class)
58 .nonnullSwitches().values()) {
59 String switchValue = switches.getSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
60 assertEquals("Switch Name should be equal", switchValue, psOpNode.getNodeId().getValue());
64 public static void compareLogicalSwitches(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
65 LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
66 HwvtepGlobalAugmentation d1Aug = src.augmentation(HwvtepGlobalAugmentation.class);
67 HwvtepGlobalAugmentation haAug = dst.augmentation(HwvtepGlobalAugmentation.class);
69 List<LogicalSwitches> d1Values =
70 d1Aug.getLogicalSwitches() != null
71 ? new ArrayList<LogicalSwitches>(d1Aug.nonnullLogicalSwitches().values()) : new ArrayList<>();
72 List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
73 List<LogicalSwitches> result2 = cmd.transform(nodePath,
74 new ArrayList<LogicalSwitches>(haAug.nonnullLogicalSwitches().values()));
76 Set<LogicalSwitches> set1 = Sets.newHashSet(result1);
77 Set<LogicalSwitches> set2 = Sets.newHashSet(result2);
78 assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
82 public static void compareLogicalSwitches(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
83 LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
84 HwvtepGlobalAugmentation d1Aug = d1.augmentation(HwvtepGlobalAugmentation.class);
85 HwvtepGlobalAugmentation d2Aug = d2.augmentation(HwvtepGlobalAugmentation.class);
86 HwvtepGlobalAugmentation haAug = ha.augmentation(HwvtepGlobalAugmentation.class);
88 List<LogicalSwitches> d1Values =
89 d1Aug.getLogicalSwitches() != null
90 ? new ArrayList<LogicalSwitches>(d1Aug.nonnullLogicalSwitches().values()) : new ArrayList<>();
91 List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
92 List<LogicalSwitches> d2Values =
93 d2Aug.getLogicalSwitches() != null
94 ? new ArrayList<LogicalSwitches>(d2Aug.nonnullLogicalSwitches().values()) : new ArrayList<>();
95 List<LogicalSwitches> result2 = cmd.transform(nodePath, d2Values);
96 //Merge data of both d1 and d2 logical switch info should be same as ha
97 Set<LogicalSwitches> set1 = new HashSet<>();
100 List<LogicalSwitches> result = cmd.transform(nodePath,
101 new ArrayList<LogicalSwitches>(haAug.nonnullLogicalSwitches().values()));
102 Set<LogicalSwitches> set2 = Sets.newHashSet(result);
103 assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
107 public static void compareRemoteUcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
108 RemoteUcastCmd cmd = new RemoteUcastCmd();
109 HwvtepGlobalAugmentation d1Aug = src.augmentation(HwvtepGlobalAugmentation.class);
110 HwvtepGlobalAugmentation haAug = dst.augmentation(HwvtepGlobalAugmentation.class);
111 List<RemoteUcastMacs> d1Values =
112 d1Aug.getRemoteUcastMacs() != null
113 ? new ArrayList<RemoteUcastMacs>(d1Aug.nonnullRemoteUcastMacs().values()) : new ArrayList<>();
114 List<RemoteUcastMacs> result1 = cmd.transform(nodePath, d1Values);
115 List<RemoteUcastMacs> result2 = cmd.transform(nodePath,
116 new ArrayList<RemoteUcastMacs>(haAug.nonnullRemoteUcastMacs().values()));
118 RemoteUcastMacs mac1 = result1.get(0);
119 RemoteUcastMacs mac2 = result2.get(0);
120 LOG.info("Mac1{} ", mac1);
121 LOG.info("Mac2{}", mac2);
122 Set<RemoteUcastMacs> set1 = Sets.newHashSet(result1);
123 Set<RemoteUcastMacs> set2 = Sets.newHashSet(result2);
124 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
127 public static void compareRemoteUcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
128 RemoteUcastCmd cmd = new RemoteUcastCmd();
129 HwvtepGlobalAugmentation d1Aug = d1.augmentation(HwvtepGlobalAugmentation.class);
130 HwvtepGlobalAugmentation d2Aug = d2.augmentation(HwvtepGlobalAugmentation.class);
131 HwvtepGlobalAugmentation haAug = ha.augmentation(HwvtepGlobalAugmentation.class);
133 List<RemoteUcastMacs> d1Values =
134 d1Aug.getRemoteUcastMacs() != null
135 ? new ArrayList<RemoteUcastMacs>(d1Aug.nonnullRemoteUcastMacs().values()) : new ArrayList<>();
136 List<RemoteUcastMacs> result1 = cmd.transform(nodePath, d1Values);
138 List<RemoteUcastMacs> d2Values =
139 d2Aug.getRemoteUcastMacs() != null
140 ? new ArrayList<RemoteUcastMacs>(d2Aug.nonnullRemoteUcastMacs().values()) : new ArrayList<>();
141 List<RemoteUcastMacs> result2 = cmd.transform(nodePath, d2Values);
142 List<RemoteUcastMacs> ruMacList = new ArrayList<>();
143 ruMacList.addAll(result1);
144 ruMacList.addAll(result2);
145 List<RemoteUcastMacs> result = cmd.transform(nodePath,
146 new ArrayList<RemoteUcastMacs>(haAug.nonnullRemoteUcastMacs().values()));
148 Set<RemoteUcastMacs> set1 = Sets.newHashSet(ruMacList);
149 Set<RemoteUcastMacs> set2 = Sets.newHashSet(result);
150 assertEquals("should have equal remote ucast macs ", 0, Sets.difference(set1, set2).size());
154 public static void compareRemoteMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
155 RemoteMcastCmd cmd = new RemoteMcastCmd();
156 HwvtepGlobalAugmentation d1Aug = src.augmentation(HwvtepGlobalAugmentation.class);
157 HwvtepGlobalAugmentation haAug = dst.augmentation(HwvtepGlobalAugmentation.class);
158 List<RemoteMcastMacs> d1Values =
159 d1Aug.getRemoteMcastMacs() != null
160 ? new ArrayList<RemoteMcastMacs>(d1Aug.nonnullRemoteMcastMacs().values()) : new ArrayList<>();
161 List<RemoteMcastMacs> result1 = cmd.transform(nodePath, d1Values);
162 List<RemoteMcastMacs> result2 = cmd.transform(nodePath,
163 new ArrayList<RemoteMcastMacs>(haAug.nonnullRemoteMcastMacs().values()));
165 Set<RemoteMcastMacs> set1 = Sets.newHashSet(result1);
166 Set<RemoteMcastMacs> set2 = Sets.newHashSet(result2);
167 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
171 public static void compareRemoteMcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
172 RemoteMcastCmd cmd = new RemoteMcastCmd();
173 HwvtepGlobalAugmentation d1Aug = d1.augmentation(HwvtepGlobalAugmentation.class);
174 HwvtepGlobalAugmentation d2Aug = d2.augmentation(HwvtepGlobalAugmentation.class);
175 HwvtepGlobalAugmentation haAug = ha.augmentation(HwvtepGlobalAugmentation.class);
177 List<RemoteMcastMacs> d1Values =
178 d1Aug.getRemoteMcastMacs() != null
179 ? new ArrayList<RemoteMcastMacs>(d1Aug.nonnullRemoteMcastMacs().values()) : new ArrayList<>();
180 List<RemoteMcastMacs> result1 = cmd.transform(nodePath, d1Values);
182 List<RemoteMcastMacs> d2Values =
183 d2Aug.getRemoteMcastMacs() != null
184 ? new ArrayList<RemoteMcastMacs>(d2Aug.nonnullRemoteMcastMacs().values()) : new ArrayList<>();
185 List<RemoteMcastMacs> result2 = cmd.transform(nodePath, d2Values);
186 List<RemoteMcastMacs> rmMacList = new ArrayList<>();
187 rmMacList.addAll(result1);
188 rmMacList.addAll(result2);
190 List<RemoteMcastMacs> result = cmd.transform(nodePath,
191 new ArrayList<RemoteMcastMacs>(haAug.nonnullRemoteMcastMacs().values()));
193 Set<RemoteMcastMacs> set1 = Sets.newHashSet(rmMacList);
194 Set<RemoteMcastMacs> set2 = Sets.newHashSet(result);
195 assertEquals("should have equal remote Mcast macs ", 0, Sets.symmetricDifference(set1, set2).size());
199 public static void compareLocalUcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
200 LocalUcastCmd cmd = new LocalUcastCmd();
201 HwvtepGlobalAugmentation d1Aug = src.augmentation(HwvtepGlobalAugmentation.class);
202 HwvtepGlobalAugmentation haAug = dst.augmentation(HwvtepGlobalAugmentation.class);
203 List<LocalUcastMacs> d1Values =
204 d1Aug.getLocalUcastMacs() != null
205 ? new ArrayList<LocalUcastMacs>(d1Aug.nonnullLocalUcastMacs().values()) : new ArrayList<>();
206 List<LocalUcastMacs> result1 = cmd.transform(nodePath, d1Values);
207 List<LocalUcastMacs> result2 = cmd.transform(nodePath,
208 new ArrayList<LocalUcastMacs>(haAug.nonnullLocalUcastMacs().values()));
210 Set<LocalUcastMacs> set1 = Sets.newHashSet(result1);
211 Set<LocalUcastMacs> set2 = Sets.newHashSet(result2);
212 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
216 public static void compareLocalUcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
217 LocalUcastCmd cmd = new LocalUcastCmd();
218 HwvtepGlobalAugmentation d1Aug = d1.augmentation(HwvtepGlobalAugmentation.class);
219 HwvtepGlobalAugmentation d2Aug = d2.augmentation(HwvtepGlobalAugmentation.class);
220 HwvtepGlobalAugmentation haAug = ha.augmentation(HwvtepGlobalAugmentation.class);
222 List<LocalUcastMacs> d1Values =
223 d1Aug.getLocalUcastMacs() != null
224 ? new ArrayList<LocalUcastMacs>(d1Aug.nonnullLocalUcastMacs().values()) : new ArrayList<>();
225 List<LocalUcastMacs> result1 = cmd.transform(nodePath, d1Values);
226 List<LocalUcastMacs> d2Values =
227 d2Aug.getLocalUcastMacs() != null
228 ? new ArrayList<LocalUcastMacs>(d2Aug.nonnullLocalUcastMacs().values()) : new ArrayList<>();
229 List<LocalUcastMacs> result2 = cmd.transform(nodePath, d2Values);
231 List<LocalUcastMacs> result = cmd.transform(nodePath,
232 new ArrayList<LocalUcastMacs>(haAug.nonnullLocalUcastMacs().values()));
234 List<LocalUcastMacs> luMacList = new ArrayList<>();
235 luMacList.addAll(result1);
236 luMacList.addAll(result2);
238 Set<LocalUcastMacs> set1 = Sets.newHashSet(luMacList);
239 Set<LocalUcastMacs> set2 = Sets.newHashSet(result);
240 assertEquals("should have equal Local ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
243 public static void compareLocalMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
244 LocalMcastCmd cmd = new LocalMcastCmd();
245 HwvtepGlobalAugmentation d1Aug = src.augmentation(HwvtepGlobalAugmentation.class);
246 HwvtepGlobalAugmentation haAug = dst.augmentation(HwvtepGlobalAugmentation.class);
247 List<LocalMcastMacs> d1Values =
248 d1Aug.getLocalUcastMacs() != null
249 ? new ArrayList<LocalMcastMacs>(d1Aug.nonnullLocalMcastMacs().values()) : new ArrayList<>();
250 List<LocalMcastMacs> result1 = cmd.transform(nodePath, d1Values);
251 List<LocalMcastMacs> result2 = cmd.transform(nodePath,
252 new ArrayList<LocalMcastMacs>(haAug.nonnullLocalMcastMacs().values()));
254 Set<LocalMcastMacs> set1 = Sets.newHashSet(result1);
255 Set<LocalMcastMacs> set2 = Sets.newHashSet(result2);
256 assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
260 public static void compareLocalMcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
261 LocalMcastCmd cmd = new LocalMcastCmd();
262 HwvtepGlobalAugmentation d1Aug = d1.augmentation(HwvtepGlobalAugmentation.class);
263 HwvtepGlobalAugmentation d2Aug = d2.augmentation(HwvtepGlobalAugmentation.class);
264 HwvtepGlobalAugmentation haAug = ha.augmentation(HwvtepGlobalAugmentation.class);
265 List<LocalMcastMacs> d1Values =
266 d1Aug.nonnullLocalMcastMacs() != null
267 ? new ArrayList<LocalMcastMacs>(d1Aug.nonnullLocalMcastMacs().values()) : new ArrayList<>();
268 List<LocalMcastMacs> result1 = cmd.transform(nodePath, d1Values);
269 List<LocalMcastMacs> d2Values =
270 d2Aug.nonnullLocalMcastMacs() != null
271 ? new ArrayList<LocalMcastMacs>(d2Aug.nonnullLocalMcastMacs().values()) : new ArrayList<>();
272 List<LocalMcastMacs> result2 = cmd.transform(nodePath, d2Values);
274 List<LocalMcastMacs> result = cmd.transform(nodePath,
275 new ArrayList<LocalMcastMacs>(haAug.nonnullLocalMcastMacs().values()));
277 List<LocalMcastMacs> lmMacList = new ArrayList<>();
278 lmMacList.addAll(result1);
279 lmMacList.addAll(result2);
281 Set<LocalMcastMacs> set1 = Sets.newHashSet(lmMacList);
282 Set<LocalMcastMacs> set2 = Sets.newHashSet(result);
283 assertEquals("should have equal Local Mcast macs ", 0, Sets.symmetricDifference(set1, set2).size());
287 public static void comparePhysicalSwitches(Node d1ps, Node d2ps, Node haps, InstanceIdentifier<Node> d1psnodePath,
288 InstanceIdentifier<Node> d2psnodePath,
289 InstanceIdentifier<Node> haPsnodePath,
290 ReadWriteTransaction readWriteTransaction, String switchName,
291 Node d1, Node d2, Node ha)
292 throws ExecutionException, InterruptedException {
294 PhysicalSwitchAugmentation d1PsAug = d1ps.augmentation(PhysicalSwitchAugmentation.class);
295 PhysicalSwitchAugmentation d2PsAug = d2ps.augmentation(PhysicalSwitchAugmentation.class);
296 PhysicalSwitchAugmentation haPsAug = haps.augmentation(PhysicalSwitchAugmentation.class);
298 HwvtepGlobalRef managerd1Ps = d1PsAug.getManagedBy();
299 assertEquals("Hwvtep node name should be same", d1PsAug.getHwvtepNodeName().getValue(),
300 haPsAug.getHwvtepNodeName().getValue());
301 assertEquals("Managers should be equal for d1 ", d1ps.getNodeId().getValue(),
302 managerd1Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
303 HwvtepGlobalRef managerd2Ps = d2PsAug.getManagedBy();
304 assertEquals("Hwvtep node name should be same", d2PsAug.getHwvtepNodeName().getValue(),
305 haPsAug.getHwvtepNodeName().getValue());
306 assertEquals("Managers should be equal for d2 ", d2ps.getNodeId().getValue(),
307 managerd2Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
308 HwvtepGlobalRef managerhaPs = haPsAug.getManagedBy();
309 assertEquals("Managers should be equal for ha ", haps.getNodeId().getValue(),
310 managerhaPs.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
312 assertEquals("Should have equal number TunnelIps",
313 d1PsAug.nonnullTunnelIps().size(), haPsAug.nonnullTunnelIps().size());
314 assertEquals("Should have equal number TunnelIps",
315 d2PsAug.nonnullTunnelIps().size(), haPsAug.nonnullTunnelIps().size());
316 if (d1PsAug.nonnullTunnelIps().size() == haPsAug.nonnullTunnelIps().size()
317 && d2PsAug.nonnullTunnelIps().size() == haPsAug.nonnullTunnelIps().size()) {
318 assertTrue(d1PsAug.nonnullTunnelIps().values().containsAll(
319 new ArrayList<TunnelIps>(haPsAug.nonnullTunnelIps().values())));
320 assertTrue(d2PsAug.nonnullTunnelIps().values().containsAll(
321 new ArrayList<TunnelIps>(haPsAug.nonnullTunnelIps().values())));
324 //Compare Termination point
325 assertTerminationPoint(DataProvider.getPortNameListD1(),
326 d1psnodePath, haPsnodePath, readWriteTransaction, d1, ha);
327 assertTerminationPoint(DataProvider.getPortNameListD2(),
328 d2psnodePath, haPsnodePath, readWriteTransaction, d2, ha);
331 public static void comparePhysicalSwitches(Node d1ps, Node haps, InstanceIdentifier<Node> d1psnodePath,
332 InstanceIdentifier<Node> haPsnodePath,
333 ReadWriteTransaction readWriteTransaction,
334 String switchName, Node d1, Node ha)
335 throws ExecutionException, InterruptedException {
336 //Compare Physical Augmentation data
337 PhysicalSwitchAugmentation d1PsAug = d1ps.augmentation(PhysicalSwitchAugmentation.class);
338 PhysicalSwitchAugmentation haPsAug = haps.augmentation(PhysicalSwitchAugmentation.class);
340 HwvtepGlobalRef managerd1Ps = d1PsAug.getManagedBy();
341 assertEquals("Hwvtep node name should be same", d1PsAug.getHwvtepNodeName().getValue(),
342 haPsAug.getHwvtepNodeName().getValue());
343 assertEquals("Managers should be equal for d1 ", d1ps.getNodeId().getValue(),
344 managerd1Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
345 HwvtepGlobalRef managerhaPs = haPsAug.getManagedBy();
346 assertEquals("Managers should be equal for ha ", haps.getNodeId().getValue(),
347 managerhaPs.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
349 assertEquals("Should have equal number TunnelIps", d1PsAug.nonnullTunnelIps().size(),
350 haPsAug.nonnullTunnelIps().size());
351 if (d1PsAug.nonnullTunnelIps().size() == haPsAug.nonnullTunnelIps().size()) {
352 assertTrue(d1PsAug.nonnullTunnelIps().values().containsAll(
353 new ArrayList<TunnelIps>(haPsAug.nonnullTunnelIps().values())));
356 //Compare Termination point
357 assertTerminationPoint(DataProvider.getPortNameListD1(), d1psnodePath, haPsnodePath,
358 readWriteTransaction, d1, ha);
361 public static void assertTerminationPoint(List<String> terminationPointNames, InstanceIdentifier<Node> d1ps,
362 InstanceIdentifier<Node> haPsa, ReadWriteTransaction readWriteTransaction,
363 Node nodeD, Node nodeHa) throws ExecutionException, InterruptedException {
364 for (String portName : terminationPointNames) {
365 InstanceIdentifier<TerminationPoint> tpPathd = d1ps.child(TerminationPoint.class,
366 new TerminationPointKey(new TpId(portName)));
367 TerminationPoint tpNoded = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathd)
369 HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationD =
370 tpNoded.augmentation(HwvtepPhysicalPortAugmentation.class);
372 InstanceIdentifier<TerminationPoint> tpPathha = haPsa.child(TerminationPoint.class,
373 new TerminationPointKey(new TpId(portName)));
374 TerminationPoint tpNodeha = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathha)
376 HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationHa =
377 tpNodeha.augmentation(HwvtepPhysicalPortAugmentation.class);
378 assertEquals("Termination point hwvtep-node-name should be same",
379 hwvtepPhysicalPortAugmentationD.getHwvtepNodeName(),
380 hwvtepPhysicalPortAugmentationHa.getHwvtepNodeName());
382 List<VlanBindings> vlanBindingsesD
383 = new ArrayList<VlanBindings>(hwvtepPhysicalPortAugmentationD.nonnullVlanBindings().values());
384 List<VlanBindings> vlanBindingsesHa
385 = new ArrayList<VlanBindings>(hwvtepPhysicalPortAugmentationHa.nonnullVlanBindings().values());
386 assertEquals("Size of VlanBindings should be same", vlanBindingsesD.size(), vlanBindingsesHa.size());
388 List<Integer> vlanKeysD = new ArrayList<>();
389 List<Integer> vlanKeysHa = new ArrayList<>();
390 String logicalSwitchRefD = new String();
391 String logicalSwitchRefHa = new String();
392 List<String> logicalSwitchNameD = new ArrayList<>();
393 List<String> logicalSwitchNameHa = new ArrayList<>();
394 if (vlanBindingsesD.size() == vlanBindingsesHa.size()) {
395 for (int i = 0; i < vlanBindingsesD.size(); i++) {
396 vlanKeysD.add(vlanBindingsesD.get(i).getVlanIdKey().getValue().toJava());
397 logicalSwitchRefD = vlanBindingsesD.get(i).getLogicalSwitchRef().getValue()
398 .firstKeyOf(Node.class).getNodeId().getValue();
399 logicalSwitchNameD.add(vlanBindingsesD.get(i).getLogicalSwitchRef().getValue()
400 .firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
402 vlanKeysHa.add(vlanBindingsesHa.get(i).getVlanIdKey().getValue().toJava());
403 logicalSwitchRefHa = vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue()
404 .firstKeyOf(Node.class).getNodeId().getValue();
405 logicalSwitchNameHa.add(vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue()
406 .firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
408 assertTrue(vlanKeysD.containsAll(vlanKeysHa));
409 assertTrue(logicalSwitchRefD.equals(nodeD.getNodeId().getValue()));
410 assertTrue(logicalSwitchRefHa.equals(nodeHa.getNodeId().getValue()));
411 assertTrue(logicalSwitchNameD.containsAll(logicalSwitchNameHa));