Fix SH DowngradeConstraints max OTN Hop count bug 80/100380/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 4 Apr 2022 10:49:06 +0000 (12:49 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Tue, 5 Apr 2022 09:26:03 +0000 (11:26 +0200)
WDM hop count setter was used both for WDM and OTN constraints
- use OTN hop count setter for OTN constraints

Junit was only testing WDM hop count and TE metrics but not OTN ones.
- add OTN parameters to tests constraints util class
- add OTN Hop Count Junit tests

JIRA: TRNSPRTPCE-611
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I1eb1057fb85d10da359670f0607985d77f89dd6b

servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ConstraintsUtils.java

index c6e9cbb8cf438e926511bcbed7edd16f6445ff61..75339e9c5ca8c1b0cd0703df570add51612b25d5 100644 (file)
@@ -302,7 +302,7 @@ public final class DowngradeConstraints {
             hcBldr.setMaxWdmHopCount(Uint8.valueOf(maxWdmHc));
         }
         if (maxOtnHc != null) {
-            hcBldr.setMaxWdmHopCount(Uint8.valueOf(maxOtnHc));
+            hcBldr.setMaxOtnHopCount(Uint8.valueOf(maxOtnHc));
         }
         return hcBldr.build();
     }
index 3a4ebd7877ab9b426018c8a9261278ad90ae0b36..8895390dc9dc755fb1c3028734e3fb08735379fe 100644 (file)
@@ -334,8 +334,8 @@ public class DowngradeConstraintsTest {
             initialSoftConstraints.getHopCount(), generatedSoftConstraints.getHopCount());
         assertEquals("updated soft constraints max-wdm-hop-count should be '3'",
             3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue());
-        assertNull("updated soft constraints max-otn-hop-count should be null",
-            generatedSoftConstraints.getHopCount().getMaxOtnHopCount());
+        assertEquals("updated soft constraints max-otn-hop-count should be '5'",
+            5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue());
 
         // test addition of hard hop-count when no soft hop-count
         initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, true, false, null, null);
@@ -346,8 +346,8 @@ public class DowngradeConstraintsTest {
             initialHardConstraints.getHopCount(), generatedSoftConstraints.getHopCount());
         assertEquals("updated soft constraints max-wdm-hop-count should be '3'",
             3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue());
-        assertNull("updated soft constraints max-otn-hop-count should be null",
-            generatedSoftConstraints.getHopCount().getMaxOtnHopCount());
+        assertEquals("updated soft constraints max-otn-hop-count should be '5'",
+            5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue());
 
         // test addition of hard hop-count when existing soft hop-count
         initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, false, null, null);
@@ -355,8 +355,8 @@ public class DowngradeConstraintsTest {
             initialHardConstraints, initialSoftConstraints);
         assertEquals("updated soft constraints max-wdm-hop-count should be '3'",
             3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue());
-        assertNull("updated soft constraints max-otn-hop-count should be null",
-            generatedSoftConstraints.getHopCount().getMaxOtnHopCount());
+        assertEquals("updated soft constraints max-otn-hop-count should be '5'",
+            5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue());
     }
 
     @Test
index d4758dc3b8eef062ece800abbc5af20d7cf24d53..faff25e4034f7854835d789802c4d5df29d39710 100644 (file)
@@ -141,6 +141,7 @@ public final class ConstraintsUtils {
         if (hopCount) {
             hc = new HopCountBuilder()
                 .setMaxWdmHopCount(Uint8.valueOf(3))
+                .setMaxOtnHopCount(Uint8.valueOf(5))
                 .build();
         }
         Map<String, Exclude> excludeMap = initialiseExcludeMap();
@@ -157,6 +158,7 @@ public final class ConstraintsUtils {
         if (teMetric) {
             tem = new TEMetricBuilder()
                 .setMaxWdmTEMetric(Uint32.valueOf(8))
+                .setMaxOtnTEMetric(Uint32.valueOf(11))
                 .build();
         }
         Distance distance = null;