2 * Copyright © 2020 Orange Labs, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.networkmodel.util;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.CoreMatchers.not;
15 import static org.hamcrest.MatcherAssert.assertThat;
16 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
17 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.fail;
24 import com.google.gson.stream.JsonReader;
25 import java.io.FileReader;
26 import java.io.IOException;
27 import java.io.Reader;
28 import java.nio.charset.StandardCharsets;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
33 import java.util.stream.Collectors;
34 import org.junit.Test;
35 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
36 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
37 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU2e;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
64 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.OtnLinkType;
65 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.TerminationPoint1;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
70 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
71 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
72 import org.opendaylight.yangtools.yang.common.QName;
73 import org.opendaylight.yangtools.yang.common.Uint16;
74 import org.opendaylight.yangtools.yang.common.Uint32;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
78 public class OpenRoadmOtnTopologyTest {
80 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnTopologyTest.class);
81 private Nodes portMappingTpdr;
82 private Nodes portMappingSpdr;
83 private Nodes portMappingBad;
85 public OpenRoadmOtnTopologyTest() {
86 try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
87 JsonReader portMappingReader = new JsonReader(reader)) {
88 Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
89 QName.create("http://org/opendaylight/transportpce/portmapping", "2021-03-10", "network"));
90 for (Nodes nodes : portMapping.nonnullNodes().values()) {
91 if (nodes.getNodeId().equals("XPDR-A1")) {
92 this.portMappingTpdr = nodes;
94 this.portMappingSpdr = nodes;
97 Map<MappingKey,Mapping> mappingList = new HashMap<>();
98 Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("XPDR0-NETWORK0").build();
99 mappingList.put(mapping.key(),mapping);
100 this.portMappingBad = new NodesBuilder()
101 .setNodeId(this.portMappingTpdr.getNodeId())
102 .setNodeInfo(new NodeInfoBuilder(this.portMappingTpdr.getNodeInfo()).setNodeType(NodeTypes.Ila).build())
103 .setMapping(mappingList)
105 LOG.info("tpdr portMapping = {}", this.portMappingTpdr.toString());
106 LOG.info("spdr portMapping = {}", this.portMappingSpdr.toString());
107 LOG.info("ila portMapping = {}", this.portMappingBad.toString());
108 } catch (IOException e) {
109 LOG.error("Cannot init OpenRoadmOtnTopologyTest ", e);
110 fail("Cannot init OpenRoadmOtnTopologyTest ");
115 public void createTopologyShardForTpdrTest() {
116 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr);
117 assertNotNull("TopologyShard should never be null", topologyShard);
118 assertEquals("Should contain a single node", 1, topologyShard.getNodes().size());
119 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
120 Node node = topologyShard.getNodes().get(0);
121 assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue());
122 // tests supporting nodes
123 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
124 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
125 .collect(Collectors.toList());
126 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
127 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
128 assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue());
129 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
130 assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue());
131 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
132 assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue());
133 assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType());
137 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
141 List<TerminationPoint> tps = node.augmentation(
142 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
143 .nonnullTerminationPoint().values().stream()
144 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
145 .collect(Collectors.toList());
146 assertEquals("node should contain 4 TPs", 4, tps.size());
148 assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue());
151 tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
153 "only If100GE interface capabitily expected",
155 tps.get(0).augmentation(
156 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
157 .TerminationPoint1.class)
158 .getTpSupportedInterfaces()
159 .getSupportedInterfaceCapability()
162 If100GE.class.getName(),
163 tps.get(0).augmentation(
164 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
165 .TerminationPoint1.class)
166 .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability()
167 .values().stream().findFirst()
168 .get().getIfCapType().getName());
170 "first TP must be of type client",
171 OpenroadmTpType.XPONDERCLIENT,
172 tps.get(0).augmentation(
173 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
174 .TerminationPoint1.class)
177 assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue());
180 tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapPort());
182 "only IfOCH interface capabitily expected",
184 tps.get(2).augmentation(
185 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
186 .TerminationPoint1.class)
187 .getTpSupportedInterfaces()
188 .getSupportedInterfaceCapability()
191 IfOCH.class.getName(),
192 tps.get(2).augmentation(
193 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
194 .TerminationPoint1.class)
195 .getTpSupportedInterfaces()
196 .getSupportedInterfaceCapability()
197 .values().stream().findFirst()
202 "the rate should be null",
203 tps.get(2).augmentation(
204 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
205 .TerminationPoint1.class)
206 .getXpdrTpPortConnectionAttributes()
209 "third TP must be of type network",
210 OpenroadmTpType.XPONDERNETWORK,
211 tps.get(2).augmentation(
212 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
217 public void createTopologyShardForSpdrTest() {
218 TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr);
219 assertNotNull("TopologyShard should never be null", topologyShard);
220 assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size());
221 assertEquals("Should contain no link", 0, topologyShard.getLinks().size());
222 List<Node> nodes = topologyShard.getNodes().stream()
223 .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue()))
224 .collect(Collectors.toList());
225 for (Node node : nodes) {
231 public void createOtnLinksForOTU4NormalTest() {
232 String nodeA = "SPDRA";
233 String tpA = "XPDR1-NETWORK1";
234 String nodeZ = "SPDRZ";
235 String tpZ = "XPDR1-NETWORK1";
236 List<Link> links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks();
237 assertEquals("2 OTU4 links should have been created", 2, links.size());
238 List<Link> sortedLinks = links.stream()
239 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
240 .collect(Collectors.toList());
242 "name of OTU4 linkid AZ",
243 "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
244 sortedLinks.get(0).getLinkId().getValue());
246 "name of OTU4 linkid ZA",
247 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
248 sortedLinks.get(1).getLinkId().getValue());
249 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
250 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
251 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
252 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
254 "available BW at OTU4 creation should be 100G (100000)",
255 Uint32.valueOf(100000),
256 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
258 "used BW at OTU4 creation should be 0",
260 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
262 OpenroadmLinkType.OTNLINK,
263 sortedLinks.get(0).augmentation(
264 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
267 "opposite link must be present",
268 "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
269 sortedLinks.get(0).augmentation(
270 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
274 "otn link type should be OTU4",
276 sortedLinks.get(0).augmentation(
277 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
282 public void createOtnLinksForNotManagedOtnlinktypeTest() {
283 String nodeA = "SPDRA";
284 String tpA = "XPDR1-NETWORK1";
285 String nodeZ = "SPDRZ";
286 String tpZ = "XPDR1-NETWORK1";
287 TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0);
288 assertNotNull("TopologyShard should never be null", topoShard);
289 assertNull("TopologyShard should not contain any node", topoShard.getNodes());
290 assertNull("TopologyShard should not contain any link", topoShard.getLinks());
294 public void createOtnLinksForODU4NormalTest() {
295 TopologyShard topoShard = OpenRoadmOtnTopology
297 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000),
298 NetworkmodelTestUtil.createTpList(false));
299 assertNotNull("TopologyShard should never be null", topoShard);
300 assertNull("list of nodes should be null", topoShard.getNodes());
301 List<Link> sortedLinks = topoShard.getLinks().stream()
302 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
303 .collect(Collectors.toList());
304 assertEquals("list of links should contain 4 links", 4, sortedLinks.size());
305 assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"));
307 "after odu4 creation, available BW of supported OTU4 should be 0",
309 sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth());
311 "after odu4 creation, used BW of supported OTU4 should be 100 000",
312 Uint32.valueOf(100000),
313 sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth());
316 "ODU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1",
317 sortedLinks.get(0).getLinkId().getValue());
319 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
320 sortedLinks.get(1).getLinkId().getValue());
321 assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue());
322 assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue());
323 assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue());
324 assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue());
326 "after odu4 creation, its available BW should be 100 000",
327 Uint32.valueOf(100000),
328 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
330 "after odu4 creation, its used BW should be 0",
332 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
334 OpenroadmLinkType.OTNLINK,
337 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
340 "opposite link must be present",
341 "ODU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1",
344 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
348 "otn link type should be ODTU4",
352 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.Link1.class)
355 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
357 "after ODU4 creation, its termination point should contain a TsPool list",
358 topoShard.getTps().get(0)
360 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
361 .TerminationPoint1.class)
362 .getXpdrTpPortConnectionAttributes()
365 "Ts pool list should be full, with 80 trib slots",
367 topoShard.getTps().get(0)
369 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
370 .TerminationPoint1.class)
371 .getXpdrTpPortConnectionAttributes()
375 "after ODU4 creation, its termination point should contain a TpnPool list",
376 topoShard.getTps().get(0)
378 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
379 .TerminationPoint1.class)
380 .getXpdrTpPortConnectionAttributes()
381 .getOdtuTpnPool().values().stream().findFirst()
385 "Tpn pool list should be full, with 80 trib ports",
387 topoShard.getTps().get(0)
389 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
390 .TerminationPoint1.class)
391 .getXpdrTpPortConnectionAttributes()
392 .getOdtuTpnPool().values().stream().findFirst()
399 public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
400 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 100000);
401 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
402 for (Link link : otu4Links) {
403 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
405 TopologyShard topoShard =
406 OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false));
407 assertNotNull("TopologyShard should never be null", topoShard);
408 assertNull("list of nodes should be null", topoShard.getNodes());
409 assertNull("list of links should be null", topoShard.getLinks());
410 assertNull("list of tps should be null", topoShard.getTps());
412 otu4LinksWithBadBWParam.clear();
414 OpenRoadmOtnTopology.createOtnLinks(
415 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 99000),
416 NetworkmodelTestUtil.createTpList(false));
417 assertNull("list of nodes should be null", topoShard.getNodes());
418 assertNull("list of links should be null", topoShard.getLinks());
419 assertNull("list of tps should be null", topoShard.getTps());
423 public void deleteOtnLinksForODU4NormalTest() {
424 TopologyShard topoShard =
425 OpenRoadmOtnTopology.deleteOtnLinks(
426 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0),
427 NetworkmodelTestUtil.createTpList(true));
428 assertNotNull("TopologyShard should never be null", topoShard);
429 assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size());
431 "after ODU4 deletion, available BW of supported OTU4 should be 100 000",
432 Uint32.valueOf(100000),
433 topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth());
435 "after ODU4 deletion, used BW of supported OTU4 should be 0",
437 topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth());
439 assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size());
441 "after ODU4 deletion, its termination points should not contain any TsPool list",
442 topoShard.getTps().get(0)
444 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
445 .TerminationPoint1.class)
446 .getXpdrTpPortConnectionAttributes()
449 "after ODU4 deletion, its termination points should not contain any TpnPool list",
450 topoShard.getTps().get(0)
452 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
453 .TerminationPoint1.class)
454 .getXpdrTpPortConnectionAttributes()
459 public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() {
460 List<Link> otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, 0);
461 List<Link> otu4LinksWithBadBWParam = new ArrayList<>();
462 for (Link link : otu4Links) {
463 otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
465 TopologyShard topoShard =
466 OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true));
467 assertNotNull("TopologyShard should never be null", topoShard);
468 assertNull("list of nodes should be null", topoShard.getNodes());
469 assertNull("list of links should be null", topoShard.getLinks());
470 assertNull("list of tps should be null", topoShard.getTps());
474 public void updateOtnLinksFor10GTest() {
475 // tests update for 10G creation
476 TopologyShard topoShard =
477 OpenRoadmOtnTopology.updateOtnLinks(
478 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
479 NetworkmodelTestUtil.createTpList(true),
480 "10G", (short)1, (short)1, false);
481 assertNotNull("TopologyShard should never be null", topoShard);
482 assertNull("list of nodes should be null", topoShard.getNodes());
483 List<Link> sortedLinks = topoShard.getLinks().stream()
484 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
485 .collect(Collectors.toList());
486 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
487 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
489 "after 10G creation, available BW of supported ODU4 should be 90000",
490 Uint32.valueOf(90000),
491 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
493 "after 10G creation, used BW of supported ODU4 should be 10000",
494 Uint32.valueOf(10000),
495 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
498 "after 10G creation, 8 (over 80) trib slot should be occupied",
500 topoShard.getTps().get(0)
502 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
503 .TerminationPoint1.class)
504 .getXpdrTpPortConnectionAttributes()
508 "trib slot 1-8 should no longer be present in Trib slot list",
509 topoShard.getTps().get(0)
511 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
512 .TerminationPoint1.class)
513 .getXpdrTpPortConnectionAttributes()
515 not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8))));
517 "trib slot 9 should always be present in trib slot list",
518 topoShard.getTps().get(0)
520 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
521 .TerminationPoint1.class)
522 .getXpdrTpPortConnectionAttributes()
524 hasItem(Uint16.valueOf(9)));
526 "after 10G creation, 1 (over 80) trib port should be occupied",
528 topoShard.getTps().get(0)
530 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
531 .TerminationPoint1.class)
532 .getXpdrTpPortConnectionAttributes()
533 .getOdtuTpnPool().values().stream().findFirst()
538 "trib port 1 should no longer be present",
539 topoShard.getTps().get(0)
541 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
542 .TerminationPoint1.class)
543 .getXpdrTpPortConnectionAttributes()
544 .getOdtuTpnPool().values().stream().findFirst()
547 not(hasItem(Uint16.valueOf(1))));
549 // tests update for 10G deletion
551 topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), "10G", (short)1,
553 sortedLinks = topoShard.getLinks().stream()
554 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
555 .collect(Collectors.toList());
556 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
557 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
559 "after 10G deletion, available BW of supported ODU4 should be 100 000",
560 Uint32.valueOf(100000),
561 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
563 "after 10G deletion, used BW of supported ODU4 should be 0",
565 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
568 "after 10G deletion, trib slot list should be full",
570 topoShard.getTps().get(0)
572 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
573 .TerminationPoint1.class)
574 .getXpdrTpPortConnectionAttributes()
578 "after 10G deletion, trib slot list should contain items 1-8",
579 topoShard.getTps().get(0)
581 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
582 .TerminationPoint1.class)
583 .getXpdrTpPortConnectionAttributes()
585 hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9)));
587 "after 10G deletion, trib port list should be full",
589 topoShard.getTps().get(0)
591 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
592 .TerminationPoint1.class)
593 .getXpdrTpPortConnectionAttributes()
594 .getOdtuTpnPool().values().stream().findFirst()
599 "after 10G deletion, trib port list should contain items 1",
600 topoShard.getTps().get(0)
602 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
603 .TerminationPoint1.class)
604 .getXpdrTpPortConnectionAttributes()
605 .getOdtuTpnPool().values().stream().findFirst()
608 hasItem(Uint16.valueOf(1)));
612 public void updateOtnLinksFor1GCreationTest() {
613 // tests update for 1G creation
614 TopologyShard topoShard =
615 OpenRoadmOtnTopology.updateOtnLinks(
616 NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000),
617 NetworkmodelTestUtil.createTpList(true),
618 "1G", (short)1, (short)1, false);
619 assertNotNull("TopologyShard should never be null", topoShard);
620 assertNull("list of nodes should be null", topoShard.getNodes());
621 List<Link> sortedLinks = topoShard.getLinks().stream()
622 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
623 .collect(Collectors.toList());
624 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
625 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
627 "after 1G creation, available BW of supported ODU4 should be 99000",
628 Uint32.valueOf(99000),
629 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
631 "after 1G creation, used BW of supported ODU4 should be 1000",
632 Uint32.valueOf(1000),
633 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
636 "after 1G creation, 1 (over 80) trib slot should be occupied",
638 topoShard.getTps().get(0)
640 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
641 .TerminationPoint1.class)
642 .getXpdrTpPortConnectionAttributes()
646 "trib slot 1 should no longer be present in Trib slot list",
647 topoShard.getTps().get(0)
649 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
650 .TerminationPoint1.class)
651 .getXpdrTpPortConnectionAttributes()
653 not(hasItem(Uint16.valueOf(1))));
655 "trib slot 2 should always be present in Trib slot list",
656 topoShard.getTps().get(0)
658 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
659 .TerminationPoint1.class)
660 .getXpdrTpPortConnectionAttributes().getTsPool(),
661 hasItem(Uint16.valueOf(2)));
663 "after 1G creation, 1 (over 80) trib port should be occupied",
665 topoShard.getTps().get(0)
667 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
668 .TerminationPoint1.class)
669 .getXpdrTpPortConnectionAttributes()
670 .getOdtuTpnPool().values().stream().findFirst()
675 "trib port 1 should no longer be present in Trib port list",
676 topoShard.getTps().get(0)
678 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
679 .TerminationPoint1.class)
680 .getXpdrTpPortConnectionAttributes()
681 .getOdtuTpnPool().values().stream().findFirst()
684 not(hasItem(Uint16.valueOf(1))));
686 // tests update for 1G deletion
689 OpenRoadmOtnTopology.updateOtnLinks(
690 topoShard.getLinks(),
692 "1G", (short)1, (short)1, true);
693 sortedLinks = topoShard.getLinks().stream()
694 .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()))
695 .collect(Collectors.toList());
696 assertEquals("list of links should contain 2 links", 2, sortedLinks.size());
697 assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODU4-"));
699 "after 1G deletion, available BW of supported ODU4 should be 100 000",
700 Uint32.valueOf(100000),
701 sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth());
703 "after 1G deletion, used BW of supported ODU4 should be 0",
705 sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth());
708 "after 1G deletion, trib slot list should be full",
710 topoShard.getTps().get(0)
712 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
713 .TerminationPoint1.class)
714 .getXpdrTpPortConnectionAttributes()
718 "after 1G deletion, trib slot list should contain items 1 and 2",
719 topoShard.getTps().get(0)
721 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
722 .TerminationPoint1.class)
723 .getXpdrTpPortConnectionAttributes()
725 hasItems(Uint16.valueOf(1), Uint16.valueOf(2)));
727 "after 1G deletion, trib port list should be full",
729 topoShard.getTps().get(0)
731 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
732 .TerminationPoint1.class)
733 .getXpdrTpPortConnectionAttributes()
734 .getOdtuTpnPool().values().stream().findFirst()
739 "after 1G deletion, trib port list should contain items 1",
740 topoShard.getTps().get(0)
742 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
743 .TerminationPoint1.class)
744 .getXpdrTpPortConnectionAttributes()
745 .getOdtuTpnPool().values().stream().findFirst()
748 hasItem(Uint16.valueOf(1)));
752 public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() {
753 List<Link> odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 100000);
754 List<Link> odu4LinksWithBadBWParam = new ArrayList<>();
755 for (Link link : odu4Links) {
756 odu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build());
758 TopologyShard topoShard =
759 OpenRoadmOtnTopology.updateOtnLinks(
760 odu4LinksWithBadBWParam,
761 NetworkmodelTestUtil.createTpList(true),
762 "1G", (short)1, (short)1, false);
763 assertNotNull("TopologyShard should never be null", topoShard);
764 assertNull("list of nodes should be null", topoShard.getNodes());
765 assertNull("list of links should be null", topoShard.getLinks());
766 assertNull("list of tps should be null", topoShard.getTps());
770 public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() {
771 List<Link> odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, 8000);
772 TopologyShard topoShard =
773 OpenRoadmOtnTopology.updateOtnLinks(
774 odu4LinksWithBadBWParam,
775 NetworkmodelTestUtil.createTpList(true),
776 "10G", (short)1, (short)1, false);
777 assertNotNull("TopologyShard should never be null", topoShard);
778 assertNull("list of nodes should be null", topoShard.getNodes());
779 assertNull("list of links should be null", topoShard.getLinks());
780 assertNull("list of tps should be null", topoShard.getTps());
783 private void checkSpdrNode(Node node) {
785 .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
786 .getXpdrAttributes().getXpdrNumber();
787 assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue());
788 if (xpdrNb.equals(Uint16.valueOf(1))) {
789 assertEquals(OpenroadmNodeType.MUXPDR, node.augmentation(Node1.class).getNodeType());
790 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
791 assertEquals(OpenroadmNodeType.SWITCH, node.augmentation(Node1.class).getNodeType());
793 // tests supporting nodes
794 List<SupportingNode> supportingNodes = node.nonnullSupportingNode().values().stream()
795 .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue()))
796 .collect(Collectors.toList());
797 assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size());
798 assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue());
799 assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue());
800 assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue());
801 assertEquals("SPDR-SA1", supportingNodes.get(1).getNodeRef().getValue());
802 assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue());
803 assertEquals("SPDR-SA1-XPDR" + xpdrNb, supportingNodes.get(2).getNodeRef().getValue());
804 checkSpdrSwitchingPools(
807 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class)
808 .getSwitchingPools());
809 List<TerminationPoint> tpList = node.augmentation(
810 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
811 .nonnullTerminationPoint().values().stream()
812 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
813 .collect(Collectors.toList());
814 checkSpdrTpList(xpdrNb, tpList);
817 private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) {
818 List<OduSwitchingPools> oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
820 "switching-pools augmentation should contain a single odu-switching-pools",
822 oduSwitchingPools.size());
824 "switching-pool-number should be 1",
826 oduSwitchingPools.get(0).getSwitchingPoolNumber());
828 "switching-pool-type should be non-blocking",
830 oduSwitchingPools.get(0).getSwitchingPoolType().getName());
832 List<NonBlockingList> nonBlockingList =
833 new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values());
834 if (xpdrNb.equals(Uint16.valueOf(1))) {
836 "Mux should contain 4 non blocking list",
838 nonBlockingList.size());
841 nonBlockingList.get(0).getNblNumber());
842 List<NonBlockingList> nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream()
843 .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber()))
844 .collect(Collectors.toList());
845 for (NonBlockingList nbl : nblList) {
847 "for a 10G mux, interconnect BW should be 10G",
849 nbl.getAvailableInterconnectBandwidth());
850 assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit());
852 "for a 10G mux, non blocking list should contain 2 entries (client + network ports)",
855 String nb = nbl.getNblNumber().toString();
858 containsInAnyOrder(new TpId("XPDR1-NETWORK1"),
859 new TpId("XPDR1-CLIENT" + nb)));
861 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
863 "Switch should contain a single non blocking list",
865 nonBlockingList.size());
868 nonBlockingList.get(0).getNblNumber());
870 "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)",
871 nonBlockingList.get(0).getTpList(),
874 nonBlockingList.get(0).getTpList(),
876 new TpId("XPDR2-CLIENT1"), new TpId("XPDR2-NETWORK1"), new TpId("XPDR2-CLIENT2"),
877 new TpId("XPDR2-NETWORK2"), new TpId("XPDR2-CLIENT3"), new TpId("XPDR2-NETWORK3"),
878 new TpId("XPDR2-CLIENT4"), new TpId("XPDR2-NETWORK4")));
882 private void checkSpdrTpList(Uint16 xpdrNb, List<TerminationPoint> tpList) {
884 "only IfOCHOTU4ODU4 interface capabitily expected",
888 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
889 .TerminationPoint1.class)
890 .getTpSupportedInterfaces()
891 .getSupportedInterfaceCapability().values().stream().findFirst()
895 "the rate should be ODU4",
899 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
900 .TerminationPoint1.class)
901 .getXpdrTpPortConnectionAttributes()
904 "openroadm-topology",
905 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
906 .get().getNetworkRef().getValue());
908 "SPDR-SA1-XPDR" + xpdrNb,
909 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
910 .get().getNodeRef().getValue());
912 "XPDR" + xpdrNb + "-NETWORK1",
913 tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst()
914 .get().getTpRef().toString());
915 if (xpdrNb.equals(Uint16.valueOf(1))) {
916 assertEquals("should contain 5 TPs", 5, tpList.size());
917 assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue());
918 assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue());
919 assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue());
921 "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type",
925 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
926 .TerminationPoint1.class)
927 .getTpSupportedInterfaces()
928 .getSupportedInterfaceCapability().values().size());
930 "supported interface capability of tp-id XPDR1-CLIENT1 should contain 3 if-cap-type",
934 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
935 .TerminationPoint1.class)
936 .getTpSupportedInterfaces()
937 .getSupportedInterfaceCapability().values().size());
938 List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2)
940 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
941 .TerminationPoint1.class)
942 .getTpSupportedInterfaces()
943 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
944 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
945 assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2",
946 String.valueOf(supportedInterfaceCapability.getIfCapType()),
947 either(containsString(String.valueOf(If10GEODU2e.class)))
948 .or(containsString(String.valueOf(If10GEODU2.class))));
950 List<SupportedInterfaceCapability> sicListClient1 = tpList.get(0)
952 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
953 .TerminationPoint1.class)
954 .getTpSupportedInterfaces()
955 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
956 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) {
957 assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE",
958 String.valueOf(supportedInterfaceCapability.getIfCapType()),
959 either(containsString(String.valueOf(If10GEODU2e.class)))
960 .or(containsString(String.valueOf(If10GEODU2.class)))
961 .or(containsString(String.valueOf(If10GE.class))));
964 "the rate should be ODU2e",
968 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
969 .TerminationPoint1.class)
970 .getXpdrTpPortConnectionAttributes()
973 "TP should be of type client",
974 OpenroadmTpType.XPONDERCLIENT,
977 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
978 .TerminationPoint1.class)
981 "TP should be of type network",
982 OpenroadmTpType.XPONDERNETWORK,
985 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
986 .TerminationPoint1.class)
988 } else if (xpdrNb.equals(Uint16.valueOf(2))) {
989 assertEquals("should contain 8 TPs", 8, tpList.size());
990 assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue());
991 assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue());
992 assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue());
993 assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue());
995 "only IfOCHOTU4ODU4 interface capabitily expected",
999 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1000 .TerminationPoint1.class)
1001 .getTpSupportedInterfaces()
1002 .getSupportedInterfaceCapability().values().stream().findFirst()
1006 "supported interface capability of tp should contain 2 IfCapType",
1010 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1011 .TerminationPoint1.class)
1012 .getTpSupportedInterfaces()
1013 .getSupportedInterfaceCapability().values().size());
1014 List<SupportedInterfaceCapability> sicListClient3 = tpList.get(2)
1016 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529
1017 .TerminationPoint1.class)
1018 .getTpSupportedInterfaces()
1019 .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList());
1020 for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) {
1021 assertThat("tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE",
1022 String.valueOf(supportedInterfaceCapability.getIfCapType()),
1023 either(containsString(String.valueOf(If100GEODU4.class)))
1024 .or(containsString(String.valueOf(If100GE.class))));
1027 "TP should be of type client", OpenroadmTpType.XPONDERCLIENT,
1030 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1031 .TerminationPoint1.class)
1034 "TP should be of type network", OpenroadmTpType.XPONDERNETWORK,
1037 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
1038 .TerminationPoint1.class)