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.junit.jupiter.api.extension.ExtendWith;
34 import org.mockito.Mock;
35 import org.mockito.junit.jupiter.MockitoExtension;
36 import org.opendaylight.mdsal.binding.api.RpcService;
37 import org.opendaylight.transportpce.common.InstanceIdentifiers;
38 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
39 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
40 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
41 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
42 import org.opendaylight.transportpce.tapi.TapiStringConstants;
43 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
44 import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
45 import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
46 import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
47 import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
48 import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
49 import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
50 import org.opendaylight.transportpce.tapi.utils.TapiContext;
51 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
52 import org.opendaylight.transportpce.tapi.utils.TapiLink;
53 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
54 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
55 import org.opendaylight.transportpce.test.AbstractTest;
56 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListInput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListOutput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.Sip;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.SipKey;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsInput;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsOutput;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsInput;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutput;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsInput;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutput;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsInput;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetailsOutput;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Node;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.topology.details.output.Topology;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
89 import org.opendaylight.yangtools.yang.common.Decimal64;
90 import org.opendaylight.yangtools.yang.common.RpcResult;
91 import org.opendaylight.yangtools.yang.common.Uint64;
92 import org.slf4j.Logger;
93 import org.slf4j.LoggerFactory;
95 @ExtendWith(MockitoExtension.class)
96 public class TapiTopologyImplTest extends AbstractTest {
97 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
100 private RpcService rpcService;
101 private static ListeningExecutorService executorService;
102 private static CountDownLatch endSignal;
103 private static final int NUM_THREADS = 3;
104 private static NetworkTransactionService networkTransactionService;
105 private static TapiContext tapiContext;
106 private static TopologyUtils topologyUtils;
107 private static ConnectivityUtils connectivityUtils;
108 private static ServiceDataStoreOperations serviceDataStoreOperations;
109 private static TapiInitialORMapping tapiInitialORMapping;
110 private static TapiLink tapiLink;
113 static void setUp() throws InterruptedException, ExecutionException {
114 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
115 endSignal = new CountDownLatch(1);
116 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
117 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
118 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
119 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
120 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
121 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
122 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
123 TapiTopologyDataUtils.PORTMAPPING_FILE);
124 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
125 tapiLink = new TapiLinkImpl(networkTransactionService);
126 serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
127 tapiContext = new TapiContext(networkTransactionService);
128 topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
130 connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
131 networkTransactionService);
132 tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
133 tapiContext, serviceDataStoreOperations);
134 tapiInitialORMapping.performTopoInitialMapping();
135 LOG.info("setup done");
139 void getTopologyDetailsForTransponder100GTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
140 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(
141 Charset.forName("UTF-8"))).toString());
142 LOG.info("TPDR100GUuid = {}", topologyUuid);
143 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
144 // TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(networkTransactionService, tapiContext, topologyUtils,
146 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
147 topologyUtils, tapiLink, networkTransactionService)
149 LOG.info("RESULT of getTopoDetailsTopo/name = {}", result.get().getResult().getTopology().getName().toString());
150 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
152 Topology topology = rpcResult.getResult().getTopology();
153 assertNotNull(topology, "Topology should not be null");
154 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(StandardCharsets.UTF_8))
156 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
157 assertEquals(1, topology.getNode().size(), "Node list size should be 1");
158 Name nodeName = topology.getNode().values().stream().findFirst().orElseThrow().getName()
159 .get(new NameKey("Tpdr100g node name"));
160 assertEquals("Tpdr100g over WDM node", nodeName.getValue(), "Node name should be 'Tpdr100g over WDM node'");
161 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
163 assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().orElseThrow().getUuid(),
164 "incorrect node uuid");
165 long nb = topology.getNode().values().stream().findFirst().orElseThrow().getOwnedNodeEdgePoint().size();
166 assertEquals(2, nb, "'Transponder 100GE' node should have 2 neps");
167 List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().orElseThrow()
168 .nonnullNodeRuleGroup().values().stream()
169 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
170 .collect(Collectors.toList());
171 assertEquals(1, nrgList.size(), "'Transponder 100GE' node should contain a single node rule groups");
172 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
173 assertEquals(nb, nodeEdgePointList.size(), "'Transponder 100GE' node -rule-group should contain 2 NEPs");
174 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
175 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
176 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
177 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
178 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
179 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
180 "the rule type should be 'FORWARDING'");
184 void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful() throws ExecutionException, InterruptedException {
185 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
186 Charset.forName("UTF-8"))).toString());
187 LOG.info("T0MultilayerUuid = {}", topologyUuid);
188 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
189 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
190 topologyUtils, tapiLink, networkTransactionService)
192 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
194 Topology topology = rpcResult.getResult().getTopology();
195 assertNotNull(topology, "Topology should not be null");
197 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
198 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> entry :
199 topology.getNode().entrySet()) {
200 LOG.debug("NODESDETECTED = {}",entry.getValue().getName().toString());
202 assertEquals(7, topology.getNode().size(), "Node list size should be 7");
203 long nb1 = topology.getNode().values().stream()
204 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
205 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
206 .equals("XPDR-A1-XPDR1+XPONDER"))
207 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
208 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
210 assertEquals(1, nb1, "XPDR-A1-XPDR1 should only have one client nep");
211 long nb2 = topology.getNode().values().stream()
212 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
213 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
214 .equals("SPDR-SA1-XPDR1+XPONDER"))
215 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
216 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
218 assertEquals(4, nb2, "SPDR-SA1-XPDR1 (mux) should have 4 client neps");
219 long nb3 = topology.getNode().values().stream()
220 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
221 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
222 .equals("SPDR-SA1-XPDR1+XPONDER"))
223 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
224 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
226 assertEquals(1, nb3, "SPDR-SA1-XPDR1 (mux) should have a single network nep");
227 long nb4 = topology.getNode().values().stream()
228 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
229 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
230 .equals("SPDR-SA1-XPDR2+XPONDER"))
231 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
232 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
234 assertEquals(4, nb4, "SPDR-SA1-XPDR2 (switch) should have 4 client neps");
235 long nb5 = topology.getNode().values().stream()
236 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
237 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
238 .equals("SPDR-SA1-XPDR2+XPONDER"))
239 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
240 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
242 assertEquals(2, nb5, "SPDR-SA1-XPDR2 (switch) should have 2 network neps");
243 long nb7 = topology.getNode().values().stream()
244 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
245 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
246 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
247 .equals("XPDR-A1-XPDR1+XPONDER"))
248 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
249 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
251 assertEquals(1, nb7, "XPDR-A1-XPDR1 should only have 1 OTSI network nep");
252 long nb8 = topology.getNode().values().stream()
253 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
254 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
255 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
256 .equals("SPDR-SA1-XPDR1+XPONDER"))
257 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
258 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
260 assertEquals(1, nb8, "SPDR-SA1-XPDR1 (mux) should have a single OTSI network nep");
261 long nb9 = topology.getNode().values().stream()
262 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
263 && node.getLayerProtocolName().contains(LayerProtocolName.DSR))
264 .filter(node -> node.getName().get(new NameKey("otsi node name")).getValue()
265 .equals("SPDR-SA1-XPDR2+XPONDER"))
266 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
267 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
269 assertEquals(2, nb9, "SPDR-SA1-XPDR2 (switch) should have 2 OTSI network nep");
271 assertEquals(10, topology.getLink().size(), "Link list size should be 10, no more transitionnal links");
272 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
273 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
275 "T0 - Multi-layer topology",
276 topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
277 "topology name should be T0 - Multi-layer topology");
279 long nbDsrOduNodes = topology.nonnullNode().values().stream()
280 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
281 long nbPhotonicNodes = topology.nonnullNode().values().stream()
282 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
283 assertEquals(6, nbDsrOduNodes, "Node list should contain 6 DSR-ODU nodes");
284 assertEquals(7, nbPhotonicNodes, "Node list should contain 7 Photonics node");
285 long nbOtsLinks = topology.getLink().values().stream()
286 .filter(l -> l.getName().containsKey(new NameKey("OTS link name"))).count();
287 long nbOtnLinks = topology.getLink().values().stream()
288 .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
289 assertEquals(8, nbOtsLinks, "Link list should contain 8 OTS links");
290 assertEquals(2, nbOtnLinks, "Link list should contain 2 OTN links");
292 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
294 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
296 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
298 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(StandardCharsets.UTF_8))
300 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
301 .getBytes(StandardCharsets.UTF_8)).toString());
302 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
303 .getBytes(StandardCharsets.UTF_8)).toString());
304 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
305 .getBytes(StandardCharsets.UTF_8)).toString());
306 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
307 .getBytes(StandardCharsets.UTF_8)).toString());
309 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
310 .getBytes(StandardCharsets.UTF_8)).toString());
312 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
313 .getBytes(StandardCharsets.UTF_8)).toString());
315 List<Link> links = topology.nonnullLink().values().stream()
316 .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
317 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
318 .collect(Collectors.toList());
319 checkOtnLink(links.get(0), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link1Uuid,
320 "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
321 checkOtnLink(links.get(1), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link2Uuid,
322 "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
327 void getTopologyDetailsForFullTapiTopologyWithLinksWhenSuccessful()
328 throws ExecutionException, InterruptedException {
329 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
330 Charset.forName("UTF-8"))).toString());
331 LOG.info("T0FullMultilayerUuid = {}", topologyUuid);
332 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
333 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
334 topologyUtils, tapiLink, networkTransactionService)
336 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
338 Topology topology = rpcResult.getResult().getTopology();
339 assertNotNull(topology, "Topology should not be null");
340 // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 3 Node per Roadm
341 assertEquals(10, topology.getNode().size(), "Node list size should be 10");
342 List<Map<NameKey, Name>> nodeNames = topology.getNode().values().stream()
343 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
344 .map(Node::getName).collect(Collectors.toList());
345 LOG.info("TopologyNodes = {}", nodeNames.toString());
346 Node nodeTsp = topology.getNode().values().stream()
347 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
348 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
349 .equals("XPDR-A1-XPDR1+XPONDER"))
350 .findAny().orElseThrow();
351 LOG.debug("XPDRA1 NEPs = {}", nodeTsp.getOwnedNodeEdgePoint().toString());
352 long nb1 = topology.getNode().values().stream()
353 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
354 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
355 .equals("XPDR-A1-XPDR1+XPONDER"))
356 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
357 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
359 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
360 assertEquals(2, nb1, "XPDR-A1-XPDR1+XPONDER should only have two client neps");
361 long inb1 = topology.getNode().values().stream()
362 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
363 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
364 .equals("XPDR-A1-XPDR1+XPONDER"))
365 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
366 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
368 assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two internal network neps");
369 long enb1 = topology.getNode().values().stream()
370 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
371 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
372 .equals("XPDR-A1-XPDR1+XPONDER"))
373 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
374 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
376 assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
377 long nb2 = topology.getNode().values().stream()
378 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
379 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
380 .equals("SPDR-SA1-XPDR1+XPONDER"))
381 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
382 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
384 assertEquals(4, nb2, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 client neps");
385 long inb3 = topology.getNode().values().stream()
386 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
387 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
388 .equals("SPDR-SA1-XPDR1+XPONDER"))
389 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
390 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
392 assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single internal network nep");
393 long enb3 = topology.getNode().values().stream()
394 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
395 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
396 .equals("SPDR-SA1-XPDR1+XPONDER"))
397 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
398 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
400 assertEquals(4, enb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have 4 external network nep");
401 long nb4 = topology.getNode().values().stream()
402 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
403 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
404 .equals("SPDR-SA1-XPDR2+XPONDER"))
405 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
406 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
408 assertEquals(4, nb4, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 client neps");
409 long inb5 = topology.getNode().values().stream()
410 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
411 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
412 .equals("SPDR-SA1-XPDR2+XPONDER"))
413 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
414 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
416 assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 internal network neps");
417 long enb5 = topology.getNode().values().stream()
418 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
419 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
420 .equals("SPDR-SA1-XPDR1+XPONDER"))
421 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
422 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
424 assertEquals(4, enb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
426 inb1 = topology.getNode().values().stream()
427 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
428 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
429 .equals("XPDR-A1-XPDR1+XPONDER"))
430 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
431 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
433 assertEquals(2, inb1, "XPDR-A1-XPDR1+XPONDER should only have two external network neps");
434 enb1 = topology.getNode().values().stream()
435 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
436 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
437 .equals("XPDR-A1-XPDR1+XPONDER"))
438 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
439 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
441 assertEquals(2, enb1, "XPDR-A1-XPDR1+XPONDER should only have two photonic network neps");
442 inb3 = topology.getNode().values().stream()
443 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
444 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
445 .equals("SPDR-SA1-XPDR1+XPONDER"))
446 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
447 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
449 assertEquals(1, inb3, "SPDR-SA1-XPDR1+XPONDER (mux) should have a single external network nep");
450 inb5 = topology.getNode().values().stream()
451 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
452 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
453 .equals("SPDR-SA1-XPDR2+XPONDER"))
454 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
455 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
457 assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
458 long inb6 = topology.getNode().values().stream()
459 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
460 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
461 .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
462 .equals("ROADM-A1+PHOTONIC_MEDIA"))
463 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
464 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("DEG")))
466 assertEquals(4, inb6, "ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 4 network neps");
467 long enb6 = topology.getNode().values().stream()
468 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
469 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
470 .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
471 .equals("ROADM-A1+PHOTONIC_MEDIA"))
472 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
473 .filter(nep -> nep.getName().values().stream().findAny().orElseThrow().getValue().contains("SRG")))
475 assertEquals(8, enb6, "ROADM-A1+PHOTONIC_MEDIA (SRG) should have 8 network neps (OTS)");
477 // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
478 // + transitional links -> 0 per network port of Xpdr + OTN links / 2
479 List<String> linkList = new ArrayList<>();
480 for (Map.Entry<LinkKey, Link> entry : topology.getLink().entrySet()) {
481 linkList.add(entry.getValue().getName().entrySet().iterator().next().getValue().toString());
483 assertEquals(9, topology.getLink().size(), "Link list size should be 8 XPDR To SRG and 1 DEG2A-DEG1C");
484 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
485 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
487 "T0 - Full Multi-layer topology",
488 topology.nonnullName().values().stream().findFirst().orElseThrow().getValue(),
489 "topology name should be T0 - Full Multi-layer topology");
491 long nbDsrOduNodes = topology.nonnullNode().values().stream()
492 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
493 long nbPhotonicNodes = topology.nonnullNode().values().stream()
494 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
495 // In DSR/ODU we create one node per Xpdr (no filtering out)
496 assertEquals(8, nbDsrOduNodes, "Node list should contain 8 DSR-ODU nodes");
497 // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
498 assertEquals(8, nbPhotonicNodes, "Node list should contain 8 Photonics nodes");
500 long nbOmsLinks = topology.getLink().values().stream()
501 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
503 long nbOmsLinks1 = topology.getLink().values().stream()
504 .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
505 // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
506 assertEquals(9, nbOmsLinks + nbOmsLinks1, "Link list should contain 9 OMS links");
510 void getNodeAndNepsDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
511 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
512 Charset.forName("UTF-8"))).toString());
513 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
514 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
515 topologyUtils, tapiLink, networkTransactionService)
517 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
519 Topology topology = rpcResult.getResult().getTopology();
520 for (Node node:topology.getNode().values()) {
521 Uuid nodeUuid = node.getUuid();
522 GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(topologyUuid, nodeUuid);
523 ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = new GetNodeDetailsImpl(tapiContext)
525 RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
527 Node node1 = rpcResult1.getResult().getNode();
528 assertNotNull(node1, "Node should not be null");
529 for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
530 Uuid onepUuid = onep.getUuid();
531 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
532 topologyUuid, nodeUuid, onepUuid);
533 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2 =
534 new GetNodeEdgePointDetailsImpl(tapiContext).invoke(input2);
535 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
536 org.opendaylight.yang.gen.v1
537 .urn.onf.otcc.yang.tapi.topology.rev221121.get.node.edge.point.details.output.NodeEdgePoint
538 onep1 = rpcResult2.getResult().getNodeEdgePoint();
539 assertNotNull(onep1, "Node Edge Point should not be null");
545 void getLinkDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
546 Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
547 Charset.forName("UTF-8"))).toString());
548 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
549 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
550 topologyUtils, tapiLink, networkTransactionService)
552 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
554 Topology topology = rpcResult.getResult().getTopology();
555 for (Link link:topology.getLink().values()) {
556 Uuid linkUuid = link.getUuid();
557 GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
558 topologyUuid, linkUuid);
559 ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = new GetLinkDetailsImpl(tapiContext)
561 RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
562 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.link.details.output.Link link1
563 = rpcResult1.getResult().getLink();
564 assertNotNull(link1, "Link should not be null");
569 void getSipDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
570 GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
571 ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result =
572 new GetServiceInterfacePointListImpl(tapiContext).invoke(input);
573 RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
574 Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
575 for (Sip sip:sipMap.values()) {
576 Uuid sipUuid = sip.getUuid();
577 GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
578 .buildGetServiceInterfacePointDetailsInput(sipUuid);
579 ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1 =
580 new GetServiceInterfacePointDetailsImpl(tapiContext).invoke(input1);
581 RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
582 org.opendaylight.yang.gen.v1
583 .urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.Sip sip1
584 = rpcResult1.getResult().getSip();
585 assertNotNull(sip1, "Sip should not be null");
589 private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
590 Uuid linkUuid, String linkName) {
591 assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
592 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
593 assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
594 "Available capacity unit should be MBPS");
595 String prefix = linkName.split("-")[0];
596 if ("OTU4".equals(prefix)) {
597 assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
598 "Available capacity -total size value should be 0");
599 } else if ("ODTU4".equals(prefix)) {
600 assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
601 "Available capacity -total size value should be 100 000");
603 assertEquals(CAPACITYUNITGBPS.VALUE, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
604 "Total capacity unit should be GBPS");
605 assertEquals(Decimal64.valueOf("100"), link.getTotalPotentialCapacity().getTotalSize().getValue(),
606 "Total capacity -total size value should be 100");
607 if ("OTU4".equals(prefix)) {
608 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
609 LayerProtocolName.PHOTONICMEDIA.getName(),
610 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
611 } else if ("ODTU4".equals(prefix)) {
612 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
613 LayerProtocolName.ODU.getName(),
614 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName());
616 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
617 "transitional link should be BIDIRECTIONAL");
618 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
619 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
620 assertEquals(topoUuid, nodeEdgePointList.get(0).getTopologyUuid(),
621 "topology uuid should be the same for the two termination point of the link");
622 assertEquals(topoUuid, nodeEdgePointList.get(1).getTopologyUuid(),
623 "topology uuid should be the same for the two termination point of the link");
624 assertThat("otn links should terminate on two distinct nodes",
625 nodeEdgePointList.get(0).getNodeUuid().getValue(),
626 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
627 assertThat("otn links should terminate on two distinct nodes",
628 nodeEdgePointList.get(1).getNodeUuid().getValue(),
629 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
630 assertThat("otn links should terminate on two distinct tps",
631 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
632 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
633 assertThat("otn links should terminate on two distinct tps",
634 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
635 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
636 assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
637 assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
638 "administrative state should be UNLOCKED");