cbb4207e7f2480e68da8faec32e6747f6ee95fcc
[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     ${owner_controller} =    SxpClusterLib.Get Owner Controller
17     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
18     Add Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${owner_controller}
19     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
20     SxpLib.Clean Routing Configuration To Controller    ClusterManagement__session_${owner_controller}
21     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_controller}
22     Put Route Definition To Cluster    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${owner_controller}
23     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${owner_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 Owner 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}    ClusterManagement__session_${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    ClusterManagement__session_${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}    ClusterManagement__session_${follower}
49
50 Custom Clean SXP Cluster
51     [Documentation]    Cleans up Route definitions
52     SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
53
54 Setup Custom SXP Cluster Session
55     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes IP
56     SxpClusterLib.Shutdown Tools Node
57     SxpClusterLib.Setup SXP Cluster Session
58     ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
59     BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
60     SxpClusterLib.Create Virtual Interface
61
62 Clean Custom SXP Cluster Session
63     [Documentation]    Cleans up resources generated by test
64     SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
65     SxpClusterLib.Clean SXP Cluster Session
66     SxpClusterLib.Delete Virtual Interface
67
68 Isolate SXP Controller
69     [Arguments]    ${controller_index}
70     [Documentation]    Isolate the cluster leader node and perform check that virtual IP is routed to a new leader,
71     ...    afterwards unisolate old leader.
72     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
73     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
74     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
75     ${running_member} =    Collections.Get From List    ${running_members}    0
76     ${active_follower} =    SxpClusterLib.Get Owner Controller    ${running_member}
77     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
78     ClusterManagement.Flush_Iptables_From_List_Or_All
79     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Check_Cluster_Is_In_Sync