2 * Copyright © 2019 Orange, 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.tapi.topology;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertNotNull;
16 import com.google.common.util.concurrent.ListenableFuture;
17 import com.google.common.util.concurrent.ListeningExecutorService;
18 import com.google.common.util.concurrent.MoreExecutors;
19 import java.nio.charset.Charset;
20 import java.nio.charset.StandardCharsets;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
25 import java.util.UUID;
26 import java.util.concurrent.CountDownLatch;
27 import java.util.concurrent.ExecutionException;
28 import java.util.concurrent.Executors;
29 import java.util.stream.Collectors;
30 import org.eclipse.jdt.annotation.Nullable;
31 import org.junit.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.Test;
33 import org.opendaylight.transportpce.common.InstanceIdentifiers;
34 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
35 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
36 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
37 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
38 import org.opendaylight.transportpce.tapi.TapiStringConstants;
39 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
40 import org.opendaylight.transportpce.tapi.utils.TapiContext;
41 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
42 import org.opendaylight.transportpce.tapi.utils.TapiLink;
43 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
44 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
45 import org.opendaylight.transportpce.test.AbstractTest;
46 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListInput;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListOutput;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.Sip;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.SipKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsInput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsOutput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsInput;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutput;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsInput;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutput;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsInput;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsOutput;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Node;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.topology.details.output.Topology;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
79 import org.opendaylight.yangtools.yang.common.Decimal64;
80 import org.opendaylight.yangtools.yang.common.RpcResult;
81 import org.opendaylight.yangtools.yang.common.Uint64;
82 import org.slf4j.Logger;
83 import org.slf4j.LoggerFactory;
85 public class TapiTopologyImplTest extends AbstractTest {
86 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
88 private static ListeningExecutorService executorService;
89 private static CountDownLatch endSignal;
90 private static final int NUM_THREADS = 3;
91 private static NetworkTransactionService networkTransactionService;
92 private static TapiContext tapiContext;
93 private static TopologyUtils topologyUtils;
94 private static ConnectivityUtils connectivityUtils;
95 private static ServiceDataStoreOperations serviceDataStoreOperations;
96 private static TapiInitialORMapping tapiInitialORMapping;
97 private static TapiLink tapiLink;
100 static void setUp() throws InterruptedException, ExecutionException {
101 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
102 endSignal = new CountDownLatch(1);
103 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
104 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
105 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
106 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
107 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
108 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
109 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
110 TapiTopologyDataUtils.PORTMAPPING_FILE);
111 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
112 tapiLink = new TapiLinkImpl(networkTransactionService);
113 serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
114 tapiContext = new TapiContext(networkTransactionService);
115 topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
117 connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
118 networkTransactionService);
119 tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
120 tapiContext, serviceDataStoreOperations);
121 tapiInitialORMapping.performTopoInitialMapping();
122 LOG.info("setup done");
126 void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
127 throws ExecutionException, InterruptedException {
128 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(
129 Charset.forName("UTF-8"))).toString());
130 LOG.info("TPDR100GUuid = {}", topologyUuid);
131 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
132 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
133 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
134 LOG.info("RESULT of getTopoDetailsTopo/name = {}", result.get().getResult().getTopology().getName().toString());
135 result.addListener(new Runnable() {
138 endSignal.countDown();
142 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
144 Topology topology = rpcResult.getResult().getTopology();
145 assertNotNull(topology, "Topology should not be null");
146 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(StandardCharsets.UTF_8))
148 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
149 assertEquals(1, topology.getNode().size(), "Node list size should be 1");
150 Name nodeName = topology.getNode().values().stream().findFirst().orElseThrow().getName()
151 .get(new NameKey("Tpdr100g node name"));
152 assertEquals("Tpdr100g over WDM node", nodeName.getValue(), "Node name should be 'Tpdr100g over WDM node'");
153 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
155 assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().orElseThrow().getUuid(),
156 "incorrect node uuid");
157 long nb = topology.getNode().values().stream().findFirst().orElseThrow().getOwnedNodeEdgePoint().size();
158 assertEquals(2, nb, "'Transponder 100GE' node should have 2 neps");
159 List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().orElseThrow()
160 .nonnullNodeRuleGroup().values().stream()
161 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
162 .collect(Collectors.toList());
163 assertEquals(1, nrgList.size(), "'Transponder 100GE' node should contain a single node rule groups");
164 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
165 assertEquals(nb, nodeEdgePointList.size(), "'Transponder 100GE' node -rule-group should contain 2 NEPs");
166 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
167 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
168 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
169 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
170 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
171 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
172 "the rule type should be 'FORWARDING'");
176 void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
177 throws ExecutionException, InterruptedException {
178 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
179 Charset.forName("UTF-8"))).toString());
180 LOG.info("T0MultilayerUuid = {}", topologyUuid);
181 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
182 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
183 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
184 result.addListener(new Runnable() {
187 endSignal.countDown();
191 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
193 Topology topology = rpcResult.getResult().getTopology();
194 assertNotNull(topology, "Topology should not be null");
196 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
197 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> entry :
198 topology.getNode().entrySet()) {
199 LOG.debug("NODESDETECTED = {}",entry.getValue().getName().toString());
201 assertEquals(7, topology.getNode().size(), "Node list size should be 7");
202 long nb1 = topology.getNode().values().stream()
203 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
204 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
205 .equals("XPDR-A1-XPDR1+XPONDER"))
206 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
207 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
209 assertEquals(1, nb1, "XPDR-A1-XPDR1 should only have one client nep");
210 long nb2 = topology.getNode().values().stream()
211 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
212 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
213 .equals("SPDR-SA1-XPDR1+XPONDER"))
214 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
215 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
217 assertEquals(4, nb2, "SPDR-SA1-XPDR1 (mux) should have 4 client neps");
218 long nb3 = topology.getNode().values().stream()
219 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
220 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
221 .equals("SPDR-SA1-XPDR1+XPONDER"))
222 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
223 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
225 assertEquals(1, nb3, "SPDR-SA1-XPDR1 (mux) should have a single network nep");
226 long nb4 = topology.getNode().values().stream()
227 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
228 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
229 .equals("SPDR-SA1-XPDR2+XPONDER"))
230 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
231 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
233 assertEquals(4, nb4, "SPDR-SA1-XPDR2 (switch) should have 4 client neps");
234 long nb5 = topology.getNode().values().stream()
235 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
236 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
237 .equals("SPDR-SA1-XPDR2+XPONDER"))
238 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
239 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
241 assertEquals(2, nb5, "SPDR-SA1-XPDR2 (switch) should have 2 network neps");
242 long nb7 = topology.getNode().values().stream()
243 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
244 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
245 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
246 .equals("XPDR-A1-XPDR1+XPONDER"))
247 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
248 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
250 assertEquals(1, nb7, "XPDR-A1-XPDR1 should only have 1 OTSI network nep");
251 long nb8 = topology.getNode().values().stream()
252 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
253 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
254 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
255 .equals("SPDR-SA1-XPDR1+XPONDER"))
256 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
257 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
259 assertEquals(1, nb8, "SPDR-SA1-XPDR1 (mux) should have a single OTSI network nep");
260 long nb9 = topology.getNode().values().stream()
261 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
262 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
263 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
264 .equals("SPDR-SA1-XPDR2+XPONDER"))
265 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
266 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
268 assertEquals(2, nb9, "SPDR-SA1-XPDR2 (switch) should have 2 OTSI network nep");
270 assertEquals(10, topology.getLink().size(), "Link list size should be 10, no more transitionnal links");
271 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
272 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
274 "T0 - Multi-layer topology",
275 topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
276 "topology name should be T0 - Multi-layer topology");
278 long nbDsrOduNodes = topology.nonnullNode().values().stream()
279 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
280 long nbPhotonicNodes = topology.nonnullNode().values().stream()
281 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
282 assertEquals(6, nbDsrOduNodes, "Node list should contain 6 DSR-ODU nodes");
283 assertEquals(7, nbPhotonicNodes, "Node list should contain 7 Photonics node");
284 long nbOtsLinks = topology.getLink().values().stream()
285 .filter(l -> l.getName().containsKey(new NameKey("OTS link name"))).count();
286 long nbOtnLinks = topology.getLink().values().stream()
287 .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
288 assertEquals(8, nbOtsLinks, "Link list should contain 8 OTS links");
289 assertEquals(2, nbOtnLinks, "Link list should contain 2 OTN links");
291 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
293 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
295 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
297 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
299 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
300 .getBytes(StandardCharsets.UTF_8)).toString());
301 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
302 .getBytes(StandardCharsets.UTF_8)).toString());
303 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
304 .getBytes(StandardCharsets.UTF_8)).toString());
305 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
306 .getBytes(StandardCharsets.UTF_8)).toString());
308 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
309 .getBytes(StandardCharsets.UTF_8)).toString());
311 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
312 .getBytes(StandardCharsets.UTF_8)).toString());
314 List<Link> links = topology.nonnullLink().values().stream()
315 .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
316 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
317 .collect(Collectors.toList());
318 checkOtnLink(links.get(0), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link1Uuid,
319 "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
320 checkOtnLink(links.get(1), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link2Uuid,
321 "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
326 void getTopologyDetailsForFullTapiTopologyWithLinksWhenSuccessful()
327 throws ExecutionException, InterruptedException {
328 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
329 Charset.forName("UTF-8"))).toString());
330 LOG.info("T0FullMultilayerUuid = {}", topologyUuid);
331 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
332 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
333 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
334 result.addListener(new Runnable() {
337 endSignal.countDown();
341 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
343 Topology topology = rpcResult.getResult().getTopology();
344 assertNotNull(topology, "Topology should not be null");
345 // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 3 Node per Roadm
346 assertEquals(10, topology.getNode().size(), "Node list size should be 10");
347 List<Map<NameKey, Name>> nodeNames = topology.getNode().values().stream()
348 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
349 .map(Node::getName).collect(Collectors.toList());
350 LOG.info("TopologyNodes = {}", nodeNames.toString());
351 Node nodeTsp = topology.getNode().values().stream()
352 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
353 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
354 .equals("XPDR-A1-XPDR1+XPONDER"))
355 .findAny().orElseThrow();
356 LOG.debug("XPDRA1 NEPs = {}", nodeTsp.getOwnedNodeEdgePoint().toString());
357 long nb1 = topology.getNode().values().stream()
358 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
359 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
360 .equals("XPDR-A1-XPDR1+XPONDER"))
361 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
362 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
364 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
365 assertEquals(2, nb1, "XPDR-A1-XPDR1+XPONDER should only have two client neps");
366 long inb1 = topology.getNode().values().stream()
367 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
368 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
369 .equals("XPDR-A1-XPDR1+XPONDER"))
370 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
371 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
373 assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two internal network neps");
374 long enb1 = topology.getNode().values().stream()
375 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
376 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
377 .equals("XPDR-A1-XPDR1+XPONDER"))
378 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
379 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
381 assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
382 long nb2 = topology.getNode().values().stream()
383 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
384 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
385 .equals("SPDR-SA1-XPDR1+XPONDER"))
386 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
387 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
389 assertEquals(4, nb2, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 client neps");
390 long inb3 = topology.getNode().values().stream()
391 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
392 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
393 .equals("SPDR-SA1-XPDR1+XPONDER"))
394 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
395 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
397 assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single internal network nep");
398 long enb3 = topology.getNode().values().stream()
399 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
400 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
401 .equals("SPDR-SA1-XPDR1+XPONDER"))
402 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
403 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
405 assertEquals(4, enb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 external network nep");
406 long nb4 = topology.getNode().values().stream()
407 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
408 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
409 .equals("SPDR-SA1-XPDR2+XPONDER"))
410 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
411 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
413 assertEquals(4, nb4, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 client neps");
414 long inb5 = topology.getNode().values().stream()
415 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
416 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
417 .equals("SPDR-SA1-XPDR2+XPONDER"))
418 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
419 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
421 assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 internal network neps");
422 long enb5 = topology.getNode().values().stream()
423 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
424 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
425 .equals("SPDR-SA1-XPDR1+XPONDER"))
426 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
427 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
429 assertEquals(4, enb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
431 inb1 = topology.getNode().values().stream()
432 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
433 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
434 .equals("XPDR-A1-XPDR1+XPONDER"))
435 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
436 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
438 assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
439 enb1 = topology.getNode().values().stream()
440 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
441 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
442 .equals("XPDR-A1-XPDR1+XPONDER"))
443 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
444 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
446 assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two photonic network neps");
447 inb3 = topology.getNode().values().stream()
448 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
449 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
450 .equals("SPDR-SA1-XPDR1+XPONDER"))
451 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
452 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
454 assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single external network nep");
455 inb5 = topology.getNode().values().stream()
456 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
457 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
458 .equals("SPDR-SA1-XPDR2+XPONDER"))
459 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
460 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
462 assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
463 Node nodeRoadm = topology.getNode().values().stream()
464 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
465 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
466 .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
467 .equals("ROADM-A1+PHOTONIC_MEDIA"))
468 .findAny().orElseThrow();
469 long inb6 = topology.getNode().values().stream()
470 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
471 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
472 .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
473 .equals("ROADM-A1+PHOTONIC_MEDIA"))
474 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
475 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("DEG")))
477 assertEquals(4, inb6, "ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 4 network neps");
478 long enb6 = topology.getNode().values().stream()
479 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
480 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
481 .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
482 .equals("ROADM-A1+PHOTONIC_MEDIA"))
483 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
484 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("SRG")))
486 assertEquals(8, enb6, "ROADM-A1+PHOTONIC_MEDIA (SRG) should have 8 network neps (OTS)");
488 // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
489 // + transitional links -> 0 per network port of Xpdr + OTN links / 2
490 List<String> linkList = new ArrayList<>();
491 for (Map.Entry<LinkKey, Link> entry : topology.getLink().entrySet()) {
492 linkList.add(entry.getValue().getName().entrySet().iterator().next().getValue().toString());
494 assertEquals(9, topology.getLink().size(), "Link list size should be 8 XPDR To SRG and 1 DEG2A-DEG1C");
495 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
496 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
498 "T0 - Full Multi-layer topology",
499 topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
500 "topology name should be T0 - Full Multi-layer topology");
502 long nbDsrOduNodes = topology.nonnullNode().values().stream()
503 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
504 long nbPhotonicNodes = topology.nonnullNode().values().stream()
505 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
506 // In DSR/ODU we create one node per Xpdr (no filtering out)
507 assertEquals(8, nbDsrOduNodes, "Node list should contain 8 DSR-ODU nodes");
508 // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
509 assertEquals(8, nbPhotonicNodes, "Node list should contain 8 Photonics nodes");
511 long nbOmsLinks = topology.getLink().values().stream()
512 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
514 long nbOmsLinks1 = topology.getLink().values().stream()
515 .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
516 // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
517 assertEquals(9, nbOmsLinks + nbOmsLinks1, "Link list should contain 9 OMS links");
521 void getNodeAndNepsDetailsWhenSuccessful()
522 throws ExecutionException, InterruptedException {
523 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
524 Charset.forName("UTF-8"))).toString());
525 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
526 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
527 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
528 result.addListener(new Runnable() {
531 endSignal.countDown();
535 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
537 Topology topology = rpcResult.getResult().getTopology();
538 for (Node node:topology.getNode().values()) {
539 //String nodeName = node.getName().values().stream().findFirst().orElseThrow().getValue();
540 Uuid nodeUuid = node.getUuid();
541 GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(topologyUuid, nodeUuid);
542 ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
543 result.addListener(new Runnable() {
546 endSignal.countDown();
550 RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
552 Node node1 = rpcResult1.getResult().getNode();
553 assertNotNull(node1, "Node should not be null");
554 for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
555 //String onepName = onep.getName().values().stream().findFirst().orElseThrow().getValue();
556 Uuid onepUuid = onep.getUuid();
557 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
558 topologyUuid, nodeUuid, onepUuid);
559 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
560 = tapiTopoImpl.getNodeEdgePointDetails(input2);
561 result.addListener(new Runnable() {
564 endSignal.countDown();
568 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
569 org.opendaylight.yang.gen.v1
570 .urn.onf.otcc.yang.tapi.topology.rev221121.get.node.edge.point.details.output.NodeEdgePoint
571 onep1 = rpcResult2.getResult().getNodeEdgePoint();
572 assertNotNull(onep1, "Node Edge Point should not be null");
578 void getLinkDetailsWhenSuccessful()
579 throws ExecutionException, InterruptedException {
580 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
581 Charset.forName("UTF-8"))).toString());
582 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
583 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
584 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
585 result.addListener(new Runnable() {
588 endSignal.countDown();
592 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
594 Topology topology = rpcResult.getResult().getTopology();
595 for (Link link:topology.getLink().values()) {
596 //String linkName = link.getName().values().stream().findFirst().orElseThrow().getValue();
597 Uuid linkUuid = link.getUuid();
598 GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
599 topologyUuid, linkUuid);
600 ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
601 result.addListener(new Runnable() {
604 endSignal.countDown();
608 RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
609 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.link.details.output.Link link1
610 = rpcResult1.getResult().getLink();
611 assertNotNull(link1, "Link should not be null");
616 void getSipDetailsWhenSuccessful()
617 throws ExecutionException, InterruptedException {
618 GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
619 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
620 ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
621 .getServiceInterfacePointList(input);
622 result.addListener(new Runnable() {
625 endSignal.countDown();
629 RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
630 Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
631 for (Sip sip:sipMap.values()) {
632 Uuid sipUuid = sip.getUuid();
633 GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
634 .buildGetServiceInterfacePointDetailsInput(sipUuid);
635 ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
636 = tapiTopoImpl.getServiceInterfacePointDetails(input1);
637 result.addListener(new Runnable() {
640 endSignal.countDown();
644 RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
645 org.opendaylight.yang.gen.v1
646 .urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.Sip sip1
647 = rpcResult1.getResult().getSip();
648 assertNotNull(sip1, "Sip should not be null");
652 private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
653 Uuid linkUuid, String linkName) {
654 assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
655 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
656 assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
657 "Available capacity unit should be MBPS");
658 String prefix = linkName.split("-")[0];
659 if ("OTU4".equals(prefix)) {
660 assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
661 "Available capacity -total size value should be 0");
662 } else if ("ODTU4".equals(prefix)) {
663 assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
664 "Available capacity -total size value should be 100 000");
666 assertEquals(CAPACITYUNITGBPS.VALUE, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
667 "Total capacity unit should be GBPS");
668 assertEquals(Decimal64.valueOf("100"), link.getTotalPotentialCapacity().getTotalSize().getValue(),
669 "Total capacity -total size value should be 100");
670 if ("OTU4".equals(prefix)) {
671 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
672 LayerProtocolName.PHOTONICMEDIA.getName(),
673 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
674 } else if ("ODTU4".equals(prefix)) {
675 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
676 LayerProtocolName.ODU.getName(),
677 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
679 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
680 "transitional link should be BIDIRECTIONAL");
681 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
682 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
683 assertEquals(topoUuid, nodeEdgePointList.get(0).getTopologyUuid(),
684 "topology uuid should be the same for the two termination point of the link");
685 assertEquals(topoUuid, nodeEdgePointList.get(1).getTopologyUuid(),
686 "topology uuid should be the same for the two termination point of the link");
687 assertThat("otn links should terminate on two distinct nodes",
688 nodeEdgePointList.get(0).getNodeUuid().getValue(),
689 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
690 assertThat("otn links should terminate on two distinct nodes",
691 nodeEdgePointList.get(1).getNodeUuid().getValue(),
692 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
693 assertThat("otn links should terminate on two distinct tps",
694 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
695 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
696 assertThat("otn links should terminate on two distinct tps",
697 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
698 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
699 assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
700 assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
701 "administrative state should be UNLOCKED");