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.common.network.RequestProcessor;
36 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
37 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
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.TapiTopologyDataUtils;
42 import org.opendaylight.transportpce.test.AbstractTest;
43 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsInput;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointDetailsOutput;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListInput;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.GetServiceInterfacePointListOutput;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.Sip;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.list.output.SipKey;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsInput;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetLinkDetailsOutput;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsInput;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeDetailsOutput;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsInput;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetNodeEdgePointDetailsOutput;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInput;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsOutput;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Node;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.topology.details.output.Topology;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
75 import org.opendaylight.yangtools.yang.common.RpcResult;
76 import org.opendaylight.yangtools.yang.common.Uint64;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
80 public class TapiTopologyImplTest extends AbstractTest {
81 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
83 private static ListeningExecutorService executorService;
84 private static CountDownLatch endSignal;
85 private static final int NUM_THREADS = 3;
86 public static NetworkTransactionService networkTransactionService;
87 public static TapiContext tapiContext;
88 public static TopologyUtils topologyUtils;
89 public static ConnectivityUtils connectivityUtils;
90 public static ServiceDataStoreOperations serviceDataStoreOperations;
91 public static TapiInitialORMapping tapiInitialORMapping;
94 public static void setUp() throws InterruptedException, ExecutionException {
95 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
96 endSignal = new CountDownLatch(1);
97 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
98 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
99 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
100 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
101 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
102 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
103 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
104 TapiTopologyDataUtils.PORTMAPPING_FILE);
105 networkTransactionService = new NetworkTransactionImpl(
106 new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
107 serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getDataStoreContextUtil().getDataBroker());
108 tapiContext = new TapiContext(networkTransactionService);
109 topologyUtils = new TopologyUtils(networkTransactionService, getDataStoreContextUtil().getDataBroker());
110 connectivityUtils = new ConnectivityUtils(serviceDataStoreOperations, new HashMap<>(), tapiContext);
111 tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
112 tapiContext, serviceDataStoreOperations);
113 tapiInitialORMapping.performTopoInitialMapping();
114 LOG.info("setup done");
118 public void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
119 throws ExecutionException, InterruptedException {
120 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(TopologyUtils.TPDR_100G);
121 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
122 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
123 result.addListener(new Runnable() {
126 endSignal.countDown();
130 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
132 Topology topology = rpcResult.getResult().getTopology();
133 assertNotNull("Topology should not be null", topology);
134 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.TPDR_100G.getBytes(StandardCharsets.UTF_8))
136 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
137 assertEquals("Node list size should be 1", 1, topology.getNode().size());
138 Name nodeName = topology.getNode().values().stream().findFirst().get().getName()
139 .get(new NameKey("Tpdr100g node name"));
140 assertEquals("Node name should be 'Tpdr100g over WDM node'", "Tpdr100g over WDM node", nodeName.getValue());
141 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeName.getValue().getBytes(StandardCharsets.UTF_8))
143 assertEquals("incorrect node uuid", nodeUuid, topology.getNode().values().stream().findFirst().get().getUuid());
144 long nb = topology.getNode().values().stream().findFirst().get().getOwnedNodeEdgePoint().size();
145 assertEquals("'Transponder 100GE' node should have 2 neps", 2, nb);
146 List<NodeRuleGroup> nrgList = topology.getNode().values().stream().findFirst().get().nonnullNodeRuleGroup()
147 .values().stream().sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
148 .collect(Collectors.toList());
149 assertEquals("'Transponder 100GE' node should contain a single node rule groups", 1, nrgList.size());
150 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
151 assertEquals("'Transponder 100GE' node -rule-group should contain 2 NEPs", nb, nodeEdgePointList.size());
152 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
153 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
154 assertEquals("local-id of the rule should be 'forward'",
155 "forward", ruleList.get(0).getLocalId());
156 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
157 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
158 assertEquals("the rule type should be 'FORWARDING'",
159 RuleType.FORWARDING, ruleList.get(0).getRuleType());
163 public void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
164 throws ExecutionException, InterruptedException {
165 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(TopologyUtils.T0_MULTILAYER);
166 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
167 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
168 result.addListener(new Runnable() {
171 endSignal.countDown();
175 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
177 Topology topology = rpcResult.getResult().getTopology();
178 assertNotNull("Topology should not be null", topology);
179 assertEquals("Node list size should be 13", 13, topology.getNode().size());
180 long nb1 = topology.getNode().values().stream()
181 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
182 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1"))
183 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
184 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
186 assertEquals("XPDR-A1-XPDR1 should only have one client nep", 1, nb1);
187 long nb2 = topology.getNode().values().stream()
188 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
189 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1"))
190 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
191 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
193 assertEquals("SPDR-SA1-XPDR1 (mux) should have 4 client neps", 4, nb2);
194 long nb3 = topology.getNode().values().stream()
195 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
196 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1"))
197 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
198 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_N"))))
200 assertEquals("SPDR-SA1-XPDR1 (mux) should have a single network nep", 1, nb3);
201 long nb4 = topology.getNode().values().stream()
202 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
203 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2"))
204 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
205 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
207 assertEquals("SPDR-SA1-XPDR2 (switch) should have 4 client neps", 4, nb4);
208 long nb5 = topology.getNode().values().stream()
209 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
210 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2"))
211 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
212 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_N"))))
214 assertEquals("SPDR-SA1-XPDR2 (switch) should have 2 network neps", 2, nb5);
215 assertEquals("Link list size should be 18", 18, topology.getLink().size());
216 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
217 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
218 assertEquals("topology name should be T0 - Multi-layer topology",
219 "T0 - Multi-layer topology",
220 topology.nonnullName().values().stream().findFirst().get().getValue());
222 long nbDsrOduNodes = topology.nonnullNode().values().stream()
223 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
224 long nbPhotonicNodes = topology.nonnullNode().values().stream()
225 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
226 assertEquals("Node list should contain 6 DSR-ODU nodes", 6, nbDsrOduNodes);
227 assertEquals("Node list should contain 7 Photonics nodes", 7, nbPhotonicNodes);
228 long nbTransititionalLinks = topology.getLink().values().stream()
229 .filter(l -> l.getName().containsKey(new NameKey("transitional link name"))).count();
230 long nbOmsLinks = topology.getLink().values().stream()
231 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
232 long nbOtnLinks = topology.getLink().values().stream()
233 .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
234 assertEquals("Link list should contain 8 transitional links", 8, nbTransititionalLinks);
235 assertEquals("Link list should contain 8 transitional links", 8, nbOmsLinks);
236 assertEquals("Link list should contain 2 OTN links", 2, nbOtnLinks);
238 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
240 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
242 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
244 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
246 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR+XPDR1-NETWORK1"
247 .getBytes(StandardCharsets.UTF_8)).toString());
248 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR+XPDR1-NETWORK1"
249 .getBytes(StandardCharsets.UTF_8)).toString());
250 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
251 .getBytes(StandardCharsets.UTF_8)).toString());
252 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
253 .getBytes(StandardCharsets.UTF_8)).toString());
255 new Uuid(UUID.nameUUIDFromBytes("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
256 .getBytes(StandardCharsets.UTF_8)).toString());
258 new Uuid(UUID.nameUUIDFromBytes("OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
259 .getBytes(StandardCharsets.UTF_8)).toString());
261 List<Link> links = topology.nonnullLink().values().stream()
262 .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
263 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
264 .collect(Collectors.toList());
265 checkOtnLink(links.get(0), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
266 "ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
267 checkOtnLink(links.get(1), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
268 "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
272 public void getTopologyDetailsForFullTapiTopologyWithLinksWhenSuccessful()
273 throws ExecutionException, InterruptedException {
274 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
275 TopologyUtils.T0_FULL_MULTILAYER);
276 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
277 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
278 result.addListener(new Runnable() {
281 endSignal.countDown();
285 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
287 Topology topology = rpcResult.getResult().getTopology();
288 assertNotNull("Topology should not be null", topology);
289 // 2 Nodes per Xpdr/Spdr node (DSR-ODU & PHOT) + 1 Node per Roadm
290 assertEquals("Node list size should be 18", 18, topology.getNode().size());
291 long nb1 = topology.getNode().values().stream()
292 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
293 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
294 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
295 .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))))
297 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
298 assertEquals("XPDR-A1-XPDR1+DSR should only have two client neps", 2, nb1);
299 long inb1 = topology.getNode().values().stream()
300 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
301 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
302 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
303 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
305 assertEquals("XPDR-A1-XPDR1+DSR should only have two internal network neps", 2, inb1);
306 long enb1 = topology.getNode().values().stream()
307 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
308 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+DSR"))
309 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
310 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
312 assertEquals("XPDR-A1-XPDR1+DSR should only have two external network neps", 2, enb1);
313 long nb2 = topology.getNode().values().stream()
314 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
315 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
316 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
317 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
319 assertEquals("SPDR-SA1-XPDR1+DSR (mux) should have 4 client neps", 4, nb2);
320 long inb3 = topology.getNode().values().stream()
321 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
322 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
323 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
324 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
326 assertEquals("SPDR-SA1-XPDR1+DSR (mux) should have a single internal network nep", 1, inb3);
327 long enb3 = topology.getNode().values().stream()
328 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
329 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+DSR"))
330 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
331 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
333 assertEquals("SPDR-SA1-XPDR1+DSR (mux) should have a single external network nep", 1, enb3);
334 long nb4 = topology.getNode().values().stream()
335 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
336 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
337 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
338 .filter(nep -> nep.getName().containsKey(new NameKey("NodeEdgePoint_C"))))
340 assertEquals("SPDR-SA1-XPDR2+DSR (switch) should have 4 client neps", 4, nb4);
341 long inb5 = topology.getNode().values().stream()
342 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
343 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
344 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
345 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint_N"))))
347 assertEquals("SPDR-SA1-XPDR2+DSR (switch) should have 4 internal network neps", 4, inb5);
348 long enb5 = topology.getNode().values().stream()
349 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
350 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+DSR"))
351 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
352 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint_N"))))
354 assertEquals("SPDR-SA1-XPDR2+DSR (switch) should have 4 external network neps", 4, enb5);
356 // Now lets check for the Photonic media nodes (same nodes as for DSR + 1 Roadm node)
357 nb1 = topology.getNode().values().stream()
358 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
359 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
360 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
361 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
363 // 2 client ports in configuration -> removed the checkTp so we have 2 NEPs
364 assertEquals("XPDR-A1-XPDR1+OTSi should only have two internal network neps", 2, nb1);
365 inb1 = topology.getNode().values().stream()
366 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
367 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
368 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
369 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
371 assertEquals("XPDR-A1-XPDR1+OTSi should only have two external network neps", 2, inb1);
372 enb1 = topology.getNode().values().stream()
373 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
374 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("XPDR-A1-XPDR1+OTSi"))
375 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
376 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
378 assertEquals("XPDR-A1-XPDR1+OTSi should only have two photonic network neps", 2, enb1);
379 nb2 = topology.getNode().values().stream()
380 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
381 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
382 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
383 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
385 assertEquals("SPDR-SA1-XPDR1+OTSi (mux) should have a single internal network nep", 1, nb2);
386 inb3 = topology.getNode().values().stream()
387 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
388 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
389 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
390 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
392 assertEquals("SPDR-SA1-XPDR1+OTSi (mux) should have a single external network nep", 1, inb3);
393 enb3 = topology.getNode().values().stream()
394 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
395 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR1+OTSi"))
396 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
397 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
399 assertEquals("SPDR-SA1-XPDR1+OTSi (mux) should have a single photonic network nep", 1, enb3);
400 nb4 = topology.getNode().values().stream()
401 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
402 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
403 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
404 .filter(nep -> nep.getName().containsKey(new NameKey("iNodeEdgePoint"))))
406 assertEquals("SPDR-SA1-XPDR2+OTSi (switch) should have 4 internal network neps", 4, nb4);
407 inb5 = topology.getNode().values().stream()
408 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
409 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
410 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
411 .filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
413 assertEquals("SPDR-SA1-XPDR2+OTSi (switch) should have 4 external network neps", 4, inb5);
414 enb5 = topology.getNode().values().stream()
415 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
416 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals("SPDR-SA1-XPDR2+OTSi"))
417 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
418 .filter(nep -> nep.getName().containsKey(new NameKey("PhotMedNodeEdgePoint"))))
420 assertEquals("SPDR-SA1-XPDR2+OTSi (switch) should have 4 photonic network neps", 4, enb5);
421 // We should have 3 neps per DEGREE-TTP port and 3 neps per SRG-PP port
422 long inb6 = topology.getNode().values().stream()
423 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
424 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
425 "ROADM-A1+PHOTONIC_MEDIA"))
426 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
427 .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("DEG")))
429 assertEquals("ROADM-A1+PHOTONIC_MEDIA (DEGREE) should have 6 network neps", 6, inb6);
430 long enb6 = topology.getNode().values().stream()
431 .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
432 .filter(node -> node.getName().values().stream().findFirst().get().getValue().equals(
433 "ROADM-A1+PHOTONIC_MEDIA"))
434 .flatMap(node -> node.getOwnedNodeEdgePoint().values().stream()
435 .filter(nep -> nep.getName().values().stream().findFirst().get().getValue().contains("SRG")))
437 assertEquals("ROADM-A1+PHOTONIC_MEDIA (SRG) should have 24 network neps", 24, enb6);
439 // Links in openroadm topology which include Roadm-to-Roadm and Xpdr-to-Roadm (ortopo / 2)
440 // + transitional links -> 1 per network port of Xpdr + OTN links / 2
441 assertEquals("Link list size should be 27", 27, topology.getLink().size());
442 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Full Multi-layer topology".getBytes()).toString());
443 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
444 assertEquals("topology name should be T0 - Full Multi-layer topology",
445 "T0 - Full Multi-layer topology",
446 topology.nonnullName().values().stream().findFirst().get().getValue());
448 long nbDsrOduNodes = topology.nonnullNode().values().stream()
449 .filter(n -> n.getName().containsKey(new NameKey("dsr/odu node name"))).count();
450 long nbPhotonicNodes = topology.nonnullNode().values().stream()
451 .filter(n -> n.getName().containsKey(new NameKey("otsi node name"))).count();
452 // In DSR/ODU we create one node per Xpdr (no filtering out)
453 assertEquals("Node list should contain 8 DSR-ODU nodes", 8, nbDsrOduNodes);
454 // We need to add the Roadms as Photonic nodes. Instead of 1 node as roadm infra we have 2 roadm nodes
455 assertEquals("Node list should contain 8 Photonics nodes", 8, nbPhotonicNodes);
456 long nbTransititionalLinks = topology.getLink().values().stream()
457 .filter(l -> l.getName().containsKey(new NameKey("transitional link name"))).count();
459 long nbOmsLinks = topology.getLink().values().stream()
460 .filter(l -> l.getName().containsKey(new NameKey("OMS link name"))).count();
462 long nbOmsLinks1 = topology.getLink().values().stream()
463 .filter(l -> l.getName().containsKey(new NameKey("XPDR-RDM link name"))).count();
464 long nbOtnLinks = topology.getLink().values().stream()
465 .filter(l -> l.getName().containsKey(new NameKey("otn link name"))).count();
466 // 1 transitional link per NETWORK port
467 assertEquals("Link list should contain 16 transitional links", 16, nbTransititionalLinks);
468 // 1 OMS per ROADM-to-ROADM link + Existing XPDR-tp-ROADM link in openroadm topology
469 assertEquals("Link list should contain 9 OMS links", 9, nbOmsLinks + nbOmsLinks1);
470 // Should we consider OTN links as links or connections??
471 assertEquals("Link list should contain 2 OTN links", 2, nbOtnLinks);
473 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
475 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(StandardCharsets.UTF_8))
477 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
479 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(StandardCharsets.UTF_8))
481 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
482 .getBytes(StandardCharsets.UTF_8)).toString());
483 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
484 .getBytes(StandardCharsets.UTF_8)).toString());
485 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
486 .getBytes(StandardCharsets.UTF_8)).toString());
487 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
488 .getBytes(StandardCharsets.UTF_8)).toString());
490 new Uuid(UUID.nameUUIDFromBytes("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
491 .getBytes(StandardCharsets.UTF_8)).toString());
493 new Uuid(UUID.nameUUIDFromBytes("OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
494 .getBytes(StandardCharsets.UTF_8)).toString());
496 List<Link> links = topology.nonnullLink().values().stream()
497 .filter(l -> l.getName().containsKey(new NameKey("otn link name")))
498 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
499 .collect(Collectors.toList());
500 checkOtnLink(links.get(0), topoUuid, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
501 "ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
502 checkOtnLink(links.get(1), topoUuid, node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
503 "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
507 public void getNodeAndNepsDetailsWhenSuccessful()
508 throws ExecutionException, InterruptedException {
509 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
510 TopologyUtils.T0_FULL_MULTILAYER);
511 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
512 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
513 result.addListener(new Runnable() {
516 endSignal.countDown();
520 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
522 Topology topology = rpcResult.getResult().getTopology();
523 for (Node node:topology.getNode().values()) {
524 String nodeName = node.getName().values().stream().findFirst().get().getValue();
525 GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(
526 TopologyUtils.T0_FULL_MULTILAYER, nodeName);
527 ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
528 result.addListener(new Runnable() {
531 endSignal.countDown();
535 RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
537 Node node1 = rpcResult1.getResult().getNode();
538 assertNotNull("Node should not be null", node1);
539 for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
540 String onepName = onep.getName().values().stream().findFirst().get().getValue();
541 GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
542 TopologyUtils.T0_FULL_MULTILAYER, nodeName, onepName);
543 ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
544 = tapiTopoImpl.getNodeEdgePointDetails(input2);
545 result.addListener(new Runnable() {
548 endSignal.countDown();
552 RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
553 org.opendaylight.yang.gen.v1
554 .urn.onf.otcc.yang.tapi.topology.rev181210.get.node.edge.point.details.output.NodeEdgePoint
555 onep1 = rpcResult2.getResult().getNodeEdgePoint();
556 assertNotNull("Node Edge Point should not be null", onep1);
562 public void getLinkDetailsWhenSuccessful()
563 throws ExecutionException, InterruptedException {
564 GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(
565 TopologyUtils.T0_FULL_MULTILAYER);
566 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
567 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
568 result.addListener(new Runnable() {
571 endSignal.countDown();
575 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
577 Topology topology = rpcResult.getResult().getTopology();
578 for (Link link:topology.getLink().values()) {
579 String linkName = link.getName().values().stream().findFirst().get().getValue();
580 GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
581 TopologyUtils.T0_FULL_MULTILAYER, linkName);
582 ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
583 result.addListener(new Runnable() {
586 endSignal.countDown();
590 RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
591 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.link.details.output.Link link1
592 = rpcResult1.getResult().getLink();
593 assertNotNull("Link should not be null", link1);
598 public void getSipDetailsWhenSuccessful()
599 throws ExecutionException, InterruptedException {
600 GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
601 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils);
602 ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
603 .getServiceInterfacePointList(input);
604 result.addListener(new Runnable() {
607 endSignal.countDown();
611 RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
612 Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
613 for (Sip sip:sipMap.values()) {
614 Uuid sipUuid = sip.getUuid();
615 GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
616 .buildGetServiceInterfacePointDetailsInput(sipUuid);
617 ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
618 = tapiTopoImpl.getServiceInterfacePointDetails(input1);
619 result.addListener(new Runnable() {
622 endSignal.countDown();
626 RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
627 org.opendaylight.yang.gen.v1
628 .urn.onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip sip1
629 = rpcResult1.getResult().getSip();
630 assertNotNull("Sip should not be null", sip1);
634 private void checkOtnLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid,
635 Uuid linkUuid, String linkName) {
636 assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("otn link name")).getValue());
637 assertEquals("bad uuid for link", linkUuid, link.getUuid());
638 assertEquals("Available capacity unit should be MBPS",
639 CapacityUnit.MBPS, link.getAvailableCapacity().getTotalSize().getUnit());
640 String prefix = linkName.split("-")[0];
641 if ("OTU4".equals(prefix)) {
642 assertEquals("Available capacity -total size value should be 0",
643 Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue());
644 } else if ("ODTU4".equals(prefix)) {
645 assertEquals("Available capacity -total size value should be 100 000",
646 Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue());
648 assertEquals("Total capacity unit should be GBPS",
649 CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit());
650 assertEquals("Total capacity -total size value should be 100",
651 Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue());
652 if ("OTU4".equals(prefix)) {
653 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
654 LayerProtocolName.PHOTONICMEDIA.getName(), link.getLayerProtocolName().get(0).getName());
655 } else if ("ODTU4".equals(prefix)) {
656 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
657 LayerProtocolName.ODU.getName(), link.getLayerProtocolName().get(0).getName());
659 assertEquals("transitional link should be BIDIRECTIONAL",
660 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
661 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
662 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
663 assertEquals("topology uuid should be the same for the two termination point of the link",
664 topoUuid, nodeEdgePointList.get(0).getTopologyUuid());
665 assertEquals("topology uuid should be the same for the two termination point of the link",
666 topoUuid, nodeEdgePointList.get(1).getTopologyUuid());
667 assertThat("otn links should terminate on two distinct nodes",
668 nodeEdgePointList.get(0).getNodeUuid().getValue(),
669 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
670 assertThat("otn links should terminate on two distinct nodes",
671 nodeEdgePointList.get(1).getNodeUuid().getValue(),
672 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
673 assertThat("otn links should terminate on two distinct tps",
674 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
675 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
676 assertThat("otn links should terminate on two distinct tps",
677 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
678 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
679 assertEquals("operational state should be ENABLED",
680 OperationalState.ENABLED, link.getOperationalState());
681 assertEquals("administrative state should be UNLOCKED",
682 AdministrativeState.UNLOCKED, link.getAdministrativeState());