2 Documentation Switch connections and cluster are restarted.
3 Suite Setup Initialization Phase
4 Suite Teardown Final Phase
5 Library RequestsLibrary
6 Resource ../../../libraries/ClusterManagement.robot
7 Resource ../../../libraries/ClusterOpenFlow.robot
8 Resource ../../../libraries/TemplatedRequests.robot
9 Resource ../../../libraries/MininetKeywords.robot
10 Resource ../../../libraries/Utils.robot
11 Resource ../../../variables/Variables.robot
16 ${VAR_DIR} ${CURDIR}/../../../variables/openflowplugin
19 Enable Stale Flow Entry
20 [Documentation] Enable stale flow entry feature.
21 # Stale flows/groups feature is only available in Boron onwards.
22 CompareStream.Run Keyword If At Least Boron TemplatedRequests.Put As Json Templated folder=${VAR_DIR}/frm-config mapping={"STALE":"true"} session=session
25 [Documentation] Add ${ITER} groups 1&2 and flows in every switch.
26 Add Groups And Flows ${ITER}
28 Start Mininet Multiple Connections
29 [Documentation] Start mininet linear with connection to all cluster instances.
30 ${mininet_conn_id}= MininetKeywords.Start Mininet Multiple Controllers ${TOOLS_SYSTEM_IP} ${ClusterManagement__member_index_list} --topo linear,${SWITCHES} --switch ovsk,protocols=OpenFlow13
31 BuiltIn.Set Suite Variable ${mininet_conn_id}
32 BuiltIn.Wait Until Keyword Succeeds 10s 1s OVSDB.Check OVS OpenFlow Connections ${TOOLS_SYSTEM_IP} ${SWITCHES*3}
35 [Documentation] Check Linear Topology.
36 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES}
38 Check Flows In Operational DS
39 [Documentation] Check Groups after mininet starts.
40 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${all_flows}
42 Check Groups In Operational DS
43 [Documentation] Check Flows after mininet starts.
44 Check Number Of Groups ${all_groups}
47 [Documentation] Check Flows in switch after mininet starts.
48 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${all_flows}
50 Check Entity Owner Status And Find Owner and Successor Before Fail
51 [Documentation] Check Entity Owner Status and identify owner and successor for first switch s1.
52 ${original_owner} ${original_successor_list} ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device openflow:1 1
53 BuiltIn.Set Suite Variable ${original_owner}
55 Disconnect Mininet From Owner
56 [Documentation] Disconnect mininet from the owner
57 ${owner_list} BuiltIn.Create List ${original_owner}
58 Disconnect Cluster Mininet break ${owner_list}
59 BuiltIn.Set Suite Variable ${owner_list}
61 Check Linear Topology After Disconnect
62 [Documentation] Check Linear Topology After Disconnecting mininet from owner.
63 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES}
65 Remove Flows And Groups After Mininet Is Disconnected
66 [Documentation] Remove 1 group 1&2 and 1 flow in every switch after mininet is disconnected.
67 Remove Single Group And Flow
69 Check Flows In Operational DS After Mininet Is Disconnected
70 [Documentation] Check Flows in Operational DS after mininet is disconnected.
71 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${less_flows}
73 Check Groups In Operational DS After Mininet Is Disconnected
74 [Documentation] Check Groups in Operational DS after mininet is disconnected.
75 Check Number Of Groups ${less_groups}
77 Check Flows In Switch After Mininet Is Disconnected
78 [Documentation] Check Flows in switch after mininet is disconnected
79 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${less_flows}
81 Reconnect Mininet To Owner
82 [Documentation] Reconnect mininet to switch 1 owner.
83 Disconnect Cluster Mininet restore ${owner_list}
85 Check Linear Topology After Reconnect
86 [Documentation] Check Linear Topology After Reconnect.
87 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES}
89 Add Flows And Groups After Reconnect
90 [Documentation] Add 1 group type 1&2 and 1 flow in every switch.
91 Add Single Group And Flow
93 Check Flows After Reconnect In Operational DS
94 [Documentation] Check Flows in Operational DS after mininet is reconnected.
95 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${all_flows}
97 Check Groups After Reconnect In Operational DS
98 [Documentation] Check Groups in Operational DS after mininet is reconnected.
99 Check Number Of Groups ${all_groups}
101 Check Flows After Reconnect In Switch
102 [Documentation] Check Flows in switch after mininet is reconnected.
103 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${all_flows}
105 Disconnect Mininet From Cluster
106 [Documentation] Disconnect Mininet from Cluster.
107 Disconnect Cluster Mininet
109 Check No Switches After Disconnect
110 [Documentation] Check no switches in topology after disconnecting mininet from cluster.
111 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check No Switches In Topology ${SWITCHES}
113 Remove Flows And Groups While Mininet Is Disconnected
114 [Documentation] Remove a group and flow while mininet Is Disconnected from cluster.
115 Remove Single Group And Flow
117 Reconnect Mininet To Cluster
118 [Documentation] Reconnect mininet to cluster by removing Iptables drop rules that were used to disconnect
119 Disconnect Cluster Mininet restore
121 Check Linear Topology After Mininet Reconnects
122 [Documentation] Check Linear Topology after reconnect.
123 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES}
125 Check Flows In Operational DS After Mininet Reconnects
126 [Documentation] Check Flows in Operational DS after mininet is reconnected.
127 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${less_flows}
129 Check Groups In Operational DS After Mininet Reconnects
130 [Documentation] Check Groups in Operational DS after mininet is reconnected to cluster.
131 Check Number Of Groups ${less_groups}
133 Check Flows In Switch After Mininet Reconnects
134 [Documentation] Check Flows in switch after mininet is reconnected to cluster.
135 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${less_flows}
137 Check Entity Owner Status And Find Owner and Successor Before Stop
138 [Documentation] Check Entity Owner Status and identify owner and successor for first switch s1.
139 ${original_owner} ${original_successor_list} ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device openflow:1 1
140 ${original_successor}= Collections.Get From List ${original_successor_list} 0
141 BuiltIn.Set Suite Variable ${original_owner}
142 BuiltIn.Set Suite Variable ${original_successor_list}
143 BuiltIn.Set Suite Variable ${original_successor}
146 [Documentation] Stop Owner Instance and verify it is shutdown
147 ClusterManagement.Stop Single Member ${original_owner}
148 BuiltIn.Set Suite Variable ${new_cluster_list} ${original_successor_list}
150 Check Shards Status After Stop
151 [Documentation] Check Status for all shards in OpenFlow application.
152 ClusterOpenFlow.Check OpenFlow Shards Status After Cluster Event ${new_cluster_list}
154 Check Entity Owner Status And Find Owner and Successor After Stop
155 [Documentation] Check Entity Owner Status and identify owner and successor.
156 ${new_owner} ${new_successor_list} ClusterOpenFlow.Get OpenFlow Entity Owner Status For One Device openflow:1 ${original_successor} ${new_cluster_list} after_stop=True
157 ${new_successor}= Collections.Get From List ${new_successor_list} 0
158 BuiltIn.Set Suite Variable ${new_owner}
159 BuiltIn.Set Suite Variable ${new_successor}
160 BuiltIn.Set Suite Variable ${new_successor_list}
162 Check Linear Topology After Owner Stop
163 [Documentation] Check Linear Topology.
164 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES} ${new_owner}
166 Add Configuration In Owner and Verify After Fail
167 [Documentation] Add Flow in Owner and verify it gets applied from all instances.
168 Add Single Group And Flow ${new_owner}
170 Check Flows In Operational DS After Owner Is Stopped
171 [Documentation] Check Flows in Operational DS after Owner is Stopped.
172 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${all_flows} ${new_owner}
174 Check Groups In Operational DS After Owner Is Stopped
175 [Documentation] Check Groups in Operational DS after Owner is Stopped.
176 Check Number Of Groups ${all_groups} ${new_owner}
178 Check Flows In Switch After Owner Is Stopped
179 [Documentation] Check Flows in switch after Owner is Stopped
180 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${all_flows}
182 Start Old Owner Instance
183 [Documentation] Start old Owner Instance and verify it is up
184 ClusterManagement.Start Single Member ${original_owner}
186 Check Linear Topology After Owner Restart
187 [Documentation] Check Linear Topology.
188 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Linear Topology ${SWITCHES}
190 Remove Configuration In Owner and Verify After Owner Restart
191 [Documentation] Add Flow in Owner and verify it gets applied from all instances.
192 Remove Single Group And Flow ${new_owner}
194 Check Flows After Owner Restart In Operational DS
195 [Documentation] Check Flows in Operational DS after owner is restarted.
196 BuiltIn.Wait Until Keyword Succeeds 30s 1s Check Number Of Flows ${less_flows}
198 Check Groups After Owner Restart In Operational DS
199 [Documentation] Check Groups in Operational DS after owner is restarted.
200 Check Number Of Groups ${less_groups}
202 Check Flows In Switch After Owner Is Restarted
203 [Documentation] Check Flows in switch after Owner is restarted
204 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${less_flows}
207 [Documentation] Stop and Start cluster.
208 # Try to stop contoller, if stop does not work or takes too long, kill controller.
209 ${status} ${result}= BuiltIn.Run Keyword And Ignore Error ClusterManagement.Stop_Members_From_List_Or_All
210 BuiltIn.Run Keyword If '${status}' != 'PASS' ClusterManagement.Kill_Members_From_List_Or_All
211 ClusterManagement.Start_Members_From_List_Or_All wait_for_sync=False
213 Check Linear Topology After Controller Restarts
214 [Documentation] Check Linear Topology after controller restarts.
215 BuiltIn.Wait Until Keyword Succeeds 300s 2s Check Linear Topology ${SWITCHES}
217 Add Flow And Group After Restart
218 [Documentation] Add 1 group type 1&2 and 1 flow in every switch.
219 Add Single Group And Flow
221 Check Flows In Operational DS After Controller Restarts
222 [Documentation] Check Flows in Operational DS after controller is restarted.
223 BuiltIn.Wait Until Keyword Succeeds 300s 2s Check Number Of Flows ${all_flows}
225 Check Groups In Operational DS After Controller Restarts
226 [Documentation] Check Groups in Operational DS after controller is restarted.
227 Check Number Of Groups ${all_groups}
229 Check Flows In Switch After Controller Restarts
230 [Documentation] Check Flows in switch after controller is restarted..
231 MininetKeywords.Check Flows In Mininet ${mininet_conn_id} ${all_flows}
234 [Documentation] Stop Mininet.
235 MininetKeywords.Stop Mininet And Exit
238 [Documentation] Check no switches in topology.
239 BuiltIn.Wait Until Keyword Succeeds 5s 1s Check No Switches In Topology ${SWITCHES}
243 [Documentation] Create controller session and set variables.
244 ClusterManagement.ClusterManagement_Setup
245 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
246 ${switches} Convert To Integer ${SWITCHES}
247 ${iter} Convert To Integer ${ITER}
248 ${all_groups}= BuiltIn.Evaluate ${switches} * ${iter} * 2
249 ${less_groups}= BuiltIn.Evaluate ${all_groups} - ${switches} * 2
250 # Stale flows/groups feature enabled in Boron onwards.
251 ${less_groups}= CompareStream.Set Variable If At Least Boron ${less_groups} ${all_groups}
252 ${all_flows}= BuiltIn.Evaluate ${switches} * ${iter+1}
253 ${less_flows}= BuiltIn.Evaluate ${all_flows} - ${switches}
254 # Stale flows/groups feature enabled in Boron onwards.
255 ${less_flows}= CompareStream.Set Variable If At Least Boron ${less_flows} ${all_flows}
256 BuiltIn.Set Suite Variable ${switches}
257 BuiltIn.Set Suite Variable ${iter}
258 BuiltIn.Set Suite Variable ${all_groups}
259 BuiltIn.Set Suite Variable ${less_groups}
260 BuiltIn.Set Suite Variable ${all_flows}
261 BuiltIn.Set Suite Variable ${less_flows}
262 BuiltIn.Set Suite Variable ${no_flows} ${SWITCHES}
265 [Documentation] Delete all sessions.
266 ${command} = BuiltIn.Set Variable sudo iptables -v -F
267 Utils.Run Command On Controller cmd=${command}
268 CompareStream.Run Keyword If At Least Boron TemplatedRequests.Put As Json Templated folder=${VAR_DIR}/frm-config mapping={"STALE":"false"} session=session
269 BuiltIn.Run Keyword And Ignore Error RequestsLibrary.Delete Request session ${CONFIG_NODES_API}
270 RequestsLibrary.Delete All Sessions
272 Disconnect Cluster Mininet
273 [Arguments] ${action}=break ${member_index_list}=${EMPTY}
274 [Documentation] Break and restore controller to mininet connection via iptables.
275 ${index_list} = ClusterManagement.List_Indices_Or_All given_list=${member_index_list}
276 : FOR ${index} IN @{index_list}
277 \ ${rule} = BuiltIn.Set Variable OUTPUT -p all --source ${ODL_SYSTEM_${index}_IP} --destination ${TOOLS_SYSTEM_IP} -j DROP
278 \ ${command} = BuiltIn.Set Variable If '${action}'=='restore' sudo /sbin/iptables -D ${rule} sudo /sbin/iptables -I ${rule}
279 \ Log To Console ${ODL_SYSTEM_${index}_IP}
280 \ Utils.Run Command On Controller ${ODL_SYSTEM_${index}_IP} cmd=${command}
281 \ ${command} = BuiltIn.Set Variable sudo /sbin/iptables -L -n
282 \ ${output} = Utils.Run Command On Controller cmd=${command}
283 \ BuiltIn.Log ${output}
286 [Arguments] ${iter}=1 ${member_index}=1
287 [Documentation] Add ${ITER} groups type 1 & 2 and flows in every switch.
288 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
289 : FOR ${switch} IN RANGE 1 ${switches+1}
290 \ TemplatedRequests.Post As Json Templated folder=${VAR_DIR}/add-group-1 mapping={"SWITCH":"${switch}"} session=${session} iterations=${iter}
291 \ TemplatedRequests.Post As Json Templated folder=${VAR_DIR}/add-group-2 mapping={"SWITCH":"${switch}"} session=${session} iterations=${iter}
292 \ TemplatedRequests.Post As Json Templated folder=${VAR_DIR}/add-flow mapping={"SWITCH":"${switch}"} session=${session} iterations=${iter}
294 Add Single Group And Flow
295 [Arguments] ${member_index}=1
296 [Documentation] Add 1 group 1&2 and 1 flow in every switch.
297 Add Groups And Flows 1 ${member_index}
299 Remove Single Group And Flow
300 [Arguments] ${member_index}=1
301 [Documentation] Remove 1 group 1&2 and 1 flow in every switch.
302 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
303 : FOR ${switch} IN RANGE 1 ${switches+1}
304 \ RequestsLibrary.Delete Request ${session} ${CONFIG_NODES_API}/node/openflow:${switch}/table/0/flow/1
305 \ RequestsLibrary.Delete Request ${session} ${CONFIG_NODES_API}/node/openflow:${switch}/group/1
306 \ RequestsLibrary.Delete Request ${session} ${CONFIG_NODES_API}/node/openflow:${switch}/group/1000
308 Check Linear Topology
309 [Arguments] ${switches} ${member_index}=1
310 [Documentation] Check Linear topology.
311 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
312 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
314 Should Be Equal As Strings ${resp.status_code} 200
315 : FOR ${switch} IN RANGE 1 ${switches+1}
316 \ Should Contain ${resp.content} "node-id":"openflow:${switch}"
317 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:1"
318 \ Should Contain ${resp.content} "tp-id":"openflow:${switch}:2"
319 \ Should Contain ${resp.content} "source-tp":"openflow:${switch}:2"
320 \ Should Contain ${resp.content} "dest-tp":"openflow:${switch}:2"
321 \ ${edge} Evaluate ${switch}==1 or ${switch}==${switches}
322 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "tp-id":"openflow:${switch}:3"
323 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "source-tp":"openflow:${switch}:3"
324 \ Run Keyword Unless ${edge} Should Contain ${resp.content} "dest-tp":"openflow:${switch}:3
326 Check No Switches In Inventory
327 [Arguments] ${switches} ${member_index}=1
328 [Documentation] Check no switch is in inventory
329 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
330 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
332 Should Be Equal As Strings ${resp.status_code} 200
333 : FOR ${switch} IN RANGE 1 ${switches+1}
334 \ Should Not Contain ${resp.content} "openflow:${switch}"
336 Check Number Of Flows
337 [Arguments] ${flows} ${member_index}=1
338 [Documentation] Check number of flows in the inventory.
339 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
340 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
342 Should Be Equal As Strings ${resp.status_code} 200
343 ${count}= Get Count ${resp.content} "priority"
344 Should Be Equal As Integers ${count} ${flows}
346 Check Number Of Groups
347 [Arguments] ${groups} ${member_index}=1
348 [Documentation] Check number of groups in the inventory.
349 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
350 ${resp}= RequestsLibrary.Get Request ${session} ${OPERATIONAL_NODES_API}
352 Should Be Equal As Strings ${resp.status_code} 200
353 ${group_count}= Get Count ${resp.content} "group-type"
354 ${count}= CompareStream.Set_Variable_If_At Least_Boron ${group_count} ${group_count/2}
355 Should Be Equal As Integers ${count} ${groups}
357 Check No Switches In Topology
358 [Arguments] ${switches} ${member_index}=1
359 [Documentation] Check no switch is in topology
360 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
361 ${resp} RequestsLibrary.Get Request ${session} ${OPERATIONAL_TOPO_API}
363 Should Be Equal As Strings ${resp.status_code} 200
364 : FOR ${switch} IN RANGE 1 ${switches+1}
365 \ Should Not Contain ${resp.content} openflow:${switch}