7 Library RequestsLibrary
8 Variables ../variables/Variables.py
12 ${vlan_topo_10} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
13 ${vlan_topo_13} sudo mn --controller=remote,ip=${CONTROLLER} --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=${CONTROLLER} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
29 ${pathpolicy_topo_10} sudo mn --controller=remote,ip=${CONTROLLER} --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://${CONTROLLER}:${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://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
55 [Documentation] Stop VTN Manager Test Suite
59 [Documentation] Check if VTN Manager is up.
60 ${resp}= RequestsLibrary.Get 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 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 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 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 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 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 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 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 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 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 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 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 ${MININET} ${pathpolicy_topo_13} ${custom}
154 Start PathSuiteVtnMaTestOF10
155 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
157 Start Mininet ${MININET} ${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 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 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 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 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 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 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 Write ${host1} ping -c 10 ${host2}
213 ${result} Read Until mininet>
214 Should Contain ${result} 64 bytes
216 Mininet Ping Should Not Succeed
217 [Arguments] ${host1} ${host2}
218 Write ${host1} ping -c 10 ${host2}
219 ${result} Read Until mininet>
220 Should Not Contain ${result} 64 bytes
223 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
224 [Documentation] Delete a interface with specified parameters.
225 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
226 Should Be Equal As Strings ${resp.status_code} 200
231 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
232 Set Suite Variable ${mininet_conn_id1}
233 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
234 Execute Command sudo ovs-vsctl set-manager ptcp:6644
235 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
236 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
237 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
238 ${result} Read Until mininet>
241 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
242 [Documentation] Create a vlanmap
243 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
244 Should Be Equal As Strings ${resp.status_code} 201
247 [Arguments] ${vtn_name}
248 [Documentation] Get data flow.
249 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
250 Should Be Equal As Strings ${resp.status_code} 200
253 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
254 [Documentation] Remove a portmap for a interface of a vbridge
255 ${json_data}= json.dumps ${portmap_data}
256 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
257 Should Be Equal As Strings ${resp.status_code} 200
259 Verify FlowMacAddress
260 [Arguments] ${host1} ${host2} ${OF_VERSION}
261 [Documentation] Verify the source and destination mac address.
262 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
263 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
265 Verify Flows On OpenFlow
266 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
267 [Documentation] Verify the mac addresses on the specified open flow.
268 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
269 Should Be Equal As Strings ${booleanValue} True
271 Verify RemovedFlowMacAddress
272 [Arguments] ${host1} ${host2} ${OF_VERSION}
273 [Documentation] Verify the removed source and destination mac address.
274 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
275 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
277 Verify Removed Flows On OpenFlow
278 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
279 [Documentation] Verify the removed mac addresses on the specified open flow.
280 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
281 Should Not Be Equal As Strings ${booleanValue} True
284 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
285 [Documentation] Verify the source and destination mac address after ping in the dumpflows
286 write ${host1} ifconfig -a | grep HWaddr
287 ${sourcemacaddr} Read Until mininet>
288 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
289 ${sourcemacaddr}= Get from List ${macaddress} ${index}
290 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
291 write ${host2} ifconfig -a | grep HWaddr
292 ${destmacaddr} Read Until mininet>
293 ${macaddress}= Split String ${destmacaddr} ${SPACE}
294 ${destmacaddr}= Get from List ${macaddress} ${index}
295 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
297 ${result} Read Until mininet>
298 Should Contain ${result} ${sourcemacaddress}
299 Should Contain ${result} ${destmacaddress}
302 [Arguments] ${cond_name} ${flowcond_data}
303 [Documentation] Create a flowcondition for a interface of a vbridge
304 ${json_data}= json.dumps ${flowcond_data}
305 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
306 Should Be Equal As Strings ${resp.status_code} 201
308 Delete a flowcondition
309 [Arguments] ${cond_name}
310 [Documentation] Delete a flowcondition for a interface of a vbridge
311 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/flowconditions/${cond_name}
312 Should Be Equal As Strings ${resp.status_code} 200
315 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
316 [Documentation] Create a flowfilter for a vtn
317 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
318 Should Be Equal As Strings ${resp.status_code} 201
321 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
322 [Documentation] Create a flowfilter for a vtn
323 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
324 Should Be Equal As Strings ${resp.status_code} 201
327 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
328 [Documentation] Create a flowfilter for a vbr
329 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
330 Should Be Equal As Strings ${resp.status_code} 201
333 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
334 [Documentation] Create a flowfilter for a vtn
335 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
336 Should Be Equal As Strings ${resp.status_code} 200
338 Add a flowfilter for drop
339 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
340 [Documentation] Create a flowfilter for a vtn
341 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
342 Should Be Equal As Strings ${resp.status_code} 200
344 Verify Flow Entry for Inet Flowfilter
345 [Documentation] Verify switch flow entry using flowfilter for a vtn
346 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
347 Should Not Be Equal As Strings ${booleanValue} True
349 Verify Removed Flow Entry for Inet Drop Flowfilter
350 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
351 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
352 Should Be Equal As Strings ${booleanValue} True
354 Verify Actions on Flow Entry
355 write ${DUMPFLOWS_OF13}
356 ${result} Read Until mininet>
357 : FOR ${flowElement} IN @{FLOWELMENTS}
358 \ should Contain ${result} ${flowElement}