c07d2a925e1d4f4f931597ba86ec275cd7e8ff01
[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 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}       4
14
15 *** Test Cases ***
16 Isolation Of SXP Service Follower W/O Bindings Listener Test
17     [Documentation]    Test SXP connection switchover only if Controller with SCS is isolated
18     Setup Nodes And Connections    listener
19     ${controller_index} =    SxpClusterLib.Get Owner Controller
20     Isolate SXP Controller    ${controller_index}    listener
21
22 Isolation Of SXP Service Follower W/O Bindings Speaker Test
23     [Documentation]    Test SXP connection switchover only if Controller with SCS is isolated
24     Setup Nodes And Connections    speaker
25     ${controller_index} =    SxpClusterLib.Get Owner Controller
26     Isolate SXP Controller    ${controller_index}    speaker
27
28 Isolation Of SXP Service Follower Listener Test
29     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated
30     Setup Nodes And Connections    listener
31     ${controller_index} =    SxpClusterLib.Get Owner Controller
32     Add Bindings To Node    ${CLUSTER_NODE_ID}    ClusterManagement__session_${controller_index}
33     Isolate SXP Controller With Bindings    ${controller_index}    ${DEVICE_NODE_ID}    listener    ${DEVICE_SESSION}
34
35 Isolation Of SXP Service Follower Speaker Test
36     [Documentation]    Test SXP binding propagation only if Controller with SCS is isolated,
37     ...    the same case as above but with initiator of connection between nodes in oposite mode
38     Setup Nodes And Connections    speaker
39     Add Bindings To Node    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
40     ${controller_index} =    SxpClusterLib.Get Owner Controller
41     Isolate SXP Controller With Bindings    ${controller_index}    ${CLUSTER_NODE_ID}    speaker    ClusterManagement__session_${controller_index}
42
43 *** Keywords ***
44 Setup Custom SXP Cluster Session
45     [Documentation]    Prepare topology for testing, creates sessions and generate Route definitions based on Cluster nodes ip
46     SxpClusterLib.Shutdown Tools Node
47     SxpClusterLib.Create Virtual Interface
48     SxpClusterLib.Setup SXP Cluster Session
49     SxpClusterLib.Setup Device Session
50     Retrieve Mac-addresses
51     Setup Virtual IP
52
53 Retrieve Mac-addresses
54     [Documentation]    Create list of ODL nodes mac-addresses
55     ${mac_addresses} =    SxpClusterLib.Map Followers To Mac Addresses
56     BuiltIn.Set Suite Variable    ${MAC_ADDRESS_TABLE}    ${mac_addresses}
57
58 Setup Virtual IP
59     [Documentation]    Enable routing to cluster through virtual IP
60     ${route} =    Sxp.Route Definition Xml    ${VIRTUAL_IP}    ${VIRTUAL_IP_MASK}    ${VIRTUAL_INTERFACE}
61     ${routes} =    Sxp.Route Definitions Xml    ${route}
62     SxpLib.Put Routing Configuration To Controller    ${routes}    ${CONTROLLER_SESSION}
63
64 Clean Custom SXP Cluster Session
65     [Documentation]    Cleans up resources generated by test
66     SxpLib.Clean Routing Configuration To Controller    ${CONTROLLER_SESSION}
67     SxpClusterLib.Clean SXP Cluster Session
68     SxpClusterLib.Delete Virtual Interface
69
70 Setup Nodes And Connections
71     [Arguments]    ${peer_mode}
72     [Documentation]    Setup and connect SXP cluster topology
73     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
74     ${controller_id} =    SxpClusterLib.Get Owner Controller
75     SxpLib.Add Node    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
76     SxpLib.Add Connection    version4    ${peer_mode}    ${VIRTUAL_IP}    64999    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
77     SxpLib.Add Node    ${CLUSTER_NODE_ID}    session=ClusterManagement__session_${controller_id}
78     SxpLib.Add Connection    version4    ${cluster_mode}    ${DEVICE_NODE_ID}    64999    ${CLUSTER_NODE_ID}    session=ClusterManagement__session_${controller_id}
79     BuiltIn.Wait Until Keyword Succeeds    20    1    SxpLib.Check Node Started    ${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
80     BuiltIn.Wait Until Keyword Succeeds    20    1    SxpLib.Check Node started    ${CLUSTER_NODE_ID}    system=${ODL_SYSTEM_${controller_id}_IP}    session=ClusterManagement__session_${controller_id}
81     BuiltIn.Wait Until Keyword Succeeds    120    1    Check Device is Connected    mode=${peer_mode}
82     BuiltIn.Wait Until Keyword Succeeds    120    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${controller_id}
83
84 Add Bindings To Node
85     [Arguments]    ${node}    ${session}
86     [Documentation]    Setup initial bindings to SXP device
87     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
88     \    SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
89
90 Isolate SXP Controller
91     [Arguments]    ${controller_index}    ${peer_mode}
92     [Documentation]    Isolate one of cluster nodes and perform check that Device is still connected then revert isolation (and check connection again).
93     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
94     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
95     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
96     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
97     ${running_member} =    Collections.Get From List    ${running_members}    0
98     ${active_follower} =    SxpClusterLib.Get Owner Controller    ${running_member}
99     BuiltIn.Wait Until Keyword Succeeds    240    1    SXpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
100     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
101     BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
102     ClusterManagement.Flush_Iptables_From_List_Or_All
103     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
104     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
105     BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
106
107 Isolate SXP Controller With Bindings
108     [Arguments]    ${controller_index}    ${node}    ${peer_mode}    ${session}=${EMPTY}
109     [Documentation]    Isolate one of cluster nodes and perform check that bindings were propagated then revert isolation (and check connection again).
110     ${cluster_mode} =    Sxp.Get Opposing Mode    ${peer_mode}
111     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
112     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_False    ${controller_index}
113     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Ip Addres Should Not Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${controller_index}
114     ${running_member} =    Collections.Get From List    ${running_members}    0
115     ${active_follower} =    SxpClusterLib.Get Owner Controller    ${running_member}
116     BuiltIn.Wait Until Keyword Succeeds    240    1    SXpClusterLib.Ip Addres Should Be Routed To Follower    ${MAC_ADDRESS_TABLE}    ${VIRTUAL_IP}    ${active_follower}
117     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
118     BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
119     BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
120     ClusterManagement.Flush_Iptables_From_List_Or_All
121     BuiltIn.Wait Until Keyword Succeeds    240    1    ClusterManagement.Sync_Status_Should_Be_True    ${controller_index}
122     BuiltIn.Wait Until Keyword Succeeds    240    1    SxpClusterLib.Check Cluster is Connected    ${CLUSTER_NODE_ID}    mode=${cluster_mode}    session=ClusterManagement__session_${active_follower}
123     BuiltIn.Wait Until Keyword Succeeds    240    1    Check Device is Connected    mode=${peer_mode}
124     BuiltIn.Wait Until Keyword Succeeds    30    1    Check Bindings    ${node}    ${session}
125
126 Check Device is Connected
127     [Arguments]    ${mode}=any    ${version}=version4    ${port}=64999
128     [Documentation]    Checks if SXP device is connected to the cluster. It means it has connection to ${VIRTUAL_IP} in state "on"
129     ${resp} =    SxpLib.Get Connections    node=${DEVICE_NODE_ID}    session=${DEVICE_SESSION}
130     SxpLib.Should Contain Connection    ${resp}    ${VIRTUAL_IP}    ${port}    ${mode}    ${version}    on
131
132 Check Bindings
133     [Arguments]    ${node}    ${session}
134     [Documentation]    Checks that bindings were propagated to Peer
135     ${resp}    SxpLib.Get Bindings    node=${node}    session=${session}
136     : FOR    ${i}    IN RANGE    1    ${BINDINGS}
137     \    SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32