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.nio.charset.StandardCharsets;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
31 import java.util.stream.Collectors;
32 import org.junit.Test;
33 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
34 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
35 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.OduSwitchingPools;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmTpType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU2e;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Link1;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.networks.network.node.SwitchingPools;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GE;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GEODU4;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If10GEODU2e;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.IfOCHOTU4ODU4;
58 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
59 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.TerminationPoint1;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
66 import org.opendaylight.yangtools.yang.common.QName;
67 import org.opendaylight.yangtools.yang.common.Uint16;
68 import org.opendaylight.yangtools.yang.common.Uint32;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
72 public class OpenRoadmOtnTopologyTest {
74 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
75 private Nodes portMappingTpdr;
76 private Nodes portMappingSpdr;
77 private Nodes portMappingBad;
79 public OpenRoadmOtnTopologyTest() {
80 try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
81 JsonReader portMappingReader = new JsonReader(reader)) {
82 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
83 QName.create("http://org/opendaylight/transportpce/portmapping", "2020-10-12", "network"));
84 for (Nodes nodes : portMapping.nonnullNodes().values()) {
85 if (nodes.getNodeId().equals("XPDR-A1")) {
86 this.portMappingTpdr = nodes;
88 this.portMappingSpdr = nodes;
91 Map<MappingKey,Mapping> mappingList = new HashMap<>();
92 Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
93 mappingList.put(mapping.key(),mapping);
94 this.portMappingBad = new NodesBuilder()
95 .setNodeId(this.portMappingTpdr.getNodeId())
96 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
97 .setMapping(mappingList)
99 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
100 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
101 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
102 } catch (IOException e) {
103 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
104 fail("Cannot init OpenRoadmOtnTopologyTest ");
109 public void createTopologyShardForTpdrTest() {
110 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
111 assertNotNull("TopologyShard should never be null", topologyShard);
112 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
113 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
114 Node node = topologyShard.getNodes().get(0);
115 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
116 // tests supporting nodes
117 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
118 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
119 .collect(Collectors.toList());
120 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
121 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
122 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
123 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
124 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
125 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
126 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
127 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
131 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
135 List<TerminationPoint> tps = node.augmentation(
136 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
137 .nonnullTerminationPoint().values().stream()
138 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
139 .collect(Collectors.toList());
140 assertEquals("node should contain 4 TPs", 4, tps.size());
142 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
145 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
147 "only If100GE interface capabitily expected",
149 tps.get(0).augmentation(
150 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
151 .TerminationPoint1.class)
152 .getTpSupportedInterfaces()
153 .getSupportedInterfaceCapability()
156 If100GE.class.getName(),
157 tps.get(0).augmentation(
158 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
159 .TerminationPoint1.class)
160 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
161 .values().stream().findFirst()
162 .get().getIfCapType().getName());
164 "first TP must be of type client",
165 OpenroadmTpType.XPONDERCLIENT,
166 tps.get(0).augmentation(
167 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
168 .TerminationPoint1.class)
171 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
174 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
176 "only IfOCHOTU4ODU4 interface capabitily expected",
178 tps.get(2).augmentation(
179 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
180 .TerminationPoint1.class)
181 .getTpSupportedInterfaces()
182 .getSupportedInterfaceCapability()
185 IfOCHOTU4ODU4.class.getName(),
186 tps.get(2).augmentation(
187 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
188 .TerminationPoint1.class)
189 .getTpSupportedInterfaces()
190 .getSupportedInterfaceCapability()
191 .values().stream().findFirst()
196 "the rate should be ODU4",
197 ODU4.class.getName(),
198 tps.get(2).augmentation(
199 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
200 .TerminationPoint1.class)
201 .getXpdrTpPortConnectionAttributes()
205 "third TP must be of type network",
206 OpenroadmTpType.XPONDERNETWORK,
207 tps.get(2).augmentation(
208 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class)
213 public void createTopologyShardForSpdrTest() {
214 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
215 assertNotNull("TopologyShard should never be null", topologyShard);
216 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
217 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
218 List<Node> nodes = topologyShard.getNodes().stream()
219 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
220 .collect(Collectors.toList());
221 for (Node node : nodes) {
227 public void createOtnLinksForOTU4NormalTest() {
228 String nodeA = "SPDRA";
229 String tpA = "XPDR1-NETWORK1";
230 String nodeZ = "SPDRZ";
231 String tpZ = "XPDR1-NETWORK1";
232 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
233 assertEquals("2 OTU4 links should have been created", 2, links.size());
234 List<Link> sortedLinks = links.stream()
235 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
236 .collect(Collectors.toList());
238 "name of OTU4 linkid AZ",
239 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
240 sortedLinks.get(0).getLinkId().getValue());
242 "name of OTU4 linkid ZA",
243 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
244 sortedLinks.get(1).getLinkId().getValue());
245 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
246 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
247 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
248 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
250 "available BW at OTU4 creation should be 100G (100000)",
251 Uint32.valueOf(100000),
252 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
254 "used BW at OTU4 creation should be 0",
256 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
258 OpenroadmLinkType.OTNLINK,
259 sortedLinks.get(0).augmentation(
260 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
263 "opposite link must be present",
264 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
265 sortedLinks.get(0).augmentation(
266 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
270 "otn link type should be OTU4",
272 sortedLinks.get(0).augmentation(
273 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
278 public void createOtnLinksForNotManagedOtnlinktypeTest() {
279 String nodeA = "SPDRA";
280 String tpA = "XPDR1-NETWORK1";
281 String nodeZ = "SPDRZ";
282 String tpZ = "XPDR1-NETWORK1";
283 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
284 assertNotNull("TopologyShard should never be null", topoShard);
285 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
286 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
290 public void createOtnLinksForODU4NormalTest() {
291 TopologyShard topoShard = OpenRoadmOtnTopology
293 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
294 NetworkmodelTestUtil.createTpList(false));
295 assertNotNull("TopologyShard should never be null", topoShard);
296 assertNull("list of nodes should be null", topoShard.getNodes());
297 List<Link> sortedLinks = topoShard.getLinks().stream()
298 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
299 .collect(Collectors.toList());
300 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
301 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
303 "after odu4 creation, available BW of supported OTU4 should be 0",
305 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
307 "after odu4 creation, used BW of supported OTU4 should be 100 000",
308 Uint32.valueOf(100000),
309 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
312 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
313 sortedLinks.get(0).getLinkId().getValue());
315 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
316 sortedLinks.get(1).getLinkId().getValue());
317 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
318 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
319 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
320 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
322 "after odu4 creation, its available BW should be 100 000",
323 Uint32.valueOf(100000),
324 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
326 "after odu4 creation, its used BW should be 0",
328 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
330 OpenroadmLinkType.OTNLINK,
333 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
336 "opposite link must be present",
337 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
340 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
344 "otn link type should be ODTU4",
348 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
351 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
353 "after ODU4 creation, its termination point should contain a TsPool list",
354 topoShard.getTps().get(0)
356 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
357 .TerminationPoint1.class)
358 .getXpdrTpPortConnectionAttributes()
361 "Ts pool list should be full, with 80 trib slots",
363 topoShard.getTps().get(0)
365 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
366 .TerminationPoint1.class)
367 .getXpdrTpPortConnectionAttributes()
371 "after ODU4 creation, its termination point should contain a TpnPool list",
372 topoShard.getTps().get(0)
374 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
375 .TerminationPoint1.class)
376 .getXpdrTpPortConnectionAttributes()
377 .getOdtuTpnPool().values().stream().findFirst()
381 "Tpn pool list should be full, with 80 trib ports",
383 topoShard.getTps().get(0)
385 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
386 .TerminationPoint1.class)
387 .getXpdrTpPortConnectionAttributes()
388 .getOdtuTpnPool().values().stream().findFirst()
395 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
396 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
397 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
398 for (Link link : otu4Links) {
399 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
401 TopologyShard topoShard =
402 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
403 assertNotNull("TopologyShard should never be null", topoShard);
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());
408 otu4LinksWithBadBWParam.clear();
410 OpenRoadmOtnTopology.createOtnLinks(
411 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
412 NetworkmodelTestUtil.createTpList(false));
413 assertNull("list of nodes should be null", topoShard.getNodes());
414 assertNull("list of links should be null", topoShard.getLinks());
415 assertNull("list of tps should be null", topoShard.getTps());
419 public void deleteOtnLinksForODU4NormalTest() {
420 TopologyShard topoShard =
421 OpenRoadmOtnTopology.deleteOtnLinks(
422 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
423 NetworkmodelTestUtil.createTpList(true));
424 assertNotNull("TopologyShard should never be null", topoShard);
425 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
427 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
428 Uint32.valueOf(100000),
429 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
431 "after ODU4 deletion, used BW of supported OTU4 should be 0",
433 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
435 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
437 "after ODU4 deletion, its termination points should not contain any TsPool list",
438 topoShard.getTps().get(0)
440 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
441 .TerminationPoint1.class)
442 .getXpdrTpPortConnectionAttributes()
445 "after ODU4 deletion, its termination points should not contain any TpnPool list",
446 topoShard.getTps().get(0)
448 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
449 .TerminationPoint1.class)
450 .getXpdrTpPortConnectionAttributes()
455 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
456 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
457 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
458 for (Link link : otu4Links) {
459 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
461 TopologyShard topoShard =
462 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
463 assertNotNull("TopologyShard should never be null", topoShard);
464 assertNull("list of nodes should be null", topoShard.getNodes());
465 assertNull("list of links should be null", topoShard.getLinks());
466 assertNull("list of tps should be null", topoShard.getTps());
470 public void updateOtnLinksFor10GTest() {
471 // tests update for 10G creation
472 TopologyShard topoShard =
473 OpenRoadmOtnTopology.updateOtnLinks(
474 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
475 NetworkmodelTestUtil.createTpList(true),
476 "10G", (short)1, (short)1, false);
477 assertNotNull("TopologyShard should never be null", topoShard);
478 assertNull("list of nodes should be null", topoShard.getNodes());
479 List<Link> sortedLinks = topoShard.getLinks().stream()
480 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
481 .collect(Collectors.toList());
482 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
483 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
485 "after 10G creation, available BW of supported ODU4 should be 90000",
486 Uint32.valueOf(90000),
487 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
489 "after 10G creation, used BW of supported ODU4 should be 10000",
490 Uint32.valueOf(10000),
491 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
494 "after 10G creation, 8 (over 80) trib slot should be occupied",
496 topoShard.getTps().get(0)
498 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
499 .TerminationPoint1.class)
500 .getXpdrTpPortConnectionAttributes()
504 "trib slot 1-8 should no longer 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 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
513 "trib slot 9 should always be present in trib slot list",
514 topoShard.getTps().get(0)
516 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
517 .TerminationPoint1.class)
518 .getXpdrTpPortConnectionAttributes()
520 hasItem(Uint16.valueOf(9)));
522 "after 10G creation, 1 (over 80) trib port should be occupied",
524 topoShard.getTps().get(0)
526 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
527 .TerminationPoint1.class)
528 .getXpdrTpPortConnectionAttributes()
529 .getOdtuTpnPool().values().stream().findFirst()
534 "trib port 1 should no longer be present",
535 topoShard.getTps().get(0)
537 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
538 .TerminationPoint1.class)
539 .getXpdrTpPortConnectionAttributes()
540 .getOdtuTpnPool().values().stream().findFirst()
543 not(hasItem(Uint16.valueOf(1))));
545 // tests update for 10G deletion
547 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
549 sortedLinks = topoShard.getLinks().stream()
550 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
551 .collect(Collectors.toList());
552 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
553 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
555 "after 10G deletion, available BW of supported ODU4 should be 100 000",
556 Uint32.valueOf(100000),
557 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
559 "after 10G deletion, used BW of supported ODU4 should be 0",
561 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
564 "after 10G deletion, trib slot list should be full",
566 topoShard.getTps().get(0)
568 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
569 .TerminationPoint1.class)
570 .getXpdrTpPortConnectionAttributes()
574 "after 10G deletion, trib slot list should contain items 1-8",
575 topoShard.getTps().get(0)
577 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
578 .TerminationPoint1.class)
579 .getXpdrTpPortConnectionAttributes()
581 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
583 "after 10G deletion, trib port list should be full",
585 topoShard.getTps().get(0)
587 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
588 .TerminationPoint1.class)
589 .getXpdrTpPortConnectionAttributes()
590 .getOdtuTpnPool().values().stream().findFirst()
595 "after 10G deletion, trib port list should contain items 1",
596 topoShard.getTps().get(0)
598 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
599 .TerminationPoint1.class)
600 .getXpdrTpPortConnectionAttributes()
601 .getOdtuTpnPool().values().stream().findFirst()
604 hasItem(Uint16.valueOf(1)));
608 public void updateOtnLinksFor1GCreationTest() {
609 // tests update for 1G creation
610 TopologyShard topoShard =
611 OpenRoadmOtnTopology.updateOtnLinks(
612 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
613 NetworkmodelTestUtil.createTpList(true),
614 "1G", (short)1, (short)1, false);
615 assertNotNull("TopologyShard should never be null", topoShard);
616 assertNull("list of nodes should be null", topoShard.getNodes());
617 List<Link> sortedLinks = topoShard.getLinks().stream()
618 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
619 .collect(Collectors.toList());
620 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
621 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
623 "after 1G creation, available BW of supported ODU4 should be 99000",
624 Uint32.valueOf(99000),
625 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
627 "after 1G creation, used BW of supported ODU4 should be 1000",
628 Uint32.valueOf(1000),
629 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
632 "after 1G creation, 1 (over 80) trib slot should be occupied",
634 topoShard.getTps().get(0)
636 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
637 .TerminationPoint1.class)
638 .getXpdrTpPortConnectionAttributes()
642 "trib slot 1 should no longer be present in Trib slot list",
643 topoShard.getTps().get(0)
645 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
646 .TerminationPoint1.class)
647 .getXpdrTpPortConnectionAttributes()
649 not(hasItem(Uint16.valueOf(1))));
651 "trib slot 2 should always be present in Trib slot list",
652 topoShard.getTps().get(0)
654 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
655 .TerminationPoint1.class)
656 .getXpdrTpPortConnectionAttributes().getTsPool(),
657 hasItem(Uint16.valueOf(2)));
659 "after 1G creation, 1 (over 80) trib port should be occupied",
661 topoShard.getTps().get(0)
663 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
664 .TerminationPoint1.class)
665 .getXpdrTpPortConnectionAttributes()
666 .getOdtuTpnPool().values().stream().findFirst()
671 "trib port 1 should no longer be present in Trib port list",
672 topoShard.getTps().get(0)
674 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
675 .TerminationPoint1.class)
676 .getXpdrTpPortConnectionAttributes()
677 .getOdtuTpnPool().values().stream().findFirst()
680 not(hasItem(Uint16.valueOf(1))));
682 // tests update for 1G deletion
685 OpenRoadmOtnTopology.updateOtnLinks(
686 topoShard.getLinks(),
688 "1G", (short)1, (short)1, true);
689 sortedLinks = topoShard.getLinks().stream()
690 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
691 .collect(Collectors.toList());
692 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
693 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
695 "after 1G deletion, available BW of supported ODU4 should be 100 000",
696 Uint32.valueOf(100000),
697 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
699 "after 1G deletion, used BW of supported ODU4 should be 0",
701 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
704 "after 1G deletion, trib slot list should be full",
706 topoShard.getTps().get(0)
708 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
709 .TerminationPoint1.class)
710 .getXpdrTpPortConnectionAttributes()
714 "after 1G deletion, trib slot list should contain items 1 and 2",
715 topoShard.getTps().get(0)
717 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
718 .TerminationPoint1.class)
719 .getXpdrTpPortConnectionAttributes()
721 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
723 "after 1G deletion, trib port list should be full",
725 topoShard.getTps().get(0)
727 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
728 .TerminationPoint1.class)
729 .getXpdrTpPortConnectionAttributes()
730 .getOdtuTpnPool().values().stream().findFirst()
735 "after 1G deletion, trib port list should contain items 1",
736 topoShard.getTps().get(0)
738 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
739 .TerminationPoint1.class)
740 .getXpdrTpPortConnectionAttributes()
741 .getOdtuTpnPool().values().stream().findFirst()
744 hasItem(Uint16.valueOf(1)));
748 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
749 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
750 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
751 for (Link link : odu4Links) {
752 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
754 TopologyShard topoShard =
755 OpenRoadmOtnTopology.updateOtnLinks(
756 odu4LinksWithBadBWParam,
757 NetworkmodelTestUtil.createTpList(true),
758 "1G", (short)1, (short)1, false);
759 assertNotNull("TopologyShard should never be null", topoShard);
760 assertNull("list of nodes should be null", topoShard.getNodes());
761 assertNull("list of links should be null", topoShard.getLinks());
762 assertNull("list of tps should be null", topoShard.getTps());
766 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
767 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
768 TopologyShard topoShard =
769 OpenRoadmOtnTopology.updateOtnLinks(
770 odu4LinksWithBadBWParam,
771 NetworkmodelTestUtil.createTpList(true),
772 "10G", (short)1, (short)1, false);
773 assertNotNull("TopologyShard should never be null", topoShard);
774 assertNull("list of nodes should be null", topoShard.getNodes());
775 assertNull("list of links should be null", topoShard.getLinks());
776 assertNull("list of tps should be null", topoShard.getTps());
779 private void checkSpdrNode(Node node) {
781 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
782 .getXpdrAttributes().getXpdrNumber();
783 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
784 if (xpdrNb.equals(Uint16.valueOf(1))) {
785 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
786 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
787 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
789 // tests supporting nodes
790 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
791 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
792 .collect(Collectors.toList());
793 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
794 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
795 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
796 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
797 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
798 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
799 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
800 checkSpdrSwitchingPools(
803 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
804 .getSwitchingPools());
805 List<TerminationPoint> tpList = node.augmentation(
806 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
807 .nonnullTerminationPoint().values().stream()
808 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
809 .collect(Collectors.toList());
810 checkSpdrTpList(xpdrNb, tpList);
813 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
814 List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
816 "switching-pools augmentation should contain a single odu-switching-pools",
818 oduSwitchingPools.size());
820 "switching-pool-number should be 1",
822 oduSwitchingPools.get(0).getSwitchingPoolNumber());
824 "switching-pool-type should be non-blocking",
826 oduSwitchingPools.get(0).getSwitchingPoolType().getName());
828 List<NonBlockingList> nonBlockingList =
829 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
830 if (xpdrNb.equals(Uint16.valueOf(1))) {
832 "Mux should contain 4 non blocking list",
834 nonBlockingList.size());
837 nonBlockingList.get(0).getNblNumber());
838 List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
839 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
840 .collect(Collectors.toList());
841 for (NonBlockingList nbl : nblList) {
843 "for a 10G mux, interconnect BW should be 10G",
845 nbl.getAvailableInterconnectBandwidth());
846 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
848 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
851 String nb = nbl.getNblNumber().toString();
854 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
855 new TpId("XPDR1-CLIENT" + nb)));
857 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
859 "Switch should contain a single non blocking list",
861 nonBlockingList.size());
864 nonBlockingList.get(0).getNblNumber());
866 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
867 nonBlockingList.get(0).getTpList(),
870 nonBlockingList.get(0).getTpList(),
872 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
873 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
874 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
878 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
880 "only IfOCHOTU4ODU4 interface capabitily expected",
884 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
885 .TerminationPoint1.class)
886 .getTpSupportedInterfaces()
887 .getSupportedInterfaceCapability().values().stream().findFirst()
891 "the rate should be ODU4",
895 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
896 .TerminationPoint1.class)
897 .getXpdrTpPortConnectionAttributes()
900 "openroadm-topology",
901 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
902 .get().getNetworkRef().getValue());
904 "SPDR-SA1-XPDR" + xpdrNb,
905 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
906 .get().getNodeRef().getValue());
908 "XPDR" + xpdrNb + "-NETWORK1",
909 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
911 if (xpdrNb.equals(Uint16.valueOf(1))) {
912 assertEquals("should contain 5 TPs", 5, tpList.size());
913 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
914 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
915 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
917 "only If10GEODU2e interface capabitily expected",
921 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
922 .TerminationPoint1.class)
923 .getTpSupportedInterfaces()
924 .getSupportedInterfaceCapability().values().stream().findFirst()
928 "the rate should be ODU2e",
932 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
933 .TerminationPoint1.class)
934 .getXpdrTpPortConnectionAttributes()
937 "TP should be of type client",
938 OpenroadmTpType.XPONDERCLIENT,
941 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
942 .TerminationPoint1.class)
945 "TP should be of type network",
946 OpenroadmTpType.XPONDERNETWORK,
949 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
950 .TerminationPoint1.class)
952 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
953 assertEquals("should contain 8 TPs", 8, tpList.size());
954 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
955 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
956 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
957 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
959 "only If100GEODU4 interface capabitily expected",
963 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
964 .TerminationPoint1.class)
965 .getTpSupportedInterfaces()
966 .getSupportedInterfaceCapability().values().stream().findFirst()
970 "the rate should be ODU4",
974 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
975 .TerminationPoint1.class)
976 .getXpdrTpPortConnectionAttributes()
979 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
982 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
983 .TerminationPoint1.class)
986 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
989 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
990 .TerminationPoint1.class)