2 * Copyright © 2020 Orange Labs, Inc. 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.transportpce.networkmodel.util;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.CoreMatchers.not;
15 import static org.hamcrest.MatcherAssert.assertThat;
16 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
17 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.fail;
24 import com.google.gson.stream.JsonReader;
25 import java.io.FileReader;
26 import java.io.IOException;
27 import java.io.Reader;
28 import java.nio.charset.StandardCharsets;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
33 import java.util.stream.Collectors;
34 import org.junit.Test;
35 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
36 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
37 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.Network;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.MappingBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.MappingKey;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.NodesBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.nodes.NodeInfoBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2e;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
65 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType;
66 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
70 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
71 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
72 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
73 import org.opendaylight.yangtools.yang.common.QName;
74 import org.opendaylight.yangtools.yang.common.Uint16;
75 import org.opendaylight.yangtools.yang.common.Uint32;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
79 public class OpenRoadmOtnTopologyTest {
81 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
82 private Nodes portMappingTpdr;
83 private Nodes portMappingSpdr;
84 private Nodes portMappingBad;
86 public OpenRoadmOtnTopologyTest() {
87 try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
88 JsonReader portMappingReader = new JsonReader(reader)) {
89 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
90 QName.create("http://org/opendaylight/transportpce/portmapping", "2021-04-26", "network"));
91 for (Nodes nodes : portMapping.nonnullNodes().values()) {
92 if (nodes.getNodeId().equals("XPDR-A1")) {
93 this.portMappingTpdr = nodes;
95 this.portMappingSpdr = nodes;
98 Map<MappingKey,Mapping> mappingList = new HashMap<>();
99 Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
100 mappingList.put(mapping.key(),mapping);
101 this.portMappingBad = new NodesBuilder()
102 .setNodeId(this.portMappingTpdr.getNodeId())
103 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
104 .setMapping(mappingList)
106 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
107 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
108 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
109 } catch (IOException e) {
110 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
111 fail("Cannot init OpenRoadmOtnTopologyTest ");
116 public void createTopologyShardForTpdrTest() {
117 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
118 assertNotNull("TopologyShard should never be null", topologyShard);
119 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
120 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
121 Node node = topologyShard.getNodes().get(0);
122 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
123 // tests supporting nodes
124 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
125 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
126 .collect(Collectors.toList());
127 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
128 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
129 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
130 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
131 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
132 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
133 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
134 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
138 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
142 List<TerminationPoint> tps = node.augmentation(
143 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
144 .nonnullTerminationPoint().values().stream()
145 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
146 .collect(Collectors.toList());
147 assertEquals("node should contain 4 TPs", 4, tps.size());
149 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
152 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
154 "only If100GE interface capabitily expected",
156 tps.get(0).augmentation(
157 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
158 .TerminationPoint1.class)
159 .getTpSupportedInterfaces()
160 .getSupportedInterfaceCapability()
163 If100GE.class.getName(),
164 tps.get(0).augmentation(
165 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
166 .TerminationPoint1.class)
167 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
168 .values().stream().findFirst()
169 .get().getIfCapType().getName());
171 "first TP must be of type client",
172 OpenroadmTpType.XPONDERCLIENT,
173 tps.get(0).augmentation(
174 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
175 .TerminationPoint1.class)
178 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
181 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
183 "only IfOCH interface capabitily expected",
185 tps.get(2).augmentation(
186 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
187 .TerminationPoint1.class)
188 .getTpSupportedInterfaces()
189 .getSupportedInterfaceCapability()
192 IfOCH.class.getName(),
193 tps.get(2).augmentation(
194 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
195 .TerminationPoint1.class)
196 .getTpSupportedInterfaces()
197 .getSupportedInterfaceCapability()
198 .values().stream().findFirst()
203 "the rate should be null",
204 tps.get(2).augmentation(
205 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
206 .TerminationPoint1.class)
207 .getXpdrTpPortConnectionAttributes()
210 "third TP must be of type network",
211 OpenroadmTpType.XPONDERNETWORK,
212 tps.get(2).augmentation(
213 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
218 public void createTopologyShardForSpdrTest() {
219 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
220 assertNotNull("TopologyShard should never be null", topologyShard);
221 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
222 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
223 List<Node> nodes = topologyShard.getNodes().stream()
224 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
225 .collect(Collectors.toList());
226 for (Node node : nodes) {
232 public void createOtnLinksForOTU4NormalTest() {
233 String nodeA = "SPDRA";
234 String tpA = "XPDR1-NETWORK1";
235 String nodeZ = "SPDRZ";
236 String tpZ = "XPDR1-NETWORK1";
237 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
238 assertEquals("2 OTU4 links should have been created", 2, links.size());
239 List<Link> sortedLinks = links.stream()
240 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
241 .collect(Collectors.toList());
243 "name of OTU4 linkid AZ",
244 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
245 sortedLinks.get(0).getLinkId().getValue());
247 "name of OTU4 linkid ZA",
248 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
249 sortedLinks.get(1).getLinkId().getValue());
250 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
251 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
252 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
253 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
255 "available BW at OTU4 creation should be 100G (100000)",
256 Uint32.valueOf(100000),
257 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
259 "used BW at OTU4 creation should be 0",
261 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
263 OpenroadmLinkType.OTNLINK,
264 sortedLinks.get(0).augmentation(
265 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
268 "opposite link must be present",
269 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
270 sortedLinks.get(0).augmentation(
271 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
275 "otn link type should be OTU4",
277 sortedLinks.get(0).augmentation(
278 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class)
283 public void createOtnLinksForNotManagedOtnlinktypeTest() {
284 String nodeA = "SPDRA";
285 String tpA = "XPDR1-NETWORK1";
286 String nodeZ = "SPDRZ";
287 String tpZ = "XPDR1-NETWORK1";
288 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
289 assertNotNull("TopologyShard should never be null", topoShard);
290 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
291 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
295 public void createOtnLinksForODU4NormalTest() {
296 TopologyShard topoShard = OpenRoadmOtnTopology
298 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
299 NetworkmodelTestUtil.createTpList(false));
300 assertNotNull("TopologyShard should never be null", topoShard);
301 assertNull("list of nodes should be null", topoShard.getNodes());
302 List<Link> sortedLinks = topoShard.getLinks().stream()
303 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
304 .collect(Collectors.toList());
305 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
306 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
308 "after odu4 creation, available BW of supported OTU4 should be 0",
310 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
312 "after odu4 creation, used BW of supported OTU4 should be 100 000",
313 Uint32.valueOf(100000),
314 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
317 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
318 sortedLinks.get(0).getLinkId().getValue());
320 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
321 sortedLinks.get(1).getLinkId().getValue());
322 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
323 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
324 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
325 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
327 "after odu4 creation, its available BW should be 100 000",
328 Uint32.valueOf(100000),
329 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
331 "after odu4 creation, its used BW should be 0",
333 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
335 OpenroadmLinkType.OTNLINK,
338 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
341 "opposite link must be present",
342 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
345 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
349 "otn link type should be ODTU4",
353 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.Link1.class)
356 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
358 "after ODU4 creation, its termination point should contain a TsPool list",
359 topoShard.getTps().get(0)
361 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
362 .TerminationPoint1.class)
363 .getXpdrTpPortConnectionAttributes()
366 "Ts pool list should be full, with 80 trib slots",
368 topoShard.getTps().get(0)
370 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
371 .TerminationPoint1.class)
372 .getXpdrTpPortConnectionAttributes()
376 "after ODU4 creation, its termination point should contain a TpnPool list",
377 topoShard.getTps().get(0)
379 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
380 .TerminationPoint1.class)
381 .getXpdrTpPortConnectionAttributes()
382 .getOdtuTpnPool().values().stream().findFirst()
386 "Tpn pool list should be full, with 80 trib ports",
388 topoShard.getTps().get(0)
390 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
391 .TerminationPoint1.class)
392 .getXpdrTpPortConnectionAttributes()
393 .getOdtuTpnPool().values().stream().findFirst()
400 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
401 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
402 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
403 for (Link link : otu4Links) {
404 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
406 TopologyShard topoShard =
407 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
408 assertNotNull("TopologyShard should never be null", topoShard);
409 assertNull("list of nodes should be null", topoShard.getNodes());
410 assertNull("list of links should be null", topoShard.getLinks());
411 assertNull("list of tps should be null", topoShard.getTps());
413 otu4LinksWithBadBWParam.clear();
415 OpenRoadmOtnTopology.createOtnLinks(
416 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
417 NetworkmodelTestUtil.createTpList(false));
418 assertNull("list of nodes should be null", topoShard.getNodes());
419 assertNull("list of links should be null", topoShard.getLinks());
420 assertNull("list of tps should be null", topoShard.getTps());
424 public void deleteOtnLinksForODU4NormalTest() {
425 TopologyShard topoShard =
426 OpenRoadmOtnTopology.deleteOtnLinks(
427 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
428 NetworkmodelTestUtil.createTpList(true));
429 assertNotNull("TopologyShard should never be null", topoShard);
430 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
432 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
433 Uint32.valueOf(100000),
434 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
436 "after ODU4 deletion, used BW of supported OTU4 should be 0",
438 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
440 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
442 "after ODU4 deletion, its termination points should not contain any TsPool list",
443 topoShard.getTps().get(0)
445 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
446 .TerminationPoint1.class)
447 .getXpdrTpPortConnectionAttributes()
450 "after ODU4 deletion, its termination points should not contain any TpnPool list",
451 topoShard.getTps().get(0)
453 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
454 .TerminationPoint1.class)
455 .getXpdrTpPortConnectionAttributes()
460 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
461 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
462 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
463 for (Link link : otu4Links) {
464 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
466 TopologyShard topoShard =
467 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
468 assertNotNull("TopologyShard should never be null", topoShard);
469 assertNull("list of nodes should be null", topoShard.getNodes());
470 assertNull("list of links should be null", topoShard.getLinks());
471 assertNull("list of tps should be null", topoShard.getTps());
475 public void updateOtnLinksFor10GTest() {
476 // tests update for 10G creation
477 TopologyShard topoShard =
478 OpenRoadmOtnTopology.updateOtnLinks(
479 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
480 NetworkmodelTestUtil.createTpList(true),
481 "10G", (short)1, (short)1, false);
482 assertNotNull("TopologyShard should never be null", topoShard);
483 assertNull("list of nodes should be null", topoShard.getNodes());
484 List<Link> sortedLinks = topoShard.getLinks().stream()
485 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
486 .collect(Collectors.toList());
487 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
488 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
490 "after 10G creation, available BW of supported ODU4 should be 90000",
491 Uint32.valueOf(90000),
492 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
494 "after 10G creation, used BW of supported ODU4 should be 10000",
495 Uint32.valueOf(10000),
496 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
499 "after 10G creation, 8 (over 80) trib slot should be occupied",
501 topoShard.getTps().get(0)
503 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
504 .TerminationPoint1.class)
505 .getXpdrTpPortConnectionAttributes()
509 "trib slot 1-8 should no longer be present in Trib slot list",
510 topoShard.getTps().get(0)
512 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
513 .TerminationPoint1.class)
514 .getXpdrTpPortConnectionAttributes()
516 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
518 "trib slot 9 should always be present in trib slot list",
519 topoShard.getTps().get(0)
521 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
522 .TerminationPoint1.class)
523 .getXpdrTpPortConnectionAttributes()
525 hasItem(Uint16.valueOf(9)));
527 "after 10G creation, 1 (over 80) trib port should be occupied",
529 topoShard.getTps().get(0)
531 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
532 .TerminationPoint1.class)
533 .getXpdrTpPortConnectionAttributes()
534 .getOdtuTpnPool().values().stream().findFirst()
539 "trib port 1 should no longer be present",
540 topoShard.getTps().get(0)
542 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
543 .TerminationPoint1.class)
544 .getXpdrTpPortConnectionAttributes()
545 .getOdtuTpnPool().values().stream().findFirst()
548 not(hasItem(Uint16.valueOf(1))));
550 // tests update for 10G deletion
552 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
554 sortedLinks = topoShard.getLinks().stream()
555 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
556 .collect(Collectors.toList());
557 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
558 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
560 "after 10G deletion, available BW of supported ODU4 should be 100 000",
561 Uint32.valueOf(100000),
562 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
564 "after 10G deletion, used BW of supported ODU4 should be 0",
566 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
569 "after 10G deletion, trib slot list should be full",
571 topoShard.getTps().get(0)
573 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
574 .TerminationPoint1.class)
575 .getXpdrTpPortConnectionAttributes()
579 "after 10G deletion, trib slot list should contain items 1-8",
580 topoShard.getTps().get(0)
582 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
583 .TerminationPoint1.class)
584 .getXpdrTpPortConnectionAttributes()
586 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
588 "after 10G deletion, trib port list should be full",
590 topoShard.getTps().get(0)
592 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
593 .TerminationPoint1.class)
594 .getXpdrTpPortConnectionAttributes()
595 .getOdtuTpnPool().values().stream().findFirst()
600 "after 10G deletion, trib port list should contain items 1",
601 topoShard.getTps().get(0)
603 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
604 .TerminationPoint1.class)
605 .getXpdrTpPortConnectionAttributes()
606 .getOdtuTpnPool().values().stream().findFirst()
609 hasItem(Uint16.valueOf(1)));
613 public void updateOtnLinksFor1GCreationTest() {
614 // tests update for 1G creation
615 TopologyShard topoShard =
616 OpenRoadmOtnTopology.updateOtnLinks(
617 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
618 NetworkmodelTestUtil.createTpList(true),
619 "1G", (short)1, (short)1, false);
620 assertNotNull("TopologyShard should never be null", topoShard);
621 assertNull("list of nodes should be null", topoShard.getNodes());
622 List<Link> sortedLinks = topoShard.getLinks().stream()
623 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
624 .collect(Collectors.toList());
625 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
626 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
628 "after 1G creation, available BW of supported ODU4 should be 99000",
629 Uint32.valueOf(99000),
630 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
632 "after 1G creation, used BW of supported ODU4 should be 1000",
633 Uint32.valueOf(1000),
634 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
637 "after 1G creation, 1 (over 80) trib slot should be occupied",
639 topoShard.getTps().get(0)
641 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
642 .TerminationPoint1.class)
643 .getXpdrTpPortConnectionAttributes()
647 "trib slot 1 should no longer be present in Trib slot list",
648 topoShard.getTps().get(0)
650 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
651 .TerminationPoint1.class)
652 .getXpdrTpPortConnectionAttributes()
654 not(hasItem(Uint16.valueOf(1))));
656 "trib slot 2 should always be present in Trib slot list",
657 topoShard.getTps().get(0)
659 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
660 .TerminationPoint1.class)
661 .getXpdrTpPortConnectionAttributes().getTsPool(),
662 hasItem(Uint16.valueOf(2)));
664 "after 1G creation, 1 (over 80) trib port should be occupied",
666 topoShard.getTps().get(0)
668 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
669 .TerminationPoint1.class)
670 .getXpdrTpPortConnectionAttributes()
671 .getOdtuTpnPool().values().stream().findFirst()
676 "trib port 1 should no longer be present in Trib port list",
677 topoShard.getTps().get(0)
679 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
680 .TerminationPoint1.class)
681 .getXpdrTpPortConnectionAttributes()
682 .getOdtuTpnPool().values().stream().findFirst()
685 not(hasItem(Uint16.valueOf(1))));
687 // tests update for 1G deletion
690 OpenRoadmOtnTopology.updateOtnLinks(
691 topoShard.getLinks(),
693 "1G", (short)1, (short)1, true);
694 sortedLinks = topoShard.getLinks().stream()
695 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
696 .collect(Collectors.toList());
697 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
698 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
700 "after 1G deletion, available BW of supported ODU4 should be 100 000",
701 Uint32.valueOf(100000),
702 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
704 "after 1G deletion, used BW of supported ODU4 should be 0",
706 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
709 "after 1G deletion, trib slot list should be full",
711 topoShard.getTps().get(0)
713 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
714 .TerminationPoint1.class)
715 .getXpdrTpPortConnectionAttributes()
719 "after 1G deletion, trib slot list should contain items 1 and 2",
720 topoShard.getTps().get(0)
722 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
723 .TerminationPoint1.class)
724 .getXpdrTpPortConnectionAttributes()
726 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
728 "after 1G deletion, trib port list should be full",
730 topoShard.getTps().get(0)
732 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
733 .TerminationPoint1.class)
734 .getXpdrTpPortConnectionAttributes()
735 .getOdtuTpnPool().values().stream().findFirst()
740 "after 1G deletion, trib port list should contain items 1",
741 topoShard.getTps().get(0)
743 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
744 .TerminationPoint1.class)
745 .getXpdrTpPortConnectionAttributes()
746 .getOdtuTpnPool().values().stream().findFirst()
749 hasItem(Uint16.valueOf(1)));
753 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
754 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
755 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
756 for (Link link : odu4Links) {
757 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
759 TopologyShard topoShard =
760 OpenRoadmOtnTopology.updateOtnLinks(
761 odu4LinksWithBadBWParam,
762 NetworkmodelTestUtil.createTpList(true),
763 "1G", (short)1, (short)1, false);
764 assertNotNull("TopologyShard should never be null", topoShard);
765 assertNull("list of nodes should be null", topoShard.getNodes());
766 assertNull("list of links should be null", topoShard.getLinks());
767 assertNull("list of tps should be null", topoShard.getTps());
771 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
772 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
773 TopologyShard topoShard =
774 OpenRoadmOtnTopology.updateOtnLinks(
775 odu4LinksWithBadBWParam,
776 NetworkmodelTestUtil.createTpList(true),
777 "10G", (short)1, (short)1, false);
778 assertNotNull("TopologyShard should never be null", topoShard);
779 assertNull("list of nodes should be null", topoShard.getNodes());
780 assertNull("list of links should be null", topoShard.getLinks());
781 assertNull("list of tps should be null", topoShard.getTps());
784 private void checkSpdrNode(Node node) {
786 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
787 .getXpdrAttributes().getXpdrNumber();
788 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
789 if (xpdrNb.equals(Uint16.valueOf(1))) {
790 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
791 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
792 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
794 // tests supporting nodes
795 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
796 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
797 .collect(Collectors.toList());
798 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
799 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
800 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
801 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
802 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
803 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
804 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
805 checkSpdrSwitchingPools(
808 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
809 .getSwitchingPools());
810 List<TerminationPoint> tpList = node.augmentation(
811 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
812 .nonnullTerminationPoint().values().stream()
813 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
814 .collect(Collectors.toList());
815 checkSpdrTpList(xpdrNb, tpList);
818 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
819 List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
821 "switching-pools augmentation should contain a single odu-switching-pools",
823 oduSwitchingPools.size());
825 "switching-pool-number should be 1",
827 oduSwitchingPools.get(0).getSwitchingPoolNumber());
829 "switching-pool-type should be non-blocking",
831 oduSwitchingPools.get(0).getSwitchingPoolType().getName());
833 List<NonBlockingList> nonBlockingList =
834 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
835 if (xpdrNb.equals(Uint16.valueOf(1))) {
837 "Mux should contain 4 non blocking list",
839 nonBlockingList.size());
842 nonBlockingList.get(0).getNblNumber());
843 List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
844 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
845 .collect(Collectors.toList());
846 for (NonBlockingList nbl : nblList) {
848 "for a 10G mux, interconnect BW should be 10G",
850 nbl.getAvailableInterconnectBandwidth());
851 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
853 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
856 String nb = nbl.getNblNumber().toString();
859 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
860 new TpId("XPDR1-CLIENT" + nb)));
862 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
864 "Switch should contain a single non blocking list",
866 nonBlockingList.size());
869 nonBlockingList.get(0).getNblNumber());
871 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
872 nonBlockingList.get(0).getTpList(),
875 nonBlockingList.get(0).getTpList(),
877 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
878 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
879 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
883 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
884 LOG.info("tpList = {}", tpList);
886 "only IfOCHOTU4ODU4 interface capabitily expected",
890 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
891 .TerminationPoint1.class)
892 .getTpSupportedInterfaces()
893 .getSupportedInterfaceCapability().values().stream().findFirst()
897 "the rate should be ODU4",
901 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
902 .TerminationPoint1.class)
903 .getXpdrTpPortConnectionAttributes()
906 "openroadm-topology",
907 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
908 .get().getNetworkRef().getValue());
910 "SPDR-SA1-XPDR" + xpdrNb,
911 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
912 .get().getNodeRef().getValue());
914 "XPDR" + xpdrNb + "-NETWORK1",
915 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
916 .get().getTpRef().toString());
917 if (xpdrNb.equals(Uint16.valueOf(1))) {
918 assertEquals("should contain 5 TPs", 5, tpList.size());
919 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
920 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
921 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
923 "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type",
927 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
928 .TerminationPoint1.class)
929 .getTpSupportedInterfaces()
930 .getSupportedInterfaceCapability().values().size());
932 "supported interface capability of tp-id XPDR1-CLIENT3 should contain 3 if-cap-type",
936 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
937 .TerminationPoint1.class)
938 .getTpSupportedInterfaces()
939 .getSupportedInterfaceCapability().values().size());
940 List<SupportedInterfaceCapability> sicListClient1 = tpList.get(0)
942 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
943 .TerminationPoint1.class)
944 .getTpSupportedInterfaces()
945 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
946 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) {
947 assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2",
948 String.valueOf(supportedInterfaceCapability.getIfCapType()),
949 either(containsString(String.valueOf(If10GEODU2e.class)))
950 .or(containsString(String.valueOf(If10GEODU2.class))));
952 List<SupportedInterfaceCapability> sicListClient3 = tpList.get(3)
954 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
955 .TerminationPoint1.class)
956 .getTpSupportedInterfaces()
957 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
958 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
959 assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE",
960 String.valueOf(supportedInterfaceCapability.getIfCapType()),
961 either(containsString(String.valueOf(If10GEODU2e.class)))
962 .or(containsString(String.valueOf(If10GEODU2.class)))
963 .or(containsString(String.valueOf(If10GE.class))));
965 assertThat("the rate should be ODU2 or ODU2e or 10GE",
966 String.valueOf(tpList.get(2)
968 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
969 .TerminationPoint1.class)
970 .getXpdrTpPortConnectionAttributes()
972 either(containsString(String.valueOf(ODU2e.class)))
973 .or(containsString(String.valueOf(ODU2.class))));
975 "TP should be of type client",
976 OpenroadmTpType.XPONDERCLIENT,
979 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
980 .TerminationPoint1.class)
983 "TP should be of type network",
984 OpenroadmTpType.XPONDERNETWORK,
987 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
988 .TerminationPoint1.class)
990 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
991 assertEquals("should contain 8 TPs", 8, tpList.size());
992 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
993 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
994 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
995 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
997 "only IfOCHOTU4ODU4 interface capabitily expected",
1001 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1002 .TerminationPoint1.class)
1003 .getTpSupportedInterfaces()
1004 .getSupportedInterfaceCapability().values().stream().findFirst()
1008 "supported interface capability of tp should contain 2 IfCapType",
1012 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1013 .TerminationPoint1.class)
1014 .getTpSupportedInterfaces()
1015 .getSupportedInterfaceCapability().values().size());
1016 List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2)
1018 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1019 .TerminationPoint1.class)
1020 .getTpSupportedInterfaces()
1021 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
1022 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
1023 assertThat("tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE",
1024 String.valueOf(supportedInterfaceCapability.getIfCapType()),
1025 either(containsString(String.valueOf(If100GEODU4.class)))
1026 .or(containsString(String.valueOf(If100GE.class))));
1029 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
1032 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1033 .TerminationPoint1.class)
1036 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
1039 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1040 .TerminationPoint1.class)