From 97b42df7417ca71f7327cf1c51e809995a213fcf Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Mon, 4 Apr 2022 12:49:06 +0200 Subject: [PATCH] Fix SH DowngradeConstraints max OTN Hop count bug 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 Change-Id: I1eb1057fb85d10da359670f0607985d77f89dd6b --- .../servicehandler/DowngradeConstraints.java | 2 +- .../servicehandler/DowngradeConstraintsTest.java | 12 ++++++------ .../servicehandler/utils/ConstraintsUtils.java | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java index c6e9cbb8c..75339e9c5 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java @@ -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(); } diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java index 3a4ebd787..8895390dc 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java @@ -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 diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ConstraintsUtils.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ConstraintsUtils.java index d4758dc3b..faff25e40 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ConstraintsUtils.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ConstraintsUtils.java @@ -141,6 +141,7 @@ public final class ConstraintsUtils { if (hopCount) { hc = new HopCountBuilder() .setMaxWdmHopCount(Uint8.valueOf(3)) + .setMaxOtnHopCount(Uint8.valueOf(5)) .build(); } Map 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; -- 2.36.6