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