SXP: Get leader only from running members
[integration/test.git] / csit / suites / sxp / cluster-routing / 010_Route_Switching.robot
index 79738997cc4a50a337b070a9b39d9434fe0edd99..40b12af1dfd1fed1bc4d4a0baf02b51ac4937474 100644 (file)
@@ -9,35 +9,27 @@ Library           ../../../libraries/Sxp.py
 Resource          ../../../libraries/ClusterManagement.robot
 Resource          ../../../libraries/SxpClusterLib.robot
 
-*** Variables ***
-${SAMPLES}        1
-${MAC_ADDRESS_TABLE}    &{EMPTY}
-${VIRTUAL_IP_1}    ${TOOLS_SYSTEM_2_IP}
-${VIRTUAL_INTERFACE_1}    eth0:0
-${VIRTUAL_IP_MASK_1}    255.255.255.0
-
 *** Test Cases ***
 Route Definition Test
     [Documentation]    Test Route update mechanism without cluster node isolation
     SxpClusterLib.Check Shards Status
-    ${active_controller} =    SxpClusterLib.Get Active Controller
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
-    Add Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${active_controller}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
+    ${active_controller} =    SxpClusterLib.Get Leader Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
+    Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${active_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
     SxpLib.Clean Routing Configuration To Controller    controller${active_controller}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
-    Put Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${active_controller}
-    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
+    Put Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${active_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
 
 Isolation of SXP service follower Test
     [Documentation]    Test Route update mechanism during Cluster isolation,
     ...    after each isolation virtual ip should be pre-routed to new leader
     SxpClusterLib.Check Shards Status
     ${any_controller} =    SxpClusterLib.Get Any Controller
-    Add Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${any_controller}
-    : FOR    ${i}    IN RANGE    0    ${SAMPLES}
-    \    ${controller_index} =    SxpClusterLib.Get Active Controller
-    \    Isolate SXP Controller    ${controller_index}
+    Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${any_controller}
+    ${controller_index} =    SxpClusterLib.Get Leader Controller
+    Isolate SXP Controller    ${controller_index}
 
 *** Keywords ***
 Put Route Definition To Cluster
@@ -57,7 +49,7 @@ Add Route Definition To Cluster
 
 Custom Clean SXP Cluster
     [Documentation]    Cleans up Route definitions
-    ${follower} =    SxpClusterLib.Get Active Controller
+    ${follower} =    SxpClusterLib.Get Leader Controller
     SxpLib.Clean Routing Configuration To Controller    controller${follower}
 
 Setup Custom SXP Cluster Session
@@ -70,7 +62,7 @@ Setup Custom SXP Cluster Session
 
 Clean Custom SXP Cluster Session
     [Documentation]    Cleans up resources generated by test
-    ${controller_index} =    SxpClusterLib.Get Active Controller
+    ${controller_index} =    SxpClusterLib.Get Leader Controller
     SxpLib.Clean Routing Configuration To Controller    controller${controller_index}
     SxpClusterLib.Clean SXP Cluster Session
     SxpClusterLib.Delete Virtual Interface
@@ -79,10 +71,10 @@ Isolate SXP Controller
     [Arguments]    ${controller_index}
     [Documentation]    Isolate one of cluster nodes and perform check that virtual ip is routed to another cluster node,
     ...    afterwards unisolate old leader.
-    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    120    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
-    BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${controller_index}
-    ${active_follower} =    SxpClusterLib.Get Active Controller
-    BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_follower}
+    @{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}
+    ${active_follower} =    SxpClusterLib.Get Leader Controller From Running    @{running_members}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
     ClusterManagement.Flush_Iptables_From_List_Or_All
-    BuiltIn.Wait Until Keyword Succeeds    120    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}