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.StandardCharsets;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
24 import java.util.UUID;
25 import java.util.concurrent.CountDownLatch;
26 import java.util.concurrent.ExecutionException;
27 import java.util.concurrent.Executors;
28 import java.util.stream.Collectors;
29 import org.eclipse.jdt.annotation.Nullable;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.Test;
32 import org.opendaylight.transportpce.common.InstanceIdentifiers;
33 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
34 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
35 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
36 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
37 import org.opendaylight.transportpce.tapi.TapiStringConstants;
38 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
39 import org.opendaylight.transportpce.tapi.utils.TapiContext;
40 import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
41 import org.opendaylight.transportpce.tapi.utils.TapiLink;
42 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
43 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
44 import org.opendaylight.transportpce.test.AbstractTest;
45 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsInput;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsOutput;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListInput;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListOutput;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.Sip;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.SipKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsInput;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsOutput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsInput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsOutput;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsInput;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsOutput;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInput;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsOutput;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Node;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.topology.details.output.Topology;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
77 import org.opendaylight.yangtools.yang.common.RpcResult;
78 import org.opendaylight.yangtools.yang.common.Uint64;
79 import org.slf4j.Logger;
80 import org.slf4j.LoggerFactory;
82 public class TapiTopologyImplTest extends AbstractTest {
83 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
85 private static ListeningExecutorService executorService;
86 private static CountDownLatch endSignal;
87 private static final int NUM_THREADS = 3;
88 private static NetworkTransactionService networkTransactionService;
89 private static TapiContext tapiContext;
90 private static TopologyUtils topologyUtils;
91 private static ConnectivityUtils connectivityUtils;
92 private static ServiceDataStoreOperations serviceDataStoreOperations;
93 private static TapiInitialORMapping tapiInitialORMapping;
94 private static TapiLink tapiLink;
97 static void setUp() throws InterruptedException, ExecutionException {
98 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
99 endSignal = new CountDownLatch(1);
100 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
101 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
102 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
103 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
104 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
105 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
106 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
107 TapiTopologyDataUtils.PORTMAPPING_FILE);
108 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
109 tapiLink = new TapiLinkImpl(networkTransactionService);
110 serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
111 tapiContext = new TapiContext(networkTransactionService);
112 topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
114 connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
115 networkTransactionService);
116 tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
117 tapiContext, serviceDataStoreOperations);
118 tapiInitialORMapping.performTopoInitialMapping();
119 LOG.info("setup done");
123 void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
124 throws ExecutionException, InterruptedException {
125 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
126 TapiStringConstants.TPDR_100G);
127 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
128 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
129 result.addListener(new Runnable() {
132 endSignal.countDown();
136 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
138 Topology topology = rpcResult.getResult().getTopology();
139 assertNotNull(topology, "Topology should not be null");
140 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(StandardCharsets.UTF_8))
142 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
143 assertEquals(1, topology.getNode().size(), "Node list size should be 1");
144 Name nodeName = topology.getNode().values().stream().findFirst().get().getName()
145 .get(new NameKey("Tpdr100g node name"));
146 assertEquals("Tpdr100g over WDM node", nodeName.getValue(), "Node name should be 'Tpdr100g over WDM node'");
147 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
149 assertEquals(nodeUuid, topology.getNode().values().stream().findFirst().get().getUuid(), "incorrect node uuid");
150 long nb = topology.getNode().values().stream().findFirst().get().getOwnedNodeEdgePoint().size();
151 assertEquals(2, nb, "'Transponder 100GE' node should have 2 neps");
152 List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().get().nonnullNodeRuleGroup()
153 .values().stream().sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
154 .collect(Collectors.toList());
155 assertEquals(1, nrgList.size(), "'Transponder 100GE' node should contain a single node rule groups");
156 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
157 assertEquals(nb, nodeEdgePointList.size(), "'Transponder 100GE' node -rule-group should contain 2 NEPs");
158 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
159 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
160 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
161 assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
162 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
163 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
167 void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
168 throws ExecutionException, InterruptedException {
169 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
170 TapiStringConstants.T0_MULTILAYER);
171 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
172 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
173 result.addListener(new Runnable() {
176 endSignal.countDown();
180 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
182 Topology topology = rpcResult.getResult().getTopology();
183 assertNotNull(topology, "Topology should not be null");
184 assertEquals(13, topology.getNode().size(), "Node list size should be 13");
185 long nb1 = topology.getNode().values().stream()
186 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
187 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
188 .equals("XPDR-A1-XPDR1+DSR"))
189 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
190 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
192 assertEquals(1, nb1, "XPDR-A1-XPDR1 should only have one client nep");
193 long nb2 = topology.getNode().values().stream()
194 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
195 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
196 .equals("SPDR-SA1-XPDR1+DSR"))
197 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
198 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
200 assertEquals(4, nb2, "SPDR-SA1-XPDR1 (mux) should have 4 client neps");
201 long nb3 = topology.getNode().values().stream()
202 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
203 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
204 .equals("SPDR-SA1-XPDR1+DSR"))
205 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
206 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
208 assertEquals(1, nb3, "SPDR-SA1-XPDR1 (mux) should have a single network nep");
209 long nb4 = topology.getNode().values().stream()
210 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
211 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
212 .equals("SPDR-SA1-XPDR2+DSR"))
213 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
214 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
216 assertEquals(4, nb4, "SPDR-SA1-XPDR2 (switch) should have 4 client neps");
217 long nb5 = topology.getNode().values().stream()
218 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
219 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
220 .equals("SPDR-SA1-XPDR2+DSR"))
221 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
222 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
224 assertEquals(2, nb5, "SPDR-SA1-XPDR2 (switch) should have 2 network neps");
225 assertEquals(18, topology.getLink().size(), "Link list size should be 18");
226 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
227 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
229 "T0 - Multi-layer topology",
230 topology.nonnullName().values().stream().findFirst().get().getValue(),
231 "topology name should be T0 - Multi-layer topology");
233 long nbDsrOduNodes = topology.nonnullNode().values().stream()
234 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
235 long nbPhotonicNodes = topology.nonnullNode().values().stream()
236 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
237 assertEquals(6, nbDsrOduNodes, "Node list should contain 6 DSR-ODU nodes");
238 assertEquals(7, nbPhotonicNodes, "Node list should contain 7 Photonics nodes");
239 long nbTransititionalLinks = topology.getLink().values().stream()
240 .filter(l -> l.getName().containsKey(new NameKey("transitional link name"))).count();
241 long nbOmsLinks = topology.getLink().values().stream()
242 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
243 long nbOtnLinks = topology.getLink().values().stream()
244 .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
245 assertEquals(8, nbTransititionalLinks, "Link list should contain 8 transitional links");
246 assertEquals(8, nbOmsLinks, "Link list should contain 8 transitional links");
247 assertEquals(2, nbOtnLinks, "Link list should contain 2 OTN links");
249 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
251 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
253 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
255 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
257 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
258 .getBytes(StandardCharsets.UTF_8)).toString());
259 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
260 .getBytes(StandardCharsets.UTF_8)).toString());
261 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
262 .getBytes(StandardCharsets.UTF_8)).toString());
263 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
264 .getBytes(StandardCharsets.UTF_8)).toString());
266 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
267 .getBytes(StandardCharsets.UTF_8)).toString());
269 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
270 .getBytes(StandardCharsets.UTF_8)).toString());
272 List<Link> links = topology.nonnullLink().values().stream()
273 .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
274 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
275 .collect(Collectors.toList());
276 checkOtnLink(links.get(0), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link1Uuid,
277 "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
278 checkOtnLink(links.get(1), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link2Uuid,
279 "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
283 void getTopologyDetailsForFullTapiTopologyWithLinksWhenSuccessful()
284 throws ExecutionException, InterruptedException {
285 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
286 TapiStringConstants.T0_FULL_MULTILAYER);
287 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
288 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
289 result.addListener(new Runnable() {
292 endSignal.countDown();
296 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
298 Topology topology = rpcResult.getResult().getTopology();
299 assertNotNull(topology, "Topology should not be null");
300 // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 1 Node per Roadm
301 assertEquals(18, topology.getNode().size(), "Node list size should be 18");
302 long nb1 = topology.getNode().values().stream()
303 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
304 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
305 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
306 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
308 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
309 assertEquals(2, nb1, "XPDR-A1-XPDR1+DSR should only have two client neps");
310 long inb1 = topology.getNode().values().stream()
311 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
312 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
313 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
314 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
316 assertEquals(2, inb1, "XPDR-A1-XPDR1+DSR should only have two internal network neps");
317 long enb1 = topology.getNode().values().stream()
318 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
319 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
320 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
321 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
323 assertEquals(2, enb1, "XPDR-A1-XPDR1+DSR should only have two external network neps");
324 long nb2 = topology.getNode().values().stream()
325 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
326 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
327 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
328 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
330 assertEquals(4, nb2, "SPDR-SA1-XPDR1+DSR (mux) should have 4 client neps");
331 long inb3 = topology.getNode().values().stream()
332 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
333 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
334 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
335 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
337 assertEquals(1, inb3, "SPDR-SA1-XPDR1+DSR (mux) should have a single internal network nep");
338 long enb3 = topology.getNode().values().stream()
339 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
340 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
341 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
342 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
344 assertEquals(4, enb3, "SPDR-SA1-XPDR1+DSR (mux) should have 4 external network nep");
345 long nb4 = topology.getNode().values().stream()
346 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
347 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
348 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
349 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
351 assertEquals(4, nb4, "SPDR-SA1-XPDR2+DSR (switch) should have 4 client neps");
352 long inb5 = topology.getNode().values().stream()
353 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
354 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
355 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
356 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
358 assertEquals(4, inb5, "SPDR-SA1-XPDR2+DSR (switch) should have 4 internal network neps");
359 long enb5 = topology.getNode().values().stream()
360 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
361 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
362 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
363 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
365 assertEquals(4, enb5, "SPDR-SA1-XPDR2+DSR (switch) should have 4 external network neps");
367 // Now lets check for the Photonic media nodes (same nodes as for DSR + 1 Roadm node)
368 nb1 = topology.getNode().values().stream()
369 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
370 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
371 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
372 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
374 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
375 assertEquals(2, nb1, "XPDR-A1-XPDR1+OTSi should only have two internal network neps");
376 inb1 = topology.getNode().values().stream()
377 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
378 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
379 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
380 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
382 assertEquals(2, inb1, "XPDR-A1-XPDR1+OTSi should only have two external network neps");
383 enb1 = topology.getNode().values().stream()
384 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
385 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
386 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
387 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
389 assertEquals(2, enb1, "XPDR-A1-XPDR1+OTSi should only have two photonic network neps");
390 nb2 = topology.getNode().values().stream()
391 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
392 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
393 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
394 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
396 assertEquals(1, nb2, "SPDR-SA1-XPDR1+OTSi (mux) should have a single internal network nep");
397 inb3 = topology.getNode().values().stream()
398 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
399 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
400 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
401 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
403 assertEquals(1, inb3, "SPDR-SA1-XPDR1+OTSi (mux) should have a single external network nep");
404 enb3 = topology.getNode().values().stream()
405 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
406 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
407 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
408 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
410 assertEquals(1, enb3, "SPDR-SA1-XPDR1+OTSi (mux) should have a single photonic network nep");
411 nb4 = topology.getNode().values().stream()
412 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
413 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
414 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
415 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
417 assertEquals(4, nb4, "SPDR-SA1-XPDR2+OTSi (switch) should have 4 internal network neps");
418 inb5 = topology.getNode().values().stream()
419 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
420 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
421 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
422 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
424 assertEquals(4, inb5, "SPDR-SA1-XPDR2+OTSi (switch) should have 4 external network neps");
425 enb5 = topology.getNode().values().stream()
426 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
427 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
428 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
429 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
431 assertEquals(4, enb5, "SPDR-SA1-XPDR2+OTSi (switch) should have 4 photonic network neps");
432 // We should have 3 neps per DEGREE-TTP port and 3 neps per SRG-PP port
433 long inb6 = topology.getNode().values().stream()
434 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
435 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
436 "ROADM-A1+PHOTONIC_MEDIA"))
437 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
438 .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("DEG")))
440 assertEquals(6, inb6, "ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 6 network neps");
441 long enb6 = topology.getNode().values().stream()
442 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
443 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
444 "ROADM-A1+PHOTONIC_MEDIA"))
445 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
446 .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("SRG")))
448 assertEquals(24, enb6, "ROADM-A1+PHOTONIC_MEDIA (SRG) should have 24 network neps");
450 // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
451 // + transitional links -> 1 per network port of Xpdr + OTN links / 2
452 assertEquals(25, topology.getLink().size(), "Link list size should be 25");
453 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
454 assertEquals(topoUuid, topology.getUuid(), "incorrect topology uuid");
456 "T0 - Full Multi-layer topology",
457 topology.nonnullName().values().stream().findFirst().get().getValue(),
458 "topology name should be T0 - Full Multi-layer topology");
460 long nbDsrOduNodes = topology.nonnullNode().values().stream()
461 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
462 long nbPhotonicNodes = topology.nonnullNode().values().stream()
463 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
464 // In DSR/ODU we create one node per Xpdr (no filtering out)
465 assertEquals(8, nbDsrOduNodes, "Node list should contain 8 DSR-ODU nodes");
466 // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
467 assertEquals(8, nbPhotonicNodes, "Node list should contain 8 Photonics nodes");
468 long nbTransititionalLinks = topology.getLink().values().stream()
469 .filter(l -> l.getName().containsKey(new NameKey("transitional link name"))).count();
471 long nbOmsLinks = topology.getLink().values().stream()
472 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
474 long nbOmsLinks1 = topology.getLink().values().stream()
475 .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
476 // 1 transitional link per NETWORK port
477 assertEquals(16, nbTransititionalLinks, "Link list should contain 16 transitional links");
478 // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
479 assertEquals(9, nbOmsLinks + nbOmsLinks1, "Link list should contain 9 OMS links");
483 void getNodeAndNepsDetailsWhenSuccessful()
484 throws ExecutionException, InterruptedException {
485 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
486 TapiStringConstants.T0_FULL_MULTILAYER);
487 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
488 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
489 result.addListener(new Runnable() {
492 endSignal.countDown();
496 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
498 Topology topology = rpcResult.getResult().getTopology();
499 for (Node node:topology.getNode().values()) {
500 String nodeName = node.getName().values().stream().findFirst().get().getValue();
501 GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(
502 TapiStringConstants.T0_FULL_MULTILAYER, nodeName);
503 ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
504 result.addListener(new Runnable() {
507 endSignal.countDown();
511 RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
513 Node node1 = rpcResult1.getResult().getNode();
514 assertNotNull(node1, "Node should not be null");
515 for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
516 String onepName = onep.getName().values().stream().findFirst().get().getValue();
517 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
518 TapiStringConstants.T0_FULL_MULTILAYER, nodeName, onepName);
519 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
520 = tapiTopoImpl.getNodeEdgePointDetails(input2);
521 result.addListener(new Runnable() {
524 endSignal.countDown();
528 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
529 org.opendaylight.yang.gen.v1
530 .urn.onf.otcc.yang.tapi.topology.rev181210.get.node.edge.point.details.output.NodeEdgePoint
531 onep1 = rpcResult2.getResult().getNodeEdgePoint();
532 assertNotNull(onep1, "Node Edge Point should not be null");
538 void getLinkDetailsWhenSuccessful()
539 throws ExecutionException, InterruptedException {
540 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
541 TapiStringConstants.T0_FULL_MULTILAYER);
542 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
543 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
544 result.addListener(new Runnable() {
547 endSignal.countDown();
551 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
553 Topology topology = rpcResult.getResult().getTopology();
554 for (Link link:topology.getLink().values()) {
555 String linkName = link.getName().values().stream().findFirst().get().getValue();
556 GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
557 TapiStringConstants.T0_FULL_MULTILAYER, linkName);
558 ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
559 result.addListener(new Runnable() {
562 endSignal.countDown();
566 RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
567 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.link.details.output.Link link1
568 = rpcResult1.getResult().getLink();
569 assertNotNull(link1, "Link should not be null");
574 void getSipDetailsWhenSuccessful()
575 throws ExecutionException, InterruptedException {
576 GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
577 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
578 ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
579 .getServiceInterfacePointList(input);
580 result.addListener(new Runnable() {
583 endSignal.countDown();
587 RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
588 Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
589 for (Sip sip:sipMap.values()) {
590 Uuid sipUuid = sip.getUuid();
591 GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
592 .buildGetServiceInterfacePointDetailsInput(sipUuid);
593 ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
594 = tapiTopoImpl.getServiceInterfacePointDetails(input1);
595 result.addListener(new Runnable() {
598 endSignal.countDown();
602 RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
603 org.opendaylight.yang.gen.v1
604 .urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip sip1
605 = rpcResult1.getResult().getSip();
606 assertNotNull(sip1, "Sip should not be null");
610 private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
611 Uuid linkUuid, String linkName) {
612 assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
613 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
614 assertEquals(CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit(),
615 "Available capacity unit should be MBPS");
616 String prefix = linkName.split("-")[0];
617 if ("OTU4".equals(prefix)) {
618 assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
619 "Available capacity -total size value should be 0");
620 } else if ("ODTU4".equals(prefix)) {
621 assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
622 "Available capacity -total size value should be 100 000");
624 assertEquals(CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
625 "Total capacity unit should be GBPS");
626 assertEquals(Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue(),
627 "Total capacity -total size value should be 100");
628 if ("OTU4".equals(prefix)) {
629 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
630 LayerProtocolName.PHOTONICMEDIA.getName(),
631 link.getLayerProtocolName().stream().findFirst().get().getName());
632 } else if ("ODTU4".equals(prefix)) {
633 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
634 LayerProtocolName.ODU.getName(),
635 link.getLayerProtocolName().stream().findFirst().get().getName());
637 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
638 "transitional link should be BIDIRECTIONAL");
639 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
640 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
641 assertEquals(topoUuid, nodeEdgePointList.get(0).getTopologyUuid(),
642 "topology uuid should be the same for the two termination point of the link");
643 assertEquals(topoUuid, nodeEdgePointList.get(1).getTopologyUuid(),
644 "topology uuid should be the same for the two termination point of the link");
645 assertThat("otn links should terminate on two distinct nodes",
646 nodeEdgePointList.get(0).getNodeUuid().getValue(),
647 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
648 assertThat("otn links should terminate on two distinct nodes",
649 nodeEdgePointList.get(1).getNodeUuid().getValue(),
650 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
651 assertThat("otn links should terminate on two distinct tps",
652 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
653 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
654 assertThat("otn links should terminate on two distinct tps",
655 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
656 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
657 assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
658 assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
659 "administrative state should be UNLOCKED");