SXP: Use KWs from ClusterManagement
[integration/test.git] / csit / suites / sxp / cluster-routing / 010_Route_Switching.robot
index 878eca48dd14df40bd67111e0bdf0009eec896eb..4d0e2246d63cb37ae4c408d5eb2bf01e412ab0b1 100644 (file)
@@ -9,78 +9,71 @@ 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
-    Check Shards Status
-    ${active_controller}    Get Active Controller
-    Wait Until Keyword Succeeds    240    1    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}
-    Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
-    Clean Routing Configuration To Controller    controller${active_controller}
-    Wait Until Keyword Succeeds    240    1    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}
-    Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
+    SxpClusterLib.Check Shards Status
+    ${owner_controller} =    SxpClusterLib.Get Owner Controller
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
+    Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${owner_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
+    SxpLib.Clean Routing Configuration To Controller    ClusterManagement__session_${owner_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
+    Put Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${owner_controller}
+    BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_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
-    Check Shards Status
-    ${any_controller}    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}    Get Active Controller
-    \    Isolate SXP Controller    ${controller_index}
+    ...    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}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${any_controller}
+    ${controller_index} =    SxpClusterLib.Get Owner Controller
+    Isolate SXP Controller    ${controller_index}
 
 *** Keywords ***
 Put Route Definition To Cluster
     [Arguments]    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
     [Documentation]    Put Route definition to DS replacing all present
-    ${route}    Route Definition Xml    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
-    ${routes}    Route Definitions Xml    ${route}
-    Put Routing Configuration To Controller    ${routes}    controller${follower}
+    ${route} =    Sxp.Route Definition Xml    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
+    ${routes} =    Sxp.Route Definitions Xml    ${route}
+    SxpLib.Put Routing Configuration To Controller    ${routes}    ClusterManagement__session_${follower}
 
 Add Route Definition To Cluster
     [Arguments]    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
     [Documentation]    Add Route definition to DS
-    ${old_routes}    Get Routing Configuration From Controller    controller${follower}
-    ${route}    Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
-    ${routes}    Route Definitions Xml    ${route}    ${old_routes}
-    Put Routing Configuration To Controller    ${routes}    controller${follower}
+    ${old_routes} =    SxpLib.Get Routing Configuration From Controller    ClusterManagement__session_${follower}
+    ${route} =    Sxp.Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
+    ${routes} =    Sxp.Route Definitions Xml    ${route}    ${old_routes}
+    SxpLib.Put Routing Configuration To Controller    ${routes}    ClusterManagement__session_${follower}
 
 Custom Clean SXP Cluster
     [Documentation]    Cleans up Route definitions
-    ${follower}    Get Active Controller
-    Clean Routing Configuration To Controller    controller${follower}
+    SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
 
 Setup Custom SXP Cluster Session
     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
-    Shutdown Tools Node
-    Setup SXP Cluster Session
-    ${mac_addresses}    Map Followers To Mac Addresses
-    Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
+    SxpClusterLib.Shutdown Tools Node
+    SxpClusterLib.Setup SXP Cluster Session
+    ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
+    BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
+    SxpClusterLib.Create Virtual Interface
 
 Clean Custom SXP Cluster Session
     [Documentation]    Cleans up resources generated by test
-    ${controller_index}    Get Active Controller
-    Clean Routing Configuration To Controller    controller${controller_index}
-    Clean SXP Cluster Session
+    SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
+    SxpClusterLib.Clean SXP Cluster Session
+    SxpClusterLib.Delete Virtual Interface
 
 Isolate SXP Controller
     [Arguments]    ${controller_index}
-    [Documentation]    Isolate one of cluster nodes and perform check that virtual ip is routed to another cluster node,
+    [Documentation]    Isolate the cluster leader node and perform check that virtual IP is routed to a new leader,
     ...    afterwards unisolate old leader.
-    Isolate_Member_From_List_Or_All    ${controller_index}
-    Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
-    Wait Until Keyword Succeeds    240    1    Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${controller_index}
-    ${active_follower}    Get Active Controller
-    Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_follower}
-    Flush_Iptables_From_List_Or_All
-    Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}
+    @{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}
+    ClusterManagement.Flush_Iptables_From_List_Or_All
+    BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}