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 [Documentation] Start VTN Manager Init Test Suite
41 Create Session session http://${ODL_SYSTEM_IP}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
42 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
46 [Documentation] Stop VTN Manager Test Suite
51 [Documentation] Start VTN Manager Test Suite
52 Create Session session http://${ODL_SYSTEM_IP}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
55 [Documentation] Stop VTN Manager Test Suite
59 [Documentation] Check if VTN Manager is up.
60 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}
61 Should Be Equal As Strings ${resp.status_code} 200
63 Fetch vtn switch inventory
64 [Arguments] ${sw_name}
65 [Documentation] Check if Switch is detected.
66 ${resp}= RequestsLibrary.Get Request session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
67 Should Be Equal As Strings ${resp.status_code} 200
70 [Arguments] ${vtn_name} ${vtn_data}
71 [Documentation] Create a vtn with specified parameters.
72 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
73 Should Be Equal As Strings ${resp.status_code} 201
76 [Arguments] ${vtn_name}
77 [Documentation] Create a vtn with specified parameters.
78 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}
79 Should Be Equal As Strings ${resp.status_code} 200
82 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
83 [Documentation] Create a vBridge in a VTN
84 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
85 Should Be Equal As Strings ${resp.status_code} 201
88 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
89 [Documentation] Create a interface into a vBridge of a VTN
90 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
91 Should Be Equal As Strings ${resp.status_code} 201
94 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
95 [Documentation] Create a portmap for a interface of a vbridge
96 ${json_data}= json.dumps ${portmap_data}
97 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
98 Should Be Equal As Strings ${resp.status_code} 200
101 [Arguments] ${vtn_name} ${vBridge_name}
102 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
103 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
104 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
105 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
106 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
107 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
110 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
111 [Documentation] Verify whether the required attributes exists.
112 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
113 \ should Contain ${resp.content} ${dataflowElement}
116 [Arguments] ${pathmap_data}
117 [Documentation] Create a pathmap for a vtn
118 ${json_data}= json.dumps ${pathmap_data}
119 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
120 Should Be Equal As Strings ${resp.status_code} 201
123 [Documentation] Get a pathmap for a vtn.
124 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathmaps
125 : FOR ${pathElement} IN @{PATHMAP_ATTR}
126 \ should Contain ${resp.content} ${pathElement}
129 [Arguments] ${pathpolicy_data}
130 [Documentation] Create a pathpolicy for a vtn
131 ${json_data}= json.dumps ${pathpolicy_data}
132 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
133 Should Be Equal As Strings ${resp.status_code} 201
136 [Documentation] Get a pathpolicy for a vtn.
137 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathpolicies/${policy_id}
138 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
139 \ should Contain ${resp.content} ${pathpolicyElement}
141 Verify flowEntryPathPolicy
142 [Arguments] ${of_version} ${port} ${output}
143 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
144 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
146 ${result} Read Until mininet>
147 Should Contain ${result} in_port=${port} actions=${output}
149 Start PathSuiteVtnMaTest
150 [Documentation] Start VTN Manager Test Suite and Mininet
152 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
154 Start PathSuiteVtnMaTestOF10
155 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
157 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
159 Stop PathSuiteVtnMaTest
160 [Documentation] Cleanup/Shutdown work at the completion of all tests.
162 Stop Mininet ${mininet_conn_id}
165 [Documentation] Delete a pathmap for a vtn
166 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/pathmaps/1
167 Should Be Equal As Strings ${resp.status_code} 200
169 Get a pathmap after delete
170 [Documentation] Get a pathmap for a vtn.
171 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathmaps
172 : FOR ${pathElement} IN @{PATHMAP_ATTR}
173 \ should Not Contain ${resp.content} ${pathElement}
176 [Documentation] Delete a pathpolicy for a vtn
177 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/pathpolicies/1
178 Should Be Equal As Strings ${resp.status_code} 200
180 Get a pathpolicy after delete
181 [Documentation] Get a pathpolicy for a vtn after delete.
182 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT}/pathpolicies/${policy_id}
183 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
184 \ should Not Contain ${resp.content} ${pathpolicyElement}
187 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
188 [Documentation] Create a macmap for a vbridge
189 ${json_data}= json.dumps ${macmap_data}
190 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
191 Should Be Equal As Strings ${resp.status_code} 201
193 Get DynamicMacAddress
195 [Documentation] Get Dynamic mac address of Host
196 write ${h} ifconfig -a | grep HWaddr
197 ${source} Read Until mininet>
198 ${HWaddress}= Split String ${source} ${SPACE}
199 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
200 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
201 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
203 Add a vBridgeMacMapping
204 [Arguments] ${tenant_name} ${Bridge_name} ${bridge_macmap_data}
205 [Documentation] Create a vbridge macmap for a bridge
206 ${json_data}= json.dumps ${bridge_macmap_data}
207 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${tenant_name}/vbridges/${Bridge_name}/macmap/allow data=${json_data} headers=${HEADERS}
208 Should Be Equal As Strings ${resp.status_code} 201
210 Mininet Ping Should Succeed
211 [Arguments] ${host1} ${host2}
212 [Documentation] Ping hosts to check connectivity
213 Write ${host1} ping -c 1 ${host2}
214 ${result} Read Until mininet>
215 Should Contain ${result} 64 bytes
217 Mininet Ping Should Not Succeed
218 [Arguments] ${host1} ${host2}
219 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
220 Write ${host1} ping -c 3 ${host2}
221 ${result} Read Until mininet>
222 Should Not Contain ${result} 64 bytes
225 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
226 [Documentation] Delete a interface with specified parameters.
227 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
228 Should Be Equal As Strings ${resp.status_code} 200
233 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
234 Set Suite Variable ${mininet_conn_id1}
235 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
236 Execute Command sudo ovs-vsctl set-manager ptcp:6644
237 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
238 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
239 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
240 ${result} Read Until mininet>
243 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
244 [Documentation] Create a vlanmap
245 ${resp}= RequestsLibrary.Post Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
246 Should Be Equal As Strings ${resp.status_code} 201
249 [Arguments] ${vtn_name}
250 [Documentation] Get data flow.
251 ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
252 Should Be Equal As Strings ${resp.status_code} 200
255 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
256 [Documentation] Remove a portmap for a interface of a vbridge
257 ${json_data}= json.dumps ${portmap_data}
258 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
259 Should Be Equal As Strings ${resp.status_code} 200
261 Verify FlowMacAddress
262 [Arguments] ${host1} ${host2} ${OF_VERSION}
263 [Documentation] Verify the source and destination mac address.
264 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
265 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
267 Verify Flows On OpenFlow
268 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
269 [Documentation] Verify the mac addresses on the specified open flow.
270 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
271 Should Be Equal As Strings ${booleanValue} True
273 Verify RemovedFlowMacAddress
274 [Arguments] ${host1} ${host2} ${OF_VERSION}
275 [Documentation] Verify the removed source and destination mac address.
276 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
277 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
279 Verify Removed Flows On OpenFlow
280 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
281 [Documentation] Verify the removed mac addresses on the specified open flow.
282 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
283 Should Not Be Equal As Strings ${booleanValue} True
286 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
287 [Documentation] Verify the source and destination mac address after ping in the dumpflows
288 write ${host1} ifconfig -a | grep HWaddr
289 ${sourcemacaddr} Read Until mininet>
290 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
291 ${sourcemacaddr}= Get from List ${macaddress} ${index}
292 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
293 write ${host2} ifconfig -a | grep HWaddr
294 ${destmacaddr} Read Until mininet>
295 ${macaddress}= Split String ${destmacaddr} ${SPACE}
296 ${destmacaddr}= Get from List ${macaddress} ${index}
297 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
299 ${result} Read Until mininet>
300 Should Contain ${result} ${sourcemacaddress}
301 Should Contain ${result} ${destmacaddress}
304 [Arguments] ${cond_name} ${flowcond_data}
305 [Documentation] Create a flowcondition for a interface of a vbridge
306 ${json_data}= json.dumps ${flowcond_data}
307 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
308 Should Be Equal As Strings ${resp.status_code} 201
310 Delete a flowcondition
311 [Arguments] ${cond_name}
312 [Documentation] Delete a flowcondition for a interface of a vbridge
313 ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT}/flowconditions/${cond_name}
314 Should Be Equal As Strings ${resp.status_code} 200
317 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
318 [Documentation] Create a flowfilter for a vtn
319 ${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}
320 Should Be Equal As Strings ${resp.status_code} 201
323 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
324 [Documentation] Create a flowfilter for a vtn
325 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
326 Should Be Equal As Strings ${resp.status_code} 201
329 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
330 [Documentation] Create a flowfilter for a vbr
331 ${resp}= RequestsLibrary.Put Request session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
332 Should Be Equal As Strings ${resp.status_code} 201
335 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
336 [Documentation] Create a flowfilter for a vtn
337 ${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}
338 Should Be Equal As Strings ${resp.status_code} 200
340 Add a flowfilter for drop
341 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
342 [Documentation] Create a flowfilter for a vtn
343 ${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}
344 Should Be Equal As Strings ${resp.status_code} 200
346 Verify Flow Entry for Inet Flowfilter
347 [Documentation] Verify switch flow entry using flowfilter for a vtn
348 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
349 Should Not Be Equal As Strings ${booleanValue} True
351 Verify Removed Flow Entry for Inet Drop Flowfilter
352 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
353 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
354 Should Be Equal As Strings ${booleanValue} True
356 Verify Actions on Flow Entry
357 write ${DUMPFLOWS_OF13}
358 ${result} Read Until mininet>
359 : FOR ${flowElement} IN @{FLOWELMENTS}
360 \ should Contain ${result} ${flowElement}