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.HashMap;
28 import java.util.List;
30 import java.util.stream.Collectors;
31 import org.junit.Test;
32 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
33 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
34 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.Network;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.Nodes;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.NodesBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingKey;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.NodeInfoBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.OduSwitchingPools;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev181130.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmTpType;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU2e;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Link1;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.networks.network.node.SwitchingPools;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GE;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If100GEODU4;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.If10GEODU2e;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181130.IfOCHOTU4ODU4;
57 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
58 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.TerminationPoint1;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
65 import org.opendaylight.yangtools.yang.common.QName;
66 import org.opendaylight.yangtools.yang.common.Uint16;
67 import org.opendaylight.yangtools.yang.common.Uint32;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
71 public class OpenRoadmOtnTopologyTest {
73 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
74 private Nodes portMappingTpdr;
75 private Nodes portMappingSpdr;
76 private Nodes portMappingBad;
78 public OpenRoadmOtnTopologyTest() {
79 try (Reader reader = new FileReader("src/test/resources/portMapping.json");
80 JsonReader portMappingReader = new JsonReader(reader)) {
81 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
82 QName.create("http://org/opendaylight/transportpce/portmapping", "2020-08-27", "network"));
83 for (Nodes nodes : portMapping.nonnullNodes().values()) {
84 if (nodes.getNodeId().equals("XPDR-A1")) {
85 this.portMappingTpdr = nodes;
87 this.portMappingSpdr = nodes;
90 Map<MappingKey,Mapping> mappingList = new HashMap<>();
91 Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
92 mappingList.put(mapping.key(),mapping);
93 this.portMappingBad = new NodesBuilder()
94 .setNodeId(this.portMappingTpdr.getNodeId())
95 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
96 .setMapping(mappingList)
98 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
99 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
100 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
101 } catch (IOException e) {
102 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
103 fail("Cannot init OpenRoadmOtnTopologyTest ");
108 public void createTopologyShardForTpdrTest() {
109 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
110 assertNotNull("TopologyShard should never be null", topologyShard);
111 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
112 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
113 Node node = topologyShard.getNodes().get(0);
114 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
115 // tests supporting nodes
116 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
117 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
118 .collect(Collectors.toList());
119 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
120 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
121 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
122 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
123 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
124 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
125 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
126 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
130 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
134 List<TerminationPoint> tps = node.augmentation(
135 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
136 .nonnullTerminationPoint().values().stream()
137 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
138 .collect(Collectors.toList());
139 assertEquals("node should contain 4 TPs", 4, tps.size());
141 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
144 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
146 "only If100GE interface capabitily expected",
148 tps.get(0).augmentation(
149 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
150 .TerminationPoint1.class)
151 .getTpSupportedInterfaces()
152 .getSupportedInterfaceCapability()
155 If100GE.class.getName(),
156 tps.get(0).augmentation(
157 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
158 .TerminationPoint1.class)
159 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
160 .values().stream().findFirst()
161 .get().getIfCapType().getName());
163 "first TP must be of type client",
164 OpenroadmTpType.XPONDERCLIENT,
165 tps.get(0).augmentation(
166 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
167 .TerminationPoint1.class)
170 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
173 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
175 "only IfOCHOTU4ODU4 interface capabitily expected",
177 tps.get(2).augmentation(
178 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
179 .TerminationPoint1.class)
180 .getTpSupportedInterfaces()
181 .getSupportedInterfaceCapability()
184 IfOCHOTU4ODU4.class.getName(),
185 tps.get(2).augmentation(
186 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
187 .TerminationPoint1.class)
188 .getTpSupportedInterfaces()
189 .getSupportedInterfaceCapability()
190 .values().stream().findFirst()
195 "the rate should be ODU4",
196 ODU4.class.getName(),
197 tps.get(2).augmentation(
198 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
199 .TerminationPoint1.class)
200 .getXpdrTpPortConnectionAttributes()
204 "third TP must be of type network",
205 OpenroadmTpType.XPONDERNETWORK,
206 tps.get(2).augmentation(
207 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class)
212 public void createTopologyShardForSpdrTest() {
213 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
214 assertNotNull("TopologyShard should never be null", topologyShard);
215 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
216 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
217 List<Node> nodes = topologyShard.getNodes().stream()
218 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
219 .collect(Collectors.toList());
220 for (Node node : nodes) {
226 public void createOtnLinksForOTU4NormalTest() {
227 String nodeA = "SPDRA";
228 String tpA = "XPDR1-NETWORK1";
229 String nodeZ = "SPDRZ";
230 String tpZ = "XPDR1-NETWORK1";
231 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
232 assertEquals("2 OTU4 links should have been created", 2, links.size());
233 List<Link> sortedLinks = links.stream()
234 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
235 .collect(Collectors.toList());
237 "name of OTU4 linkid AZ",
238 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
239 sortedLinks.get(0).getLinkId().getValue());
241 "name of OTU4 linkid ZA",
242 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
243 sortedLinks.get(1).getLinkId().getValue());
244 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
245 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
246 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
247 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
249 "available BW at OTU4 creation should be 100G (100000)",
250 Uint32.valueOf(100000),
251 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
253 "used BW at OTU4 creation should be 0",
255 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
257 OpenroadmLinkType.OTNLINK,
258 sortedLinks.get(0).augmentation(
259 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
262 "opposite link must be present",
263 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
264 sortedLinks.get(0).augmentation(
265 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
269 "otn link type should be OTU4",
271 sortedLinks.get(0).augmentation(
272 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
277 public void createOtnLinksForNotManagedOtnlinktypeTest() {
278 String nodeA = "SPDRA";
279 String tpA = "XPDR1-NETWORK1";
280 String nodeZ = "SPDRZ";
281 String tpZ = "XPDR1-NETWORK1";
282 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
283 assertNotNull("TopologyShard should never be null", topoShard);
284 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
285 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
289 public void createOtnLinksForODU4NormalTest() {
290 TopologyShard topoShard = OpenRoadmOtnTopology
292 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
293 NetworkmodelTestUtil.createTpList(false));
294 assertNotNull("TopologyShard should never be null", topoShard);
295 assertNull("list of nodes should be null", topoShard.getNodes());
296 List<Link> sortedLinks = topoShard.getLinks().stream()
297 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
298 .collect(Collectors.toList());
299 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
300 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
302 "after odu4 creation, available BW of supported OTU4 should be 0",
304 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
306 "after odu4 creation, used BW of supported OTU4 should be 100 000",
307 Uint32.valueOf(100000),
308 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
311 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
312 sortedLinks.get(0).getLinkId().getValue());
314 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
315 sortedLinks.get(1).getLinkId().getValue());
316 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
317 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
318 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
319 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
321 "after odu4 creation, its available BW should be 100 000",
322 Uint32.valueOf(100000),
323 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
325 "after odu4 creation, its used BW should be 0",
327 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
329 OpenroadmLinkType.OTNLINK,
332 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
335 "opposite link must be present",
336 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
339 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
343 "otn link type should be ODTU4",
347 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
350 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
352 "after ODU4 creation, its termination point should contain a TsPool list",
353 topoShard.getTps().get(0)
355 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
356 .TerminationPoint1.class)
357 .getXpdrTpPortConnectionAttributes()
360 "Ts pool list should be full, with 80 trib slots",
362 topoShard.getTps().get(0)
364 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
365 .TerminationPoint1.class)
366 .getXpdrTpPortConnectionAttributes()
370 "after ODU4 creation, its termination point should contain a TpnPool list",
371 topoShard.getTps().get(0)
373 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
374 .TerminationPoint1.class)
375 .getXpdrTpPortConnectionAttributes()
376 .getOdtuTpnPool().values().stream().findFirst()
380 "Tpn pool list should be full, with 80 trib ports",
382 topoShard.getTps().get(0)
384 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
385 .TerminationPoint1.class)
386 .getXpdrTpPortConnectionAttributes()
387 .getOdtuTpnPool().values().stream().findFirst()
394 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
395 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
396 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
397 for (Link link : otu4Links) {
398 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
400 TopologyShard topoShard =
401 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
402 assertNotNull("TopologyShard should never be null", topoShard);
403 assertNull("list of nodes should be null", topoShard.getNodes());
404 assertNull("list of links should be null", topoShard.getLinks());
405 assertNull("list of tps should be null", topoShard.getTps());
407 otu4LinksWithBadBWParam.clear();
409 OpenRoadmOtnTopology.createOtnLinks(
410 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
411 NetworkmodelTestUtil.createTpList(false));
412 assertNull("list of nodes should be null", topoShard.getNodes());
413 assertNull("list of links should be null", topoShard.getLinks());
414 assertNull("list of tps should be null", topoShard.getTps());
418 public void deleteOtnLinksForODU4NormalTest() {
419 TopologyShard topoShard =
420 OpenRoadmOtnTopology.deleteOtnLinks(
421 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
422 NetworkmodelTestUtil.createTpList(true));
423 assertNotNull("TopologyShard should never be null", topoShard);
424 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
426 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
427 Uint32.valueOf(100000),
428 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
430 "after ODU4 deletion, used BW of supported OTU4 should be 0",
432 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
434 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
436 "after ODU4 deletion, its termination points should not contain any TsPool list",
437 topoShard.getTps().get(0)
439 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
440 .TerminationPoint1.class)
441 .getXpdrTpPortConnectionAttributes()
444 "after ODU4 deletion, its termination points should not contain any TpnPool list",
445 topoShard.getTps().get(0)
447 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
448 .TerminationPoint1.class)
449 .getXpdrTpPortConnectionAttributes()
454 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
455 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
456 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
457 for (Link link : otu4Links) {
458 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
460 TopologyShard topoShard =
461 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
462 assertNotNull("TopologyShard should never be null", topoShard);
463 assertNull("list of nodes should be null", topoShard.getNodes());
464 assertNull("list of links should be null", topoShard.getLinks());
465 assertNull("list of tps should be null", topoShard.getTps());
469 public void updateOtnLinksFor10GTest() {
470 // tests update for 10G creation
471 TopologyShard topoShard =
472 OpenRoadmOtnTopology.updateOtnLinks(
473 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
474 NetworkmodelTestUtil.createTpList(true),
475 "10G", (short)1, (short)1, false);
476 assertNotNull("TopologyShard should never be null", topoShard);
477 assertNull("list of nodes should be null", topoShard.getNodes());
478 List<Link> sortedLinks = topoShard.getLinks().stream()
479 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
480 .collect(Collectors.toList());
481 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
482 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
484 "after 10G creation, available BW of supported ODU4 should be 90000",
485 Uint32.valueOf(90000),
486 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
488 "after 10G creation, used BW of supported ODU4 should be 10000",
489 Uint32.valueOf(10000),
490 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
493 "after 10G creation, 8 (over 80) trib slot should be occupied",
495 topoShard.getTps().get(0)
497 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
498 .TerminationPoint1.class)
499 .getXpdrTpPortConnectionAttributes()
503 "trib slot 1-8 should no longer be present in Trib slot list",
504 topoShard.getTps().get(0)
506 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
507 .TerminationPoint1.class)
508 .getXpdrTpPortConnectionAttributes()
510 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
512 "trib slot 9 should always be present in trib slot list",
513 topoShard.getTps().get(0)
515 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
516 .TerminationPoint1.class)
517 .getXpdrTpPortConnectionAttributes()
519 hasItem(Uint16.valueOf(9)));
521 "after 10G creation, 1 (over 80) trib port should be occupied",
523 topoShard.getTps().get(0)
525 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
526 .TerminationPoint1.class)
527 .getXpdrTpPortConnectionAttributes()
528 .getOdtuTpnPool().values().stream().findFirst()
533 "trib port 1 should no longer be present",
534 topoShard.getTps().get(0)
536 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
537 .TerminationPoint1.class)
538 .getXpdrTpPortConnectionAttributes()
539 .getOdtuTpnPool().values().stream().findFirst()
542 not(hasItem(Uint16.valueOf(1))));
544 // tests update for 10G deletion
546 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
548 sortedLinks = topoShard.getLinks().stream()
549 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
550 .collect(Collectors.toList());
551 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
552 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
554 "after 10G deletion, available BW of supported ODU4 should be 100 000",
555 Uint32.valueOf(100000),
556 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
558 "after 10G deletion, used BW of supported ODU4 should be 0",
560 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
563 "after 10G deletion, trib slot list should be full",
565 topoShard.getTps().get(0)
567 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
568 .TerminationPoint1.class)
569 .getXpdrTpPortConnectionAttributes()
573 "after 10G deletion, trib slot list should contain items 1-8",
574 topoShard.getTps().get(0)
576 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
577 .TerminationPoint1.class)
578 .getXpdrTpPortConnectionAttributes()
580 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
582 "after 10G deletion, trib port list should be full",
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().values().stream().findFirst()
594 "after 10G deletion, trib port list should contain items 1",
595 topoShard.getTps().get(0)
597 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
598 .TerminationPoint1.class)
599 .getXpdrTpPortConnectionAttributes()
600 .getOdtuTpnPool().values().stream().findFirst()
603 hasItem(Uint16.valueOf(1)));
607 public void updateOtnLinksFor1GCreationTest() {
608 // tests update for 1G creation
609 TopologyShard topoShard =
610 OpenRoadmOtnTopology.updateOtnLinks(
611 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
612 NetworkmodelTestUtil.createTpList(true),
613 "1G", (short)1, (short)1, false);
614 assertNotNull("TopologyShard should never be null", topoShard);
615 assertNull("list of nodes should be null", topoShard.getNodes());
616 List<Link> sortedLinks = topoShard.getLinks().stream()
617 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
618 .collect(Collectors.toList());
619 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
620 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
622 "after 1G creation, available BW of supported ODU4 should be 99000",
623 Uint32.valueOf(99000),
624 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
626 "after 1G creation, used BW of supported ODU4 should be 1000",
627 Uint32.valueOf(1000),
628 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
631 "after 1G creation, 1 (over 80) trib slot should be occupied",
633 topoShard.getTps().get(0)
635 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
636 .TerminationPoint1.class)
637 .getXpdrTpPortConnectionAttributes()
641 "trib slot 1 should no longer be present in Trib slot list",
642 topoShard.getTps().get(0)
644 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
645 .TerminationPoint1.class)
646 .getXpdrTpPortConnectionAttributes()
648 not(hasItem(Uint16.valueOf(1))));
650 "trib slot 2 should always be present in Trib slot list",
651 topoShard.getTps().get(0)
653 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
654 .TerminationPoint1.class)
655 .getXpdrTpPortConnectionAttributes().getTsPool(),
656 hasItem(Uint16.valueOf(2)));
658 "after 1G creation, 1 (over 80) trib port should be occupied",
660 topoShard.getTps().get(0)
662 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
663 .TerminationPoint1.class)
664 .getXpdrTpPortConnectionAttributes()
665 .getOdtuTpnPool().values().stream().findFirst()
670 "trib port 1 should no longer be present in Trib port list",
671 topoShard.getTps().get(0)
673 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
674 .TerminationPoint1.class)
675 .getXpdrTpPortConnectionAttributes()
676 .getOdtuTpnPool().values().stream().findFirst()
679 not(hasItem(Uint16.valueOf(1))));
681 // tests update for 1G deletion
684 OpenRoadmOtnTopology.updateOtnLinks(
685 topoShard.getLinks(),
687 "1G", (short)1, (short)1, true);
688 sortedLinks = topoShard.getLinks().stream()
689 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
690 .collect(Collectors.toList());
691 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
692 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
694 "after 1G deletion, available BW of supported ODU4 should be 100 000",
695 Uint32.valueOf(100000),
696 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
698 "after 1G deletion, used BW of supported ODU4 should be 0",
700 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
703 "after 1G deletion, trib slot list should be full",
705 topoShard.getTps().get(0)
707 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
708 .TerminationPoint1.class)
709 .getXpdrTpPortConnectionAttributes()
713 "after 1G deletion, trib slot list should contain items 1 and 2",
714 topoShard.getTps().get(0)
716 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
717 .TerminationPoint1.class)
718 .getXpdrTpPortConnectionAttributes()
720 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
722 "after 1G deletion, trib port list should be full",
724 topoShard.getTps().get(0)
726 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
727 .TerminationPoint1.class)
728 .getXpdrTpPortConnectionAttributes()
729 .getOdtuTpnPool().values().stream().findFirst()
734 "after 1G deletion, trib port list should contain items 1",
735 topoShard.getTps().get(0)
737 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
738 .TerminationPoint1.class)
739 .getXpdrTpPortConnectionAttributes()
740 .getOdtuTpnPool().values().stream().findFirst()
743 hasItem(Uint16.valueOf(1)));
747 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
748 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
749 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
750 for (Link link : odu4Links) {
751 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
753 TopologyShard topoShard =
754 OpenRoadmOtnTopology.updateOtnLinks(
755 odu4LinksWithBadBWParam,
756 NetworkmodelTestUtil.createTpList(true),
757 "1G", (short)1, (short)1, false);
758 assertNotNull("TopologyShard should never be null", topoShard);
759 assertNull("list of nodes should be null", topoShard.getNodes());
760 assertNull("list of links should be null", topoShard.getLinks());
761 assertNull("list of tps should be null", topoShard.getTps());
765 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
766 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
767 TopologyShard topoShard =
768 OpenRoadmOtnTopology.updateOtnLinks(
769 odu4LinksWithBadBWParam,
770 NetworkmodelTestUtil.createTpList(true),
771 "10G", (short)1, (short)1, false);
772 assertNotNull("TopologyShard should never be null", topoShard);
773 assertNull("list of nodes should be null", topoShard.getNodes());
774 assertNull("list of links should be null", topoShard.getLinks());
775 assertNull("list of tps should be null", topoShard.getTps());
778 private void checkSpdrNode(Node node) {
780 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
781 .getXpdrAttributes().getXpdrNumber();
782 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
783 if (xpdrNb.equals(Uint16.valueOf(1))) {
784 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
785 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
786 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
788 // tests supporting nodes
789 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
790 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
791 .collect(Collectors.toList());
792 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
793 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
794 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
795 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
796 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
797 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
798 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
799 checkSpdrSwitchingPools(
802 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
803 .getSwitchingPools());
804 List<TerminationPoint> tpList = node.augmentation(
805 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
806 .nonnullTerminationPoint().values().stream()
807 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
808 .collect(Collectors.toList());
809 checkSpdrTpList(xpdrNb, tpList);
812 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
813 List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
815 "switching-pools augmentation should contain a single odu-switching-pools",
817 oduSwitchingPools.size());
819 "switching-pool-number should be 1",
821 oduSwitchingPools.get(0).getSwitchingPoolNumber());
823 "switching-pool-type should be non-blocking",
825 oduSwitchingPools.get(0).getSwitchingPoolType().getName());
827 List<NonBlockingList> nonBlockingList =
828 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
829 if (xpdrNb.equals(Uint16.valueOf(1))) {
831 "Mux should contain 4 non blocking list",
833 nonBlockingList.size());
836 nonBlockingList.get(0).getNblNumber());
837 List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
838 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
839 .collect(Collectors.toList());
840 for (NonBlockingList nbl : nblList) {
842 "for a 10G mux, interconnect BW should be 10G",
844 nbl.getAvailableInterconnectBandwidth());
845 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
847 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
850 String nb = nbl.getNblNumber().toString();
853 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
854 new TpId("XPDR1-CLIENT" + nb)));
856 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
858 "Switch should contain a single non blocking list",
860 nonBlockingList.size());
863 nonBlockingList.get(0).getNblNumber());
865 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
866 nonBlockingList.get(0).getTpList(),
869 nonBlockingList.get(0).getTpList(),
871 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
872 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
873 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
877 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
879 "only IfOCHOTU4ODU4 interface capabitily expected",
883 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
884 .TerminationPoint1.class)
885 .getTpSupportedInterfaces()
886 .getSupportedInterfaceCapability().values().stream().findFirst()
890 "the rate should be ODU4",
894 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
895 .TerminationPoint1.class)
896 .getXpdrTpPortConnectionAttributes()
899 "openroadm-topology",
900 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
901 .get().getNetworkRef().getValue());
903 "SPDR-SA1-XPDR" + xpdrNb,
904 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
905 .get().getNodeRef().getValue());
907 "XPDR" + xpdrNb + "-NETWORK1",
908 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
910 if (xpdrNb.equals(Uint16.valueOf(1))) {
911 assertEquals("should contain 5 TPs", 5, tpList.size());
912 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
913 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
914 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
916 "only If10GEODU2e interface capabitily expected",
920 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
921 .TerminationPoint1.class)
922 .getTpSupportedInterfaces()
923 .getSupportedInterfaceCapability().values().stream().findFirst()
927 "the rate should be ODU2e",
931 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
932 .TerminationPoint1.class)
933 .getXpdrTpPortConnectionAttributes()
936 "TP should be of type client",
937 OpenroadmTpType.XPONDERCLIENT,
940 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
941 .TerminationPoint1.class)
944 "TP should be of type network",
945 OpenroadmTpType.XPONDERNETWORK,
948 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
949 .TerminationPoint1.class)
951 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
952 assertEquals("should contain 8 TPs", 8, tpList.size());
953 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
954 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
955 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
956 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
958 "only If100GEODU4 interface capabitily expected",
962 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
963 .TerminationPoint1.class)
964 .getTpSupportedInterfaces()
965 .getSupportedInterfaceCapability().values().stream().findFirst()
969 "the rate should be ODU4",
973 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
974 .TerminationPoint1.class)
975 .getXpdrTpPortConnectionAttributes()
978 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
981 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
982 .TerminationPoint1.class)
985 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
988 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
989 .TerminationPoint1.class)