Fail power setup if node is not connected 72/104072/1
authorJonas Mårtensson <jonas.martensson@smartoptics.com>
Mon, 19 Dec 2022 21:54:47 +0000 (21:54 +0000)
committerGilles Thouenon <gilles.thouenon@orange.com>
Wed, 18 Jan 2023 07:23:42 +0000 (08:23 +0100)
Currently, if getting info from a node fails, power setup just
continues with the next node. This is wrong since power levels
have to be adjusted for each node in the path sequentially.

Instead, return false from setPower if getting node info fails.
Also adapt UT.

JIRA: TRNSPRTPCE-715
Change-Id: I44fdfbe871b320b2d9e2bc174c769d6a521fb50c
Signed-off-by: Jonas Mårtensson <jonas.martensson@smartoptics.com>
Co-authored-by: Gilles Thouenon <gilles.thouenon@orange.com>
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtImpl.java
olm/src/test/java/org/opendaylight/transportpce/olm/power/PowerMgmtTest.java

index d3b16f3110fa8d4dcf71e5acb59830e7b1a90057..c63d495de2cf9887c7c0fdc0268875d54c585c34 100644 (file)
@@ -111,7 +111,7 @@ public class PowerMgmtImpl implements PowerMgmt {
             Nodes inputNode = this.portMapping.getNode(nodeId);
             if (inputNode == null || inputNode.getNodeInfo() == null) {
                 LOG.error("OLM-PowerMgmtImpl : Error retrieving mapping node for {}", nodeId);
-                continue;
+                return false;
             }
             OpenroadmNodeVersion openroadmVersion = inputNode.getNodeInfo().getOpenroadmVersion();
 
index a96fc1a972a1c8788c5130916804c94fb23ea81d..d68c6588e93afd38ca2c3d4f143660b4ab176860 100644 (file)
@@ -66,7 +66,7 @@ public class PowerMgmtTest {
     public void testSetPowerWhenMappingReturnNull() {
         Mockito.when(this.portMapping.getNode(Mockito.anyString())).thenReturn(null);
         boolean output = this.powerMgmt.setPower(OlmPowerServiceRpcImplUtil.getServicePowerSetupInput());
-        Assert.assertEquals(true, output);
+        Assert.assertEquals(false, output);
     }
 
     @Test