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 Run Keyword If '${OPENFLOW_VERSION}' == 'OF13' Add Table Miss Flows
221 Write ${host1} ping -c 1 ${host2}
222 ${result} Read Until mininet>
223 Should Contain ${result} 64 bytes
225 Mininet Ping Should Not Succeed
226 [Arguments] ${host1} ${host2}
227 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
228 Run Keyword If '${OPENFLOW_VERSION}' == 'OF13' Add Table Miss Flows
229 Write ${host1} ping -c 3 ${host2}
230 ${result} Read Until mininet>
231 Should Not Contain ${result} 64 bytes
234 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
235 [Documentation] Delete a interface with specified parameters.
236 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
237 Should Be Equal As Strings ${resp.status_code} 200
242 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
243 Set Suite Variable ${mininet_conn_id1}
244 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
245 Execute Command sudo ovs-vsctl set-manager ptcp:6644
246 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
247 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
248 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
249 ${result} Read Until mininet>
252 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
253 [Documentation] Create a vlanmap
254 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
255 Should Be Equal As Strings ${resp.status_code} 201
258 [Arguments] ${vtn_name}
259 [Documentation] Get data flow.
260 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
261 Should Be Equal As Strings ${resp.status_code} 200
264 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
265 [Documentation] Remove a portmap for a interface of a vbridge
266 ${json_data}= json.dumps ${portmap_data}
267 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
268 Should Be Equal As Strings ${resp.status_code} 200
270 Verify FlowMacAddress
271 [Arguments] ${host1} ${host2} ${OF_VERSION}
272 [Documentation] Verify the source and destination mac address.
273 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
274 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
276 Verify Flows On OpenFlow
277 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
278 [Documentation] Verify the mac addresses on the specified open flow.
279 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
280 Should Be Equal As Strings ${booleanValue} True
282 Verify RemovedFlowMacAddress
283 [Arguments] ${host1} ${host2} ${OF_VERSION}
284 [Documentation] Verify the removed source and destination mac address.
285 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
286 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
288 Verify Removed Flows On OpenFlow
289 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
290 [Documentation] Verify the removed mac addresses on the specified open flow.
291 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
292 Should Not Be Equal As Strings ${booleanValue} True
295 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
296 [Documentation] Verify the source and destination mac address after ping in the dumpflows
297 write ${host1} ifconfig -a | grep HWaddr
298 ${sourcemacaddr} Read Until mininet>
299 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
300 ${sourcemacaddr}= Get from List ${macaddress} ${index}
301 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
302 write ${host2} ifconfig -a | grep HWaddr
303 ${destmacaddr} Read Until mininet>
304 ${macaddress}= Split String ${destmacaddr} ${SPACE}
305 ${destmacaddr}= Get from List ${macaddress} ${index}
306 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
308 ${result} Read Until mininet>
309 Should Contain ${result} ${sourcemacaddress}
310 Should Contain ${result} ${destmacaddress}
313 [Arguments] ${cond_name} ${flowcond_data}
314 [Documentation] Create a flowcondition for a interface of a vbridge
315 ${json_data}= json.dumps ${flowcond_data}
316 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
317 Should Be Equal As Strings ${resp.status_code} 201
319 Delete a flowcondition
320 [Arguments] ${cond_name}
321 [Documentation] Delete a flowcondition for a interface of a vbridge
322 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/flowconditions/${cond_name}
323 Should Be Equal As Strings ${resp.status_code} 200
326 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
327 [Documentation] Create a flowfilter for a vtn
328 ${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}
329 Should Be Equal As Strings ${resp.status_code} 201
332 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
333 [Documentation] Create a flowfilter for a vtn
334 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
335 Should Be Equal As Strings ${resp.status_code} 201
338 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
339 [Documentation] Create a flowfilter for a vbr
340 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
341 Should Be Equal As Strings ${resp.status_code} 201
344 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
345 [Documentation] Create a flowfilter for a vtn
346 ${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}
347 Should Be Equal As Strings ${resp.status_code} 200
349 Add a flowfilter for drop
350 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
351 [Documentation] Create a flowfilter for a vtn
352 ${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}
353 Should Be Equal As Strings ${resp.status_code} 200
355 Verify Flow Entry for Inet Flowfilter
356 [Documentation] Verify switch flow entry using flowfilter for a vtn
357 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
358 Should Not Be Equal As Strings ${booleanValue} True
360 Verify Removed Flow Entry for Inet Drop Flowfilter
361 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
362 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
363 Should Be Equal As Strings ${booleanValue} True
365 Verify Actions on Flow Entry
366 write ${DUMPFLOWS_OF13}
367 ${result} Read Until mininet>
368 : FOR ${flowElement} IN @{FLOWELMENTS}
369 \ should Contain ${result} ${flowElement}