7 Library RequestsLibrary
8 Variables ../variables/Variables.py
12 ${vlan_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom vlan_vtn_test.py --topo vlantopo
13 ${vlan_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom vlan_vtn_test.py --topo vlantopo --switch ovsk,protocols=OpenFlow13
14 ${REST_CONTEXT_VTNS} controller/nb/v2/vtn/default/vtns
15 ${REST_CONTEXT} controller/nb/v2/vtn/default
16 ${VERSION_VTN} controller/nb/v2/vtn/version
17 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
18 ${DUMPFLOWS_OF10} dpctl dump-flows -O OpenFlow10
19 ${DUMPFLOWS_OF13} dpctl dump-flows -O OpenFlow13
21 @{FLOWELMENTS} nw_src=10.0.0.1 nw_dst=10.0.0.3 actions=drop
22 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1","interface":"if2"}
23 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2","interface":"if3"}
24 ${vlanmap_bridge1} {"vlan": "200"}
25 ${vlanmap_bridge2} {"vlan": "300"}
26 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1_vlan"}
27 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2_vlan"}
28 ${pathpolicy_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
29 ${pathpolicy_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow10
30 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
32 @{PATHPOLICY_ATTR} "id":"1" "type":"OF" "name":"s4-eth2"
33 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
35 ${out_before_pathpolicy} output:2
36 ${out_after_pathpolicy} output:3
40 [Arguments] ${version_flag}=none
41 [Documentation] Start VTN Manager Init Test Suite
42 Create Session session http://${ODL_SYSTEM_IP}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
43 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
45 Run Keyword If '${version_flag}' == 'OF13' Set Global Variable ${OPENFLOW_VERSION} OF13
46 ... ELSE Set Global Variable ${OPENFLOW_VERSION} OF10
49 [Documentation] Stop VTN Manager Test Suite
53 [Documentation] Start VTN Manager Test Suite
54 Create Session session http://${ODL_SYSTEM_IP}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
57 [Documentation] Stop VTN Manager Test Suite
61 [Documentation] Add Flow entried to handle table miss situation
62 Write dpctl add-flow priority=0,actions=output:CONTROLLER -OOpenFlow13
66 [Documentation] Check if VTN Manager is up.
67 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}
68 Should Be Equal As Strings ${resp.status_code} 200
70 Fetch vtn switch inventory
71 [Arguments] ${sw_name}
72 [Documentation] Check if Switch is detected.
73 ${resp}= RequestsLibrary.Get Request session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
74 Should Be Equal As Strings ${resp.status_code} 200
77 [Arguments] ${vtn_name} ${vtn_data}
78 [Documentation] Create a vtn with specified parameters.
79 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
80 Should Be Equal As Strings ${resp.status_code} 201
83 [Arguments] ${vtn_name}
84 [Documentation] Create a vtn with specified parameters.
85 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}
86 Should Be Equal As Strings ${resp.status_code} 200
89 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
90 [Documentation] Create a vBridge in a VTN
91 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
92 Should Be Equal As Strings ${resp.status_code} 201
95 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
96 [Documentation] Create a interface into a vBridge of a VTN
97 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
98 Should Be Equal As Strings ${resp.status_code} 201
101 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
102 [Documentation] Create a portmap for a interface of a vbridge
103 ${json_data}= json.dumps ${portmap_data}
104 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
105 Should Be Equal As Strings ${resp.status_code} 200
108 [Arguments] ${vtn_name} ${vBridge_name}
109 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
110 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
111 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
112 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
113 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
114 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
117 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
118 [Documentation] Verify whether the required attributes exists.
119 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
120 \ should Contain ${resp.content} ${dataflowElement}
123 [Arguments] ${pathmap_data}
124 [Documentation] Create a pathmap for a vtn
125 ${json_data}= json.dumps ${pathmap_data}
126 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
127 Should Be Equal As Strings ${resp.status_code} 201
130 [Documentation] Get a pathmap for a vtn.
131 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathmaps
132 : FOR ${pathElement} IN @{PATHMAP_ATTR}
133 \ should Contain ${resp.content} ${pathElement}
136 [Arguments] ${pathpolicy_data}
137 [Documentation] Create a pathpolicy for a vtn
138 ${json_data}= json.dumps ${pathpolicy_data}
139 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
140 Should Be Equal As Strings ${resp.status_code} 201
143 [Documentation] Get a pathpolicy for a vtn.
144 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathpolicies/${policy_id}
145 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
146 \ should Contain ${resp.content} ${pathpolicyElement}
148 Verify flowEntryPathPolicy
149 [Arguments] ${of_version} ${port} ${output}
150 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
151 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
153 ${result} Read Until mininet>
154 Should Contain ${result} in_port=${port} actions=${output}
156 Start PathSuiteVtnMaTest
157 [Documentation] Start VTN Manager Test Suite and Mininet
159 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
161 Start PathSuiteVtnMaTestOF10
162 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
164 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
166 Stop PathSuiteVtnMaTest
167 [Documentation] Cleanup/Shutdown work at the completion of all tests.
169 Stop Mininet ${mininet_conn_id}
172 [Documentation] Delete a pathmap for a vtn
173 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/pathmaps/1
174 Should Be Equal As Strings ${resp.status_code} 200
176 Get a pathmap after delete
177 [Documentation] Get a pathmap for a vtn.
178 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathmaps
179 : FOR ${pathElement} IN @{PATHMAP_ATTR}
180 \ should Not Contain ${resp.content} ${pathElement}
183 [Documentation] Delete a pathpolicy for a vtn
184 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/pathpolicies/1
185 Should Be Equal As Strings ${resp.status_code} 200
187 Get a pathpolicy after delete
188 [Documentation] Get a pathpolicy for a vtn after delete.
189 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathpolicies/${policy_id}
190 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
191 \ should Not Contain ${resp.content} ${pathpolicyElement}
194 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
195 [Documentation] Create a macmap for a vbridge
196 ${json_data}= json.dumps ${macmap_data}
197 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
198 Should Be Equal As Strings ${resp.status_code} 201
200 Get DynamicMacAddress
202 [Documentation] Get Dynamic mac address of Host
203 write ${h} ifconfig -a | grep HWaddr
204 ${source} Read Until mininet>
205 ${HWaddress}= Split String ${source} ${SPACE}
206 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
207 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
208 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
210 Add a vBridgeMacMapping
211 [Arguments] ${tenant_name} ${Bridge_name} ${bridge_macmap_data}
212 [Documentation] Create a vbridge macmap for a bridge
213 ${json_data}= json.dumps ${bridge_macmap_data}
214 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${tenant_name}/vbridges/${Bridge_name}/macmap/allow data=${json_data} headers=${HEADERS}
215 Should Be Equal As Strings ${resp.status_code} 201
217 Mininet Ping Should Succeed
218 [Arguments] ${host1} ${host2}
219 [Documentation] Ping hosts to check connectivity
220 Write ${host1} ping -c 1 ${host2}
221 ${result} Read Until mininet>
222 Should Contain ${result} 64 bytes
224 Mininet Ping Should Not Succeed
225 [Arguments] ${host1} ${host2}
226 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
227 Write ${host1} ping -c 3 ${host2}
228 ${result} Read Until mininet>
229 Should Not Contain ${result} 64 bytes
232 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
233 [Documentation] Delete a interface with specified parameters.
234 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
235 Should Be Equal As Strings ${resp.status_code} 200
239 [Documentation] Create custom topology for vlan functionality
240 Install Package On Ubuntu System vlan
241 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
242 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
245 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
246 [Documentation] Create a vlanmap
247 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
248 Should Be Equal As Strings ${resp.status_code} 201
251 [Arguments] ${vtn_name}
252 [Documentation] Get data flow.
253 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
254 Should Be Equal As Strings ${resp.status_code} 200
257 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
258 [Documentation] Remove a portmap for a interface of a vbridge
259 ${json_data}= json.dumps ${portmap_data}
260 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
261 Should Be Equal As Strings ${resp.status_code} 200
263 Verify FlowMacAddress
264 [Arguments] ${host1} ${host2} ${OF_VERSION}
265 [Documentation] Verify the source and destination mac address.
266 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
267 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
269 Verify Flows On OpenFlow
270 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
271 [Documentation] Verify the mac addresses on the specified open flow.
272 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
273 Should Be Equal As Strings ${booleanValue} True
275 Verify RemovedFlowMacAddress
276 [Arguments] ${host1} ${host2} ${OF_VERSION}
277 [Documentation] Verify the removed source and destination mac address.
278 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
279 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
281 Verify Removed Flows On OpenFlow
282 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
283 [Documentation] Verify the removed mac addresses on the specified open flow.
284 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
285 Should Not Be Equal As Strings ${booleanValue} True
288 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
289 [Documentation] Verify the source and destination mac address after ping in the dumpflows
290 write ${host1} ifconfig -a | grep HWaddr
291 ${sourcemacaddr} Read Until mininet>
292 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
293 ${sourcemacaddr}= Get from List ${macaddress} ${index}
294 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
295 write ${host2} ifconfig -a | grep HWaddr
296 ${destmacaddr} Read Until mininet>
297 ${macaddress}= Split String ${destmacaddr} ${SPACE}
298 ${destmacaddr}= Get from List ${macaddress} ${index}
299 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
301 ${result} Read Until mininet>
302 Should Contain ${result} ${sourcemacaddress}
303 Should Contain ${result} ${destmacaddress}
306 [Arguments] ${cond_name} ${flowcond_data}
307 [Documentation] Create a flowcondition for a interface of a vbridge
308 ${json_data}= json.dumps ${flowcond_data}
309 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
310 Should Be Equal As Strings ${resp.status_code} 201
312 Delete a flowcondition
313 [Arguments] ${cond_name}
314 [Documentation] Delete a flowcondition for a interface of a vbridge
315 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/flowconditions/${cond_name}
316 Should Be Equal As Strings ${resp.status_code} 200
319 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
320 [Documentation] Create a flowfilter for a vtn
321 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
322 Should Be Equal As Strings ${resp.status_code} 201
325 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
326 [Documentation] Create a flowfilter for a vtn
327 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
328 Should Be Equal As Strings ${resp.status_code} 201
331 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
332 [Documentation] Create a flowfilter for a vbr
333 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
334 Should Be Equal As Strings ${resp.status_code} 201
337 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
338 [Documentation] Create a flowfilter for a vtn
339 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
340 Should Be Equal As Strings ${resp.status_code} 200
342 Add a flowfilter for drop
343 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
344 [Documentation] Create a flowfilter for a vtn
345 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
346 Should Be Equal As Strings ${resp.status_code} 200
348 Verify Flow Entry for Inet Flowfilter
349 [Documentation] Verify switch flow entry using flowfilter for a vtn
350 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
351 Should Not Be Equal As Strings ${booleanValue} True
353 Verify Removed Flow Entry for Inet Drop Flowfilter
354 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
355 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
356 Should Be Equal As Strings ${booleanValue} True
358 Verify Actions on Flow Entry
359 write ${DUMPFLOWS_OF13}
360 ${result} Read Until mininet>
361 : FOR ${flowElement} IN @{FLOWELMENTS}
362 \ should Contain ${result} ${flowElement}