SXP: wait for node start/stop
[integration/test.git] / csit / suites / sxp / cluster-routing / 020_Sxp_Node_Switching.robot
index c762361f4c02ab9292878e5c36dd7b9b13213d03..a4a4b2e10f62d0180954c4e5ded4db2c9a9b1b07 100644 (file)
@@ -4,45 +4,68 @@ Documentation     Test suite to test cluster connection and propagation switchov
 ...               Resources of this VM are not required. At suite start this node is shutted down to reduce routing conflicts.
 Suite Setup       Setup Custom SXP Cluster Session
 Suite Teardown    Clean Custom SXP Cluster Session
-Test Teardown     Clean Custom SXP Cluster
 Library           ../../../libraries/Sxp.py
 Resource          ../../../libraries/ClusterManagement.robot
 Resource          ../../../libraries/SxpClusterLib.robot
 
 *** Variables ***
 ${BINDINGS}       4
+${NEW_OWNER}      ${EMPTY}
 
 *** Test Cases ***
 Isolation Of SXP Service Follower W/O Bindings Listener Test
-    [Documentation]    Test SXP connection switchover only if Controller with SCS is isolated
-    Setup Nodes And Connections    listener
-    ${controller_index} =    SxpClusterLib.Get Owner Controller
-    Isolate SXP Controller    ${controller_index}    listener
+    [Documentation]    Device is listener. Connection between device and cluster must be established despite of cluster owner isolation
+    [Setup]    Setup Nodes And Connections    listener
+    ${cluster_owner} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
+    Check Connections    ${cluster_owner}    listener
+    Isolate SXP Controller    ${cluster_owner}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
+    Check Connections    ${NEW_OWNER}    listener
+    [Teardown]    Clean Custom SXP Cluster
 
 Isolation Of SXP Service Follower W/O Bindings Speaker Test
-    [Documentation]    Test SXP connection switchover only if Controller with SCS is isolated
-    Setup Nodes And Connections    speaker
-    ${controller_index} =    SxpClusterLib.Get Owner Controller
-    Isolate SXP Controller    ${controller_index}    speaker
+    [Documentation]    Device is speaker. Connection between device and cluster must be established despite of cluster owner isolation
+    [Setup]    Setup Nodes And Connections    speaker
+    ${cluster_owner} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
+    Check Connections    ${cluster_owner}    speaker
+    Isolate SXP Controller    ${cluster_owner}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
+    Check Connections    ${NEW_OWNER}    speaker
+    [Teardown]    Clean Custom SXP Cluster
 
 Isolation Of SXP Service Follower Listener Test
