Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / sxp / cluster-binding / 010_Bindings_consistency.robot
1 *** Settings ***
2 Documentation       Test suite to test cluster binding propagation
3
4 Library             ../../../libraries/Sxp.py
5 Resource            ../../../libraries/ClusterManagement.robot
6 Resource            ../../../libraries/SxpClusterLib.robot
7 Resource            ../../../libraries/SxpLib.robot
8
9 Suite Setup         SxpClusterLib.Setup SXP Cluster Session With Device
10 Suite Teardown      SxpClusterLib.Clean SXP Cluster Session
11
12
13 *** Variables ***
14 ${RUNNING_MEMBER}       ${EMPTY}
15
16
17 *** Test Cases ***
18 Isolation of SXP service follower Test Speaker Part
19     [Documentation]    Test SXP binding propagation from device to cluster after cluster owner is isolated
20     [Setup]    Setup Custom SXP Cluster    speaker
21     ${controller_index} =    SxpClusterLib.Get Owner Controller
22     BuiltIn.Wait Until Keyword Succeeds
23     ...    120x
24     ...    1s
25     ...    Check Bindings
26     ...    ${INADDR_ANY}
27     ...    ClusterManagement__session_${controller_index}
28     Isolate SXP Controller    ${controller_index}    ${INADDR_ANY}
29     BuiltIn.Wait Until Keyword Succeeds
30     ...    120x
31     ...    1s
32     ...    Check Bindings
33     ...    ${INADDR_ANY}
34     ...    ClusterManagement__session_${RUNNING_MEMBER}
35     UnIsolate SXP Controller    ${controller_index}
36     BuiltIn.Wait Until Keyword Succeeds
37     ...    120x
38     ...    1s
39     ...    Check Bindings
40     ...    ${INADDR_ANY}
41     ...    ClusterManagement__session_${controller_index}
42     [Teardown]    SxpClusterLib.Clean SXP Cluster
43
44 Isolation of SXP noservice follower Test Speaker Part
45     [Documentation]    Test SXP binding propagation from device to cluster after cluster (not owner) node is isolated
46     [Setup]    Setup Custom SXP Cluster    speaker
47     ${controller_index} =    SxpClusterLib.Get Not Owner Controller
48     BuiltIn.Wait Until Keyword Succeeds
49     ...    120x
50     ...    1s
51     ...    Check Bindings
52     ...    ${INADDR_ANY}
53     ...    ClusterManagement__session_${controller_index}
54     Isolate SXP Controller    ${controller_index}    ${INADDR_ANY}
55     BuiltIn.Wait Until Keyword Succeeds
56     ...    120x
57     ...    1s
58     ...    Check Bindings
59     ...    ${INADDR_ANY}
60     ...    ClusterManagement__session_${RUNNING_MEMBER}
61     UnIsolate SXP Controller    ${controller_index}
62     BuiltIn.Wait Until Keyword Succeeds
63     ...    120x
64     ...    1s
65     ...    Check Bindings
66     ...    ${INADDR_ANY}
67     ...    ClusterManagement__session_${controller_index}
68     [Teardown]    SxpClusterLib.Clean SXP Cluster
69
70 Isolation of SXP service follower Test Listener Part
71     [Documentation]    Test SXP binding propagation from cluster to device after cluster owner is isolated
72     [Setup]    Setup Custom SXP Cluster    listener    ${INADDR_ANY}    ${CONTROLLER_SESSION}
73     ${controller_index} =    SxpClusterLib.Get Owner Controller
74     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
75     Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
76     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
77     UnIsolate SXP Controller    ${controller_index}
78     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
79     [Teardown]    SxpClusterLib.Clean SXP Cluster
80
81 Isolation of SXP noservice follower Test Listener Part
82     [Documentation]    Test SXP binding propagation from cluster to device after cluster (not owner) node is isolated
83     [Setup]    Setup Custom SXP Cluster    listener    ${INADDR_ANY}    ${CONTROLLER_SESSION}
84     ${controller_index} =    SxpClusterLib.Get Not Owner Controller
85     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
86     Isolate SXP Controller    ${controller_index}    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
87     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
88     UnIsolate SXP Controller    ${controller_index}
89     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Check Bindings    ${DEVICE_NODE_ID}    ${DEVICE_SESSION}
90     [Teardown]    SxpClusterLib.Clean SXP Cluster
91
92
93 *** Keywords ***
94 Setup Custom SXP Cluster
95     [Documentation]    Setup custom SXP cluster topology with ${NUM_ODL_SYSTEM} nodes and one device
96     [Arguments]    ${mode}    ${node}=${DEVICE_NODE_ID}    ${session}=${DEVICE_SESSION}
97     SxpClusterLib.Check Shards Status
98     SxpClusterLib.Setup SXP Cluster    ${mode}
99     FOR    ${i}    IN RANGE    1    25
100         SxpLib.Add Bindings    ${i}0    ${i}.${i}.${i}.${i}/32    node=${node}    session=${session}
101     END
102
103 Isolate SXP Controller
104     [Documentation]    Isolate one of cluster nodes and perform check that device is connected
105     [Arguments]    ${controller_index}    ${node}    ${session}=ClusterManagement__session_${controller_index}
106     @{running_members} =    ClusterManagement.Isolate_Member_From_List_Or_All    ${controller_index}
107     BuiltIn.Wait Until Keyword Succeeds
108     ...    120x
109     ...    1s
110     ...    ClusterManagement.Verify_Members_Are_Ready
111     ...    member_index_list=${running_members}
112     ...    verify_cluster_sync=True
113     ...    verify_restconf=True
114     ...    verify_system_status=False
115     ...    service_list=${EMPTY_LIST}
116     ${running_member} =    Collections.Get From List    ${running_members}    0
117     BuiltIn.Set Test Variable    ${RUNNING_MEMBER}    ${running_member}
118     BuiltIn.Wait Until Keyword Succeeds
119     ...    240x
120     ...    1s
121     ...    ClusterManagement.Sync_Status_Should_Be_False
122     ...    ${controller_index}
123     BuiltIn.Wait Until Keyword Succeeds
124     ...    120x
125     ...    1s
126     ...    SxpClusterLib.Check Device is Connected
127     ...    ${DEVICE_NODE_ID}
128     ...    session=${DEVICE_SESSION}
129
130 UnIsolate SXP Controller
131     [Documentation]    Un-Isolate one of cluster nodes and perform check that device is connected
132     [Arguments]    ${controller_index}
133     ClusterManagement.Flush_Iptables_From_List_Or_All
134     BuiltIn.Wait Until Keyword Succeeds
135     ...    120x
136     ...    1s
137     ...    ClusterManagement.Verify_Members_Are_Ready
138     ...    member_index_list=${EMPTY}
139     ...    verify_cluster_sync=True
140     ...    verify_restconf=True
141     ...    verify_system_status=False
142     ...    service_list=${EMPTY_LIST}
143     BuiltIn.Wait Until Keyword Succeeds
144     ...    120x
145     ...    1s
146     ...    SxpClusterLib.Check Device is Connected
147     ...    ${DEVICE_NODE_ID}
148     ...    session=${DEVICE_SESSION}
149
150 Check Bindings
151     [Documentation]    Checks that bindings were propagated to Peer
152     [Arguments]    ${node}    ${session}
153     ${resp} =    SxpLib.Get Bindings    node=${node}    session=${session}
154     FOR    ${i}    IN RANGE    1    25
155         SxpLib.Should Contain Binding    ${resp}    ${i}0    ${i}.${i}.${i}.${i}/32
156     END