2 Documentation Cluster OpenFlow library. So far this library is only to be used by OpenFlow cluster test as it is very specific for this test.
5 Library RequestsLibrary
6 Library ${CURDIR}/ScaleClient.py
7 Resource ClusterManagement.robot
8 Resource CompareStream.robot
9 Resource MininetKeywords.robot
11 Resource ../variables/openflowplugin/Variables.robot
12 Variables ../variables/Variables.py
16 @{SHARD_OPER_LIST} inventory topology default entity-ownership
17 @{SHARD_CONF_LIST} inventory topology default
18 ${config_table_0} ${RFC8040_NODES_API}/node=openflow%3A1/flow-node-inventory:table=0
19 ${operational_table_0}
20 ... ${RFC8040_NODES_API}/node=openflow%3A1/flow-node-inventory:table=0?${RFC8040_OPERATIONAL_CONTENT}
22 ... ${RFC8040_NODES_API}/node=openflow%3A1/node-connector=openflow%3A1%3A1?${RFC8040_OPERATIONAL_CONTENT}
26 Get InventoryConfig Shard Status
27 [Documentation] Check Status for Inventory Config shard in OpenFlow application.
28 [Arguments] ${controller_index_list}=${EMPTY}
29 ${inv_conf_leader} ${inv_conf_followers_list}= Wait Until Keyword Succeeds
32 ... ClusterManagement.Get_Leader_And_Followers_For_Shard
33 ... shard_name=inventory
35 ... member_index_list=${controller_index_list}
36 Log config inventory Leader is ${inv_conf_leader} and followers are ${inv_conf_followers_list}
37 RETURN ${inv_conf_leader} ${inv_conf_followers_list}
39 Check OpenFlow Shards Status
40 [Documentation] Check Status for all shards in OpenFlow application.
41 [Arguments] ${controller_index_list}=${EMPTY}
42 CompareStream.Run_Keyword_If_At_Least_Phosphorus
43 ... Collections.Remove Values From List
44 ... ${SHARD_OPER_LIST}
46 Log ${SHARD_OPER_LIST}
47 ClusterManagement.Verify_Leader_Exists_For_Each_Shard
48 ... shard_name_list=${SHARD_OPER_LIST}
49 ... shard_type=operational
50 ... member_index_list=${controller_index_list}
51 ClusterManagement.Verify_Leader_Exists_For_Each_Shard
52 ... shard_name_list=${SHARD_CONF_LIST}
54 ... member_index_list=${controller_index_list}
56 Check OpenFlow Shards Status After Cluster Event
57 [Documentation] Check Shards Status after some cluster event.
58 [Arguments] ${controller_index_list}=${EMPTY}
59 Wait Until Keyword Succeeds
62 ... ClusterOpenFlow.Check OpenFlow Shards Status
63 ... ${controller_index_list}
65 Get OpenFlow Entity Owner Status For One Device
66 [Documentation] Check Entity Owner Status and identify owner and successors for the device ${device}. Request is sent to controller ${controller_index}.
67 [Arguments] ${device} ${controller_index} ${controller_index_list}=${EMPTY} ${after_stop}=False
68 ${owner} ${successor_list}= Wait Until Keyword Succeeds
71 ... ClusterManagement.Verify_Owner_And_Successors_For_Device
72 ... device_name=${device}
73 ... device_type=openflow
74 ... member_index=${controller_index}
75 ... candidate_list=${controller_index_list}
76 ... after_stop=${after_stop}
77 RETURN ${owner} ${successor_list}
79 Check OpenFlow Device Owner
80 [Documentation] Check owner and candidates for the device ${device}. Request is sent to controller ${controller_index}.
81 [Arguments] ${device} ${controller_index} ${expected_owner} ${expected_candidate_list}=${EMPTY}
82 ${owner} ${successor_list}= ClusterManagement.Verify_Owner_And_Successors_For_Device
83 ... device_name=${device}
84 ... device_type=openflow
85 ... member_index=${controller_index}
86 ... candidate_list=${expected_candidate_list}
87 Should Be Equal ${owner} ${expected_owner}
89 Check OpenFlow Network Operational Information For Sample Topology
90 [Documentation] Check devices in tree,2 are in operational inventory and topology in all instances in ${controller_index_list}.
91 ... Inventory should show 1x node_id per device 1x node_id per connector. Topology should show 2x node_id per device + 3x node_id per connector
92 ... + 5x node_id per link termination. TODO: A Keyword that can calculate this based on mininet topology.
93 [Arguments] ${controller_index_list}=${EMPTY}
94 ${dictionary}= Create Dictionary openflow:1=4 openflow:2=5 openflow:3=5
95 Wait Until Keyword Succeeds
98 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
99 ... uri=${RFC8040_OPERATIONAL_NODES_API}
100 ... dictionary=${dictionary}
101 ... member_index_list=${controller_index_list}
102 ${dictionary}= Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
103 Wait Until Keyword Succeeds
106 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
107 ... uri=${RFC8040_OPERATIONAL_TOPO_API}
108 ... dictionary=${dictionary}
109 ... member_index_list=${controller_index_list}
111 Check No OpenFlow Network Operational Information
112 [Documentation] Check device is not in operational inventory or topology in all cluster instances in ${controller_index_list}.
113 [Arguments] ${controller_index_list}=${EMPTY}
114 ${dictionary}= Create Dictionary openflow=0
115 Wait Until Keyword Succeeds
118 ... ClusterManagement.Check_No_Content_Member_List_Or_All
119 ... uri=${RFC8040_OPERATIONAL_NODES_API}
120 ... member_index_list=${controller_index_list}
121 ${dictionary}= Create Dictionary openflow=0
122 Wait Until Keyword Succeeds
125 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
126 ... uri=${RFC8040_OPERATIONAL_TOPO_API}
127 ... dictionary=${dictionary}
128 ... member_index_list=${controller_index_list}
130 Add Sample Flow And Verify
131 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
132 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
133 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
134 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
135 # replicating some of the matches in the flows section. Same comment applies for further keywords.
136 IF '${ODL_OF_PLUGIN}' == 'helium'
137 Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
139 IF '${ODL_OF_PLUGIN}' == 'lithium'
140 Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
142 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All
143 ... ${config_table_0}/flow=1
145 ... ${controller_index}
146 ... ${controller_index_list}
147 Wait Until Keyword Succeeds
150 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
151 ... uri=${operational_table_0}
152 ... dictionary=${dictionary}
153 ... member_index_list=${controller_index_list}
156 [Documentation] Verify sample flow gets applied in all instances in ${controller_index_list}.
157 [Arguments] ${controller_index_list}=${EMPTY}
158 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
159 # replicating some of the matches in the flows section. Same comment applies for further keywords.
160 IF '${ODL_OF_PLUGIN}' == 'helium'
161 Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
163 IF '${ODL_OF_PLUGIN}' == 'lithium'
164 Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
166 Wait Until Keyword Succeeds
169 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
170 ... uri=${operational_table_0}
171 ... dictionary=${dictionary}
172 ... member_index_list=${controller_index_list}
174 Modify Sample Flow And Verify
175 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
176 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
177 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
178 IF '${ODL_OF_PLUGIN}' == 'helium'
179 Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
181 IF '${ODL_OF_PLUGIN}' == 'lithium'
182 Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
184 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All
185 ... ${config_table_0}/flow=1
187 ... ${controller_index}
188 ... ${controller_index_list}
189 Wait Until Keyword Succeeds
192 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
193 ... uri=${operational_table_0}
194 ... dictionary=${dictionary}
195 ... member_index_list=${controller_index_list}
197 Delete Sample Flow And Verify
198 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
199 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
200 ${dictionary}= Create Dictionary 10.0.1.0/24=0
201 ClusterManagement.Delete_And_Check_Member_List_Or_All
202 ... ${config_table_0}/flow=1
203 ... ${controller_index}
204 ... ${controller_index_list}
205 Wait Until Keyword Succeeds
208 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
209 ... uri=${operational_table_0}
210 ... dictionary=${dictionary}
211 ... member_index_list=${controller_index_list}
213 Send RPC Add Sample Flow And Verify
214 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
215 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
216 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
217 IF '${ODL_OF_PLUGIN}' == 'helium'
218 Set Test Variable &{dictionary} 10.0.1.0/24=2
220 IF '${ODL_OF_PLUGIN}' == 'lithium'
221 Set Test Variable &{dictionary} 10.0.1.0/24=1
223 ClusterManagement.Post_As_Json_To_Member
224 ... uri=/rests/operations/sal-flow:add-flow
226 ... member_index=${controller_index}
227 Wait Until Keyword Succeeds
230 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
231 ... uri=${operational_table_0}
232 ... dictionary=${dictionary}
233 ... member_index_list=${controller_index_list}
235 Send RPC Delete Sample Flow And Verify
236 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
237 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
238 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
239 ${dictionary}= Create Dictionary 10.0.1.0/24=0
240 ClusterManagement.Post_As_Json_To_Member
241 ... uri=/rests/operations/sal-flow:remove-flow
243 ... member_index=${controller_index}
244 Wait Until Keyword Succeeds
247 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
248 ... uri=${operational_table_0}
249 ... dictionary=${dictionary}
250 ... member_index_list=${controller_index_list}
252 Take OpenFlow Device Link Down and Verify
253 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
254 [Arguments] ${controller_index_list}=${EMPTY}
255 ${dictionary}= Create Dictionary "link-down":true=1
256 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 down
257 Wait Until Keyword Succeeds
260 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
261 ... uri=${operational_port_1}
262 ... dictionary=${dictionary}
263 ... member_index_list=${controller_index_list}
264 ${dictionary}= Create Dictionary openflow:1=16 openflow:2=14 openflow:3=19
265 Wait Until Keyword Succeeds
268 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
269 ... uri=${RFC8040_OPERATIONAL_TOPO_API}
270 ... dictionary=${dictionary}
271 ... member_index_list=${controller_index_list}
273 Take OpenFlow Device Link Up and Verify
274 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
275 [Arguments] ${controller_index_list}=${EMPTY}
276 ${dictionary}= Create Dictionary "link-down":true=0
277 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 up
278 Wait Until Keyword Succeeds
281 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
282 ... uri=${operational_port_1}
283 ... dictionary=${dictionary}
284 ... member_index_list=${controller_index_list}
285 ${dictionary}= Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
286 Wait Until Keyword Succeeds
289 ... ClusterManagement.Check_Item_Occurrence_Member_List_Or_All
290 ... uri=${RFC8040_OPERATIONAL_TOPO_API}
291 ... dictionary=${dictionary}
292 ... member_index_list=${controller_index_list}
294 Verify Switch Connections Running On Member
295 [Documentation] Check if number of Switch connections on member of given index is equal to ${switch_count}.
296 [Arguments] ${switch_count} ${member_index}
297 ${count}= ScaleClient.Get_Switches_Count controller=${ODL_SYSTEM_${member_index}_IP}
298 BuiltIn.Should_Be_Equal_As_Numbers ${switch_count} ${count}
300 Check Flows Operational Datastore On Member
301 [Documentation] Check if number of Operational Flows on member of given index is equal to ${flow_count}.
302 [Arguments] ${flow_count} ${member_index}
303 ${sw} ${reported_flow} ${found_flow}= ScaleClient.Flow Stats Collected
304 ... controller=${ODL_SYSTEM_${member_index}_IP}
305 BuiltIn.Should_Be_Equal_As_Numbers ${flow_count} ${found_flow}
307 Check Linear Topology On Member
308 [Documentation] Check Linear topology.
309 [Arguments] ${switches} ${member_index}=1
310 ${session}= Resolve_Http_Session_For_Member member_index=${member_index}
311 ${resp}= RequestsLibrary.Get Request ${session} ${RFC8040_OPERATIONAL_TOPO_API}
313 Should Be Equal As Strings ${resp.status_code} 200
314 FOR ${switch} IN RANGE 1 ${switches+1}
315 Should Contain ${resp.text} "node-id":"openflow:${switch}"
316 Should Contain ${resp.text} "tp-id":"openflow:${switch}:1"
317 Should Contain ${resp.text} "tp-id":"openflow:${switch}:2"
318 Should Contain ${resp.text} "source-tp":"openflow:${switch}:2"
319 Should Contain ${resp.text} "dest-tp":"openflow:${switch}:2"
320 ${edge}= Evaluate ${switch}==1 or ${switch}==${switches}
322 Should Contain ${resp.text} "tp-id":"openflow:${switch}:3"
325 Should Contain ${resp.text} "source-tp":"openflow:${switch}:3"
328 Should Contain ${resp.text} "dest-tp":"openflow:${switch}:3
332 Check No Switches On Member
333 [Documentation] Check no switch is in topology
334 [Arguments] ${switches} ${member_index}=1
335 ${session}= Resolve_Http_Session_For_Member member_index=${member_index}
336 ${resp}= RequestsLibrary.Get Request ${session} ${RFC8040_OPERATIONAL_TOPO_API}
338 Should Be Equal As Strings ${resp.status_code} 200
339 FOR ${switch} IN RANGE 1 ${switches+1}
340 Should Not Contain ${resp.text} openflow:${switch}
343 Check Number Of Flows On Member
344 [Documentation] Check number of flows in the inventory.
345 [Arguments] ${flows} ${member_index}=1
346 ${session}= Resolve_Http_Session_For_Member member_index=${member_index}
347 ${resp}= RequestsLibrary.Get Request ${session} ${RFC8040_OPERATIONAL_NODES_API}
349 Should Be Equal As Strings ${resp.status_code} 200
350 ${count}= Get Count ${resp.text} "priority"
351 Should Be Equal As Integers ${count} ${flows}
353 Check Number Of Groups On Member
354 [Documentation] Check number of groups in the inventory.
355 [Arguments] ${groups} ${member_index}=1
356 ${session}= Resolve_Http_Session_For_Member member_index=${member_index}
357 ${resp}= RequestsLibrary.Get Request ${session} ${RFC8040_OPERATIONAL_NODES_API}
359 Should Be Equal As Strings ${resp.status_code} 200
360 ${group_count}= Get Count ${resp.text} "group-type"
361 Should Be Equal As Integers ${group_count} ${groups}