Remove usage of removed RPC add-entry
[integration/test.git] / csit / suites / sxp / cluster-routing / 020_Sxp_Node_Switching.robot
1 *** Settings ***
2 Documentation     Test suite to test cluster connection and propagation 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     Clean SXP Cluster
8 Library           ../../../libraries/Sxp.py
9 Resource          ../../../libraries/ClusterManagement.robot
10 Resource          ../../../libraries/SxpClusterLib.robot
11
12 *** Variables ***
13 ${BINDINGS}       25
14 ${SAMPLES}        1
15 ${MAC_ADDRESS_TABLE}    &{EMPTY}
16 ${VIRTUAL_IP}     ${TOOLS_SYSTEM_2_IP}
17 ${VIRTUAL_INTERFACE}    eth0:0
18 ${VIRTUAL_IP_MASK}    255.255.255.0
19
20 *** Test Cases ***
21 Isolation of SXP service follower Test
22     [Documentation]    Test SXP connection switchover only if Controller with SCS is isolated
23     Check Shards Status
24     Setup Custom SXP Cluster    ${VIRTUAL_IP}    listener
25     : FOR    ${i}    IN RANGE    0    ${SAMPLES}
26     \    ${controller_index}    Get Active Controller
27     \    Isolate SXP Controller    ${controller_index}    listener
28
29 Isolation of SXP service follower Test Listener Part
30     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
31     Check Shards Status
32     ${controller_index}    Get Active Controller
33     Setup Custom SXP Cluster    ${VIRTUAL_IP}    listener
34     Setup SXP Cluster Bindings    ${CLUSTER_NODE_ID}    controller${controller_index}
35     : FOR    ${i}    IN RANGE    0    ${SAMPLES}
36     \    ${controller_index}    Get Active Controller
37     \    Isolate SXP Controller With Bindings    ${controller_index}    ${DEVICE_NODE_ID}    listener    ${DEVICE_SESSION}
38
39 Isolation of SXP service follower Test Speaker Part
40     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated,
41     ...    the same case as above but with initiator of connection between nodes in oposite mode
42     Check Shards Status
43     Setup Custom SXP Cluster    ${VIRTUAL_IP}    speaker
44     Setup SXP Cluster Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
45     : FOR    ${i}    IN RANGE    0    ${SAMPLES}
46     \    ${controller_index}    Get Active Controller
47     \    Isolate SXP Controller With Bindings    ${controller_index}    ${CLUSTER_NODE_ID}    speaker
48
49 *** Keywords ***
50 Setup Custom SXP Cluster Session
51     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
52     Shutdown Tools Node
53     Setup SXP Cluster Session
54     ${controller_index}    Get Active Controller
55     ${mac_addresses}    Map Followers To Mac Addresses
56     Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
57     ${route}    Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
58     ${routes}    Route Definitions Xml    ${route}
59     Put Routing Configuration To Controller    ${routes}    controller${controller_index}
60
61 Clean Custom SXP Cluster Session
62     [Documentation]    Cleans up resources generated by test
63     ${controller_index}    Get Active Controller
64     Clean Routing Configuration To Controller    controller${controller_index}
65     Clean SXP Cluster Session
66
67 Setup Custom SXP Cluster
68     [Arguments]    ${peer_address}    ${peer_mode}
69     [Documentation]    Setup and connect SXP cluster topology
70     Add Node    ${DEVICE_NODE_ID}    ip=0.0.0.0    session=${DEVICE_SESSION}
71     Wait Until Keyword Succeeds    20    1    Check Node Started    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}    system=${TOOLS_SYSTEM_IP}
72     ...    ip=${EMPTY}
73     ${cluster_mode}    Get Opposing Mode    ${peer_mode}
74     Add Connection    version4    ${peer_mode}    ${peer_address}    64999    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
75     ${controller_id}    Get Active Controller
76     Add Node    ${CLUSTER_NODE_ID}    ip=${peer_address}    session=controller${controller_id}
77     Wait Until Keyword Succeeds    20    1    Check Cluster Node started    ${CLUSTER_NODE_ID}
78     Add Connection    version4    ${cluster_mode}    ${TOOLS_SYSTEM_IP}    64999    ${CLUSTER_NODE_ID}    session=controller${controller_id}
79     Wait Until Keyword Succeeds    120    1    Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=controller${controller_id}
80
81 Setup SXP Cluster Bindings
82     [Arguments]    ${node}    ${session}
83     [Documentation]    Setup initial bindings to SXP device
84     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
85     \    Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
86
87 Isolate SXP Controller
88     [Arguments]    ${controller_index}    ${peer_mode}
89     [Documentation]    Isolate one of cluster nodes and perform check that Device is still connected then revert isolation (and check connection again).
90     ${cluster_mode}    Get Opposing Mode    ${peer_mode}
91     Isolate_Member_From_List_Or_All    ${controller_index}
92     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
93     Wait Until Keyword Succeeds    240    1    Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
94     ${active_follower}    Get Active Controller
95     Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
96     Wait Until Keyword Succeeds    60    1    Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=controller${active_follower}
97     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${VIRTUAL_IP}    ${peer_mode}
98     ...    session=${DEVICE_SESSION}
99     Flush_Iptables_From_List_Or_All
100     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}
101     Wait Until Keyword Succeeds    60    1    Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=controller${active_follower}
102     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${VIRTUAL_IP}    ${peer_mode}
103     ...    session=${DEVICE_SESSION}
104
105 Isolate SXP Controller With Bindings
106     [Arguments]    ${controller_index}    ${node}    ${peer_mode}    ${session}=${EMPTY}
107     [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated then revert isolation (and check connection again).
108     ${find_session}    Set Variable If    '${session}' == '${EMPTY}'    ${True}    ${False}
109     ${cluster_mode}    Get Opposing Mode    ${peer_mode}
110     ${session}    Set Variable If    ${find_session}    controller${controller_index}    ${session}
111     Isolate_Member_From_List_Or_All    ${controller_index}
112     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_False    ${controller_index}
113     Wait Until Keyword Succeeds    240    1    Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
114     ${active_follower}    Get Active Controller
115     Wait Until Keyword Succeeds    240    1    Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
116     Wait Until Keyword Succeeds    60    1    Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=controller${active_follower}
117     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${VIRTUAL_IP}    ${peer_mode}
118     ...    session=${DEVICE_SESSION}
119     ${session}    Set Variable If    ${find_session}    controller${active_follower}    ${session}
120     Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
121     Flush_Iptables_From_List_Or_All
122     Wait Until Keyword Succeeds    240    1    Sync_Status_Should_Be_True    ${controller_index}
123     Wait Until Keyword Succeeds    60    1    Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=controller${active_follower}
124     Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${VIRTUAL_IP}    ${peer_mode}
125     ...    session=${DEVICE_SESSION}
126     Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
127
128 Check Device is Connected
129     [Arguments]    ${node}    ${remote_ip}    ${mode}=any    ${version}=version4    ${port}=64999    ${session}=session
130     [Documentation]    Checks if SXP device is connected to at least one cluster node
131     ${resp}    Get Connections    node=${node}    session=${session}
132     Should Contain Connection    ${resp}    ${remote_ip}    ${port}    ${mode}    ${version}
133
134 Check Bindings
135     [Arguments]    ${node}    ${session}
136     [Documentation]    Checks that bindings were propagated to Peer
137     ${resp}    Get Bindings    node=${node}    session=${session}
138     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
139     \    Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32