SXP: Get leader only from running members
[integration/test.git] / csit / suites / sxp / cluster-routing / 010_Route_Switching.robot
1 *** Settings ***
2 Documentation     Test suite to test cluster connection switchover using virtual ip, this suite requires additional TOOLS_SYSTEM VM.
3 ...               VM is used for its assigned ip-address that will be overlayed by virtual-ip used in test suites.
4 ...               Resources of this VM are not required and after start of Test suite this node shutted down and to reduce routing conflicts.
5 Suite Setup       Setup Custom SXP Cluster Session
6 Suite Teardown    Clean Custom SXP Cluster Session
7 Test Teardown     Custom Clean SXP Cluster
8 Library           ../../../libraries/Sxp.py
9 Resource          ../../../libraries/ClusterManagement.robot
10 Resource          ../../../libraries/SxpClusterLib.robot
11
12 *** Test Cases ***
13 Route Definition Test
14     [Documentation]    Test Route update mechanism without cluster node isolation
15     SxpClusterLib.Check Shards Status
16     ${active_controller} =    SxpClusterLib.Get Leader Controller
17     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
18     Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${active_controller}
19     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
20     SxpLib.Clean Routing Configuration To Controller    controller${active_controller}
21     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
22     Put Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${active_controller}
23     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_controller}
24
25 Isolation of SXP service follower Test
26     [Documentation]    Test Route update mechanism during Cluster isolation,
27     ...    after each isolation virtual ip should be pre-routed to new leader
28     SxpClusterLib.Check Shards Status
29     ${any_controller} =    SxpClusterLib.Get Any Controller
30     Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${any_controller}
31     ${controller_index} =    SxpClusterLib.Get Leader Controller
32     Isolate SXP Controller    ${controller_index}
33
34 *** Keywords ***
35 Put Route Definition To Cluster
36     [Arguments]    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
37     [Documentation]    Put Route definition to DS replacing all present
38     ${route} =    Sxp.Route Definition Xml    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
39     ${routes} =    Sxp.Route Definitions Xml    ${route}
40     SxpLib.Put Routing Configuration To Controller    ${routes}    controller${follower}
41
42 Add Route Definition To Cluster
43     [Arguments]    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
44     [Documentation]    Add Route definition to DS
45     ${old_routes} =    SxpLib.Get Routing Configuration From Controller    controller${follower}
46     ${route} =    Sxp.Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
47     ${routes} =    Sxp.Route Definitions Xml    ${route}    ${old_routes}
48     SxpLib.Put Routing Configuration To Controller    ${routes}    controller${follower}
49
50 Custom Clean SXP Cluster
51     [Documentation]    Cleans up Route definitions
52     ${follower} =    SxpClusterLib.Get Leader Controller
53     SxpLib.Clean Routing Configuration To Controller    controller${follower}
54
55 Setup Custom SXP Cluster Session
56     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
57     SxpClusterLib.Shutdown Tools Node
58     SxpClusterLib.Setup SXP Cluster Session
59     ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
60     BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
61     SxpClusterLib.Create Virtual Interface
62
63 Clean Custom SXP Cluster Session
64     [Documentation]    Cleans up resources generated by test
65     ${controller_index} =    SxpClusterLib.Get Leader Controller
66     SxpLib.Clean Routing Configuration To Controller    controller${controller_index}
67     SxpClusterLib.Clean SXP Cluster Session
68     SxpClusterLib.Delete Virtual Interface
69
70 Isolate SXP Controller
71     [Arguments]    ${controller_index}
72     [Documentation]    Isolate one of cluster nodes and perform check that virtual ip is routed to another cluster node,
73     ...    afterwards unisolate old leader.
74     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
75     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
76     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
77     ${active_follower} =    SxpClusterLib.Get Leader Controller From Running    @{running_members}
78     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
79     ClusterManagement.Flush_Iptables_From_List_Or_All
80     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}