Introduce new ServiceType to use otn-switch 97/97797/4
authorGilles Thouenon <gilles.thouenon@orange.com>
Tue, 7 Sep 2021 12:11:25 +0000 (14:11 +0200)
committerGilles Thouenon <gilles.thouenon@orange.com>
Tue, 16 Nov 2021 17:36:19 +0000 (18:36 +0100)
Will allow 100GE services supported by 100G OTN switch.
Add also UT for ServiceType class.

JIRA: TRNSPRTPCE-499
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: Id111b1897c82ef26fd28d9df5033ee97cf97fffa

common/src/main/java/org/opendaylight/transportpce/common/StringConstants.java
common/src/main/java/org/opendaylight/transportpce/common/service/ServiceTypes.java
common/src/test/java/org/opendaylight/transportpce/common/service/ServiceTypeTest.java [new file with mode: 0644]

index b1aa101d9dc02b709b2f21eebcf05cfe52b84be5..08aa2d2e281914da6e8990e2b6b0317dc1362d3a 100644 (file)
@@ -27,6 +27,7 @@ public final class StringConstants {
 
     public static final String SERVICE_TYPE_100GE_T = "100GEt";
     public static final String SERVICE_TYPE_100GE_M = "100GEm";
+    public static final String SERVICE_TYPE_100GE_S = "100GEs";
 
     public static final String SERVICE_TYPE_OTU4 = "OTU4";
     public static final String SERVICE_TYPE_OTUC4 = "OTUC4";
index db7dab6a539408c4e80cd8fcbff0092ada88ecc4..6c968770ba74e19a64f4630362640213df83996b 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Map;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.PortQual;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,9 +37,13 @@ public final class ServiceTypes {
                 if (Uint32.valueOf(400).equals(serviceRate)) {
                     return StringConstants.SERVICE_TYPE_400GE;
                 }
-                if (Uint32.valueOf(100).equals(serviceRate)
-                        && (mapping == null || !PortQual.SwitchClient.getName().equals(mapping.getPortQual()))) {
-                    return StringConstants.SERVICE_TYPE_100GE_T;
+                if (Uint32.valueOf(100).equals(serviceRate)) {
+                    if (mapping == null || !PortQual.SwitchClient.getName().equals(mapping.getPortQual())) {
+                        return StringConstants.SERVICE_TYPE_100GE_T;
+                    }
+                    if (XpdrNodeTypes.Switch.equals(mapping.getXponderType())) {
+                        return StringConstants.SERVICE_TYPE_100GE_S;
+                    }
                 }
                 return getOtnServiceType(serviceFormat, serviceRate);
 
diff --git a/common/src/test/java/org/opendaylight/transportpce/common/service/ServiceTypeTest.java b/common/src/test/java/org/opendaylight/transportpce/common/service/ServiceTypeTest.java
new file mode 100644 (file)
index 0000000..0eeb37b
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2021 Orange.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.common.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.PortQual;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+public class ServiceTypeTest {
+
+    @Test
+    public void getServiceTypeForServiceFormatUnknownTest() {
+        String serviceType = ServiceTypes.getServiceType("toto", null, null);
+        assertNull("service-type should be null", serviceType);
+    }
+
+    @Test
+    public void getServiceTypeForServiceFormatOCTest() {
+        String serviceType = ServiceTypes.getServiceType("OC", Uint32.valueOf(100), null);
+        assertEquals("service-type should be 100GEt", "100GEt", serviceType);
+        serviceType = ServiceTypes.getServiceType("OC", null, null);
+        assertNull("service-type should be null", serviceType);
+    }
+
+    @Test
+    public void getServiceTypeForServiceFormatEthernetTest() {
+        String serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(400), null);
+        assertEquals("service-type should be 400GE", "400GE", serviceType);
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), null);
+        assertEquals("service-type should be 100GEt", "100GEt", serviceType);
+        Mapping mapping = new MappingBuilder()
+            .setLogicalConnectionPoint("logicalConnectionPoint")
+            .setPortQual(PortQual.XpdrClient.getName())
+            .build();
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
+        assertEquals("service-type should be 100GEt", "100GEt", serviceType);
+
+        mapping = new MappingBuilder()
+            .setLogicalConnectionPoint("logicalConnectionPoint")
+            .setPortQual(PortQual.SwitchClient.getName())
+            .build();
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
+        assertEquals("service-type should be 100GEm", "100GEm", serviceType);
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(10), mapping);
+        assertEquals("service-type should be 10GE", "10GE", serviceType);
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(1), mapping);
+        assertEquals("service-type should be 1GE", "1GE", serviceType);
+
+        mapping = new MappingBuilder()
+            .setLogicalConnectionPoint("logicalConnectionPoint")
+            .setPortQual(PortQual.SwitchClient.getName())
+            .setXponderType(XpdrNodeTypes.Switch)
+            .build();
+        serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
+        assertEquals("service-type should be 100GEs", "100GEs", serviceType);
+    }
+
+    @Test
+    public void getOtnServiceTypeForServiceFormatEthernetTest() {
+        String serviceType = ServiceTypes.getOtnServiceType("toto", Uint32.valueOf(123));
+        assertNull("service-type should be null", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(123));
+        assertNull("service-type should be null", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(1));
+        assertEquals("service-type should be 1GE", "1GE", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(10));
+        assertEquals("service-type should be 10GE", "10GE", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(100));
+        assertEquals("service-type should be 100GEm", "100GEm", serviceType);
+
+        serviceType = ServiceTypes.getOtnServiceType("OTU", Uint32.valueOf(100));
+        assertEquals("service-type should be OTU4", "OTU4", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("OTU", Uint32.valueOf(400));
+        assertEquals("service-type should be OTUC4", "OTUC4", serviceType);
+
+        serviceType = ServiceTypes.getOtnServiceType("ODU", Uint32.valueOf(100));
+        assertEquals("service-type should be ODU4", "ODU4", serviceType);
+        serviceType = ServiceTypes.getOtnServiceType("ODU", Uint32.valueOf(400));
+        assertEquals("service-type should be ODUC4", "ODUC4", serviceType);
+
+    }
+
+}
\ No newline at end of file