SXP: Increase node start timeout
[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_2 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. At suite start this node is shutted down to reduce routing conflicts.
5 Suite Setup       Setup Custom SXP Cluster Session
6 Suite Teardown    Clean Custom SXP Cluster Session
7 Library           ../../../libraries/Sxp.py
8 Resource          ../../../libraries/ClusterManagement.robot
9 Resource          ../../../libraries/SxpClusterLib.robot
10
11 *** Variables ***
12 ${BINDINGS}       4
13 ${NEW_OWNER}      ${EMPTY}
14
15 *** Test Cases ***
16 Isolation Of SXP Service Follower W/O Bindings Listener Test
17     [Documentation]    Device is listener. Connection between device and cluster must be established despite of cluster owner isolation
18     [Setup]    Setup Nodes And Connections    listener
19     ${cluster_owner} =    SxpClusterLib.Get Owner Controller
20     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
21     Check Connections    ${cluster_owner}    listener
22     Isolate SXP Controller    ${cluster_owner}
23     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
24     Check Connections    ${NEW_OWNER}    listener
25     [Teardown]    Clean Custom SXP Cluster
26
27 Isolation Of SXP Service Follower W/O Bindings Speaker Test
28     [Documentation]    Device is speaker. Connection between device and cluster must be established despite of cluster owner isolation
29     [Setup]    Setup Nodes And Connections    speaker
30     ${cluster_owner} =    SxpClusterLib.Get Owner Controller
31     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
32     Check Connections    ${cluster_owner}    speaker
33     Isolate SXP Controller    ${cluster_owner}
34     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
35     Check Connections    ${NEW_OWNER}    speaker
36     [Teardown]    Clean Custom SXP Cluster
37
38 Isolation Of SXP Service Follower Listener Test
39     [Documentation]    Device is listener. Cluster owner is isolated but bindings must be propagated to the device throught virtual IP
40     [Setup]    Setup Nodes And Connections    listener
41     ${cluster_owner} =    SxpClusterLib.Get Owner Controller
42     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
43     Check Connections    ${cluster_owner}    ${DEVICE_NODE_ID}    listener
44     Add Bindings To Node    ${CLUSTER_NODE_ID}    ClusterManagement__session_${cluster_owner}
45     Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
46     Isolate SXP Controller    ${cluster_owner}
47     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
48     Check Connections    ${NEW_OWNER}    ${DEVICE_NODE_ID}    listener
49     Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
50     [Teardown]    Clean Custom SXP Cluster
51
52 Isolation Of SXP Service Follower Speaker Test
53     [Documentation]    Device is speaker. Cluster owner is isolated but bindings must be propagated to the cluster throught virtual IP
54     [Setup]    Setup Nodes And Connections    speaker
55     ${cluster_owner} =    SxpClusterLib.Get Owner Controller
56     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${cluster_owner}
57     Check Connections    ${cluster_owner}    ${CLUSTER_NODE_ID}    speaker
58     Add Bindings To Node    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
59     Check Bindings    ${CLUSTER_NODE_ID}    ClusterManagement__session_${cluster_owner}
60     Isolate SXP Controller    ${cluster_owner}
61     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${NEW_OWNER}
62     Check Connections    ${NEW_OWNER}    ${CLUSTER_NODE_ID}    speaker
63     Check Bindings    ${CLUSTER_NODE_ID}    ClusterManagement__session_${NEW_OWNER}
64     [Teardown]    Clean Custom SXP Cluster
65
66 *** Keywords ***
67 Setup Custom SXP Cluster Session
68     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes IP
69     SxpClusterLib.Shutdown Tools Node
70     SxpClusterLib.Create Virtual Interface
71     SxpClusterLib.Setup SXP Cluster Session
72     SxpClusterLib.Setup Device Session
73     Retrieve Mac-addresses
74     Setup Virtual IP
75
76 Retrieve Mac-addresses
77     [Documentation]    Create list of ODL nodes mac-addresses
78     ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
79     BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
80
81 Setup Virtual IP
82     [Documentation]    Enable routing to cluster through virtual IP
83     ${route} =    Sxp.Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
84     ${routes} =    Sxp.Route Definitions Xml    ${route}
85     SxpLib.Put Routing Configuration To Controller    ${routes}    ${CONTROLLER_SESSION}
86
87 Setup Nodes And Connections
88     [Arguments]    ${peer_mode}
89     [Documentation]    Setup and connect SXP cluster topology and one device
90     SxpLib.Add Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
91     BuiltIn.Wait Until Keyword Succeeds    20x    10s    SxpLib.Check Node Started    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
92     SxpLib.Add Connection    version4    ${peer_mode}    ${VIRTUAL_IP}    64999    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
93     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
94     SxpLib.Add Node    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
95     BuiltIn.Wait Until Keyword Succeeds    20x    10s    SxpClusterLib.Check Cluster Node Started    ${CLUSTER_NODE_ID}
96     SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
97
98 Clean Custom SXP Cluster Session
99     [Documentation]    Clean up resources generated by test
100     SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
101     SxpClusterLib.Clean SXP Cluster Session
102     SxpClusterLib.Delete Virtual Interface
103
104 Clean Custom SXP Cluster
105     [Documentation]    Disconnect SXP cluster topology
106     ClusterManagement.Flush_Iptables_From_List_Or_All
107     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Check_Cluster_Is_In_Sync
108     SxpLib.Delete Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
109     SxpLib.Delete Node    ${CLUSTER_NODE_ID}    session=${CONTROLLER_SESSION}
110
111 Add Bindings To Node
112     [Arguments]    ${node}    ${session}
113     [Documentation]    Setup initial bindings to SXP device/controller ${node} with ${session}
114     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
115     \    SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
116
117 Isolate SXP Controller
118     [Arguments]    ${controller_index}
119     [Documentation]    Isolate cluster node specified by ${controller_index} and find new owner
120     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
121     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
122     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
123     ${running_member} =    Collections.Get From List    ${running_members}    0
124     ${new_owner} =    SxpClusterLib.Get Owner Controller    ${running_member}
125     BuiltIn.Set Test Variable    ${NEW_OWNER}    ${new_owner}
126
127 Check Connections
128     [Arguments]    ${controller_index}    ${peer_mode}
129     [Documentation]    Check that connection is established between device and the cluster
130     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
131     BuiltIn.Wait Until Keyword Succeeds    60    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${controller_index}
132     BuiltIn.Wait Until Keyword Succeeds    60    1    Check Device is Connected    ${DEVICE_NODE_ID}    ${peer_mode}    session=${DEVICE_SESSION}
133
134 Check Device is Connected
135     [Arguments]    ${node}    ${mode}    ${session}    ${version}=version4    ${port}=64999
136     [Documentation]    Check if SXP device is connected to the cluster. It means it has connection to ${VIRTUAL_IP} in state "on"
137     ${resp} =    SxpLib.Get Connections    node=${node}    session=${session}
138     SxpLib.Should Contain Connection    ${resp}    ${VIRTUAL_IP}    ${port}    ${mode}    ${version}    on
139
140 Check Bindings
141     [Arguments]    ${node}    ${session}
142     [Documentation]    Check that bindings were propagated to the peer ${node}
143     ${resp} =    SxpLib.Get Bindings    node=${node}    session=${session}
144     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
145     \    SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32