import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opendaylight.mdsal.binding.api.DataBroker;
void convertNodeForRoadmWhenNoOtnMuxAttached() {
ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
-
assertEquals(1, tapiFullFactory.getTapiNodes().size(), "Node list size should be 1");
assertEquals(0, tapiFullFactory.getTapiLinks().size(), "Link list size should be empty");
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
int myInt = 0;
for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : tapiNodes) {
if (node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
- && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
+ && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
LOG.info("LOOP ROADM node found at rank {}, with Name {} and Uuid {}",
- myInt, node.getName().toString(), node.getUuid());
+ myInt, node.getName(), node.getUuid());
}
myInt++;
}
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
Uuid nodeUuid, String otsiNodeType, String nodeId) {
if (!node.getUuid().equals(nodeUuid)) {
- LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName().toString(), nodeId);
+ LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName(), nodeId);
LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid);
}
assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
"incorrect node name");
assertThat("one value-name should be 'dsr/odu node name'",
new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
+ //TODO this variable are only accessed in switch/case block -> report this in the right place
nepsOMS = node.nonnullOwnedNodeEdgePoint().values().stream()
.filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
.sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
.sorted((nrg1, nrg2) -> nrg1.getName().entrySet().iterator().next().getValue().toString()
.compareTo(nrg2.getName().entrySet().iterator().next().getValue().toString()))
.collect(Collectors.toList());
- LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4.toString());
+ LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4);
List<Integer> nepNumber = new ArrayList<>(List.of(2, 4, 4));
checkNodeRuleGroupForRdm(nrgList4, nepNumber);
break;
private void checkNodeRuleGroupForTpdrDSR(
List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
- assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
- for (NodeRuleGroup nodeRuleGroup : nrgList) {
- assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
- "each node-rule-group should contain 2 NEP for transponder DSR");
- }
- Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
- assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
- List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
- assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
- nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
- either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
- assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
- nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
- either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
- assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
- "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
- assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
- "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
- List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
- assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
- assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
- assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
- "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
- assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
- "the rule type should be 'FORWARDING'");
+ rawCheckNodeRuleGroupDSR("Transponder", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
}
private void checkNodeRuleGroupForMuxDSR(
List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
- assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
- Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
- assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
- List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
- assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
- nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
- either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
- assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
- "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
- assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
- "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
- List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
- assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
- assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
- assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
- "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
- assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
- "the rule type should be 'FORWARDING'");
+ rawCheckNodeRuleGroupDSR("Muxponder", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
}
private void checkNodeRuleGroupForSwitchDSR(
List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
- assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
+ rawCheckNodeRuleGroupDSR("Switch", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
+ }
+
+ private void rawCheckNodeRuleGroupDSR(String nodeType,
+ List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
+ int nrgListSize;
+ int nrgNb;
+ int nepClNb;
+ List<Integer> nepUuidCheckList;
+ List<Integer> nodeIdCheckList;
+ switch (nodeType) {
+ case "Switch":
+ nrgListSize = 2;
+ nrgNb = 1;
+ nepClNb = 4;
+ nepUuidCheckList = List.of(5,6);
+ nodeIdCheckList = List.of(3,4);
+ break;
+ case "Transponder":
+ nrgListSize = 4;
+ nrgNb = 1;
+ nepClNb = 1;
+ nepUuidCheckList = List.of(0,1);
+ nodeIdCheckList = List.of(0,1);
+ break;
+ case "Muxponder":
+ default:
+ nrgListSize = 8;
+ nrgNb = 2;
+ nepClNb = 4;
+ nepUuidCheckList = List.of(1);
+ nodeIdCheckList = List.of(0,1);
+ break;
+ }
+ assertEquals(nrgListSize, nrgList.size(),
+ nodeType + " DSR should contain " + nrgListSize + " node rule group (DSR-I_ODU/I-ODU-E_ODU)");
Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
- assertEquals(8, nrgList.get(indNrg).getNodeEdgePoint().size(), "Switch-DSR nrg should contain 8 NEP");
- List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
- .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
- .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
- .collect(Collectors.toList());
- Integer xxxxx = 0;
- for (NodeEdgePoint nep : nrg) {
- LOG.info("nep number {} UUID is {} ", xxxxx, nep.getNodeEdgePointUuid());
- xxxxx++;
+ List<NodeEdgePoint> nodeEdgePointList;
+ if (nodeType.equals("Switch")) {
+ assertEquals(8, nrgList.get(indNrg).getNodeEdgePoint().size(), "Switch-DSR nrg should contain 8 NEP");
+ nodeEdgePointList = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
+ .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
+ .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
+ .collect(Collectors.toList());
+ Integer xxxxx = 0;
+ for (NodeEdgePoint nep : nodeEdgePointList) {
+ LOG.info("nep number {} UUID is {} ", xxxxx, nep.getNodeEdgePointUuid());
+ xxxxx++;
+ }
+ LOG.info("nep SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK1 UUID is {} ",
+ UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))));
+ LOG.info("nep SPDR-SA1-XPDR2+DSR+XPDR2-CLIENT4 UUID is {} ",
+ UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))));
+ assertEquals(networkNepUuid, nodeEdgePointList.get(6).getNodeEdgePointUuid(),
+ "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
+ assertEquals(clientNepUuid, nodeEdgePointList.get(5).getNodeEdgePointUuid(),
+ "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
+ //TODO nep number 6 rather ?
+ //TODO regroup with else condition ?
+ } else {
+ nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
+ for (int i : nepUuidCheckList) {
+ assertThat("node-rule-group nb " + nrgNb + " should be between nep-client" + nepClNb
+ + " and nep-network1",
+ nodeEdgePointList.get(i).getNodeEdgePointUuid().getValue(),
+ either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
+ }
}
- LOG.info("nep SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK1 UUID is {} ",
- UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))));
- LOG.info("nep SPDR-SA1-XPDR2+DSR+XPDR2-CLIENT4 UUID is {} ",
- UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))));
- assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
- "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
- assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
- "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
- assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- @Nullable
- List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
- assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
- assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
- assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
+ for (int i : nodeIdCheckList) {
+ assertEquals(nodeEdgePointList.get(i).getNodeUuid(), nodeUuid,
+ "any item of the node-rule-group should have the same nodeUuid");
+ }
+ List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
+ assertEquals(1, rule.size(), "node-rule-group should contain a single rule");
+ assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
+ assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
"the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
- assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
+ assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
"the rule type should be 'FORWARDING'");
+ //TODO regroup with rawCheckNodeRuleGroupOTsi ?
}
private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, List<Integer> nbNeps) {
private void checkNodeRuleGroupForTpdrOTSi(
List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
- assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
- List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
- assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
- assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
- nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
- either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
- assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
- nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
- either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
- assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
- assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
- assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
- assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
- "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
- assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
- "the rule type should be 'FORWARDING'");
+ rawCheckNodeRuleGroupOTsi("Tpdr", nrgList, enepUuid, inepUuid, nodeUuid);
}
private void checkNodeRuleGroupForMuxOTSi(
List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
- assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
+ rawCheckNodeRuleGroupOTsi("Mux", nrgList, enepUuid, inepUuid, nodeUuid);
+ }
+
+ private void checkNodeRuleGroupForSwitchOTSi(
+ List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
+ rawCheckNodeRuleGroupOTsi("Switch", nrgList, enepUuid, inepUuid, nodeUuid);
+ }
+
+ private void rawCheckNodeRuleGroupOTsi(String nodeType,
+ List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
+ int nrgListSize;
+ String network;
+ switch (nodeType) {
+ case "Switch":
+ nrgListSize = 4;
+ network = "XPDR2-NETWORK2";
+ break;
+ case "Tpdr":
+ case "Mux":
+ default:
+ nrgListSize = 1;
+ network = "XPDR1-NETWORK1";
+ break;
+ }
+ assertEquals(nrgListSize, nrgList.size(),
+ nodeType + "-OTSi should contain " + nrgListSize + " node rule group");
List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
- assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
- assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
+ for (NodeRuleGroup nodeRuleGroup : nrgList) {
+ assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
+ "each node-rule-group should contain 2 NEP for " + nodeType + "-OTSi");
+ }
+ assertThat(nodeType + "-OTSi node-rule-group should be between eNEP and iNEP of " + network,
nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
- assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
+ assertThat(nodeType + "-OTSi node-rule-group should be between eNEP and iNEP of " + network,
nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForSwitchOTSi(
- List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
- assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
- for (NodeRuleGroup nodeRuleGroup : nrgList) {
- assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
- "each node-rule-group should contain 2 NEP for Switch-OTSi");
- }
- List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
- assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
- nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
- either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
- assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
- nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
- either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
- List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
- assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
- "any item of the node-rule-group should have the same nodeUuid");
- List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
- assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
- assertEquals("forward", ruleList0.get(0).getLocalId(), "local-id of the rule should be 'forward'");
- assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
- "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
- assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().stream().findFirst().orElseThrow(),
- "the rule type should be 'FORWARDING'");
- }
-
private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
rawCheckNep(
List.of(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,