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.Assert.assertEquals;
14 import static org.junit.Assert.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.BeforeClass;
31 import org.junit.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.TapiTopologyDataUtils;
43 import org.opendaylight.transportpce.test.AbstractTest;
44 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsInput;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsOutput;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListInput;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListOutput;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.Sip;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.SipKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsInput;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsOutput;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsInput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsOutput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsInput;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsOutput;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInput;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsOutput;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Node;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.topology.details.output.Topology;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
76 import org.opendaylight.yangtools.yang.common.RpcResult;
77 import org.opendaylight.yangtools.yang.common.Uint64;
78 import org.slf4j.Logger;
79 import org.slf4j.LoggerFactory;
81 public class TapiTopologyImplTest extends AbstractTest {
82 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
84 private static ListeningExecutorService executorService;
85 private static CountDownLatch endSignal;
86 private static final int NUM_THREADS = 3;
87 public static NetworkTransactionService networkTransactionService;
88 public static TapiContext tapiContext;
89 public static TopologyUtils topologyUtils;
90 public static ConnectivityUtils connectivityUtils;
91 public static ServiceDataStoreOperations serviceDataStoreOperations;
92 public static TapiInitialORMapping tapiInitialORMapping;
93 public static TapiLink tapiLink;
96 public static void setUp() throws InterruptedException, ExecutionException {
97 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
98 endSignal = new CountDownLatch(1);
99 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
100 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
101 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
102 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
103 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
104 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
105 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
106 TapiTopologyDataUtils.PORTMAPPING_FILE);
107 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
108 tapiLink = new TapiLink(networkTransactionService);
109 serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
110 tapiContext = new TapiContext(networkTransactionService);
111 topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker(),
113 connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext,
114 networkTransactionService);
115 tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
116 tapiContext, serviceDataStoreOperations);
117 tapiInitialORMapping.performTopoInitialMapping();
118 LOG.info("setup done");
122 public void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
123 throws ExecutionException, InterruptedException {
124 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
125 TapiStringConstants.TPDR_100G);
126 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
127 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
128 result.addListener(new Runnable() {
131 endSignal.countDown();
135 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
137 Topology topology = rpcResult.getResult().getTopology();
138 assertNotNull("Topology should not be null", topology);
139 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(StandardCharsets.UTF_8))
141 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
142 assertEquals("Node list size should be 1", 1, topology.getNode().size());
143 Name nodeName = topology.getNode().values().stream().findFirst().get().getName()
144 .get(new NameKey("Tpdr100g node name"));
145 assertEquals("Node name should be 'Tpdr100g over WDM node'", "Tpdr100g over WDM node", nodeName.getValue());
146 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
148 assertEquals("incorrect node uuid", nodeUuid, topology.getNode().values().stream().findFirst().get().getUuid());
149 long nb = topology.getNode().values().stream().findFirst().get().getOwnedNodeEdgePoint().size();
150 assertEquals("'Transponder 100GE' node should have 2 neps", 2, nb);
151 List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().get().nonnullNodeRuleGroup()
152 .values().stream().sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
153 .collect(Collectors.toList());
154 assertEquals("'Transponder 100GE' node should contain a single node rule groups", 1, nrgList.size());
155 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
156 assertEquals("'Transponder 100GE' node -rule-group should contain 2 NEPs", nb, nodeEdgePointList.size());
157 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
158 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
159 assertEquals("local-id of the rule should be 'forward'",
160 "forward", ruleList.get(0).getLocalId());
161 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
162 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
163 assertEquals("the rule type should be 'FORWARDING'",
164 RuleType.FORWARDING, ruleList.get(0).getRuleType());
168 public void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
169 throws ExecutionException, InterruptedException {
170 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
171 TapiStringConstants.T0_MULTILAYER);
172 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
173 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
174 result.addListener(new Runnable() {
177 endSignal.countDown();
181 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
183 Topology topology = rpcResult.getResult().getTopology();
184 assertNotNull("Topology should not be null", topology);
185 assertEquals("Node list size should be 13", 13, topology.getNode().size());
186 long nb1 = topology.getNode().values().stream()
187 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
188 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
189 .equals("XPDR-A1-XPDR1+DSR"))
190 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
191 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
193 assertEquals("XPDR-A1-XPDR1 should only have one client nep", 1, nb1);
194 long nb2 = topology.getNode().values().stream()
195 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
196 .filter(node -> node.getName().get(new NameKey("dsr/odu node name")).getValue()
197 .equals("SPDR-SA1-XPDR1+DSR"))
198 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
199 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
201 assertEquals("SPDR-SA1-XPDR1 (mux) should have 4 client neps", 4, nb2);
202 long nb3 = 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("SPDR-SA1-XPDR1+DSR"))
206 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
207 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
209 assertEquals("SPDR-SA1-XPDR1 (mux) should have a single network nep", 1, nb3);
210 long nb4 = 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-XPDR2+DSR"))
214 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
215 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
217 assertEquals("SPDR-SA1-XPDR2 (switch) should have 4 client neps", 4, nb4);
218 long nb5 = 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-XPDR2+DSR"))
222 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
223 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
225 assertEquals("SPDR-SA1-XPDR2 (switch) should have 2 network neps", 2, nb5);
226 assertEquals("Link list size should be 18", 18, topology.getLink().size());
227 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
228 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
229 assertEquals("topology name should be T0 - Multi-layer topology",
230 "T0 - Multi-layer topology",
231 topology.nonnullName().values().stream().findFirst().get().getValue());
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("Node list should contain 6 DSR-ODU nodes", 6, nbDsrOduNodes);
238 assertEquals("Node list should contain 7 Photonics nodes", 7, nbPhotonicNodes);
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("Link list should contain 8 transitional links", 8, nbTransititionalLinks);
246 assertEquals("Link list should contain 8 transitional links", 8, nbOmsLinks);
247 assertEquals("Link list should contain 2 OTN links", 2, nbOtnLinks);
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 public 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 should not be null", topology);
300 // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 1 Node per Roadm
301 assertEquals("Node list size should be 18", 18, topology.getNode().size());
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("XPDR-A1-XPDR1+DSR should only have two client neps", 2, nb1);
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("XPDR-A1-XPDR1+DSR should only have two internal network neps", 2, inb1);
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("XPDR-A1-XPDR1+DSR should only have two external network neps", 2, enb1);
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("SPDR-SA1-XPDR1+DSR (mux) should have 4 client neps", 4, nb2);
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("SPDR-SA1-XPDR1+DSR (mux) should have a single internal network nep", 1, inb3);
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("SPDR-SA1-XPDR1+DSR (mux) should have 4 external network nep", 4, enb3);
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("SPDR-SA1-XPDR2+DSR (switch) should have 4 client neps", 4, nb4);
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("SPDR-SA1-XPDR2+DSR (switch) should have 4 internal network neps", 4, inb5);
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("SPDR-SA1-XPDR2+DSR (switch) should have 4 external network neps", 4, enb5);
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("XPDR-A1-XPDR1+OTSi should only have two internal network neps", 2, nb1);
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("XPDR-A1-XPDR1+OTSi should only have two external network neps", 2, inb1);
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("XPDR-A1-XPDR1+OTSi should only have two photonic network neps", 2, enb1);
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("SPDR-SA1-XPDR1+OTSi (mux) should have a single internal network nep", 1, nb2);
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("SPDR-SA1-XPDR1+OTSi (mux) should have a single external network nep", 1, inb3);
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("SPDR-SA1-XPDR1+OTSi (mux) should have a single photonic network nep", 1, enb3);
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("SPDR-SA1-XPDR2+OTSi (switch) should have 4 internal network neps", 4, nb4);
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("SPDR-SA1-XPDR2+OTSi (switch) should have 4 external network neps", 4, inb5);
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("SPDR-SA1-XPDR2+OTSi (switch) should have 4 photonic network neps", 4, enb5);
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("ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 6 network neps", 6, inb6);
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("ROADM-A1+PHOTONIC_MEDIA (SRG) should have 24 network neps", 24, enb6);
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("Link list size should be 25", 25, topology.getLink().size());
453 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
454 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
455 assertEquals("topology name should be T0 - Full Multi-layer topology",
456 "T0 - Full Multi-layer topology",
457 topology.nonnullName().values().stream().findFirst().get().getValue());
459 long nbDsrOduNodes = topology.nonnullNode().values().stream()
460 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
461 long nbPhotonicNodes = topology.nonnullNode().values().stream()
462 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
463 // In DSR/ODU we create one node per Xpdr (no filtering out)
464 assertEquals("Node list should contain 8 DSR-ODU nodes", 8, nbDsrOduNodes);
465 // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
466 assertEquals("Node list should contain 8 Photonics nodes", 8, nbPhotonicNodes);
467 long nbTransititionalLinks = topology.getLink().values().stream()
468 .filter(l -> l.getName().containsKey(new NameKey("transitional link name"))).count();
470 long nbOmsLinks = topology.getLink().values().stream()
471 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
473 long nbOmsLinks1 = topology.getLink().values().stream()
474 .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
475 // 1 transitional link per NETWORK port
476 assertEquals("Link list should contain 16 transitional links", 16, nbTransititionalLinks);
477 // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
478 assertEquals("Link list should contain 9 OMS links", 9, nbOmsLinks + nbOmsLinks1);
482 public void getNodeAndNepsDetailsWhenSuccessful()
483 throws ExecutionException, InterruptedException {
484 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
485 TapiStringConstants.T0_FULL_MULTILAYER);
486 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
487 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
488 result.addListener(new Runnable() {
491 endSignal.countDown();
495 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
497 Topology topology = rpcResult.getResult().getTopology();
498 for (Node node:topology.getNode().values()) {
499 String nodeName = node.getName().values().stream().findFirst().get().getValue();
500 GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(
501 TapiStringConstants.T0_FULL_MULTILAYER, nodeName);
502 ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
503 result.addListener(new Runnable() {
506 endSignal.countDown();
510 RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
512 Node node1 = rpcResult1.getResult().getNode();
513 assertNotNull("Node should not be null", node1);
514 for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
515 String onepName = onep.getName().values().stream().findFirst().get().getValue();
516 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
517 TapiStringConstants.T0_FULL_MULTILAYER, nodeName, onepName);
518 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
519 = tapiTopoImpl.getNodeEdgePointDetails(input2);
520 result.addListener(new Runnable() {
523 endSignal.countDown();
527 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
528 org.opendaylight.yang.gen.v1
529 .urn.onf.otcc.yang.tapi.topology.rev181210.get.node.edge.point.details.output.NodeEdgePoint
530 onep1 = rpcResult2.getResult().getNodeEdgePoint();
531 assertNotNull("Node Edge Point should not be null", onep1);
537 public void getLinkDetailsWhenSuccessful()
538 throws ExecutionException, InterruptedException {
539 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
540 TapiStringConstants.T0_FULL_MULTILAYER);
541 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
542 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
543 result.addListener(new Runnable() {
546 endSignal.countDown();
550 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
552 Topology topology = rpcResult.getResult().getTopology();
553 for (Link link:topology.getLink().values()) {
554 String linkName = link.getName().values().stream().findFirst().get().getValue();
555 GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
556 TapiStringConstants.T0_FULL_MULTILAYER, linkName);
557 ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
558 result.addListener(new Runnable() {
561 endSignal.countDown();
565 RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
566 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.link.details.output.Link link1
567 = rpcResult1.getResult().getLink();
568 assertNotNull("Link should not be null", link1);
573 public void getSipDetailsWhenSuccessful()
574 throws ExecutionException, InterruptedException {
575 GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
576 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
577 ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
578 .getServiceInterfacePointList(input);
579 result.addListener(new Runnable() {
582 endSignal.countDown();
586 RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
587 Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
588 for (Sip sip:sipMap.values()) {
589 Uuid sipUuid = sip.getUuid();
590 GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
591 .buildGetServiceInterfacePointDetailsInput(sipUuid);
592 ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
593 = tapiTopoImpl.getServiceInterfacePointDetails(input1);
594 result.addListener(new Runnable() {
597 endSignal.countDown();
601 RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
602 org.opendaylight.yang.gen.v1
603 .urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip sip1
604 = rpcResult1.getResult().getSip();
605 assertNotNull("Sip should not be null", sip1);
609 private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
610 Uuid linkUuid, String linkName) {
611 assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("otn link name")).getValue());
612 assertEquals("bad uuid for link", linkUuid, link.getUuid());
613 assertEquals("Available capacity unit should be MBPS",
614 CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit());
615 String prefix = linkName.split("-")[0];
616 if ("OTU4".equals(prefix)) {
617 assertEquals("Available capacity -total size value should be 0",
618 Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue());
619 } else if ("ODTU4".equals(prefix)) {
620 assertEquals("Available capacity -total size value should be 100 000",
621 Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue());
623 assertEquals("Total capacity unit should be GBPS",
624 CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit());
625 assertEquals("Total capacity -total size value should be 100",
626 Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue());
627 if ("OTU4".equals(prefix)) {
628 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
629 LayerProtocolName.PHOTONICMEDIA.getName(),
630 link.getLayerProtocolName().stream().findFirst().get().getName());
631 } else if ("ODTU4".equals(prefix)) {
632 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
633 LayerProtocolName.ODU.getName(),
634 link.getLayerProtocolName().stream().findFirst().get().getName());
636 assertEquals("transitional link should be BIDIRECTIONAL",
637 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
638 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
639 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
640 assertEquals("topology uuid should be the same for the two termination point of the link",
641 topoUuid, nodeEdgePointList.get(0).getTopologyUuid());
642 assertEquals("topology uuid should be the same for the two termination point of the link",
643 topoUuid, nodeEdgePointList.get(1).getTopologyUuid());
644 assertThat("otn links should terminate on two distinct nodes",
645 nodeEdgePointList.get(0).getNodeUuid().getValue(),
646 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
647 assertThat("otn links should terminate on two distinct nodes",
648 nodeEdgePointList.get(1).getNodeUuid().getValue(),
649 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
650 assertThat("otn links should terminate on two distinct tps",
651 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
652 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
653 assertThat("otn links should terminate on two distinct tps",
654 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
655 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
656 assertEquals("operational state should be ENABLED",
657 OperationalState.ENABLED, link.getOperationalState());
658 assertEquals("administrative state should be UNLOCKED",
659 AdministrativeState.UNLOCKED, link.getAdministrativeState());