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.hasItem;
11 import static org.hamcrest.CoreMatchers.hasItems;
12 import static org.hamcrest.CoreMatchers.not;
13 import static org.hamcrest.MatcherAssert.assertThat;
14 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
15 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.assertNotNull;
18 import static org.junit.Assert.assertNull;
19 import static org.junit.Assert.assertTrue;
20 import static org.junit.Assert.fail;
22 import com.google.gson.stream.JsonReader;
23 import java.io.FileReader;
24 import java.io.IOException;
25 import java.io.Reader;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.stream.Collectors;
29 import org.junit.Test;
30 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
31 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
32 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.Network;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.Nodes;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.NodesBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.NodeInfoBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmTpType;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU2e;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Link1;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.networks.network.node.SwitchingPools;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GE;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GEODU4;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If10GEODU2e;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.IfOCHOTU4ODU4;
53 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
54 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.TerminationPoint1;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
61 import org.opendaylight.yangtools.yang.common.QName;
62 import org.opendaylight.yangtools.yang.common.Uint16;
63 import org.opendaylight.yangtools.yang.common.Uint32;
64 import org.slf4j.Logger;
65 import org.slf4j.LoggerFactory;
68 public class OpenRoadmOtnTopologyTest {
70 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
71 private Nodes portMappingTpdr;
72 private Nodes portMappingSpdr;
73 private Nodes portMappingBad;
75 public OpenRoadmOtnTopologyTest() {
76 try (Reader reader = new FileReader("src/test/resources/portMapping.json");
77 JsonReader portMappingReader = new JsonReader(reader)) {
78 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
79 QName.create("http://org/opendaylight/transportpce/portmapping", "2020-08-27", "network"));
80 for (Nodes nodes : portMapping.getNodes()) {
81 if (nodes.getNodeId().equals("XPDR-A1")) {
82 this.portMappingTpdr = nodes;
84 this.portMappingSpdr = nodes;
87 List<Mapping> mappingList = new ArrayList<>();
88 mappingList.add(new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build());
89 this.portMappingBad = new NodesBuilder()
90 .setNodeId(this.portMappingTpdr.getNodeId())
91 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
92 .setMapping(mappingList)
94 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
95 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
96 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
97 } catch (IOException e) {
98 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
99 fail("Cannot init OpenRoadmOtnTopologyTest ");
104 public void createTopologyShardForTpdrTest() {
105 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
106 assertNotNull("TopologyShard should never be null", topologyShard);
107 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
108 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
109 Node node = topologyShard.getNodes().get(0);
110 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
111 // tests supporting nodes
112 List<SupportingNode> supportingNodes = node.getSupportingNode().stream()
113 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
114 .collect(Collectors.toList());
115 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
116 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
117 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
118 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
119 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
120 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
121 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
122 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
126 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
130 List<TerminationPoint> tps = node.augmentation(
131 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
132 .getTerminationPoint().stream()
133 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
134 .collect(Collectors.toList());
135 assertEquals("node should contain 4 TPs", 4, tps.size());
137 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
140 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
142 "only If100GE interface capabitily expected",
144 tps.get(0).augmentation(
145 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
146 .TerminationPoint1.class)
147 .getTpSupportedInterfaces()
148 .getSupportedInterfaceCapability()
151 If100GE.class.getName(),
152 tps.get(0).augmentation(
153 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
154 .TerminationPoint1.class)
155 .getTpSupportedInterfaces().getSupportedInterfaceCapability()
156 .get(0).getIfCapType().getName());
158 "first TP must be of type client",
159 OpenroadmTpType.XPONDERCLIENT,
160 tps.get(0).augmentation(
161 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
162 .TerminationPoint1.class)
165 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
168 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
170 "only IfOCHOTU4ODU4 interface capabitily expected",
172 tps.get(2).augmentation(
173 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
174 .TerminationPoint1.class)
175 .getTpSupportedInterfaces()
176 .getSupportedInterfaceCapability()
179 IfOCHOTU4ODU4.class.getName(),
180 tps.get(2).augmentation(
181 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
182 .TerminationPoint1.class)
183 .getTpSupportedInterfaces()
184 .getSupportedInterfaceCapability()
189 "the rate should be ODU4",
190 ODU4.class.getName(),
191 tps.get(2).augmentation(
192 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
193 .TerminationPoint1.class)
194 .getXpdrTpPortConnectionAttributes()
198 "third TP must be of type network",
199 OpenroadmTpType.XPONDERNETWORK,
200 tps.get(2).augmentation(
201 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class)
206 public void createTopologyShardForSpdrTest() {
207 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
208 assertNotNull("TopologyShard should never be null", topologyShard);
209 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
210 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
211 List<Node> nodes = topologyShard.getNodes().stream()
212 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
213 .collect(Collectors.toList());
214 for (Node node : nodes) {
220 public void createOtnLinksForOTU4NormalTest() {
221 String nodeA = "SPDRA";
222 String tpA = "XPDR1-NETWORK1";
223 String nodeZ = "SPDRZ";
224 String tpZ = "XPDR1-NETWORK1";
225 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
226 assertEquals("2 OTU4 links should have been created", 2, links.size());
227 List<Link> sortedLinks = links.stream()
228 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
229 .collect(Collectors.toList());
231 "name of OTU4 linkid AZ",
232 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
233 sortedLinks.get(0).getLinkId().getValue());
235 "name of OTU4 linkid ZA",
236 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
237 sortedLinks.get(1).getLinkId().getValue());
238 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
239 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
240 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
241 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
243 "available BW at OTU4 creation should be 100G (100000)",
244 Uint32.valueOf(100000),
245 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
247 "used BW at OTU4 creation should be 0",
249 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
251 OpenroadmLinkType.OTNLINK,
252 sortedLinks.get(0).augmentation(
253 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
256 "opposite link must be present",
257 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
258 sortedLinks.get(0).augmentation(
259 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
263 "otn link type should be OTU4",
265 sortedLinks.get(0).augmentation(
266 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
271 public void createOtnLinksForNotManagedOtnlinktypeTest() {
272 String nodeA = "SPDRA";
273 String tpA = "XPDR1-NETWORK1";
274 String nodeZ = "SPDRZ";
275 String tpZ = "XPDR1-NETWORK1";
276 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
277 assertNotNull("TopologyShard should never be null", topoShard);
278 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
279 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
283 public void createOtnLinksForODU4NormalTest() {
284 TopologyShard topoShard = OpenRoadmOtnTopology
286 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
287 NetworkmodelTestUtil.createTpList(false));
288 assertNotNull("TopologyShard should never be null", topoShard);
289 assertNull("list of nodes should be null", topoShard.getNodes());
290 List<Link> sortedLinks = topoShard.getLinks().stream()
291 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
292 .collect(Collectors.toList());
293 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
294 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
296 "after odu4 creation, available BW of supported OTU4 should be 0",
298 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
300 "after odu4 creation, used BW of supported OTU4 should be 100 000",
301 Uint32.valueOf(100000),
302 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
305 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
306 sortedLinks.get(0).getLinkId().getValue());
308 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
309 sortedLinks.get(1).getLinkId().getValue());
310 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
311 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
312 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
313 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
315 "after odu4 creation, its available BW should be 100 000",
316 Uint32.valueOf(100000),
317 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
319 "after odu4 creation, its used BW should be 0",
321 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
323 OpenroadmLinkType.OTNLINK,
326 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
329 "opposite link must be present",
330 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
333 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
337 "otn link type should be ODTU4",
341 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
344 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
346 "after ODU4 creation, its termination point should contain a TsPool list",
347 topoShard.getTps().get(0)
349 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
350 .TerminationPoint1.class)
351 .getXpdrTpPortConnectionAttributes()
354 "Ts pool list should be full, with 80 trib slots",
356 topoShard.getTps().get(0)
358 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
359 .TerminationPoint1.class)
360 .getXpdrTpPortConnectionAttributes()
364 "after ODU4 creation, its termination point should contain a TpnPool list",
365 topoShard.getTps().get(0)
367 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
368 .TerminationPoint1.class)
369 .getXpdrTpPortConnectionAttributes()
370 .getOdtuTpnPool().get(0)
373 "Tpn pool list should be full, with 80 trib ports",
375 topoShard.getTps().get(0)
377 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
378 .TerminationPoint1.class)
379 .getXpdrTpPortConnectionAttributes()
380 .getOdtuTpnPool().get(0)
386 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
387 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
388 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
389 for (Link link : otu4Links) {
390 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
392 TopologyShard topoShard =
393 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
394 assertNotNull("TopologyShard should never be null", topoShard);
395 assertNull("list of nodes should be null", topoShard.getNodes());
396 assertNull("list of links should be null", topoShard.getLinks());
397 assertNull("list of tps should be null", topoShard.getTps());
399 otu4LinksWithBadBWParam.clear();
401 OpenRoadmOtnTopology.createOtnLinks(
402 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
403 NetworkmodelTestUtil.createTpList(false));
404 assertNull("list of nodes should be null", topoShard.getNodes());
405 assertNull("list of links should be null", topoShard.getLinks());
406 assertNull("list of tps should be null", topoShard.getTps());
410 public void deleteOtnLinksForODU4NormalTest() {
411 TopologyShard topoShard =
412 OpenRoadmOtnTopology.deleteOtnLinks(
413 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
414 NetworkmodelTestUtil.createTpList(true));
415 assertNotNull("TopologyShard should never be null", topoShard);
416 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
418 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
419 Uint32.valueOf(100000),
420 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
422 "after ODU4 deletion, used BW of supported OTU4 should be 0",
424 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
426 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
428 "after ODU4 deletion, its termination points should not contain any TsPool list",
429 topoShard.getTps().get(0)
431 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
432 .TerminationPoint1.class)
433 .getXpdrTpPortConnectionAttributes()
436 "after ODU4 deletion, its termination points should not contain any TpnPool list",
437 topoShard.getTps().get(0)
439 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
440 .TerminationPoint1.class)
441 .getXpdrTpPortConnectionAttributes()
446 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
447 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
448 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
449 for (Link link : otu4Links) {
450 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
452 TopologyShard topoShard =
453 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
454 assertNotNull("TopologyShard should never be null", topoShard);
455 assertNull("list of nodes should be null", topoShard.getNodes());
456 assertNull("list of links should be null", topoShard.getLinks());
457 assertNull("list of tps should be null", topoShard.getTps());
461 public void updateOtnLinksFor10GTest() {
462 // tests update for 10G creation
463 TopologyShard topoShard =
464 OpenRoadmOtnTopology.updateOtnLinks(
465 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
466 NetworkmodelTestUtil.createTpList(true),
467 "10G", (short)1, (short)1, false);
468 assertNotNull("TopologyShard should never be null", topoShard);
469 assertNull("list of nodes should be null", topoShard.getNodes());
470 List<Link> sortedLinks = topoShard.getLinks().stream()
471 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
472 .collect(Collectors.toList());
473 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
474 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
476 "after 10G creation, available BW of supported ODU4 should be 90000",
477 Uint32.valueOf(90000),
478 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
480 "after 10G creation, used BW of supported ODU4 should be 10000",
481 Uint32.valueOf(10000),
482 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
485 "after 10G creation, 8 (over 80) trib slot should be occupied",
487 topoShard.getTps().get(0)
489 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
490 .TerminationPoint1.class)
491 .getXpdrTpPortConnectionAttributes()
495 "trib slot 1-8 should no longer be present in Trib slot list",
496 topoShard.getTps().get(0)
498 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
499 .TerminationPoint1.class)
500 .getXpdrTpPortConnectionAttributes()
502 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
504 "trib slot 9 should always be present in trib slot list",
505 topoShard.getTps().get(0)
507 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
508 .TerminationPoint1.class)
509 .getXpdrTpPortConnectionAttributes()
511 hasItem(Uint16.valueOf(9)));
513 "after 10G creation, 1 (over 80) trib port should be occupied",
515 topoShard.getTps().get(0)
517 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
518 .TerminationPoint1.class)
519 .getXpdrTpPortConnectionAttributes()
520 .getOdtuTpnPool().get(0)
524 "trib port 1 should no longer be present",
525 topoShard.getTps().get(0)
527 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
528 .TerminationPoint1.class)
529 .getXpdrTpPortConnectionAttributes()
530 .getOdtuTpnPool().get(0)
532 not(hasItem(Uint16.valueOf(1))));
534 // tests update for 10G deletion
536 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
538 sortedLinks = topoShard.getLinks().stream()
539 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
540 .collect(Collectors.toList());
541 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
542 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
544 "after 10G deletion, available BW of supported ODU4 should be 100 000",
545 Uint32.valueOf(100000),
546 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
548 "after 10G deletion, used BW of supported ODU4 should be 0",
550 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
553 "after 10G deletion, trib slot list should be full",
555 topoShard.getTps().get(0)
557 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
558 .TerminationPoint1.class)
559 .getXpdrTpPortConnectionAttributes()
563 "after 10G deletion, trib slot list should contain items 1-8",
564 topoShard.getTps().get(0)
566 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
567 .TerminationPoint1.class)
568 .getXpdrTpPortConnectionAttributes()
570 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
572 "after 10G deletion, trib port list should be full",
574 topoShard.getTps().get(0)
576 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
577 .TerminationPoint1.class)
578 .getXpdrTpPortConnectionAttributes()
579 .getOdtuTpnPool().get(0)
583 "after 10G deletion, trib port list should contain items 1",
584 topoShard.getTps().get(0)
586 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
587 .TerminationPoint1.class)
588 .getXpdrTpPortConnectionAttributes()
589 .getOdtuTpnPool().get(0)
591 hasItem(Uint16.valueOf(1)));
595 public void updateOtnLinksFor1GCreationTest() {
596 // tests update for 1G creation
597 TopologyShard topoShard =
598 OpenRoadmOtnTopology.updateOtnLinks(
599 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
600 NetworkmodelTestUtil.createTpList(true),
601 "1G", (short)1, (short)1, false);
602 assertNotNull("TopologyShard should never be null", topoShard);
603 assertNull("list of nodes should be null", topoShard.getNodes());
604 List<Link> sortedLinks = topoShard.getLinks().stream()
605 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
606 .collect(Collectors.toList());
607 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
608 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
610 "after 1G creation, available BW of supported ODU4 should be 99000",
611 Uint32.valueOf(99000),
612 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
614 "after 1G creation, used BW of supported ODU4 should be 1000",
615 Uint32.valueOf(1000),
616 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
619 "after 1G creation, 1 (over 80) trib slot should be occupied",
621 topoShard.getTps().get(0)
623 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
624 .TerminationPoint1.class)
625 .getXpdrTpPortConnectionAttributes()
629 "trib slot 1 should no longer be present in Trib slot list",
630 topoShard.getTps().get(0)
632 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
633 .TerminationPoint1.class)
634 .getXpdrTpPortConnectionAttributes()
636 not(hasItem(Uint16.valueOf(1))));
638 "trib slot 2 should always be present in Trib slot list",
639 topoShard.getTps().get(0)
641 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
642 .TerminationPoint1.class)
643 .getXpdrTpPortConnectionAttributes().getTsPool(),
644 hasItem(Uint16.valueOf(2)));
646 "after 1G creation, 1 (over 80) trib port should be occupied",
648 topoShard.getTps().get(0)
650 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
651 .TerminationPoint1.class)
652 .getXpdrTpPortConnectionAttributes()
653 .getOdtuTpnPool().get(0)
657 "trib port 1 should no longer be present in Trib port list",
658 topoShard.getTps().get(0)
660 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
661 .TerminationPoint1.class)
662 .getXpdrTpPortConnectionAttributes()
663 .getOdtuTpnPool().get(0)
665 not(hasItem(Uint16.valueOf(1))));
667 // tests update for 1G deletion
670 OpenRoadmOtnTopology.updateOtnLinks(
671 topoShard.getLinks(),
673 "1G", (short)1, (short)1, true);
674 sortedLinks = topoShard.getLinks().stream()
675 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
676 .collect(Collectors.toList());
677 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
678 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
680 "after 1G deletion, available BW of supported ODU4 should be 100 000",
681 Uint32.valueOf(100000),
682 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
684 "after 1G deletion, used BW of supported ODU4 should be 0",
686 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
689 "after 1G deletion, trib slot list should be full",
691 topoShard.getTps().get(0)
693 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
694 .TerminationPoint1.class)
695 .getXpdrTpPortConnectionAttributes()
699 "after 1G deletion, trib slot list should contain items 1 and 2",
700 topoShard.getTps().get(0)
702 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
703 .TerminationPoint1.class)
704 .getXpdrTpPortConnectionAttributes()
706 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
708 "after 1G deletion, trib port list should be full",
710 topoShard.getTps().get(0)
712 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
713 .TerminationPoint1.class)
714 .getXpdrTpPortConnectionAttributes()
715 .getOdtuTpnPool().get(0)
719 "after 1G deletion, trib port list should contain items 1",
720 topoShard.getTps().get(0)
722 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
723 .TerminationPoint1.class)
724 .getXpdrTpPortConnectionAttributes()
725 .getOdtuTpnPool().get(0)
727 hasItem(Uint16.valueOf(1)));
731 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
732 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
733 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
734 for (Link link : odu4Links) {
735 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
737 TopologyShard topoShard =
738 OpenRoadmOtnTopology.updateOtnLinks(
739 odu4LinksWithBadBWParam,
740 NetworkmodelTestUtil.createTpList(true),
741 "1G", (short)1, (short)1, false);
742 assertNotNull("TopologyShard should never be null", topoShard);
743 assertNull("list of nodes should be null", topoShard.getNodes());
744 assertNull("list of links should be null", topoShard.getLinks());
745 assertNull("list of tps should be null", topoShard.getTps());
749 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
750 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
751 TopologyShard topoShard =
752 OpenRoadmOtnTopology.updateOtnLinks(
753 odu4LinksWithBadBWParam,
754 NetworkmodelTestUtil.createTpList(true),
755 "10G", (short)1, (short)1, false);
756 assertNotNull("TopologyShard should never be null", topoShard);
757 assertNull("list of nodes should be null", topoShard.getNodes());
758 assertNull("list of links should be null", topoShard.getLinks());
759 assertNull("list of tps should be null", topoShard.getTps());
762 private void checkSpdrNode(Node node) {
764 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
765 .getXpdrAttributes().getXpdrNumber();
766 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
767 if (xpdrNb.equals(Uint16.valueOf(1))) {
768 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
769 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
770 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
772 // tests supporting nodes
773 List<SupportingNode> supportingNodes = node.getSupportingNode().stream()
774 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
775 .collect(Collectors.toList());
776 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
777 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
778 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
779 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
780 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
781 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
782 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
783 checkSpdrSwitchingPools(
786 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
787 .getSwitchingPools());
788 List<TerminationPoint> tpList = node.augmentation(
789 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
790 .getTerminationPoint().stream()
791 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
792 .collect(Collectors.toList());
793 checkSpdrTpList(xpdrNb, tpList);
796 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
798 "switching-pools augmentation should contain a single odu-switching-pools",
800 sp.getOduSwitchingPools().size());
802 "switching-pool-number should be 1",
804 sp.getOduSwitchingPools().get(0).getSwitchingPoolNumber());
806 "switching-pool-type should be non-blocking",
808 sp.getOduSwitchingPools().get(0).getSwitchingPoolType().getName());
809 if (xpdrNb.equals(Uint16.valueOf(1))) {
811 "Mux should contain 4 non blocking list",
813 sp.getOduSwitchingPools().get(0).getNonBlockingList().size());
816 sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getNblNumber());
817 List<NonBlockingList> nblList = sp.getOduSwitchingPools().get(0).getNonBlockingList().stream()
818 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
819 .collect(Collectors.toList());
820 for (NonBlockingList nbl : nblList) {
822 "for a 10G mux, interconnect BW should be 10G",
824 nbl.getAvailableInterconnectBandwidth());
825 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
827 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
830 String nb = nbl.getNblNumber().toString();
833 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
834 new TpId("XPDR1-CLIENT" + nb)));
836 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
838 "Switch should contain a single non blocking list",
840 sp.getOduSwitchingPools().get(0).getNonBlockingList().size());
843 sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getNblNumber());
845 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
846 sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getTpList(),
849 sp.getOduSwitchingPools().get(0).getNonBlockingList().get(0).getTpList(),
851 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
852 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
853 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
857 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
859 "only IfOCHOTU4ODU4 interface capabitily expected",
863 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
864 .TerminationPoint1.class)
865 .getTpSupportedInterfaces()
866 .getSupportedInterfaceCapability().get(0)
869 "the rate should be ODU4",
873 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
874 .TerminationPoint1.class)
875 .getXpdrTpPortConnectionAttributes()
878 "openroadm-topology",
879 tpList.get(4).getSupportingTerminationPoint().get(0).getNetworkRef().getValue());
881 "SPDR-SA1-XPDR" + xpdrNb,
882 tpList.get(4).getSupportingTerminationPoint().get(0).getNodeRef().getValue());
884 "XPDR" + xpdrNb + "-NETWORK1",
885 tpList.get(4).getSupportingTerminationPoint().get(0).getTpRef());
886 if (xpdrNb.equals(Uint16.valueOf(1))) {
887 assertEquals("should contain 5 TPs", 5, tpList.size());
888 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
889 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
890 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
892 "only If10GEODU2e interface capabitily expected",
896 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
897 .TerminationPoint1.class)
898 .getTpSupportedInterfaces()
899 .getSupportedInterfaceCapability().get(0)
902 "the rate should be ODU2e",
906 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
907 .TerminationPoint1.class)
908 .getXpdrTpPortConnectionAttributes()
911 "TP should be of type client",
912 OpenroadmTpType.XPONDERCLIENT,
915 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
916 .TerminationPoint1.class)
919 "TP should be of type network",
920 OpenroadmTpType.XPONDERNETWORK,
923 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
924 .TerminationPoint1.class)
926 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
927 assertEquals("should contain 8 TPs", 8, tpList.size());
928 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
929 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
930 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
931 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
933 "only If100GEODU4 interface capabitily expected",
937 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
938 .TerminationPoint1.class)
939 .getTpSupportedInterfaces()
940 .getSupportedInterfaceCapability().get(0)
943 "the rate should be ODU4",
947 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
948 .TerminationPoint1.class)
949 .getXpdrTpPortConnectionAttributes()
952 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
955 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
956 .TerminationPoint1.class)
959 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
962 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
963 .TerminationPoint1.class)