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.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.assertNotNull;
18 import com.google.common.util.concurrent.ListenableFuture;
19 import com.google.common.util.concurrent.ListeningExecutorService;
20 import com.google.common.util.concurrent.MoreExecutors;
21 import java.nio.charset.Charset;
22 import java.util.ArrayList;
23 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.Before;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.opendaylight.transportpce.common.InstanceIdentifiers;
34 import org.opendaylight.transportpce.common.NetworkUtils;
35 import org.opendaylight.transportpce.tapi.utils.TopologyDataUtils;
36 import org.opendaylight.transportpce.test.AbstractTest;
37 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
38 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
39 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
42 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
43 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsInput;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.GetTopologyDetailsOutput;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.get.topology.details.output.Topology;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
66 import org.opendaylight.yangtools.yang.common.RpcResult;
67 import org.opendaylight.yangtools.yang.common.Uint64;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
72 public class TapiTopologyImplTest extends AbstractTest {
73 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
75 private static ListeningExecutorService executorService;
76 private static CountDownLatch endSignal;
77 private static final int NUM_THREADS = 3;
80 public void setUp() throws InterruptedException {
81 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
82 endSignal = new CountDownLatch(1);
83 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
84 TopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
85 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
86 TopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
87 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil());
88 LOG.info("setup done");
92 public void getTopologyDetailsForOpenroadmTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
93 GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(NetworkUtils.OVERLAY_NETWORK_ID);
94 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker());
95 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
96 result.addListener(new Runnable() {
99 endSignal.countDown();
103 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
105 Topology topology = rpcResult.getResult().getTopology();
106 assertNotNull("Topology should not be null", topology);
107 assertEquals("Nodes list size should be 1", 1, topology.getNode().size());
108 List<Node> topologyNodeList = new ArrayList<>(topology.nonnullNode().values());
109 List<Node> nodeList = new ArrayList<>(topologyNodeList);
110 List<Name> nameList = new ArrayList<>(nodeList.get(0).nonnullName().values());
111 assertEquals("Node name should be TAPI Ethernet Node",
112 "TAPI Ethernet Node", nameList.get(0).getValue());
113 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("Ethernet Topology".getBytes()).toString());
114 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes("TAPI Ethernet Node".getBytes()).toString());
115 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
116 assertEquals("incorrect node uuid", nodeUuid, topologyNodeList.get(0).getUuid());
117 Uuid onep1Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 0".getBytes()).toString());
118 Uuid onep2Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 1".getBytes()).toString());
119 List<OwnedNodeEdgePoint> edgePointList = new ArrayList<>(topologyNodeList.get(0)
120 .nonnullOwnedNodeEdgePoint().values());
121 assertEquals("incorrect uuid for nep1",
122 onep1Uuid, edgePointList.get(1).getUuid());
123 assertEquals("incorrect uuid for nep1",
124 onep2Uuid, edgePointList.get(0).getUuid());
128 public void getTopologyDetailsForOtnTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
129 GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(NetworkUtils.OTN_NETWORK_ID);
130 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker());
131 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
132 result.addListener(new Runnable() {
135 endSignal.countDown();
139 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
141 Topology topology = rpcResult.getResult().getTopology();
142 assertNotNull("Topology should not be null", topology);
143 assertEquals("Node list size should be 4", 4, topology.getNode().size());
144 assertEquals("Link list size should be 5", 5, topology.getLink().size());
145 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
146 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
147 assertEquals("topology name should be T0 - Multi-layer topology",
148 "T0 - Multi-layer topology",
149 topology.nonnullName().values().stream().findFirst().get().getValue());
151 List<Node> nodes = topology.nonnullNode().values().stream()
152 .sorted((n1,n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
153 .collect(Collectors.toList());
154 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
156 checkDsrNode(nodes.get(0), node1Uuid, false);
157 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8")))
159 checkDsrNode(nodes.get(1), node2Uuid, true);
160 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
162 checkOtsiNode(nodes.get(2), node3Uuid, false);
163 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8")))
165 checkOtsiNode(nodes.get(3), node4Uuid, true);
167 List<Link> links = topology.nonnullLink().values().stream()
168 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
169 .collect(Collectors.toList());
170 checkTransitionalLink(links.get(0), topoUuid, node1Uuid, node3Uuid, "DSR+XPDR1-NETWORK1",
171 "iOTSi+XPDR1-NETWORK1");
172 checkTransitionalLink(links.get(1), topoUuid, node2Uuid, node4Uuid, "DSR+XPDR2-NETWORK1",
173 "iOTSi+XPDR2-NETWORK1");
176 private void checkDsrNode(Node node, Uuid nodeUuid, boolean isSwitch) {
177 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
178 assertEquals("administrative state should be UNLOCKED",
179 AdministrativeState.UNLOCKED, node.getAdministrativeState());
180 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
181 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
182 assertEquals("value-name should be 'dsr/odu node name'",
183 "dsr/odu node name", node.nonnullName().values().stream().findFirst().get().getValueName());
184 assertEquals("dsr node should manage 2 protocol layers : dsr and odu",
185 2, node.getLayerProtocolName().size());
186 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
187 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
188 List<OwnedNodeEdgePoint> neps = node.nonnullOwnedNodeEdgePoint().values().stream()
189 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
190 .collect(Collectors.toList());
192 assertEquals("Switch-DSR node should have 8 NEPs", 8, neps.size());
193 OwnedNodeEdgePoint nep1 = neps.get(5);
194 Uuid client4NepUuid = new Uuid(
195 UUID.nameUUIDFromBytes("DSR+XPDR2-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString());
196 checkNepClient100G(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C4");
197 OwnedNodeEdgePoint nep2 = neps.get(1);
198 Uuid networkNepUuid = new Uuid(
199 UUID.nameUUIDFromBytes("DSR+XPDR2-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
200 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "NodeEdgePoint_N1");
201 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
202 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
203 .collect(Collectors.toList());
204 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
206 assertEquals("Mux-DSR node should have 5 NEPs", 5, neps.size());
207 OwnedNodeEdgePoint nep1 = neps.get(0);
208 Uuid client4NepUuid = new Uuid(
209 UUID.nameUUIDFromBytes("DSR+XPDR1-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString());
210 checkNepClient10G(nep1, client4NepUuid, "XPDR1-CLIENT4", "NodeEdgePoint_C4");
212 OwnedNodeEdgePoint nep2 = neps.get(1);
213 Uuid networkNepUuid = new Uuid(
214 UUID.nameUUIDFromBytes("DSR+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
215 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR1-NETWORK1", "NodeEdgePoint_N1");
216 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
217 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
218 .collect(Collectors.toList());
219 checkNodeRuleGroupForMuxDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
223 private void checkOtsiNode(Node node, Uuid nodeUuid, boolean isSwitch) {
224 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
225 assertEquals("administrative state should be UNLOCKED",
226 AdministrativeState.UNLOCKED, node.getAdministrativeState());
227 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
228 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
229 assertEquals("value-name should be 'dsr/odu node name'",
230 "otsi node name", node.nonnullName().values().stream().findFirst().get().getValueName());
231 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
232 1, node.getLayerProtocolName().size());
233 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
234 LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().get(0));
235 List<OwnedNodeEdgePoint> neps = node.nonnullOwnedNodeEdgePoint().values().stream()
236 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
237 .collect(Collectors.toList());
239 assertEquals("Switch-OTSi node should have 8 NEPs", 8, neps.size());
240 OwnedNodeEdgePoint nep1 = neps.get(0);
241 Uuid inepUuid = new Uuid(
242 UUID.nameUUIDFromBytes("iOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString());
243 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint_2");
244 OwnedNodeEdgePoint nep2 = neps.get(5);
245 Uuid enepUuid = new Uuid(
246 UUID.nameUUIDFromBytes("eOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString());
247 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint_2");
248 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
249 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
250 .collect(Collectors.toList());
251 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
253 assertEquals("Mux-OTSi node should have 2 NEPs", 2, neps.size());
254 OwnedNodeEdgePoint nep1 = neps.get(0);
255 Uuid enepUuid = new Uuid(
256 UUID.nameUUIDFromBytes("eOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
257 checkNepOtsiNode(nep1, enepUuid, "XPDR1-NETWORK1", "eNodeEdgePoint_1");
258 OwnedNodeEdgePoint nep2 = neps.get(1);
259 Uuid inepUuid = new Uuid(
260 UUID.nameUUIDFromBytes("iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
261 checkNepOtsiNode(nep2, inepUuid, "XPDR1-NETWORK1", "iNodeEdgePoint_1");
262 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
263 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
264 .collect(Collectors.toList());
265 checkNodeRuleGroupForMuxOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
269 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
270 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
271 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
272 Name name = nameList.get(0);
273 assertEquals("value of client nep should be '" + portName + "'",
274 portName, name.getValue());
275 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
276 nepName, name.getValueName());
277 assertEquals("Client nep should support 2 kind of cep",
278 2, nep.getSupportedCepLayerProtocolQualifier().size());
279 assertThat("client nep should support 2 kind of cep",
280 nep.getSupportedCepLayerProtocolQualifier(),
281 hasItems(ODUTYPEODU2E.class, DIGITALSIGNALTYPE10GigELAN.class));
282 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
283 checkCommonPartOfNep(nep);
286 private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
287 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
288 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
289 Name name = nameList.get(0);
290 assertEquals("value of network nep should be '" + portName + "'",
291 portName, name.getValue());
292 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
293 nepName, name.getValueName());
294 assertEquals("Network nep should support 1 kind of cep",
295 1, nep.getSupportedCepLayerProtocolQualifier().size());
296 assertThat("network nep should support 1 kind of cep",
297 nep.getSupportedCepLayerProtocolQualifier(),
298 hasItem(ODUTYPEODU4.class));
299 assertEquals("network nep should be of ODU protocol type", LayerProtocolName.ODU, nep.getLayerProtocolName());
300 checkCommonPartOfNep(nep);
303 private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
305 assertEquals("muxponder DSR should contain 4 node rule group", 4, nrgList.size());
306 for (NodeRuleGroup nodeRuleGroup : nrgList) {
307 assertEquals("each node-rule-group should contain 2 NEP for muxponder DSR",
308 2, nodeRuleGroup.getNodeEdgePoint().size());
310 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
311 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
312 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
313 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
314 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
315 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
316 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
317 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
318 nodeEdgePointList.get(0).getNodeUuid(), nodeUuid);
319 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
320 nodeEdgePointList.get(1).getNodeUuid(), nodeUuid);
321 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
322 assertEquals("node-rule-group nb 2 should contain a single rule", 1, rule.size());
323 assertEquals("local-id of the rule should be 'forward'",
324 "forward", rule.get(0).getLocalId());
325 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
326 ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule());
327 assertEquals("the rule type should be 'FORWARDING'",
328 RuleType.FORWARDING, rule.get(0).getRuleType());
331 private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
333 assertEquals("Switch-DSR should contain a single node rule group", 1, nrgList.size());
334 assertEquals("Switch-DSR node-rule-group should contain 8 NEP", 8, nrgList.get(0).getNodeEdgePoint().size());
335 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
336 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
337 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
338 .collect(Collectors.toList());
339 assertEquals("in the sorted node-rule-group, nep number 2 should be XPDR2-NETWORK1",
340 networkNepUuid, nrg.get(1).getNodeEdgePointUuid());
341 assertEquals("in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4",
342 clientNepUuid, nrg.get(5).getNodeEdgePointUuid());
343 assertEquals("any item of the node-rule-group should have the same nodeUuid",
344 nodeUuid, nrg.get(1).getNodeUuid());
345 assertEquals("any item of the node-rule-group should have the same nodeUuid",
346 nodeUuid, nrg.get(5).getNodeUuid());
348 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
349 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
350 assertEquals("local-id of the rule should be 'forward'",
351 "forward", ruleList.get(0).getLocalId());
352 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
353 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
354 assertEquals("the rule type should be 'FORWARDING'",
355 RuleType.FORWARDING, ruleList.get(0).getRuleType());
358 private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
360 assertEquals("Mux-OTSi should contain a single node rule group", 1, nrgList.size());
361 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
362 assertEquals("Mux-OTSi node-rule-group should contain 2 NEP", 2, nodeEdgePointList.size());
363 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
364 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
365 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
366 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
367 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
368 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
369 assertEquals("any item of the node-rule-group should have the same nodeUuid",
370 nodeUuid, nodeEdgePointList.get(0).getNodeUuid());
371 assertEquals("any item of the node-rule-group should have the same nodeUuid",
372 nodeUuid, nodeEdgePointList.get(1).getNodeUuid());
373 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
374 assertEquals("node-rule-group should contain a single rule", 1, ruleList.size());
375 assertEquals("local-id of the rule should be 'forward'",
376 "forward", ruleList.get(0).getLocalId());
377 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
378 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule());
379 assertEquals("the rule type should be 'FORWARDING'",
380 RuleType.FORWARDING, ruleList.get(0).getRuleType());
383 private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
385 assertEquals("Switch-OTSi should contain 4 node rule group", 4, nrgList.size());
386 for (NodeRuleGroup nodeRuleGroup : nrgList) {
387 assertEquals("each node-rule-group should contain 2 NEP for Switch-OTSi",
388 2, nodeRuleGroup.getNodeEdgePoint().size());
390 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
391 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
392 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
393 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
394 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
395 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
396 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
397 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
398 assertEquals("any item of the node-rule-group should have the same nodeUuid",
399 nodeUuid, nodeEdgePointList0.get(0).getNodeUuid());
400 assertEquals("any item of the node-rule-group should have the same nodeUuid",
401 nodeUuid, nodeEdgePointList0.get(1).getNodeUuid());
402 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
403 assertEquals("node-rule-group should contain a single rule", 1, ruleList0.size());
404 assertEquals("local-id of the rule should be 'forward'",
405 "forward", ruleList0.get(0).getLocalId());
406 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
407 ForwardingRule.MAYFORWARDACROSSGROUP, ruleList0.get(0).getForwardingRule());
408 assertEquals("the rule type should be 'FORWARDING'",
409 RuleType.FORWARDING, ruleList0.get(0).getRuleType());
412 private void checkNepClient100G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
413 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
414 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
415 assertEquals("value of client nep should be '" + portName + "'",
416 portName, nameList.get(0).getValue());
417 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
418 nepName, nameList.get(0).getValueName());
419 assertEquals("Client nep should support 2 kind of cep",
420 2, nep.getSupportedCepLayerProtocolQualifier().size());
421 assertThat("client nep should support 2 kind of cep",
422 nep.getSupportedCepLayerProtocolQualifier(),
423 hasItems(ODUTYPEODU4.class, DIGITALSIGNALTYPE100GigE.class));
424 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
425 checkCommonPartOfNep(nep);
428 private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
429 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
430 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
431 assertEquals("value of OTSi nep should be '" + portName + "'",
432 portName, nameList.get(0).getValue());
433 assertEquals("value-name of OTSi nep should be '" + nepName + "'",
434 nepName, nameList.get(0).getValueName());
435 assertEquals("OTSi nep should support 2 kind of cep",
436 2, nep.getSupportedCepLayerProtocolQualifier().size());
437 assertThat("OTSi nep should support 2 kind of cep",
438 nep.getSupportedCepLayerProtocolQualifier(),
439 hasItems(PHOTONICLAYERQUALIFIEROMS.class, PHOTONICLAYERQUALIFIEROTSi.class));
440 assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
441 LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
442 assertEquals("OTSi nep should support one SIP", 1, nep.getMappedServiceInterfacePoint().size());
443 checkCommonPartOfNep(nep);
446 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep) {
447 assertEquals("link port direction should be DIRECTIONAL",
448 PortDirection.BIDIRECTIONAL, nep.getLinkPortDirection());
449 assertEquals("administrative state should be UNLOCKED",
450 AdministrativeState.UNLOCKED, nep.getAdministrativeState());
451 assertEquals("termination state should be TERMINATED BIDIRECTIONAL",
452 TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState());
453 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, nep.getLifecycleState());
454 assertEquals("client nep should support 1 SIP", 1, nep.getMappedServiceInterfacePoint().size());
455 assertEquals("termination direction should be BIDIRECTIONAL",
456 TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection());
457 assertEquals("operational state of client nep should be ENABLED",
458 OperationalState.ENABLED, nep.getOperationalState());
459 assertEquals("link-port-role of client nep should be SYMMETRIC",
460 PortRole.SYMMETRIC, nep.getLinkPortRole());
463 private void checkTransitionalLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, String tp1,
465 Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((tp1 + "--" + tp2).getBytes(Charset.forName("UTF-8")))
467 assertEquals("bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2, linkUuid, link.getUuid());
468 assertEquals("Available capacity unit should be GBPS",
469 CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit());
470 assertEquals("Available capacity -total size value should be 100",
471 Uint64.valueOf(100), link.getAvailableCapacity().getTotalSize().getValue());
472 assertEquals("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
473 2, link.getTransitionedLayerProtocolName().size());
474 assertThat("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
475 link.getTransitionedLayerProtocolName(),
476 hasItems(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()));
477 assertEquals("transitional link should be BIDIRECTIONAL",
478 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
479 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
480 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
481 assertEquals("topology uuid should be the same for the two termination point of the link",
482 topoUuid, nodeEdgePointList.get(0).getTopologyUuid());
483 assertEquals("topology uuid should be the same for the two termination point of the link",
484 topoUuid, nodeEdgePointList.get(1).getTopologyUuid());
485 assertThat("transitional links should terminate on DSR node and Photonic node",
486 nodeEdgePointList.get(0).getNodeUuid().getValue(),
487 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
488 assertThat("transitional links should terminate on DSR node and Photonic node",
489 nodeEdgePointList.get(1).getNodeUuid().getValue(),
490 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
491 Uuid nep1Uuid = new Uuid(UUID.nameUUIDFromBytes(tp1.getBytes(Charset.forName("UTF-8"))).toString());
492 Uuid nep2Uuid = new Uuid(UUID.nameUUIDFromBytes(tp2.getBytes(Charset.forName("UTF-8"))).toString());
493 assertThat("transitional links should terminate on " + tp1 + " and " + tp2 + " neps",
494 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
495 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
496 assertThat("transitional links should terminate on DSR node and Photonic node",
497 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
498 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));