Add Cluster routing tests
[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     Check Shards Status
23     ${active_controller}    Get Active Controller
24     Wait Until Keyword Succeeds    240    1    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     Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_controller}
27     Clean Routing Configuration To Controller    controller${active_controller}
28     Wait Until Keyword Succeeds    240    1    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     Wait Until Keyword Succeeds    240    1    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     Check Shards Status
36     ${any_controller}    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}    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}    Route Definition Xml    ${virtual_ip}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
47     ${routes}    Route Definitions Xml    ${route}
48     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}    Get Routing Configuration From Controller    controller${follower}
54     ${route}    Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
55     ${routes}    Route Definitions Xml    ${route}    ${old_routes}
56     Put Routing Configuration To Controller    ${routes}    controller${follower}
57
58 Custom Clean SXP Cluster
59     [Documentation]    Cleans up Route definitions
60     ${follower}    Get Active Controller
61     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     Shutdown Tools Node
66     Setup SXP Cluster Session
67     ${mac_addresses}    Map Followers To Mac Addresses
68     Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
69
70 Clean Custom SXP Cluster Session
71     [Documentation]    Cleans up resources generated by test
72     ${controller_index}    Get Active Controller
73     Clean Routing Configuration To Controller    controller${controller_index}
74     Clean SXP Cluster Session
75
76 Isolate SXP Controller
77     [Arguments]    ${controller_index}
78     [Documentation]    Isolate one of cluster nodes and perform check that virtual ip is routed to another cluster node,
79     ...    afterwards unisolate old leader.
80     Isolate_Member_From_List_Or_All    ${controller_index}
81     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
82     Wait Until Keyword Succeeds    240    1    Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${controller_index}
83     ${active_follower}    Get Active Controller
84     Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP_1}    ${active_follower}
85     Flush_Iptables_From_List_Or_All
86     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}