-    [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
-    Setup Nodes And Connections    listener
-    ${controller_index} =    SxpClusterLib.Get Owner Controller
-    Add Bindings To Node    ${CLUSTER_NODE_ID}    ClusterManagement__session_${controller_index}
-    Isolate SXP Controller With Bindings    ${controller_index}    ${DEVICE_NODE_ID}    listener    ${DEVICE_SESSION}
+    [Documentation]    Device is listener. Cluster owner is isolated but bindings must be propagated to the device throught virtual IP
+    [Setup]    Setup Nodes And Connections    listener
+    ${cluster_owner} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
+    Check Connections    ${cluster_owner}    ${DEVICE_NODE_ID}    listener
+    Add Bindings To Node    ${CLUSTER_NODE_ID}    ClusterManagement__session_${cluster_owner}
+    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    Isolate SXP Controller    ${cluster_owner}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
+    Check Connections    ${NEW_OWNER}    ${DEVICE_NODE_ID}    listener
+    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
+    [Teardown]    Clean Custom SXP Cluster
 
 Isolation Of SXP Service Follower Speaker Test
-    [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated,
-    ...    the same case as above but with initiator of connection between nodes in oposite mode
-    Setup Nodes And Connections    speaker
+    [Documentation]    Device is speaker. Cluster owner is isolated but bindings must be propagated to the cluster throught virtual IP
+    [Setup]    Setup Nodes And Connections    speaker
+    ${cluster_owner} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
+    Check Connections    ${cluster_owner}    ${CLUSTER_NODE_ID}    speaker
     Add Bindings To Node    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
-    ${controller_index} =    SxpClusterLib.Get Owner Controller
-    Isolate SXP Controller With Bindings    ${controller_index}    ${CLUSTER_NODE_ID}    speaker    ClusterManagement__session_${controller_index}
+    Check Bindings    ${CLUSTER_NODE_ID}    ClusterManagement__session_${cluster_owner}
+    Isolate SXP Controller    ${cluster_owner}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
+    Check Connections    ${NEW_OWNER}    ${CLUSTER_NODE_ID}    speaker
+    Check Bindings    ${CLUSTER_NODE_ID}    ClusterManagement__session_${NEW_OWNER}
+    [Teardown]    Clean Custom SXP Cluster
 
 *** Keywords ***
 Setup Custom SXP Cluster Session
-    [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
+    [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes IP
     SxpClusterLib.Shutdown Tools Node
     SxpClusterLib.Create Virtual Interface
     SxpClusterLib.Setup SXP Cluster Session
@@ -61,82 +84,62 @@ Setup Virtual IP
     ${routes} =    Sxp.Route Definitions Xml    ${route}
     SxpLib.Put Routing Configuration To Controller    ${routes}    ${CONTROLLER_SESSION}
 
-Clean Custom SXP Cluster Session
-    [Documentation]    Cleans up resources generated by test
-    SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
-    SxpClusterLib.Clean SXP Cluster Session
-    SxpClusterLib.Delete Virtual Interface
-
 Setup Nodes And Connections
     [Arguments]    ${peer_mode}
-    [Documentation]    Setup and connect SXP cluster topology
-    ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
-    ${controller_id} =    SxpClusterLib.Get Owner Controller
+    [Documentation]    Setup and connect SXP cluster topology and one device
     SxpLib.Add Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    SxpLib.Add Connection    version4    ${peer_mode}    ${VIRTUAL_IP}    64999    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    SxpLib.Add Node    ${CLUSTER_NODE_ID}    session=ClusterManagement__session_${controller_id}
-    SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${CLUSTER_NODE_ID}    session=ClusterManagement__session_${controller_id}
     BuiltIn.Wait Until Keyword Succeeds    20    1    SxpLib.Check Node Started    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
-    BuiltIn.Wait Until Keyword Succeeds    20    1    SxpLib.Check Node started    ${CLUSTER_NODE_ID}    system=${ODL_SYSTEM_${controller_id}_IP}    session=ClusterManagement__session_${controller_id}
-    BuiltIn.Wait Until Keyword Succeeds    120    1    Check Device is Connected    mode=${peer_mode}
-    BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${controller_id}
+    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}
+    SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
+
+Clean Custom SXP Cluster Session
+    [Documentation]    Clean up resources generated by test
+    SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
+    SxpClusterLib.Clean SXP Cluster Session
+    SxpClusterLib.Delete Virtual Interface
 
 Clean Custom SXP Cluster
     [Documentation]    Disconnect SXP cluster topology
+    ClusterManagement.Flush_Iptables_From_List_Or_All
+    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Check_Cluster_Is_In_Sync
     SxpLib.Delete Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
     SxpLib.Delete Node    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
 
 Add Bindings To Node
     [Arguments]    ${node}    ${session}
-    [Documentation]    Setup initial bindings to SXP device
+    [Documentation]    Setup initial bindings to SXP device/controller ${node} with ${session}
     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
     \    SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
 
 Isolate SXP Controller
-    [Arguments]    ${controller_index}    ${peer_mode}
-    [Documentation]    Isolate one of cluster nodes and perform check that Device is still connected then revert isolation (and check connection again).
-    ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
+    [Arguments]    ${controller_index}
+    [Documentation]    Isolate cluster node specified by ${controller_index} and find new owner
     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
     ${running_member} =    Collections.Get From List    ${running_members}    0
-    ${active_follower} =    SxpClusterLib.Get Owner Controller    ${running_member}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SXpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
-    ClusterManagement.Flush_Iptables_From_List_Or_All
-    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
+    ${new_owner} =    SxpClusterLib.Get Owner Controller    ${running_member}
+    BuiltIn.Set Test Variable    ${NEW_OWNER}    ${new_owner}
 
-Isolate SXP Controller With Bindings
-    [Arguments]    ${controller_index}    ${node}    ${peer_mode}    ${session}=${EMPTY}
-    [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated then revert isolation (and check connection again).
+Check Connections
+    [Arguments]    ${controller_index}    ${peer_mode}
+    [Documentation]    Check that connection is established between device and the cluster
     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
-    @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
-    ${running_member} =    Collections.Get From List    ${running_members}    0
-    ${active_follower} =    SxpClusterLib.Get Owner Controller    ${running_member}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SXpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
-    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
-    ClusterManagement.Flush_Iptables_From_List_Or_All
-    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
-    BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
+    BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${peer_mode}    session=${DEVICE_SESSION}
 
 Check Device is Connected
-    [Arguments]    ${mode}=any    ${version}=version4    ${port}=64999
-    [Documentation]    Checks if SXP device is connected to the cluster. It means it has connection to ${VIRTUAL_IP} in state "on"
-    ${resp} =    SxpLib.Get Connections    node=${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
+    [Arguments]    ${node}    ${mode}    ${session}    ${version}=version4    ${port}=64999
+    [Documentation]    Check if SXP device is connected to the cluster. It means it has connection to ${VIRTUAL_IP} in state "on"
+    ${resp} =    SxpLib.Get Connections    node=${node}    session=${session}
     SxpLib.Should Contain Connection    ${resp}    ${VIRTUAL_IP}    ${port}    ${mode}    ${version}    on
 
 Check Bindings
     [Arguments]    ${node}    ${session}
-    [Documentation]    Checks that bindings were propagated to Peer
-    ${resp}    SxpLib.Get Bindings    node=${node}    session=${session}
+    [Documentation]    Check that bindings were propagated to the peer ${node}
+    ${resp}    SxpLib.Get Bindings    node=${node}    session=${session}
     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
     \    SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32