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.Ignore;
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.rev200827.Network;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.Nodes;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.NodesBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.MappingKey;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.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.common.types.rev181019.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;
73 public class OpenRoadmOtnTopologyTest {
75 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
76 private Nodes portMappingTpdr;
77 private Nodes portMappingSpdr;
78 private Nodes portMappingBad;
80 public OpenRoadmOtnTopologyTest() {
81 try (Reader reader = new FileReader("src/test/resources/portMapping.json");
82 JsonReader portMappingReader = new JsonReader(reader)) {
83 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
84 QName.create("http://org/opendaylight/transportpce/portmapping", "2020-08-27", "network"));
85 for (Nodes nodes : portMapping.nonnullNodes().values()) {
86 if (nodes.getNodeId().equals("XPDR-A1")) {
87 this.portMappingTpdr = nodes;
89 this.portMappingSpdr = nodes;
92 Map<MappingKey,Mapping> mappingList = new HashMap<>();
93 Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
94 mappingList.put(mapping.key(),mapping);
95 this.portMappingBad = new NodesBuilder()
96 .setNodeId(this.portMappingTpdr.getNodeId())
97 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
98 .setMapping(mappingList)
100 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
101 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
102 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
103 } catch (IOException e) {
104 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
105 fail("Cannot init OpenRoadmOtnTopologyTest ");
110 public void createTopologyShardForTpdrTest() {
111 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
112 assertNotNull("TopologyShard should never be null", topologyShard);
113 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
114 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
115 Node node = topologyShard.getNodes().get(0);
116 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
117 // tests supporting nodes
118 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
119 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
120 .collect(Collectors.toList());
121 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
122 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
123 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
124 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
125 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
126 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
127 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
128 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
132 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
136 List<TerminationPoint> tps = node.augmentation(
137 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
138 .nonnullTerminationPoint().values().stream()
139 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
140 .collect(Collectors.toList());
141 assertEquals("node should contain 4 TPs", 4, tps.size());
143 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
146 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
148 "only If100GE interface capabitily expected",
150 tps.get(0).augmentation(
151 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
152 .TerminationPoint1.class)
153 .getTpSupportedInterfaces()
154 .getSupportedInterfaceCapability()
157 If100GE.class.getName(),
158 tps.get(0).augmentation(
159 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
160 .TerminationPoint1.class)
161 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
162 .values().stream().findFirst()
163 .get().getIfCapType().getName());
165 "first TP must be of type client",
166 OpenroadmTpType.XPONDERCLIENT,
167 tps.get(0).augmentation(
168 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
169 .TerminationPoint1.class)
172 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
175 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
177 "only IfOCHOTU4ODU4 interface capabitily expected",
179 tps.get(2).augmentation(
180 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
181 .TerminationPoint1.class)
182 .getTpSupportedInterfaces()
183 .getSupportedInterfaceCapability()
186 IfOCHOTU4ODU4.class.getName(),
187 tps.get(2).augmentation(
188 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
189 .TerminationPoint1.class)
190 .getTpSupportedInterfaces()
191 .getSupportedInterfaceCapability()
192 .values().stream().findFirst()
197 "the rate should be ODU4",
198 ODU4.class.getName(),
199 tps.get(2).augmentation(
200 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
201 .TerminationPoint1.class)
202 .getXpdrTpPortConnectionAttributes()
206 "third TP must be of type network",
207 OpenroadmTpType.XPONDERNETWORK,
208 tps.get(2).augmentation(
209 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.TerminationPoint1.class)
214 public void createTopologyShardForSpdrTest() {
215 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
216 assertNotNull("TopologyShard should never be null", topologyShard);
217 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
218 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
219 List<Node> nodes = topologyShard.getNodes().stream()
220 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
221 .collect(Collectors.toList());
222 for (Node node : nodes) {
228 public void createOtnLinksForOTU4NormalTest() {
229 String nodeA = "SPDRA";
230 String tpA = "XPDR1-NETWORK1";
231 String nodeZ = "SPDRZ";
232 String tpZ = "XPDR1-NETWORK1";
233 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
234 assertEquals("2 OTU4 links should have been created", 2, links.size());
235 List<Link> sortedLinks = links.stream()
236 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
237 .collect(Collectors.toList());
239 "name of OTU4 linkid AZ",
240 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
241 sortedLinks.get(0).getLinkId().getValue());
243 "name of OTU4 linkid ZA",
244 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
245 sortedLinks.get(1).getLinkId().getValue());
246 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
247 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
248 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
249 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
251 "available BW at OTU4 creation should be 100G (100000)",
252 Uint32.valueOf(100000),
253 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
255 "used BW at OTU4 creation should be 0",
257 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
259 OpenroadmLinkType.OTNLINK,
260 sortedLinks.get(0).augmentation(
261 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
264 "opposite link must be present",
265 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
266 sortedLinks.get(0).augmentation(
267 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
271 "otn link type should be OTU4",
273 sortedLinks.get(0).augmentation(
274 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
279 public void createOtnLinksForNotManagedOtnlinktypeTest() {
280 String nodeA = "SPDRA";
281 String tpA = "XPDR1-NETWORK1";
282 String nodeZ = "SPDRZ";
283 String tpZ = "XPDR1-NETWORK1";
284 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
285 assertNotNull("TopologyShard should never be null", topoShard);
286 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
287 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
291 public void createOtnLinksForODU4NormalTest() {
292 TopologyShard topoShard = OpenRoadmOtnTopology
294 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
295 NetworkmodelTestUtil.createTpList(false));
296 assertNotNull("TopologyShard should never be null", topoShard);
297 assertNull("list of nodes should be null", topoShard.getNodes());
298 List<Link> sortedLinks = topoShard.getLinks().stream()
299 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
300 .collect(Collectors.toList());
301 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
302 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
304 "after odu4 creation, available BW of supported OTU4 should be 0",
306 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
308 "after odu4 creation, used BW of supported OTU4 should be 100 000",
309 Uint32.valueOf(100000),
310 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
313 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
314 sortedLinks.get(0).getLinkId().getValue());
316 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
317 sortedLinks.get(1).getLinkId().getValue());
318 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
319 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
320 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
321 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
323 "after odu4 creation, its available BW should be 100 000",
324 Uint32.valueOf(100000),
325 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
327 "after odu4 creation, its used BW should be 0",
329 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
331 OpenroadmLinkType.OTNLINK,
334 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
337 "opposite link must be present",
338 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
341 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class)
345 "otn link type should be ODTU4",
349 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class)
352 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
354 "after ODU4 creation, its termination point should contain a TsPool list",
355 topoShard.getTps().get(0)
357 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
358 .TerminationPoint1.class)
359 .getXpdrTpPortConnectionAttributes()
362 "Ts pool list should be full, with 80 trib slots",
364 topoShard.getTps().get(0)
366 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
367 .TerminationPoint1.class)
368 .getXpdrTpPortConnectionAttributes()
372 "after ODU4 creation, its termination point should contain a TpnPool list",
373 topoShard.getTps().get(0)
375 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
376 .TerminationPoint1.class)
377 .getXpdrTpPortConnectionAttributes()
378 .getOdtuTpnPool().values().stream().findFirst()
382 "Tpn pool list should be full, with 80 trib ports",
384 topoShard.getTps().get(0)
386 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
387 .TerminationPoint1.class)
388 .getXpdrTpPortConnectionAttributes()
389 .getOdtuTpnPool().values().stream().findFirst()
396 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
397 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
398 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
399 for (Link link : otu4Links) {
400 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
402 TopologyShard topoShard =
403 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
404 assertNotNull("TopologyShard should never be null", topoShard);
405 assertNull("list of nodes should be null", topoShard.getNodes());
406 assertNull("list of links should be null", topoShard.getLinks());
407 assertNull("list of tps should be null", topoShard.getTps());
409 otu4LinksWithBadBWParam.clear();
411 OpenRoadmOtnTopology.createOtnLinks(
412 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
413 NetworkmodelTestUtil.createTpList(false));
414 assertNull("list of nodes should be null", topoShard.getNodes());
415 assertNull("list of links should be null", topoShard.getLinks());
416 assertNull("list of tps should be null", topoShard.getTps());
420 public void deleteOtnLinksForODU4NormalTest() {
421 TopologyShard topoShard =
422 OpenRoadmOtnTopology.deleteOtnLinks(
423 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
424 NetworkmodelTestUtil.createTpList(true));
425 assertNotNull("TopologyShard should never be null", topoShard);
426 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
428 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
429 Uint32.valueOf(100000),
430 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
432 "after ODU4 deletion, used BW of supported OTU4 should be 0",
434 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
436 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
438 "after ODU4 deletion, its termination points should not contain any TsPool list",
439 topoShard.getTps().get(0)
441 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
442 .TerminationPoint1.class)
443 .getXpdrTpPortConnectionAttributes()
446 "after ODU4 deletion, its termination points should not contain any TpnPool list",
447 topoShard.getTps().get(0)
449 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
450 .TerminationPoint1.class)
451 .getXpdrTpPortConnectionAttributes()
456 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
457 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
458 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
459 for (Link link : otu4Links) {
460 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
462 TopologyShard topoShard =
463 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
464 assertNotNull("TopologyShard should never be null", topoShard);
465 assertNull("list of nodes should be null", topoShard.getNodes());
466 assertNull("list of links should be null", topoShard.getLinks());
467 assertNull("list of tps should be null", topoShard.getTps());
471 public void updateOtnLinksFor10GTest() {
472 // tests update for 10G creation
473 TopologyShard topoShard =
474 OpenRoadmOtnTopology.updateOtnLinks(
475 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
476 NetworkmodelTestUtil.createTpList(true),
477 "10G", (short)1, (short)1, false);
478 assertNotNull("TopologyShard should never be null", topoShard);
479 assertNull("list of nodes should be null", topoShard.getNodes());
480 List<Link> sortedLinks = topoShard.getLinks().stream()
481 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
482 .collect(Collectors.toList());
483 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
484 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
486 "after 10G creation, available BW of supported ODU4 should be 90000",
487 Uint32.valueOf(90000),
488 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
490 "after 10G creation, used BW of supported ODU4 should be 10000",
491 Uint32.valueOf(10000),
492 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
495 "after 10G creation, 8 (over 80) trib slot should be occupied",
497 topoShard.getTps().get(0)
499 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
500 .TerminationPoint1.class)
501 .getXpdrTpPortConnectionAttributes()
505 "trib slot 1-8 should no longer be present in Trib slot list",
506 topoShard.getTps().get(0)
508 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
509 .TerminationPoint1.class)
510 .getXpdrTpPortConnectionAttributes()
512 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
514 "trib slot 9 should always be present in trib slot list",
515 topoShard.getTps().get(0)
517 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
518 .TerminationPoint1.class)
519 .getXpdrTpPortConnectionAttributes()
521 hasItem(Uint16.valueOf(9)));
523 "after 10G creation, 1 (over 80) trib port should be occupied",
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().values().stream().findFirst()
535 "trib port 1 should no longer be present",
536 topoShard.getTps().get(0)
538 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
539 .TerminationPoint1.class)
540 .getXpdrTpPortConnectionAttributes()
541 .getOdtuTpnPool().values().stream().findFirst()
544 not(hasItem(Uint16.valueOf(1))));
546 // tests update for 10G deletion
548 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
550 sortedLinks = topoShard.getLinks().stream()
551 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
552 .collect(Collectors.toList());
553 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
554 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
556 "after 10G deletion, available BW of supported ODU4 should be 100 000",
557 Uint32.valueOf(100000),
558 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
560 "after 10G deletion, used BW of supported ODU4 should be 0",
562 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
565 "after 10G deletion, trib slot list should be full",
567 topoShard.getTps().get(0)
569 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
570 .TerminationPoint1.class)
571 .getXpdrTpPortConnectionAttributes()
575 "after 10G deletion, trib slot list should contain items 1-8",
576 topoShard.getTps().get(0)
578 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
579 .TerminationPoint1.class)
580 .getXpdrTpPortConnectionAttributes()
582 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
584 "after 10G deletion, trib port list should be full",
586 topoShard.getTps().get(0)
588 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
589 .TerminationPoint1.class)
590 .getXpdrTpPortConnectionAttributes()
591 .getOdtuTpnPool().values().stream().findFirst()
596 "after 10G deletion, trib port list should contain items 1",
597 topoShard.getTps().get(0)
599 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
600 .TerminationPoint1.class)
601 .getXpdrTpPortConnectionAttributes()
602 .getOdtuTpnPool().values().stream().findFirst()
605 hasItem(Uint16.valueOf(1)));
609 public void updateOtnLinksFor1GCreationTest() {
610 // tests update for 1G creation
611 TopologyShard topoShard =
612 OpenRoadmOtnTopology.updateOtnLinks(
613 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
614 NetworkmodelTestUtil.createTpList(true),
615 "1G", (short)1, (short)1, false);
616 assertNotNull("TopologyShard should never be null", topoShard);
617 assertNull("list of nodes should be null", topoShard.getNodes());
618 List<Link> sortedLinks = topoShard.getLinks().stream()
619 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
620 .collect(Collectors.toList());
621 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
622 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
624 "after 1G creation, available BW of supported ODU4 should be 99000",
625 Uint32.valueOf(99000),
626 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
628 "after 1G creation, used BW of supported ODU4 should be 1000",
629 Uint32.valueOf(1000),
630 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
633 "after 1G creation, 1 (over 80) trib slot should be occupied",
635 topoShard.getTps().get(0)
637 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
638 .TerminationPoint1.class)
639 .getXpdrTpPortConnectionAttributes()
643 "trib slot 1 should no longer be present in Trib slot list",
644 topoShard.getTps().get(0)
646 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
647 .TerminationPoint1.class)
648 .getXpdrTpPortConnectionAttributes()
650 not(hasItem(Uint16.valueOf(1))));
652 "trib slot 2 should always be present in Trib slot list",
653 topoShard.getTps().get(0)
655 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
656 .TerminationPoint1.class)
657 .getXpdrTpPortConnectionAttributes().getTsPool(),
658 hasItem(Uint16.valueOf(2)));
660 "after 1G creation, 1 (over 80) trib port should be occupied",
662 topoShard.getTps().get(0)
664 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
665 .TerminationPoint1.class)
666 .getXpdrTpPortConnectionAttributes()
667 .getOdtuTpnPool().values().stream().findFirst()
672 "trib port 1 should no longer be present in Trib port list",
673 topoShard.getTps().get(0)
675 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
676 .TerminationPoint1.class)
677 .getXpdrTpPortConnectionAttributes()
678 .getOdtuTpnPool().values().stream().findFirst()
681 not(hasItem(Uint16.valueOf(1))));
683 // tests update for 1G deletion
686 OpenRoadmOtnTopology.updateOtnLinks(
687 topoShard.getLinks(),
689 "1G", (short)1, (short)1, true);
690 sortedLinks = topoShard.getLinks().stream()
691 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
692 .collect(Collectors.toList());
693 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
694 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
696 "after 1G deletion, available BW of supported ODU4 should be 100 000",
697 Uint32.valueOf(100000),
698 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
700 "after 1G deletion, used BW of supported ODU4 should be 0",
702 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
705 "after 1G deletion, trib slot list should be full",
707 topoShard.getTps().get(0)
709 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
710 .TerminationPoint1.class)
711 .getXpdrTpPortConnectionAttributes()
715 "after 1G deletion, trib slot list should contain items 1 and 2",
716 topoShard.getTps().get(0)
718 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
719 .TerminationPoint1.class)
720 .getXpdrTpPortConnectionAttributes()
722 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
724 "after 1G deletion, trib port list should be full",
726 topoShard.getTps().get(0)
728 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
729 .TerminationPoint1.class)
730 .getXpdrTpPortConnectionAttributes()
731 .getOdtuTpnPool().values().stream().findFirst()
736 "after 1G deletion, trib port list should contain items 1",
737 topoShard.getTps().get(0)
739 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
740 .TerminationPoint1.class)
741 .getXpdrTpPortConnectionAttributes()
742 .getOdtuTpnPool().values().stream().findFirst()
745 hasItem(Uint16.valueOf(1)));
749 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
750 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
751 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
752 for (Link link : odu4Links) {
753 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
755 TopologyShard topoShard =
756 OpenRoadmOtnTopology.updateOtnLinks(
757 odu4LinksWithBadBWParam,
758 NetworkmodelTestUtil.createTpList(true),
759 "1G", (short)1, (short)1, false);
760 assertNotNull("TopologyShard should never be null", topoShard);
761 assertNull("list of nodes should be null", topoShard.getNodes());
762 assertNull("list of links should be null", topoShard.getLinks());
763 assertNull("list of tps should be null", topoShard.getTps());
767 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
768 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
769 TopologyShard topoShard =
770 OpenRoadmOtnTopology.updateOtnLinks(
771 odu4LinksWithBadBWParam,
772 NetworkmodelTestUtil.createTpList(true),
773 "10G", (short)1, (short)1, false);
774 assertNotNull("TopologyShard should never be null", topoShard);
775 assertNull("list of nodes should be null", topoShard.getNodes());
776 assertNull("list of links should be null", topoShard.getLinks());
777 assertNull("list of tps should be null", topoShard.getTps());
780 private void checkSpdrNode(Node node) {
782 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
783 .getXpdrAttributes().getXpdrNumber();
784 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
785 if (xpdrNb.equals(Uint16.valueOf(1))) {
786 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
787 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
788 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
790 // tests supporting nodes
791 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
792 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
793 .collect(Collectors.toList());
794 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
795 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
796 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
797 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
798 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
799 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
800 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
801 checkSpdrSwitchingPools(
804 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class)
805 .getSwitchingPools());
806 List<TerminationPoint> tpList = node.augmentation(
807 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
808 .nonnullTerminationPoint().values().stream()
809 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
810 .collect(Collectors.toList());
811 checkSpdrTpList(xpdrNb, tpList);
814 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
815 List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
817 "switching-pools augmentation should contain a single odu-switching-pools",
819 oduSwitchingPools.size());
821 "switching-pool-number should be 1",
823 oduSwitchingPools.get(0).getSwitchingPoolNumber());
825 "switching-pool-type should be non-blocking",
827 oduSwitchingPools.get(0).getSwitchingPoolType().getName());
829 List<NonBlockingList> nonBlockingList =
830 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
831 if (xpdrNb.equals(Uint16.valueOf(1))) {
833 "Mux should contain 4 non blocking list",
835 nonBlockingList.size());
838 nonBlockingList.get(0).getNblNumber());
839 List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
840 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
841 .collect(Collectors.toList());
842 for (NonBlockingList nbl : nblList) {
844 "for a 10G mux, interconnect BW should be 10G",
846 nbl.getAvailableInterconnectBandwidth());
847 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
849 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
852 String nb = nbl.getNblNumber().toString();
855 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
856 new TpId("XPDR1-CLIENT" + nb)));
858 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
860 "Switch should contain a single non blocking list",
862 nonBlockingList.size());
865 nonBlockingList.get(0).getNblNumber());
867 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
868 nonBlockingList.get(0).getTpList(),
871 nonBlockingList.get(0).getTpList(),
873 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
874 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
875 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
879 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
881 "only IfOCHOTU4ODU4 interface capabitily expected",
885 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
886 .TerminationPoint1.class)
887 .getTpSupportedInterfaces()
888 .getSupportedInterfaceCapability().values().stream().findFirst()
892 "the rate should be ODU4",
896 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
897 .TerminationPoint1.class)
898 .getXpdrTpPortConnectionAttributes()
901 "openroadm-topology",
902 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
903 .get().getNetworkRef().getValue());
905 "SPDR-SA1-XPDR" + xpdrNb,
906 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
907 .get().getNodeRef().getValue());
909 "XPDR" + xpdrNb + "-NETWORK1",
910 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
912 if (xpdrNb.equals(Uint16.valueOf(1))) {
913 assertEquals("should contain 5 TPs", 5, tpList.size());
914 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
915 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
916 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
918 "only If10GEODU2e interface capabitily expected",
922 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
923 .TerminationPoint1.class)
924 .getTpSupportedInterfaces()
925 .getSupportedInterfaceCapability().values().stream().findFirst()
929 "the rate should be ODU2e",
933 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
934 .TerminationPoint1.class)
935 .getXpdrTpPortConnectionAttributes()
938 "TP should be of type client",
939 OpenroadmTpType.XPONDERCLIENT,
942 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
943 .TerminationPoint1.class)
946 "TP should be of type network",
947 OpenroadmTpType.XPONDERNETWORK,
950 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
951 .TerminationPoint1.class)
953 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
954 assertEquals("should contain 8 TPs", 8, tpList.size());
955 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
956 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
957 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
958 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
960 "only If100GEODU4 interface capabitily expected",
964 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
965 .TerminationPoint1.class)
966 .getTpSupportedInterfaces()
967 .getSupportedInterfaceCapability().values().stream().findFirst()
971 "the rate should be ODU4",
975 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130
976 .TerminationPoint1.class)
977 .getXpdrTpPortConnectionAttributes()
980 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
983 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
984 .TerminationPoint1.class)
987 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
990 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
991 .TerminationPoint1.class)