Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / openflowplugin / Clustering_Bulkomatic / 020__Cluster_HA_Data_Recovery_BulkFlow_2Node_Cluster.robot
1 *** Settings ***
2 Documentation       Test suite for 2Node Cluster HA with Bulk Flows - Cluster node convergance and Data consistency after leader and follower restart with one switch connected
3
4 Resource            ../../../libraries/SetupUtils.robot
5 Resource            ../../../libraries/BulkomaticKeywords.robot
6 Resource            ../../../libraries/MininetKeywords.robot
7 Resource            ../../../libraries/ClusterManagement.robot
8 Resource            ../../../libraries/ClusterOpenFlow.robot
9 Resource            ../../../libraries/Utils.robot
10 Variables           ../../../variables/Variables.py
11
12 Suite Setup         SetupUtils.Setup_Utils_For_Setup_And_Teardown
13 Suite Teardown      Delete All Sessions
14 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
15
16
17 *** Variables ***
18 ${operation_timeout}        100s
19 ${restart_timeout}          350s
20 ${flow_count_per_switch}    10000
21 ${switch_count}             1
22 ${flow_count_after_add}     10000
23 ${flow_count_after_del}     0
24 ${orig_json_config_add}     sal_add_bulk_flow_config.json
25 ${orig_json_config_get}     sal_get_bulk_flow_config.json
26 ${orig_json_config_del}     sal_del_bulk_flow_config.json
27
28
29 *** Test Cases ***
30 Check Shards Status and Initialize Variables
31     [Documentation]    Check Status for all shards in OpenFlow application.
32     ClusterOpenFlow.Check OpenFlow Shards Status
33     ${temp_json_config_add}=    BulkomaticKeywords.Set DPN And Flow Count In Json Add
34     ...    ${orig_json_config_add}
35     ...    ${switch_count}
36     ...    ${flow_count_per_switch}
37     ${temp_json_config_get}=    BulkomaticKeywords.Set DPN And Flow Count In Json Get
38     ...    ${orig_json_config_get}
39     ...    ${switch_count}
40     ...    ${flow_count_after_add}
41     ${temp_json_config_del}=    BulkomaticKeywords.Set DPN And Flow Count In Json Del
42     ...    ${orig_json_config_del}
43     ...    ${switch_count}
44     ...    ${flow_count_per_switch}
45     Set Suite Variable    ${temp_json_config_add}
46     Set Suite Variable    ${temp_json_config_get}
47     Set Suite Variable    ${temp_json_config_del}
48
49 Get Inventory Follower Before Leader Restart
50     [Documentation]    Find a follower in the inventory config shard
51     ${inventory_leader}    ${inventory_followers}=    ClusterOpenFlow.Get InventoryConfig Shard Status
52     ${Inventory_Pre_Leader_List}=    Create List    ${Inventory_Leader}
53     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
54     Set Suite Variable    ${Inventory_Followers}
55     Set Suite Variable    ${Follower_Node_1}
56     Set Suite Variable    ${Inventory_Leader}
57     Set Suite Variable    ${Inventory_Pre_Leader_List}
58     ${Inventory_Pre_Leader}=    Set Variable    ${Inventory_Leader}
59     Set Suite Variable    ${Inventory_Pre_Leader}
60
61 Shutdown Leader From Cluster Node
62     [Documentation]    Shutdown Leader Node and Start it Up
63     ClusterManagement.Kill Single Member    ${Inventory_Leader}
64
65 Check Shards Status After Leader Shutdown
66     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
67     Wait Until Keyword Succeeds
68     ...    ${operation_timeout}
69     ...    2s
70     ...    ClusterOpenFlow.Check OpenFlow Shards Status
71     ...    ${Inventory_Followers}
72
73 Check Shard Status For Leader After PreLeader Shutdown
74     [Documentation]    Find a Leader in the inventory config shard
75     ${Inventory_Leader_Post}    ${inventory_followers}=    ClusterOpenFlow.Get InventoryConfig Shard Status
76     ...    ${Inventory_Followers}
77     ${Inventory_Leader_List_Post}=    Create List    ${Inventory_Leader_Post}
78     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
79     Set Suite Variable    ${Inventory_Followers}
80     Set Suite Variable    ${Follower_Node_1}
81     Set Suite Variable    ${Inventory_Leader_Post}
82     Set Suite Variable    ${Inventory_Leader_List_Post}
83
84 Start Mininet Connect To Follower Node1
85     [Documentation]    Start mininet with connection to Follower Node1
86     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller
87     ...    ${TOOLS_SYSTEM_IP}
88     ...    ${ODL_SYSTEM_${Follower_Node_1}_IP}
89     ...    --topo linear,${switch_count}
90     Set Suite Variable    ${mininet_conn_id}
91
92 Add Bulk Flow From Follower
93     [Documentation]    ${flow_count_per_switch} Flows added via Follower Node1 and verify it gets applied in all instances.
94     BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add}    ${Follower_Node_1}    ${operation_timeout}
95
96 Get Bulk Flows And Verify In Leader
97     [Documentation]    Initiate get operation and check flow count across cluster nodes.
98     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
99     ...    ${temp_json_config_get}
100     ...    ${operation_timeout}
101     ...    ${flow_count_after_add}
102     ...    ${Inventory_Leader_List_Post}
103
104 Verify Flows In Switch Before Cluster Restart
105     [Documentation]    Verify flows are installed in switch before cluster restart.
106     MininetKeywords.Verify Aggregate Flow From Mininet Session
107     ...    ${mininet_conn_id}
108     ...    ${flow_count_after_add}
109     ...    ${operation_timeout}
110
111 Restart Pre Leader From Cluster Node
112     [Documentation]    Restart Leader Node.
113     ClusterManagement.Start Single Member    ${Inventory_Leader}
114
115 Check Shards Status After Leader Restart
116     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
117     Wait Until Keyword Succeeds    ${restart_timeout}    2s    ClusterOpenFlow.Check OpenFlow Shards Status
118
119 Verify Data Recovery After Leader Restart
120     [Documentation]    ${flow_count_after_add} Flows preserved in all controller instances.
121     Wait Until Keyword Succeeds
122     ...    ${operation_timeout}
123     ...    2s
124     ...    BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
125     ...    ${temp_json_config_get}
126     ...    ${operation_timeout}
127     ...    ${flow_count_after_add}
128     ...    ${Inventory_Leader_List_Post}
129
130 Verify Flows In Switch After Leader Restart
131     [Documentation]    Verify flows are installed in switch after cluster restart.
132     MininetKeywords.Verify Aggregate Flow From Mininet Session
133     ...    ${mininet_conn_id}
134     ...    ${flow_count_after_add}
135     ...    ${operation_timeout}
136
137 Stop Mininet Connected To Follower Node1
138     [Documentation]    Stop mininet and exit connection.
139     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
140     Utils.Clean Mininet System
141
142 Delete All Flows From Follower Node1
143     [Documentation]    ${flow_count_after_add} Flows deleted via Follower Node1 and verify it gets applied in all instances.
144     BulkomaticKeywords.Delete Bulk Flow In Node
145     ...    ${temp_json_config_del}
146     ...    ${Follower_Node_1}
147     ...    ${operation_timeout}
148
149 Verify No Flows In Leader Node
150     [Documentation]    Verify flow count is ${flow_count_after_del} across cluster nodes.
151     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
152     ...    ${temp_json_config_get}
153     ...    ${operation_timeout}
154     ...    ${flow_count_after_del}
155     ...    ${Inventory_Leader_List_Post}
156
157 Get Inventory Follower And Leader Before Cluster Restart
158     [Documentation]    Find a follower in the inventory config shard
159     ${inventory_leader}    ${inventory_followers}=    ClusterOpenFlow.Get InventoryConfig Shard Status
160     ${Active_Nodes}=    Create List
161     ${Follower_Node_1}=    Get From List    ${Inventory_Followers}    0
162     ${Follower_Node_2}=    Get From List    ${Inventory_Followers}    1
163     Append To List    ${Active_Nodes}    ${inventory_leader}    ${Follower_Node_1}
164     Set Suite Variable    ${Active_Nodes}
165     ${Inventory_Leader_List}=    Create List    ${inventory_leader}
166     ${Inventory_Follower_Node1_List}=    Create List    ${Follower_Node_1}
167     Set Suite Variable    ${Follower_Node_1}
168     Set Suite Variable    ${Follower_Node_2}
169     Set Suite Variable    ${Inventory_Leader}
170     Set Suite Variable    ${Inventory_Leader_List}
171     Set Suite Variable    ${Inventory_Follower_Node1_List}
172
173 Shutdown Follower From Cluster Node
174     [Documentation]    Shutdown Follower Node2 and Start it Up.
175     ClusterManagement.Kill Single Member    ${Follower_Node_2}
176
177 Check Shards Status After Follower Shutdown
178     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
179     Wait Until Keyword Succeeds
180     ...    ${operation_timeout}
181     ...    2s
182     ...    ClusterOpenFlow.Check OpenFlow Shards Status
183     ...    ${Active_Nodes}
184
185 Start Mininet Connect To Follower Node
186     [Documentation]    Start mininet with connection to Follower Node1.
187     ${mininet_conn_id}=    MininetKeywords.Start Mininet Single Controller
188     ...    ${TOOLS_SYSTEM_IP}
189     ...    ${ODL_SYSTEM_${Follower_Node_1}_IP}
190     ...    --topo linear,${switch_count}
191     Set Suite Variable    ${mininet_conn_id}
192
193 Add Bulk Flow From Follower Node1
194     [Documentation]    ${flow_count_after_add} Flows added via Follower Node1 and verify it gets applied in all instances.
195     BulkomaticKeywords.Add Bulk Flow In Node    ${temp_json_config_add}    ${Follower_Node_1}    ${operation_timeout}
196
197 Get Bulk Flows And Verify In Leader Before Follower Restart
198     [Documentation]    Initiate get operation and check flow count ${flow_count_after_add} only across active cluster nodes
199     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
200     ...    ${temp_json_config_get}
201     ...    ${operation_timeout}
202     ...    ${flow_count_after_add}
203     ...    ${Inventory_Leader_List}
204
205 Verify Flows In Switch Before Follower Restart
206     [Documentation]    Verify flows are installed in switch before follower restart.
207     MininetKeywords.Verify Aggregate Flow From Mininet Session
208     ...    ${mininet_conn_id}
209     ...    ${flow_count_after_add}
210     ...    ${operation_timeout}
211
212 Restart Follower From Cluster Node
213     [Documentation]    Restart Follower Node2.
214     ClusterManagement.Start Single Member    ${Follower_Node_2}
215
216 Check Shards Status After Follower Restart
217     [Documentation]    Wait for node convergence and check status for all shards in OpenFlow application.
218     Wait Until Keyword Succeeds    ${restart_timeout}    2s    ClusterOpenFlow.Check OpenFlow Shards Status
219
220 Verify Data Recovery After Follower Restart
221     [Documentation]    ${flow_count_after_add} Flows preserved in all controller instances.
222     Wait Until Keyword Succeeds
223     ...    ${operation_timeout}
224     ...    2s
225     ...    BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
226     ...    ${temp_json_config_get}
227     ...    ${operation_timeout}
228     ...    ${flow_count_after_add}
229     ...    ${Inventory_Leader_List}
230
231 Verify Flows In Switch After Follower Restart
232     [Documentation]    Verify flows are installed in switch after cluster restart.
233     MininetKeywords.Verify Aggregate Flow From Mininet Session
234     ...    ${mininet_conn_id}
235     ...    ${flow_count_after_add}
236     ...    ${operation_timeout}
237
238 Stop Mininet Connected To Follower Node
239     [Documentation]    Stop mininet and exit connection.
240     MininetKeywords.Stop Mininet And Exit    ${mininet_conn_id}
241     Utils.Clean Mininet System
242
243 Delete All Flows From Follower Node
244     [Documentation]    ${flow_count_after_add} Flows deleted via Follower Node1 and verify it gets applied in all instances.
245     BulkomaticKeywords.Delete Bulk Flow In Node
246     ...    ${temp_json_config_del}
247     ...    ${Follower_Node_1}
248     ...    ${operation_timeout}
249
250 Verify No Flows In Leader Node After Follower Restart
251     [Documentation]    Verify flow count is ${flow_count_after_del} across cluster nodes.
252     BulkomaticKeywords.Get Bulk Flow And Verify Count In Cluster
253     ...    ${temp_json_config_get}
254     ...    ${operation_timeout}
255     ...    ${flow_count_after_del}
256     ...    ${Inventory_Leader_List}