SXP: wait for node start/stop 58/77858/5
authorIvan Hrasko <ihrasko@cisco.com>
Thu, 15 Nov 2018 16:17:03 +0000 (17:17 +0100)
committerTomas Markovic <tomas.markovic@pantheon.tech>
Mon, 19 Nov 2018 07:54:29 +0000 (07:54 +0000)
Change-Id: I626c0bc4e08eb120a6e10d1677b620cfc53273c1
Signed-off-by: Ivan Hrasko <ihrasko@cisco.com>
csit/libraries/SxpClusterLib.robot
csit/libraries/SxpLib.robot
csit/suites/sxp/cluster-routing/020_Sxp_Node_Switching.robot

index ca593bdff229057a88c8117d9436db39d5ee468a..55168a4ac37404ca0a225e3c9784a9955e5ce2bb 100644 (file)
@@ -59,17 +59,21 @@ Setup SXP Cluster
     SxpLib.Add Node    ${INADDR_ANY}    session=${CONTROLLER_SESSION}
     SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${INADDR_ANY}    session=${CONTROLLER_SESSION}
     BuiltIn.Wait Until Keyword Succeeds    12x    10s    SxpLib.Check Node Started    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    BuiltIn.Wait Until Keyword Succeeds    12x    10s    Check Cluster Node started    ${INADDR_ANY}    ip=${EMPTY}
+    BuiltIn.Wait Until Keyword Succeeds    12x    10s    Check Cluster Node Started    ${INADDR_ANY}    ip=${EMPTY}
     BuiltIn.Wait Until Keyword Succeeds    48x    10s    Check Device is Connected    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
 
 Clean SXP Cluster
     [Documentation]    Disconnect SXP cluster topology
     SxpLib.Delete Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
+    BuiltIn.Wait Until Keyword Succeeds    12x    10s    SxpLib.Check Node Stopped    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
     BuiltIn.Wait Until Keyword Succeeds    3x    10s    SxpLib.Delete Node    ${INADDR_ANY}    session=${CONTROLLER_SESSION}
+    BuiltIn.Wait Until Keyword Succeeds    12x    10s    SxpClusterLib.Check Cluster Node Stopped    ${INADDR_ANY}    ip=${EMPTY}
 
-Check Cluster Node started
+Check Cluster Node Started
     [Arguments]    ${node}    ${port}=64999    ${ip}=${node}
     [Documentation]    Verify that SxpNode has data written to Operational datastore and Node is running on one of cluster nodes
+    ${resp} =    RequestsLibrary.Get Request    ${CONTROLLER_SESSION}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
+    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
     ${started} =    BuiltIn.Set Variable    ${False}
     : FOR    ${i}    IN RANGE    ${NUM_ODL_SYSTEM}
     \    ${rc} =    Utils.Run Command On Remote System    ${ODL_SYSTEM_${i+1}_IP}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}
@@ -77,9 +81,11 @@ Check Cluster Node started
     \    ${started} =    BuiltIn.Set Variable If    '${rc}' == '0'    ${True}    ${started}
     BuiltIn.Should Be True    ${started}
 
-Check Cluster Node stopped
+Check Cluster Node Stopped
     [Arguments]    ${node}    ${port}=64999    ${ip}=${node}
     [Documentation]    Verify that SxpNode has data removed from Operational datastore and Node is stopped
+    ${resp} =    RequestsLibrary.Get Request    ${CONTROLLER_SESSION}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
+    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
     ${stopped} =    BuiltIn.Set Variable    ${False}
     : FOR    ${i}    IN RANGE    ${NUM_ODL_SYSTEM}
     \    ${rc} =    Utils.Run Command On Remote System    ${ODL_SYSTEM_${i+1}_IP}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}
index b3a29a1d138ab2f6bf56c5dfe338716a85a77e0c..bb5f14cd11c2c9c96c8464560ce910ad4ea58229 100644 (file)
@@ -328,9 +328,23 @@ Check Node Started
     [Documentation]    Verify that SxpNode has data writen to Operational datastore and is running
     ${resp} =    RequestsLibrary.Get Request    ${session}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
-    ${rc} =    Utils.Run Command On Remote System    ${system}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    prompt=${ODL_SYSTEM_PROMPT}
+    ${rc} =    Get Node Running Status    ${node}    ${port}    ${system}    ${session}    ${ip}
     BuiltIn.Should Be Equal As Strings    ${rc}    0
 
+Check Node Stopped
+    [Arguments]    ${node}    ${port}=64999    ${system}=${node}    ${session}=session    ${ip}=${node}
+    [Documentation]    Verify that SxpNode has data removed from Operational datastore and is not running
+    ${resp} =    RequestsLibrary.Get Request    ${session}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
+    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
+    ${rc} =    Get Node Running Status    ${node}    ${port}    ${system}    ${session}    ${ip}
+    BuiltIn.Should Be Equal As Strings    ${rc}    1
+
+Get Node Running Status
+    [Arguments]    ${node}    ${port}    ${system}    ${session}    ${ip}
+    [Documentation]    Get status if node is running by checking that netty server is running
+    ${rc} =    Utils.Run Command On Remote System    ${system}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    prompt=${ODL_SYSTEM_PROMPT}
+    [Return]    ${rc}
+
 Clean SXP Environment
     [Arguments]    ${node_range}=1
     [Documentation]    Destroy created sessions
index 99bc24d28ae4b006c14d4616328b0b7200edfb4f..a4a4b2e10f62d0180954c4e5ded4db2c9a9b1b07 100644 (file)
@@ -92,7 +92,7 @@ Setup Nodes And Connections
     SxpLib.Add Connection    version4    ${peer_mode}    ${VIRTUAL_IP}    64999    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
     SxpLib.Add Node    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
-    BuiltIn.Wait Until Keyword Succeeds    20    1    SxpClusterLib.Check Cluster Node started    ${CLUSTER_NODE_ID}
+    BuiltIn.Wait Until Keyword Succeeds    20    1    SxpClusterLib.Check Cluster Node Started    ${CLUSTER_NODE_ID}
     SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
 
 Clean Custom SXP Cluster Session