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.List;
23 import java.util.UUID;
24 import java.util.concurrent.CountDownLatch;
25 import java.util.concurrent.ExecutionException;
26 import java.util.concurrent.Executors;
27 import java.util.stream.Collectors;
28 import org.eclipse.jdt.annotation.Nullable;
29 import org.junit.BeforeClass;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.opendaylight.transportpce.common.InstanceIdentifiers;
33 import org.opendaylight.transportpce.common.NetworkUtils;
34 import org.opendaylight.transportpce.tapi.utils.TopologyDataUtils;
35 import org.opendaylight.transportpce.test.AbstractTest;
36 import org.opendaylight.transportpce.test.DataStoreContext;
37 import org.opendaylight.transportpce.test.DataStoreContextImpl;
38 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
39 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
42 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
43 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
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.topology.Link;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
65 import org.opendaylight.yangtools.yang.common.RpcResult;
66 import org.opendaylight.yangtools.yang.common.Uint64;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
71 public class TapiTopologyImplTest extends AbstractTest {
72 private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
74 private static ListeningExecutorService executorService;
75 private static CountDownLatch endSignal;
76 private static final int NUM_THREADS = 3;
77 private static DataStoreContext dataStoreContextUtil;
80 public static void setUp() throws InterruptedException {
81 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
82 endSignal = new CountDownLatch(1);
83 dataStoreContextUtil = new DataStoreContextImpl();
84 TopologyDataUtils.writeTopologyFromFileToDatastore(dataStoreContextUtil,
85 TopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
86 TopologyDataUtils.writeTopologyFromFileToDatastore(dataStoreContextUtil,
87 TopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
88 TopologyDataUtils.writePortmappingFromFileToDatastore(dataStoreContextUtil);
89 LOG.info("setup done");
93 public void getTopologyDetailsForOpenroadmTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
94 GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(NetworkUtils.OVERLAY_NETWORK_ID);
95 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(dataStoreContextUtil.getDataBroker());
96 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
97 result.addListener(new Runnable() {
100 endSignal.countDown();
104 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
106 Topology topology = rpcResult.getResult().getTopology();
107 assertNotNull("Topology should not be null", topology);
108 assertEquals("Nodes list size should be 1", 1, topology.getNode().size());
109 assertEquals("Node name should be TAPI Ethernet Node",
110 "TAPI Ethernet Node", topology.getNode().get(0).getName().get(0).getValue());
111 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("Ethernet Topology".getBytes()).toString());
112 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes("TAPI Ethernet Node".getBytes()).toString());
113 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
114 assertEquals("incorrect node uuid", nodeUuid, topology.getNode().get(0).getUuid());
115 Uuid onep1Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 0".getBytes()).toString());
116 Uuid onep2Uuid = new Uuid(UUID.nameUUIDFromBytes("OwnedNodeEdgePoint 1".getBytes()).toString());
117 assertEquals("incorrect uuid for nep1",
118 onep1Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(1).getUuid());
119 assertEquals("incorrect uuid for nep1",
120 onep2Uuid, topology.getNode().get(0).getOwnedNodeEdgePoint().get(0).getUuid());
124 public void getTopologyDetailsForOtnTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
125 GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(NetworkUtils.OTN_NETWORK_ID);
126 TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(dataStoreContextUtil.getDataBroker());
127 ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
128 result.addListener(new Runnable() {
131 endSignal.countDown();
135 RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
137 Topology topology = rpcResult.getResult().getTopology();
138 assertNotNull("Topology should not be null", topology);
139 assertEquals("Node list size should be 4", 4, topology.getNode().size());
140 assertEquals("Link list size should be 5", 5, topology.getLink().size());
141 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes("T0 - Multi-layer topology".getBytes()).toString());
142 assertEquals("incorrect topology uuid", topoUuid, topology.getUuid());
143 assertEquals("topology name should be T0 - Multi-layer topology",
144 "T0 - Multi-layer topology",
145 topology.getName().get(0).getValue());
147 List<Node> nodes = topology.getNode().values().stream()
148 .sorted((n1,n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
149 .collect(Collectors.toList());
150 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
152 checkDsrNode(nodes.get(0), node1Uuid, false);
153 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8")))
155 checkDsrNode(nodes.get(1), node2Uuid, true);
156 Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
158 checkOtsiNode(nodes.get(2), node3Uuid, false);
159 Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8")))
161 checkOtsiNode(nodes.get(3), node4Uuid, true);
163 List<Link> links = topology.getLink().values().stream()
164 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
165 .collect(Collectors.toList());
166 checkTransitionalLink(links.get(0), topoUuid, node1Uuid, node3Uuid, "DSR+XPDR1-NETWORK1",
167 "iOTSi+XPDR1-NETWORK1");
168 checkTransitionalLink(links.get(1), topoUuid, node2Uuid, node4Uuid, "DSR+XPDR2-NETWORK1",
169 "iOTSi+XPDR2-NETWORK1");
172 private void checkDsrNode(Node node, Uuid nodeUuid, boolean isSwitch) {
173 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
174 assertEquals("administrative state should be UNLOCKED",
175 AdministrativeState.UNLOCKED, node.getAdministrativeState());
176 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
177 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
178 assertEquals("value-name should be 'dsr/odu node name'",
179 "dsr/odu node name", node.getName().get(0).getValueName());
180 assertEquals("dsr node should manage 2 protocol layers : dsr and odu",
181 2, node.getLayerProtocolName().size());
182 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
183 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
184 List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().values().stream()
185 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
186 .collect(Collectors.toList());
188 assertEquals("Switch-DSR node should have 8 NEPs", 8, neps.size());
189 OwnedNodeEdgePoint nep1 = neps.get(5);
190 Uuid client4NepUuid = new Uuid(
191 UUID.nameUUIDFromBytes("DSR+XPDR2-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString());
192 checkNepClient100G(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C4");
193 OwnedNodeEdgePoint nep2 = neps.get(1);
194 Uuid networkNepUuid = new Uuid(
195 UUID.nameUUIDFromBytes("DSR+XPDR2-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
196 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "NodeEdgePoint_N1");
197 List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
198 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
199 .collect(Collectors.toList());
200 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
202 assertEquals("Mux-DSR node should have 5 NEPs", 5, neps.size());
203 OwnedNodeEdgePoint nep1 = neps.get(0);
204 Uuid client4NepUuid = new Uuid(
205 UUID.nameUUIDFromBytes("DSR+XPDR1-CLIENT4".getBytes(Charset.forName("UTF-8"))).toString());
206 checkNepClient10G(nep1, client4NepUuid, "XPDR1-CLIENT4", "NodeEdgePoint_C4");
208 OwnedNodeEdgePoint nep2 = neps.get(1);
209 Uuid networkNepUuid = new Uuid(
210 UUID.nameUUIDFromBytes("DSR+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
211 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR1-NETWORK1", "NodeEdgePoint_N1");
212 List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
213 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
214 .collect(Collectors.toList());
215 checkNodeRuleGroupForMuxDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
219 private void checkOtsiNode(Node node, Uuid nodeUuid, boolean isSwitch) {
220 assertEquals("incorrect node uuid", nodeUuid, node.getUuid());
221 assertEquals("administrative state should be UNLOCKED",
222 AdministrativeState.UNLOCKED, node.getAdministrativeState());
223 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, node.getLifecycleState());
224 assertEquals("operational state should be ENABLED", OperationalState.ENABLED, node.getOperationalState());
225 assertEquals("value-name should be 'dsr/odu node name'",
226 "otsi node name", node.getName().get(0).getValueName());
227 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
228 1, node.getLayerProtocolName().size());
229 assertEquals("otsi node should manage a single protocol layer : PHOTONIC_MEDIA",
230 LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().get(0));
231 List<OwnedNodeEdgePoint> neps = node.getOwnedNodeEdgePoint().values().stream()
232 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
233 .collect(Collectors.toList());
235 assertEquals("Switch-OTSi node should have 8 NEPs", 8, neps.size());
236 OwnedNodeEdgePoint nep1 = neps.get(0);
237 Uuid inepUuid = new Uuid(
238 UUID.nameUUIDFromBytes("iOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString());
239 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint_2");
240 OwnedNodeEdgePoint nep2 = neps.get(5);
241 Uuid enepUuid = new Uuid(
242 UUID.nameUUIDFromBytes("eOTSi+XPDR2-NETWORK2".getBytes(Charset.forName("UTF-8"))).toString());
243 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint_2");
244 List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
245 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
246 .collect(Collectors.toList());
247 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
249 assertEquals("Mux-OTSi node should have 2 NEPs", 2, neps.size());
250 OwnedNodeEdgePoint nep1 = neps.get(0);
251 Uuid enepUuid = new Uuid(
252 UUID.nameUUIDFromBytes("eOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
253 checkNepOtsiNode(nep1, enepUuid, "XPDR1-NETWORK1", "eNodeEdgePoint_1");
254 OwnedNodeEdgePoint nep2 = neps.get(1);
255 Uuid inepUuid = new Uuid(
256 UUID.nameUUIDFromBytes("iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
257 checkNepOtsiNode(nep2, inepUuid, "XPDR1-NETWORK1", "iNodeEdgePoint_1");
258 List<NodeRuleGroup> nrgList = node.getNodeRuleGroup().values().stream()
259 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
260 .collect(Collectors.toList());
261 checkNodeRuleGroupForMuxOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
265 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
266 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
267 assertEquals("value of client nep should be '" + portName + "'",
268 portName, nep.getName().get(0).getValue());
269 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
270 nepName, nep.getName().get(0).getValueName());
271 assertEquals("Client nep should support 2 kind of cep",
272 2, nep.getSupportedCepLayerProtocolQualifier().size());
273 assertThat("client nep should support 2 kind of cep",
274 nep.getSupportedCepLayerProtocolQualifier(),
275 hasItems(ODUTYPEODU2E.class, DIGITALSIGNALTYPE10GigELAN.class));
276 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
277 checkCommonPartOfNep(nep);
280 private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
281 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
282 assertEquals("value of network nep should be '" + portName + "'",
283 portName, nep.getName().get(0).getValue());
284 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
285 nepName, nep.getName().get(0).getValueName());
286 assertEquals("Network nep should support 1 kind of cep",
287 1, nep.getSupportedCepLayerProtocolQualifier().size());
288 assertThat("network nep should support 1 kind of cep",
289 nep.getSupportedCepLayerProtocolQualifier(),
290 hasItem(ODUTYPEODU4.class));
291 assertEquals("network nep should be of ODU protocol type", LayerProtocolName.ODU, nep.getLayerProtocolName());
292 checkCommonPartOfNep(nep);
295 private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
297 assertEquals("muxponder DSR should contain 4 node rule group", 4, nrgList.size());
298 for (NodeRuleGroup nodeRuleGroup : nrgList) {
299 assertEquals("each node-rule-group should contain 2 NEP for muxponder DSR",
300 2, nodeRuleGroup.getNodeEdgePoint().size());
302 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
303 nrgList.get(1).getNodeEdgePoint().get(0).getNodeEdgePointUuid().getValue(),
304 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
305 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
306 nrgList.get(1).getNodeEdgePoint().get(1).getNodeEdgePointUuid().getValue(),
307 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
308 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
309 nrgList.get(1).getNodeEdgePoint().get(0).getNodeUuid(), nodeUuid);
310 assertEquals("node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node",
311 nrgList.get(1).getNodeEdgePoint().get(1).getNodeUuid(), nodeUuid);
312 assertEquals("node-rule-group nb 2 should contain a single rule", 1, nrgList.get(1).getRule().size());
313 assertEquals("local-id of the rule should be 'forward'",
314 "forward", nrgList.get(1).getRule().get(0).getLocalId());
315 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
316 ForwardingRule.MAYFORWARDACROSSGROUP, nrgList.get(1).getRule().get(0).getForwardingRule());
317 assertEquals("the rule type should be 'FORWARDING'",
318 RuleType.FORWARDING, nrgList.get(1).getRule().get(0).getRuleType());
321 private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
323 assertEquals("Switch-DSR should contain a single node rule group", 1, nrgList.size());
324 assertEquals("Switch-DSR node-rule-group should contain 8 NEP", 8, nrgList.get(0).getNodeEdgePoint().size());
325 List<NodeEdgePoint> nrg = nrgList.get(0).getNodeEdgePoint().values().stream()
326 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
327 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
328 .collect(Collectors.toList());
329 assertEquals("in the sorted node-rule-group, nep number 2 should be XPDR2-NETWORK1",
330 networkNepUuid, nrg.get(1).getNodeEdgePointUuid());
331 assertEquals("in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4",
332 clientNepUuid, nrg.get(5).getNodeEdgePointUuid());
333 assertEquals("any item of the node-rule-group should have the same nodeUuid",
334 nodeUuid, nrg.get(1).getNodeUuid());
335 assertEquals("any item of the node-rule-group should have the same nodeUuid",
336 nodeUuid, nrg.get(5).getNodeUuid());
337 assertEquals("node-rule-group should contain a single rule", 1, nrgList.get(0).getRule().size());
338 assertEquals("local-id of the rule should be 'forward'",
339 "forward", nrgList.get(0).getRule().get(0).getLocalId());
340 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
341 ForwardingRule.MAYFORWARDACROSSGROUP, nrgList.get(0).getRule().get(0).getForwardingRule());
342 assertEquals("the rule type should be 'FORWARDING'",
343 RuleType.FORWARDING, nrgList.get(0).getRule().get(0).getRuleType());
346 private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
348 assertEquals("Mux-OTSi should contain a single node rule group", 1, nrgList.size());
349 assertEquals("Mux-OTSi node-rule-group should contain 2 NEP", 2, nrgList.get(0).getNodeEdgePoint().size());
350 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
351 nrgList.get(0).getNodeEdgePoint().get(0).getNodeEdgePointUuid().getValue(),
352 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
353 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
354 nrgList.get(0).getNodeEdgePoint().get(1).getNodeEdgePointUuid().getValue(),
355 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
356 assertEquals("any item of the node-rule-group should have the same nodeUuid",
357 nodeUuid, nrgList.get(0).getNodeEdgePoint().get(0).getNodeUuid());
358 assertEquals("any item of the node-rule-group should have the same nodeUuid",
359 nodeUuid, nrgList.get(0).getNodeEdgePoint().get(1).getNodeUuid());
360 assertEquals("node-rule-group should contain a single rule", 1, nrgList.get(0).getRule().size());
361 assertEquals("local-id of the rule should be 'forward'",
362 "forward", nrgList.get(0).getRule().get(0).getLocalId());
363 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
364 ForwardingRule.MAYFORWARDACROSSGROUP, nrgList.get(0).getRule().get(0).getForwardingRule());
365 assertEquals("the rule type should be 'FORWARDING'",
366 RuleType.FORWARDING, nrgList.get(0).getRule().get(0).getRuleType());
369 private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
371 assertEquals("Switch-OTSi should contain 4 node rule group", 4, nrgList.size());
372 for (NodeRuleGroup nodeRuleGroup : nrgList) {
373 assertEquals("each node-rule-group should contain 2 NEP for Switch-OTSi",
374 2, nodeRuleGroup.getNodeEdgePoint().size());
376 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
377 nrgList.get(1).getNodeEdgePoint().get(0).getNodeEdgePointUuid().getValue(),
378 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
379 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
380 nrgList.get(1).getNodeEdgePoint().get(1).getNodeEdgePointUuid().getValue(),
381 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
382 assertEquals("any item of the node-rule-group should have the same nodeUuid",
383 nodeUuid, nrgList.get(0).getNodeEdgePoint().get(0).getNodeUuid());
384 assertEquals("any item of the node-rule-group should have the same nodeUuid",
385 nodeUuid, nrgList.get(0).getNodeEdgePoint().get(1).getNodeUuid());
386 assertEquals("node-rule-group should contain a single rule", 1, nrgList.get(0).getRule().size());
387 assertEquals("local-id of the rule should be 'forward'",
388 "forward", nrgList.get(0).getRule().get(0).getLocalId());
389 assertEquals("the forwarding rule should be 'MAYFORWARDACROSSGROUP'",
390 ForwardingRule.MAYFORWARDACROSSGROUP, nrgList.get(0).getRule().get(0).getForwardingRule());
391 assertEquals("the rule type should be 'FORWARDING'",
392 RuleType.FORWARDING, nrgList.get(0).getRule().get(0).getRuleType());
395 private void checkNepClient100G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
396 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
397 assertEquals("value of client nep should be '" + portName + "'",
398 portName, nep.getName().get(0).getValue());
399 assertEquals("value-name of client nep for '" + portName + "' should be '" + nepName + "'",
400 nepName, nep.getName().get(0).getValueName());
401 assertEquals("Client nep should support 2 kind of cep",
402 2, nep.getSupportedCepLayerProtocolQualifier().size());
403 assertThat("client nep should support 2 kind of cep",
404 nep.getSupportedCepLayerProtocolQualifier(),
405 hasItems(ODUTYPEODU4.class, DIGITALSIGNALTYPE100GigE.class));
406 assertEquals("client nep should be of ETH protocol type", LayerProtocolName.ETH, nep.getLayerProtocolName());
407 checkCommonPartOfNep(nep);
410 private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
411 assertEquals("bad uuid for " + portName, nepUuid, nep.getUuid());
412 assertEquals("value of OTSi nep should be '" + portName + "'",
413 portName, nep.getName().get(0).getValue());
414 assertEquals("value-name of OTSi nep should be '" + nepName + "'",
415 nepName, nep.getName().get(0).getValueName());
416 assertEquals("OTSi nep should support 2 kind of cep",
417 2, nep.getSupportedCepLayerProtocolQualifier().size());
418 assertThat("OTSi nep should support 2 kind of cep",
419 nep.getSupportedCepLayerProtocolQualifier(),
420 hasItems(PHOTONICLAYERQUALIFIEROMS.class, PHOTONICLAYERQUALIFIEROTSi.class));
421 assertEquals("OTSi nep should be of PHOTONIC_MEDIA protocol type",
422 LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName());
423 assertEquals("OTSi nep should support one SIP", 1, nep.getMappedServiceInterfacePoint().size());
424 checkCommonPartOfNep(nep);
427 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep) {
428 assertEquals("link port direction should be DIRECTIONAL",
429 PortDirection.BIDIRECTIONAL, nep.getLinkPortDirection());
430 assertEquals("administrative state should be UNLOCKED",
431 AdministrativeState.UNLOCKED, nep.getAdministrativeState());
432 assertEquals("termination state should be TERMINATED BIDIRECTIONAL",
433 TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState());
434 assertEquals("life-cycle state should be INSTALLED", LifecycleState.INSTALLED, nep.getLifecycleState());
435 assertEquals("client nep should support 1 SIP", 1, nep.getMappedServiceInterfacePoint().size());
436 assertEquals("termination direction should be BIDIRECTIONAL",
437 TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection());
438 assertEquals("operational state of client nep should be ENABLED",
439 OperationalState.ENABLED, nep.getOperationalState());
440 assertEquals("link-port-role of client nep should be SYMMETRIC",
441 PortRole.SYMMETRIC, nep.getLinkPortRole());
444 private void checkTransitionalLink(Link link, Uuid topoUuid, Uuid node1Uuid, Uuid node2Uuid, String tp1,
446 Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((tp1 + "--" + tp2).getBytes(Charset.forName("UTF-8")))
448 assertEquals("bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2, linkUuid, link.getUuid());
449 assertEquals("Available capacity unit should be GBPS",
450 CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit());
451 assertEquals("Available capacity -total size value should be 100",
452 Uint64.valueOf(100), link.getAvailableCapacity().getTotalSize().getValue());
453 assertEquals("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
454 2, link.getTransitionedLayerProtocolName().size());
455 assertThat("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
456 link.getTransitionedLayerProtocolName(),
457 hasItems(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()));
458 assertEquals("transitional link should be BIDIRECTIONAL",
459 ForwardingDirection.BIDIRECTIONAL, link.getDirection());
460 assertEquals("topology uuid should be the same for the two termination point of the link",
461 topoUuid, link.getNodeEdgePoint().get(0).getTopologyUuid());
462 assertEquals("topology uuid should be the same for the two termination point of the link",
463 topoUuid, link.getNodeEdgePoint().get(1).getTopologyUuid());
464 assertThat("transitional links should terminate on DSR node and Photonic node",
465 link.getNodeEdgePoint().get(0).getNodeUuid().getValue(),
466 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
467 assertThat("transitional links should terminate on DSR node and Photonic node",
468 link.getNodeEdgePoint().get(1).getNodeUuid().getValue(),
469 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
470 Uuid nep1Uuid = new Uuid(UUID.nameUUIDFromBytes(tp1.getBytes(Charset.forName("UTF-8"))).toString());
471 Uuid nep2Uuid = new Uuid(UUID.nameUUIDFromBytes(tp2.getBytes(Charset.forName("UTF-8"))).toString());
472 assertThat("transitional links should terminate on " + tp1 + " and " + tp2 + " neps",
473 link.getNodeEdgePoint().get(0).getNodeEdgePointUuid().getValue(),
474 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
475 assertThat("transitional links should terminate on DSR node and Photonic node",
476 link.getNodeEdgePoint().get(1).getNodeEdgePointUuid().getValue(),
477 either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));