2 * Copyright © 2020 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.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.MatcherAssert.assertThat;
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNull;
17 import static org.junit.Assert.fail;
19 import com.google.common.util.concurrent.FluentFuture;
20 import java.nio.charset.Charset;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Optional;
26 import java.util.UUID;
27 import java.util.concurrent.ExecutionException;
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.mdsal.binding.api.DataBroker;
33 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
34 import org.opendaylight.transportpce.common.InstanceIdentifiers;
35 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
36 import org.opendaylight.transportpce.test.AbstractTest;
37 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
47 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
48 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
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.LifecycleState;
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.PortDirection;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
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.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.binding.InstanceIdentifier;
77 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
78 import org.opendaylight.yangtools.yang.common.Uint64;
79 import org.slf4j.Logger;
80 import org.slf4j.LoggerFactory;
82 public class ConvertORTopoObjectToTapiTooObjectTest extends AbstractTest {
83 private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoObjectToTapiTooObjectTest.class);
85 private static Node otnMuxA;
86 private static Node otnMuxC;
87 private static Node otnSwitch;
88 private static Node tpdr100G;
89 private static List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
90 .networks.network.Link> otnLinks;
91 private static Uuid topologyUuid;
92 private static DataBroker dataBroker = getDataBroker();
95 public static void setUp() throws InterruptedException, ExecutionException {
96 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
97 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
98 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
99 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
100 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
101 TapiTopologyDataUtils.PORTMAPPING_FILE);
103 KeyedInstanceIdentifier<Node, NodeKey> muxAIID = InstanceIdentifier.create(Networks.class)
104 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
105 .class, new NetworkKey(new NetworkId("otn-topology")))
106 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
107 FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
108 .read(LogicalDatastoreType.CONFIGURATION, muxAIID);
109 KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
110 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
111 .class, new NetworkKey(new NetworkId("otn-topology")))
112 .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
113 FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
114 .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
115 KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
116 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
117 .class, new NetworkKey(new NetworkId("otn-topology")))
118 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
119 FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
120 .read(LogicalDatastoreType.CONFIGURATION, switchIID);
122 otnMuxA = muxAFuture.get().get();
123 otnMuxC = muxCFuture.get().get();
124 otnSwitch = switchFuture.get().get();
126 KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
127 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
128 .class, new NetworkKey(new NetworkId("otn-topology")))
129 .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
130 FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
131 .read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
132 tpdr100G = tpdrFuture.get().get();
134 InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
135 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
136 .class, new NetworkKey(new NetworkId("otn-topology")))
137 .augmentation(Network1.class);
138 FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
139 .read(LogicalDatastoreType.CONFIGURATION, linksIID);
140 otnLinks = linksFuture.get().get().getLink().values().stream().collect(Collectors.toList());
141 Collections.sort(otnLinks, (l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()));
142 topologyUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes(Charset.forName("UTF-8")))
144 LOG.info("TEST SETUP READY");
148 public void convertNodeForTransponder100G() {
149 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
150 List<String> networkPortList = new ArrayList<>();
151 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
152 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
153 networkPortList.add(tp.getTpId().getValue());
156 tapiFactory.convertNode(tpdr100G, networkPortList);
157 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
158 = tapiFactory.getTapiNodes().values().stream()
159 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
160 .collect(Collectors.toList());
162 assertEquals("Node list size should be 2", 2, tapiFactory.getTapiNodes().size());
163 assertEquals("Link list size should be 2", 2, tapiFactory.getTapiLinks().size());
165 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
167 checkDsrNode(tapiNodes.get(1), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1");
168 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
170 checkOtsiNode(tapiNodes.get(0), otsiNodeUuid, "tpdr", "XPDR-A1-XPDR1");
172 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
173 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
174 .collect(Collectors.toList());
175 checkTransitionalLink(tapiLinks.get(1), dsrNodeUuid, otsiNodeUuid,
176 "XPDR-A1-XPDR1+DSR+XPDR1-NETWORK1", "XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1", "XPDR-A1-XPDR1");
180 public void convertNodeForOtnMuxponder() {
181 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
182 List<String> networkPortList = new ArrayList<>();
183 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
184 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
185 networkPortList.add(tp.getTpId().getValue());
188 tapiFactory.convertNode(otnMuxA, networkPortList);
189 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
190 = tapiFactory.getTapiNodes().values().stream()
191 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
192 .collect(Collectors.toList());
194 assertEquals("Node list size should be 2", 2, tapiFactory.getTapiNodes().size());
195 assertEquals("Link list size should be 1", 1, tapiFactory.getTapiLinks().size());
196 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
198 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1");
199 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
201 checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "mux", "SPDR-SA1-XPDR1");
203 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
204 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
205 .collect(Collectors.toList());
206 checkTransitionalLink(tapiLinks.get(0), dsrNodeUuid, otsiNodeUuid,
207 "SPDR-SA1-XPDR1+DSR+XPDR1-NETWORK1", "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1", "SPDR-SA1-XPDR1");
211 public void convertNodeForOtnSwitch() {
212 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
213 List<String> networkPortList = new ArrayList<>();
214 for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
215 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
216 networkPortList.add(tp.getTpId().getValue());
219 tapiFactory.convertNode(otnSwitch, networkPortList);
220 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
221 = tapiFactory.getTapiNodes().values().stream()
222 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
223 .collect(Collectors.toList());
225 assertEquals("Node list size should be 2", 2, tapiFactory.getTapiNodes().size());
226 assertEquals("Link list size should be 4", 4, tapiFactory.getTapiLinks().size());
228 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8")))
230 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "switch", "SPDR-SA1-XPDR2");
231 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8")))
233 checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "switch", "SPDR-SA1-XPDR2");
235 List<Link> tapiLinks = tapiFactory.getTapiLinks().values().stream()
236 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
237 .collect(Collectors.toList());
238 checkTransitionalLink(tapiLinks.get(0), dsrNodeUuid, otsiNodeUuid,
239 "SPDR-SA1-XPDR2+DSR+XPDR2-NETWORK4", "SPDR-SA1-XPDR2+iOTSi+XPDR2-NETWORK4", "SPDR-SA1-XPDR2");
243 public void convertOtnLink() {
244 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
245 List<String> networkPortListA = new ArrayList<>();
246 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
247 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
248 networkPortListA.add(tp.getTpId().getValue());
251 tapiFactory.convertNode(otnMuxA, networkPortListA);
252 List<String> networkPortListC = new ArrayList<>();
253 for (TerminationPoint tp : otnMuxC.augmentation(Node1.class).getTerminationPoint().values()) {
254 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
255 networkPortListC.add(tp.getTpId().getValue());
258 tapiFactory.convertNode(otnMuxC, networkPortListC);
259 tapiFactory.convertLinks(otnLinks);
260 assertEquals("Link list size should be 4", 4, tapiFactory.getTapiLinks().size());
262 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
264 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
266 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
268 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
270 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR+XPDR1-NETWORK1"
271 .getBytes(Charset.forName("UTF-8"))).toString());
272 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+DSR+XPDR1-NETWORK1"
273 .getBytes(Charset.forName("UTF-8"))).toString());
274 Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
275 .getBytes(Charset.forName("UTF-8"))).toString());
276 Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
277 .getBytes(Charset.forName("UTF-8"))).toString());
279 new Uuid(UUID.nameUUIDFromBytes("ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
280 .getBytes(Charset.forName("UTF-8"))).toString());
282 new Uuid(UUID.nameUUIDFromBytes("OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"
283 .getBytes(Charset.forName("UTF-8"))).toString());
285 List<Link> links = tapiFactory.getTapiLinks().values().stream()
286 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
287 .collect(Collectors.toList());
288 checkOtnLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
289 "ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
290 checkOtnLink(links.get(2), node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
291 "OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1");
295 public void convertRoadmInfrastructureWhenNoXponderAttached() {
296 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
297 tapiFactory.convertRoadmInfrastructure();
299 assertEquals("Node list size should be 1", 1, tapiFactory.getTapiNodes().size());
300 assertEquals("Link list size should be empty", 0, tapiFactory.getTapiLinks().size());
301 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
302 = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
303 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
305 checkOtsiNode(tapiNodes.get(0), otsiNodeUuid, "infra", "ROADM-infra");
309 public void convertRoadmInfrastructureWhenOtnMuxAttached() {
310 ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topologyUuid);
311 List<String> networkPortListA = new ArrayList<>();
312 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
313 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
314 networkPortListA.add(tp.getTpId().getValue());
317 tapiFactory.convertNode(otnMuxA, networkPortListA);
318 tapiFactory.convertRoadmInfrastructure();
320 assertEquals("Node list size should be 3", 3, tapiFactory.getTapiNodes().size());
321 assertEquals("Link list size should be 2", 2, tapiFactory.getTapiLinks().size());
322 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
323 = tapiFactory.getTapiNodes().values().stream()
324 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
325 .collect(Collectors.toList());
326 Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
328 checkOtsiNode(tapiNodes.get(2), otsiNodeUuid, "infra", "ROADM-infra");
330 List<Link> links = tapiFactory.getTapiLinks().values().stream()
331 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
332 .collect(Collectors.toList());
333 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
335 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
337 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eOTSi+XPDR1-NETWORK1"
338 .getBytes(Charset.forName("UTF-8"))).toString());
339 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1")
340 .getBytes(Charset.forName("UTF-8"))).toString());
342 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1--XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1"
343 .getBytes(Charset.forName("UTF-8"))).toString());
344 checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
345 "SPDR-SA1-XPDR1--XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1");
348 private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
349 Uuid nodeUuid, String dsrNodeType, String nodeId) {
350 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
351 assertEquals("incorrect node name", nodeId, node.getName().get(new NameKey("dsr/odu node name")).getValue());
352 assertEquals("administrative state should be UNLOCKED",
353 AdministrativeState.UNLOCKED, node.getAdministrativeState());
354 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
355 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
356 assertEquals("value-name should be 'dsr/odu node name'",
357 "dsr/odu node name", node.nonnullName().values().stream().findFirst().get().getValueName());
358 assertEquals("dsr node should manage 2 protocol layers : dsr and odu",
359 2, node.getLayerProtocolName().size());
360 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
361 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
362 List<OwnedNodeEdgePoint> nepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
363 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_N")))
364 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
365 .collect(Collectors.toList());
366 List<OwnedNodeEdgePoint> nepsC;
367 switch (dsrNodeType) {
369 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
370 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
371 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
372 .collect(Collectors.toList());
373 assertEquals("Switch-DSR node should have 4 NEPs network", 4, nepsN.size());
374 assertEquals("Switch-DSR node should have 4 NEPs client", 4, nepsC.size());
375 OwnedNodeEdgePoint nep1 = nepsC.get(2);
376 Uuid client4NepUuid = new Uuid(
377 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
379 checkNepClient100GSwitch(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C");
380 OwnedNodeEdgePoint nep2 = nepsN.get(1);
381 Uuid networkNepUuid = new Uuid(
382 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
384 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "NodeEdgePoint_N");
385 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
386 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
387 .collect(Collectors.toList());
388 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
391 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
392 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
393 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
394 .collect(Collectors.toList());
395 assertEquals("Mux-DSR node should have 1 NEP network", 1, nepsN.size());
396 assertEquals("Mux-DSR node should have 4 NEPs client", 4, nepsC.size());
397 OwnedNodeEdgePoint nep3 = nepsC.get(2);
398 Uuid client3NepUuid = new Uuid(
399 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
401 checkNepClient10G(nep3, client3NepUuid, "XPDR1-CLIENT3", "NodeEdgePoint_C");
403 OwnedNodeEdgePoint nep4 = nepsN.get(0);
404 Uuid networkNepUuid2 = new Uuid(
405 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
407 checkNepNetworkODU4(nep4, networkNepUuid2, "XPDR1-NETWORK1", "NodeEdgePoint_N");
408 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
409 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
410 .collect(Collectors.toList());
411 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, networkNepUuid2, nodeUuid);
414 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
415 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
416 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
417 .collect(Collectors.toList());
418 assertEquals("Tpdr-DSR node should have 2 NEPs network", 2, nepsN.size());
419 assertEquals("Tpdr-DSR node should have 2 NEPs client", 2, nepsC.size());
420 OwnedNodeEdgePoint nep5 = nepsC.get(0);
421 Uuid client1NepUuid = new Uuid(
422 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
424 checkNepClient100GTpdr(nep5, client1NepUuid, "XPDR1-CLIENT1", "100G-tpdr");
426 OwnedNodeEdgePoint nep6 = nepsN.get(0);
427 Uuid networkNepUuid3 = new Uuid(
428 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
430 checkNepNetworkODU4(nep6, networkNepUuid3, "XPDR1-NETWORK1", "NodeEdgePoint_N");
431 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
432 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
433 .collect(Collectors.toList());
434 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, networkNepUuid3, nodeUuid);
442 private void checkOtsiNode(
443 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
444 Uuid nodeUuid, String otsiNodeType, String nodeId) {
445 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
446 assertEquals("incorrect node name", nodeId, node.getName().get(new NameKey("otsi node name")).getValue());
447 assertEquals("administrative state should be UNLOCKED",
448 AdministrativeState.UNLOCKED, node.getAdministrativeState());
449 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
450 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
451 assertEquals("value-name should be 'dsr/odu node name'",
452 "otsi node name", node.nonnullName().values().stream().findFirst().get().getValueName());
453 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
454 1, node.getLayerProtocolName().size());
455 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
456 LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().get(0));
457 List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
458 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
459 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
460 .collect(Collectors.toList());
461 List<OwnedNodeEdgePoint> nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
462 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
463 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
464 .collect(Collectors.toList());
465 switch (otsiNodeType) {
467 assertEquals("Switch-OTSi node should have 4 eNEPs", 4, nepsE.size());
468 assertEquals("Switch-OTSi node should have 4 iNEPs", 4, nepsI.size());
469 OwnedNodeEdgePoint nep1 = nepsI.get(1);
470 Uuid inepUuid = new Uuid(
471 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
473 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint");
474 OwnedNodeEdgePoint nep2 = nepsE.get(0);
475 Uuid enepUuid = new Uuid(
476 UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
478 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint");
479 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
480 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
481 .collect(Collectors.toList());
482 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
485 assertEquals("Mux-OTSi node should have 1 eNEP", 1, nepsE.size());
486 assertEquals("Mux-OTSi node should have 1 iNEPs", 1, nepsI.size());
487 OwnedNodeEdgePoint nep3 = nepsE.get(0);
488 Uuid enepUuid2 = new Uuid(
489 UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
491 checkNepOtsiNode(nep3, enepUuid2, "XPDR1-NETWORK1", "eNodeEdgePoint");
492 OwnedNodeEdgePoint nep4 = nepsI.get(0);
493 Uuid inepUuid2 = new Uuid(
494 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
496 checkNepOtsiNode(nep4, inepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint");
497 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
498 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
499 .collect(Collectors.toList());
500 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
503 assertEquals("Tpdr-OTSi node should have 2 eNEPs", 2, nepsE.size());
504 assertEquals("Tpdr-OTSi node should have 2 iNEPs", 2, nepsI.size());
505 OwnedNodeEdgePoint nep5 = nepsE.get(0);
506 Uuid enepUuid3 = new Uuid(
507 UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
509 checkNepOtsiNode(nep5, enepUuid3, "XPDR1-NETWORK1", "eNodeEdgePoint");
510 OwnedNodeEdgePoint nep6 = nepsI.get(0);
511 Uuid inepUuid3 = new Uuid(
512 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
514 checkNepOtsiNode(nep6, inepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint");
515 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
516 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
517 .collect(Collectors.toList());
518 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
521 Iterator<OwnedNodeEdgePoint> nepIterator = node.nonnullOwnedNodeEdgePoint().values().iterator();
523 while (nepIterator.hasNext()) {
524 OwnedNodeEdgePoint nep = nepIterator.next();
525 Uuid nepUuid = new Uuid(
526 UUID.nameUUIDFromBytes((String.join("+", "roadm node", "nep", String.valueOf(count)))
527 .getBytes(Charset.forName("UTF-8"))).toString());
528 checkNepOtsiRdmNode(nep, nepUuid, new StringBuilder("NodeEdgePoint_").append(count).toString(),
529 "NodeEdgePoint name");
532 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
533 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
534 .collect(Collectors.toList());
535 checkNodeRuleGroupForRdmInfra(nrgList4, count - 1);
540 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
541 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
542 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
543 Name name = nameList.get(0);
544 assertEquals("value of client nep should be '" + portName + "'",
545 portName, name.getValue());
546 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
547 nepName, name.getValueName());
548 assertEquals("Client nep should support 3 kind of cep",
549 3, nep.getSupportedCepLayerProtocolQualifier().size());
550 assertThat("client nep should support 3 kind of cep",
551 nep.getSupportedCepLayerProtocolQualifier(),
552 hasItems(ODUTYPEODU2.class, ODUTYPEODU2E.class, DIGITALSIGNALTYPE10GigELAN.class));
553 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
554 checkCommonPartOfNep(nep, false);
557 private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
558 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
559 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
560 Name name = nameList.get(0);
561 assertEquals("value of network nep should be '" + portName + "'",
562 portName, name.getValue());
563 assertEquals("value-name of network nep for '" + portName + "' should be '" + nepName + "'",
564 nepName, name.getValueName());
565 assertEquals("Network nep should support 1 kind of cep",
566 1, nep.getSupportedCepLayerProtocolQualifier().size());
567 assertThat("network nep should support 1 kind of cep",
568 nep.getSupportedCepLayerProtocolQualifier(),
569 hasItem(ODUTYPEODU4.class));
570 assertEquals("network nep should be of ODU protocol type", LayerProtocolName.ODU, nep.getLayerProtocolName());
571 checkCommonPartOfNep(nep, false);
574 private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
576 assertEquals("transponder DSR should contain 2 node rule group", 2, nrgList.size());
577 for (NodeRuleGroup nodeRuleGroup : nrgList) {
578 assertEquals("each node-rule-group should contain 2 NEP for transponder DSR",
579 2, nodeRuleGroup.getNodeEdgePoint().size());
581 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
582 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
583 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
584 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
585 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
586 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
587 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
588 assertEquals("node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node",
589 nodeEdgePointList.get(0).getNodeUuid(), nodeUuid);
590 assertEquals("node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node",
591 nodeEdgePointList.get(1).getNodeUuid(), nodeUuid);
592 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
593 assertEquals("node-rule-group nb 1 should contain a single rule", 1, rule.size());
594 assertEquals("local-id of the rule should be 'forward'",
595 "forward", rule.get(0).getLocalId());
596 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
597 ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule());
598 assertEquals("the rule type should be 'FORWARDING'",
599 RuleType.FORWARDING, rule.get(0).getRuleType());
602 private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
604 assertEquals("muxponder DSR should contain 4 node rule group", 4, nrgList.size());
605 for (NodeRuleGroup nodeRuleGroup : nrgList) {
606 assertEquals("each node-rule-group should contain 2 NEP for muxponder DSR",
607 2, nodeRuleGroup.getNodeEdgePoint().size());
609 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
610 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
611 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
612 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
613 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
614 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
615 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
616 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
617 nodeEdgePointList.get(0).getNodeUuid(), nodeUuid);
618 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
619 nodeEdgePointList.get(1).getNodeUuid(), nodeUuid);
620 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
621 assertEquals("node-rule-group nb 2 should contain a single rule", 1, rule.size());
622 assertEquals("local-id of the rule should be 'forward'",
623 "forward", rule.get(0).getLocalId());
624 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
625 ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule());
626 assertEquals("the rule type should be 'FORWARDING'",
627 RuleType.FORWARDING, rule.get(0).getRuleType());
630 private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
632 assertEquals("Switch-DSR should contain a single node rule group", 1, nrgList.size());
633 assertEquals("Switch-DSR node-rule-group should contain 8 NEP", 8, nrgList.get(0).getNodeEdgePoint().size());
634 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
635 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
636 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
637 .collect(Collectors.toList());
638 assertEquals("in the sorted node-rule-group, nep number 2 should be XPDR2-NETWORK1",
639 networkNepUuid, nrg.get(4).getNodeEdgePointUuid());
640 assertEquals("in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4",
641 clientNepUuid, nrg.get(3).getNodeEdgePointUuid());
642 assertEquals("any item of the node-rule-group should have the same nodeUuid",
643 nodeUuid, nrg.get(4).getNodeUuid());
644 assertEquals("any item of the node-rule-group should have the same nodeUuid",
645 nodeUuid, nrg.get(3).getNodeUuid());
647 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
648 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
649 assertEquals("local-id of the rule should be 'forward'",
650 "forward", ruleList.get(0).getLocalId());
651 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
652 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
653 assertEquals("the rule type should be 'FORWARDING'",
654 RuleType.FORWARDING, ruleList.get(0).getRuleType());
657 private void checkNodeRuleGroupForRdmInfra(List<NodeRuleGroup> nrgList, int nbNeps) {
658 assertEquals("RDM infra node - OTSi should contain a single node rule groups", 1, nrgList.size());
660 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
661 assertEquals("RDM infra node -rule-group should contain " + nbNeps + " NEP",
662 nbNeps, nodeEdgePointList.size());
664 assertNull("RDM infra node -rule-group should contain no NEP", nrgList.get(0).getNodeEdgePoint());
666 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
667 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
668 assertEquals("local-id of the rule should be 'forward'",
669 "forward", ruleList.get(0).getLocalId());
670 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
671 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
672 assertEquals("the rule type should be 'FORWARDING'",
673 RuleType.FORWARDING, ruleList.get(0).getRuleType());
676 private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
678 assertEquals("Tpdr-OTSi should contain two node rule groups", 2, nrgList.size());
679 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
680 assertEquals("Tpdr-OTSi node-rule-group should contain 2 NEP", 2, nodeEdgePointList.size());
681 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
682 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
683 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
684 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
685 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
686 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
687 assertEquals("any item of the node-rule-group should have the same nodeUuid",
688 nodeUuid, nodeEdgePointList.get(0).getNodeUuid());
689 assertEquals("any item of the node-rule-group should have the same nodeUuid",
690 nodeUuid, nodeEdgePointList.get(1).getNodeUuid());
691 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
692 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
693 assertEquals("local-id of the rule should be 'forward'",
694 "forward", ruleList.get(0).getLocalId());
695 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
696 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
697 assertEquals("the rule type should be 'FORWARDING'",
698 RuleType.FORWARDING, ruleList.get(0).getRuleType());
701 private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
703 assertEquals("Mux-OTSi should contain a single node rule group", 1, nrgList.size());
704 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
705 assertEquals("Mux-OTSi node-rule-group should contain 2 NEP", 2, nodeEdgePointList.size());
706 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
707 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
708 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
709 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
710 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
711 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
712 assertEquals("any item of the node-rule-group should have the same nodeUuid",
713 nodeUuid, nodeEdgePointList.get(0).getNodeUuid());
714 assertEquals("any item of the node-rule-group should have the same nodeUuid",
715 nodeUuid, nodeEdgePointList.get(1).getNodeUuid());
716 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
717 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
718 assertEquals("local-id of the rule should be 'forward'",
719 "forward", ruleList.get(0).getLocalId());
720 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
721 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
722 assertEquals("the rule type should be 'FORWARDING'",
723 RuleType.FORWARDING, ruleList.get(0).getRuleType());
726 private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
728 assertEquals("Switch-OTSi should contain 4 node rule group", 4, nrgList.size());
729 for (NodeRuleGroup nodeRuleGroup : nrgList) {
730 assertEquals("each node-rule-group should contain 2 NEP for Switch-OTSi",
731 2, nodeRuleGroup.getNodeEdgePoint().size());
733 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
734 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
735 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
736 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
737 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
738 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
739 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
740 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
741 assertEquals("any item of the node-rule-group should have the same nodeUuid",
742 nodeUuid, nodeEdgePointList0.get(0).getNodeUuid());
743 assertEquals("any item of the node-rule-group should have the same nodeUuid",
744 nodeUuid, nodeEdgePointList0.get(1).getNodeUuid());
745 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
746 assertEquals("node-rule-group should contain a single rule", 1, ruleList0.size());
747 assertEquals("local-id of the rule should be 'forward'",
748 "forward", ruleList0.get(0).getLocalId());
749 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
750 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList0.get(0).getForwardingRule());
751 assertEquals("the rule type should be 'FORWARDING'",
752 RuleType.FORWARDING, ruleList0.get(0).getRuleType());
755 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
756 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
757 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
758 assertEquals("value of client nep should be '" + portName + "'",
759 portName, nameList.get(0).getValue());
760 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
761 nepName, nameList.get(0).getValueName());
762 assertEquals("Client nep should support 2 kind of cep",
763 2, nep.getSupportedCepLayerProtocolQualifier().size());
764 assertThat("client nep should support 2 kind of cep",
765 nep.getSupportedCepLayerProtocolQualifier(),
766 hasItems(ODUTYPEODU4.class, DIGITALSIGNALTYPE100GigE.class));
767 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
768 checkCommonPartOfNep(nep, false);
771 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
772 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
773 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
774 assertEquals("value of client nep should be '" + portName + "'",
775 portName, nameList.get(0).getValue());
776 assertEquals("value-name of client nep for '" + portName + "' should be 100G-tpdr'",
777 nepName, nameList.get(0).getValueName());
778 assertEquals("Client nep should support 1 kind of cep",
779 1, nep.getSupportedCepLayerProtocolQualifier().size());
780 assertThat("client nep should support 2 kind of cep",
781 nep.getSupportedCepLayerProtocolQualifier(),
782 hasItems(DIGITALSIGNALTYPE100GigE.class));
783 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
784 checkCommonPartOfNep(nep, false);
787 private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
788 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
789 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
790 assertEquals("value of OTSi nep should be '" + portName + "'",
791 portName, nameList.get(0).getValue());
792 assertEquals("value-name of OTSi nep should be '" + nepName + "'",
793 nepName, nameList.get(0).getValueName());
794 assertEquals("OTSi nep should support 2 kind of cep",
795 2, nep.getSupportedCepLayerProtocolQualifier().size());
796 assertThat("OTSi nep should support 2 kind of cep",
797 nep.getSupportedCepLayerProtocolQualifier(),
798 hasItems(PHOTONICLAYERQUALIFIEROMS.class, PHOTONICLAYERQUALIFIEROTSi.class));
799 assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
800 LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
801 assertEquals("OTSi nep should support one SIP", 1, nep.getMappedServiceInterfacePoint().size());
802 checkCommonPartOfNep(nep, false);
805 private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
806 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
807 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
808 assertEquals("value of OTSi nep should be '" + portName + "'",
809 portName, nameList.get(0).getValue());
810 assertEquals("value-name of OTSi nep should be '" + nepName + "'",
811 nepName, nameList.get(0).getValueName());
812 assertEquals("OTSi nep of RDM infra node should support only 1 kind of cep",
813 1, nep.getSupportedCepLayerProtocolQualifier().size());
814 assertThat("OTSi nep should support 2 kind of cep",
815 nep.getSupportedCepLayerProtocolQualifier(),
816 hasItems(PHOTONICLAYERQUALIFIEROMS.class));
817 assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
818 LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
819 assertEquals("OTSi nep of RDM infra should support no SIP", 0, nep.nonnullMappedServiceInterfacePoint().size());
820 checkCommonPartOfNep(nep, true);
823 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean isRdm) {
824 assertEquals("link port direction should be DIRECTIONAL",
825 PortDirection.BIDIRECTIONAL, nep.getLinkPortDirection());
826 assertEquals("administrative state should be UNLOCKED",
827 AdministrativeState.UNLOCKED, nep.getAdministrativeState());
828 assertEquals("termination state should be TERMINATED BIDIRECTIONAL",
829 TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState());
830 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, nep.getLifecycleState());
832 assertEquals("client nep should support 1 SIP", 1, nep.getMappedServiceInterfacePoint().size());
834 assertEquals("termination direction should be BIDIRECTIONAL",
835 TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection());
836 assertEquals("operational state of client nep should be ENABLED",
837 OperationalState.ENABLED, nep.getOperationalState());
838 assertEquals("link-port-role of client nep should be SYMMETRIC",
839 PortRole.SYMMETRIC, nep.getLinkPortRole());
842 private void checkTransitionalLink(Link link, Uuid node1Uuid, Uuid node2Uuid, String tp1, String tp2,
844 Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((ietfNodeId + "--" + tp1 + "--" + tp2)
845 .getBytes(Charset.forName("UTF-8"))).toString());
846 assertEquals("bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2, linkUuid, link.getUuid());
847 assertEquals("Available capacity unit should be GBPS",
848 CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit());
849 assertEquals("Available capacity -total size value should be 100",
850 Uint64.valueOf(100), link.getAvailableCapacity().getTotalSize().getValue());
851 assertEquals("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
852 2, link.getTransitionedLayerProtocolName().size());
853 assertThat("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
854 link.getTransitionedLayerProtocolName(),
855 hasItems(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()));
856 assertEquals("transitional link should be BIDIRECTIONAL",
857 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
858 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
859 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
860 assertEquals("topology uuid should be the same for the two termination point of the link",
861 topologyUuid, nodeEdgePointList.get(0).getTopologyUuid());
862 assertEquals("topology uuid should be the same for the two termination point of the link",
863 topologyUuid, nodeEdgePointList.get(1).getTopologyUuid());
864 assertThat("transitional links should terminate on DSR node and Photonic node",
865 nodeEdgePointList.get(0).getNodeUuid().getValue(),
866 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
867 assertThat("transitional links should terminate on DSR node and Photonic node",
868 nodeEdgePointList.get(1).getNodeUuid().getValue(),
869 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
870 Uuid nep1Uuid = new Uuid(UUID.nameUUIDFromBytes(tp1.getBytes(Charset.forName("UTF-8"))).toString());
871 Uuid nep2Uuid = new Uuid(UUID.nameUUIDFromBytes(tp2.getBytes(Charset.forName("UTF-8"))).toString());
872 assertThat("transitional links should terminate on " + tp1 + " and " + tp2 + " neps",
873 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
874 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
875 assertThat("transitional links should terminate on DSR node and Photonic node",
876 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
877 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
880 private void checkOtnLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
882 assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("otn link name")).getValue());
883 assertEquals("bad uuid for link", linkUuid, link.getUuid());
884 assertEquals("Available capacity unit should be MBPS",
885 CapacityUnit.MBPS, link.getAvailableCapacity().getTotalSize().getUnit());
886 String prefix = linkName.split("-")[0];
887 if ("OTU4".equals(prefix)) {
888 assertEquals("Available capacity -total size value should be 0",
889 Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue());
890 } else if ("ODU4".equals(prefix)) {
891 assertEquals("Available capacity -total size value should be 100 000",
892 Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue());
894 assertEquals("Total capacity unit should be GBPS",
895 CapacityUnit.GBPS, link.getTotalPotentialCapacity().getTotalSize().getUnit());
896 assertEquals("Total capacity -total size value should be 100",
897 Uint64.valueOf(100), link.getTotalPotentialCapacity().getTotalSize().getValue());
898 if ("OTU4".equals(prefix)) {
899 assertEquals("otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
900 LayerProtocolName.PHOTONICMEDIA.getName(), link.getLayerProtocolName().get(0).getName());
901 } else if ("ODU4".equals(prefix)) {
902 assertEquals("otn link should be between 2 nodes of protocol layers ODU",
903 LayerProtocolName.ODU.getName(), link.getLayerProtocolName().get(0).getName());
905 assertEquals("otn tapi link should be BIDIRECTIONAL",
906 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
907 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
908 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
909 assertEquals("topology uuid should be the same for the two termination point of the link",
910 topologyUuid, nodeEdgePointList.get(0).getTopologyUuid());
911 assertEquals("topology uuid should be the same for the two termination point of the link",
912 topologyUuid, nodeEdgePointList.get(1).getTopologyUuid());
913 assertThat("otn links should terminate on two distinct nodes",
914 nodeEdgePointList.get(0).getNodeUuid().getValue(),
915 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
916 assertThat("otn links should terminate on two distinct nodes",
917 nodeEdgePointList.get(1).getNodeUuid().getValue(),
918 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
919 assertThat("otn links should terminate on two distinct tps",
920 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
921 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
922 assertThat("otn links should terminate on two distinct tps",
923 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
924 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
925 assertEquals("operational state should be ENABLED",
926 OperationalState.ENABLED, link.getOperationalState());
927 assertEquals("administrative state should be UNLOCKED",
928 AdministrativeState.UNLOCKED, link.getAdministrativeState());
931 private void checkOmsLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
933 assertEquals("bad name for the link", linkName, link.getName().get(new NameKey("OMS link name")).getValue());
934 assertEquals("bad uuid for link", linkUuid, link.getUuid());
935 assertEquals("oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA",
936 LayerProtocolName.PHOTONICMEDIA.getName(), link.getLayerProtocolName().get(0).getName());
937 assertEquals("otn tapi link should be BIDIRECTIONAL",
938 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
939 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
940 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
941 assertEquals("oms link should be between 2 neps",2 , nodeEdgePointList.size());
942 assertEquals("topology uuid should be the same for the two termination point of the link",
943 topologyUuid, nodeEdgePointList.get(0).getTopologyUuid());
944 assertEquals("topology uuid should be the same for the two termination point of the link",
945 topologyUuid, nodeEdgePointList.get(1).getTopologyUuid());
946 assertThat("oms links should terminate on two distinct nodes",
947 nodeEdgePointList.get(0).getNodeUuid().getValue(),
948 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
949 assertThat("oms links should terminate on two distinct nodes",
950 nodeEdgePointList.get(1).getNodeUuid().getValue(),
951 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
952 assertThat("oms links should terminate on two distinct tps",
953 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
954 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
955 assertThat("oms links should terminate on two distinct tps",
956 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
957 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));