SXP cluster tests: declare variables in one place
[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 *** Variables ***
13 ${SAMPLES}        1
14 ${MAC_ADDRESS_TABLE}    &{EMPTY}
15 ${VIRTUAL_IP_1}    ${TOOLS_SYSTEM_2_IP}
16 ${VIRTUAL_INTERFACE_1}    eth0:0
17 ${VIRTUAL_IP_MASK_1}    255.255.255.0
18
19 *** Test Cases ***
20 Route Definition Test
21     [Documentation]    Test Route update mechanism without cluster node isolation
22     SxpClusterLib.Check Shards Status
23     ${active_controller} =    SxpClusterLib.Get Active Controller
24     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
25     Add Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${active_controller}
26     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
27     SxpLib.Clean Routing Configuration To Controller    controller${active_controller}
28     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
29     Put Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${active_controller}
30     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
31
32 Isolation of SXP service follower Test
33     [Documentation]    Test Route update mechanism during Cluster isolation,
34     ...    after each isolation virtual ip should be pre-routed to new leader
35     SxpClusterLib.Check Shards Status
36     ${any_controller} =    SxpClusterLib.Get Any Controller
37     Add Route Definition To Cluster    ${VIRTUAL_IP_1}    ${VIRTUAL_IP_MASK_1}    ${VIRTUAL_INTERFACE_1}    ${any_controller}
38     : FOR    ${i}    IN RANGE    0    ${SAMPLES}
39     \    ${controller_index} =    SxpClusterLib.Get Active Controller
40     \    Isolate SXP Controller    ${controller_index}
41
42 *** Keywords ***
43 Put Route Definition To Cluster
44     [Arguments]    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
45     [Documentation]    Put Route definition to DS replacing all present
46     ${route} =    Sxp.Route Definition Xml    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
47     ${routes} =    Sxp.Route Definitions Xml    ${route}
48     SxpLib.Put Routing Configuration To Controller    ${routes}    controller${follower}
49
50 Add Route Definition To Cluster
51     [Arguments]    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}    ${follower}
52     [Documentation]    Add Route definition to DS
53     ${old_routes} =    SxpLib.Get Routing Configuration From Controller    controller${follower}
54     ${route} =    Sxp.Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
55     ${routes} =    Sxp.Route Definitions Xml    ${route}    ${old_routes}
56     SxpLib.Put Routing Configuration To Controller    ${routes}    controller${follower}
57
58 Custom Clean SXP Cluster
59     [Documentation]    Cleans up Route definitions
60     ${follower} =    SxpClusterLib.Get Active Controller
61     SxpLib.Clean Routing Configuration To Controller    controller${follower}
62
63 Setup Custom SXP Cluster Session
64     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
65     SxpClusterLib.Shutdown Tools Node
66     SxpClusterLib.Setup SXP Cluster Session
67     ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
68     BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
69     SxpClusterLib.Create Virtual Interface
70
71 Clean Custom SXP Cluster Session
72     [Documentation]    Cleans up resources generated by test
73     ${controller_index} =    SxpClusterLib.Get Active Controller
74     SxpLib.Clean Routing Configuration To Controller    controller${controller_index}
75     SxpClusterLib.Clean SXP Cluster Session
76     SxpClusterLib.Delete Virtual Interface
77
78 Isolate SXP Controller
79     [Arguments]    ${controller_index}
80     [Documentation]    Isolate one of cluster nodes and perform check that virtual ip is routed to another cluster node,
81     ...    afterwards unisolate old leader.
82     ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
83     BuiltIn.Wait Until Keyword Succeeds    120    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
84     BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${controller_index}
85     ${active_follower} =    SxpClusterLib.Get Active Controller
86     BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_follower}
87     ClusterManagement.Flush_Iptables_From_List_Or_All
88     BuiltIn.Wait Until Keyword Succeeds    120    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}