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
37 ${flowcond_restconfigdata} {"input":{"operation":"SET","present":"false","name":"cond_1","vtn-flow-match":[{"vtn-ether-match":{"destination-address":"ba:bd:0f:e3:a8:c8","ether-type":"2048","source-address":"ca:9e:58:0c:1e:f0","vlan-id": "1"},"vtn-inet-match":{"source-network":"10.0.0.1/32","protocol":1,"destination-network":"10.0.0.2/32"},"index":"1"}]}}
41 [Documentation] Start VTN Manager Init Test Suite
42 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
43 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
47 [Documentation] Stop VTN Manager Test Suite
52 [Documentation] Start VTN Manager Test Suite
53 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
55 Start SuiteVtnMaRestConfTest
56 [Documentation] Start VTN Manager Rest Config Api Test Suite
57 Create Session session http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
60 [Documentation] Stop VTN Manager Test Suite
64 [Documentation] Check if VTN Manager is up.
65 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}
66 Should Be Equal As Strings ${resp.status_code} 200
68 Fetch vtn switch inventory
69 [Arguments] ${sw_name}
70 [Documentation] Check if Switch is detected.
71 ${resp}= RequestsLibrary.Get session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
72 Should Be Equal As Strings ${resp.status_code} 200
75 [Arguments] ${vtn_name} ${vtn_data}
76 [Documentation] Create a vtn with specified parameters.
77 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
78 Should Be Equal As Strings ${resp.status_code} 201
81 [Arguments] ${vtn_name}
82 [Documentation] Create a vtn with specified parameters.
83 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}
84 Should Be Equal As Strings ${resp.status_code} 200
87 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
88 [Documentation] Create a vBridge in a VTN
89 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
90 Should Be Equal As Strings ${resp.status_code} 201
93 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
94 [Documentation] Create a interface into a vBridge of a VTN
95 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
96 Should Be Equal As Strings ${resp.status_code} 201
99 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
100 [Documentation] Create a portmap for a interface of a vbridge
101 ${json_data}= json.dumps ${portmap_data}
102 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
103 Should Be Equal As Strings ${resp.status_code} 200
106 [Arguments] ${vtn_name} ${vBridge_name}
107 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
108 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
109 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
110 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
111 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
112 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
115 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
116 [Documentation] Verify whether the required attributes exists.
117 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
118 \ should Contain ${resp.content} ${dataflowElement}
121 [Arguments] ${pathmap_data}
122 [Documentation] Create a pathmap for a vtn
123 ${json_data}= json.dumps ${pathmap_data}
124 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
125 Should Be Equal As Strings ${resp.status_code} 201
128 [Documentation] Get a pathmap for a vtn.
129 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
130 : FOR ${pathElement} IN @{PATHMAP_ATTR}
131 \ should Contain ${resp.content} ${pathElement}
134 [Arguments] ${pathpolicy_data}
135 [Documentation] Create a pathpolicy for a vtn
136 ${json_data}= json.dumps ${pathpolicy_data}
137 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
138 Should Be Equal As Strings ${resp.status_code} 201
141 [Documentation] Get a pathpolicy for a vtn.
142 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
143 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
144 \ should Contain ${resp.content} ${pathpolicyElement}
146 Verify flowEntryPathPolicy
147 [Arguments] ${of_version} ${port} ${output}
148 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
149 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
151 ${result} Read Until mininet>
152 Should Contain ${result} in_port=${port} actions=${output}
154 Start PathSuiteVtnMaTest
155 [Documentation] Start VTN Manager Test Suite and Mininet
157 Start Mininet ${MININET} ${pathpolicy_topo_13} ${custom}
159 Start PathSuiteVtnMaTestOF10
160 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
162 Start Mininet ${MININET} ${pathpolicy_topo_10} ${custom}
164 Stop PathSuiteVtnMaTest
165 [Documentation] Cleanup/Shutdown work at the completion of all tests.
167 Stop Mininet ${mininet_conn_id}
170 [Documentation] Delete a pathmap for a vtn
171 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathmaps/1
172 Should Be Equal As Strings ${resp.status_code} 200
174 Get a pathmap after delete
175 [Documentation] Get a pathmap for a vtn.
176 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
177 : FOR ${pathElement} IN @{PATHMAP_ATTR}
178 \ should Not Contain ${resp.content} ${pathElement}
181 [Documentation] Delete a pathpolicy for a vtn
182 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathpolicies/1
183 Should Be Equal As Strings ${resp.status_code} 200
185 Get a pathpolicy after delete
186 [Documentation] Get a pathpolicy for a vtn after delete.
187 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
188 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
189 \ should Not Contain ${resp.content} ${pathpolicyElement}
192 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
193 [Documentation] Create a macmap for a vbridge
194 ${json_data}= json.dumps ${macmap_data}
195 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
196 Should Be Equal As Strings ${resp.status_code} 201
198 Get DynamicMacAddress
200 [Documentation] Get Dynamic mac address of Host
201 write ${h} ifconfig -a | grep HWaddr
202 ${source} Read Until mininet>
203 ${HWaddress}= Split String ${source} ${SPACE}
204 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
205 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
206 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
208 Add a vBridgeMacMapping
209 [Arguments] ${tenant_name} ${Bridge_name} ${bridge_macmap_data}
210 [Documentation] Create a vbridge macmap for a bridge
211 ${json_data}= json.dumps ${bridge_macmap_data}
212 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${tenant_name}/vbridges/${Bridge_name}/macmap/allow data=${json_data} headers=${HEADERS}
213 Should Be Equal As Strings ${resp.status_code} 201
215 Mininet Ping Should Succeed
216 [Arguments] ${host1} ${host2}
217 Write ${host1} ping -c 10 ${host2}
218 ${result} Read Until mininet>
219 Should Contain ${result} 64 bytes
221 Mininet Ping Should Not Succeed
222 [Arguments] ${host1} ${host2}
223 Write ${host1} ping -c 10 ${host2}
224 ${result} Read Until mininet>
225 Should Not Contain ${result} 64 bytes
228 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
229 [Documentation] Delete a interface with specified parameters.
230 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
231 Should Be Equal As Strings ${resp.status_code} 200
236 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
237 Set Suite Variable ${mininet_conn_id1}
238 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
239 Execute Command sudo ovs-vsctl set-manager ptcp:6644
240 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
241 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
242 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
243 ${result} Read Until mininet>
246 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
247 [Documentation] Create a vlanmap
248 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
249 Should Be Equal As Strings ${resp.status_code} 201
252 [Arguments] ${vtn_name}
253 [Documentation] Get data flow.
254 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
255 Should Be Equal As Strings ${resp.status_code} 200
258 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
259 [Documentation] Remove a portmap for a interface of a vbridge
260 ${json_data}= json.dumps ${portmap_data}
261 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
262 Should Be Equal As Strings ${resp.status_code} 200
264 Verify FlowMacAddress
265 [Arguments] ${host1} ${host2} ${OF_VERSION}
266 [Documentation] Verify the source and destination mac address.
267 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
268 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
270 Verify Flows On OpenFlow
271 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
272 [Documentation] Verify the mac addresses on the specified open flow.
273 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
274 Should Be Equal As Strings ${booleanValue} True
276 Verify RemovedFlowMacAddress
277 [Arguments] ${host1} ${host2} ${OF_VERSION}
278 [Documentation] Verify the removed source and destination mac address.
279 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
280 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
282 Verify Removed Flows On OpenFlow
283 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
284 [Documentation] Verify the removed mac addresses on the specified open flow.
285 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
286 Should Not Be Equal As Strings ${booleanValue} True
289 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
290 [Documentation] Verify the source and destination mac address after ping in the dumpflows
291 write ${host1} ifconfig -a | grep HWaddr
292 ${sourcemacaddr} Read Until mininet>
293 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
294 ${sourcemacaddr}= Get from List ${macaddress} ${index}
295 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
296 write ${host2} ifconfig -a | grep HWaddr
297 ${destmacaddr} Read Until mininet>
298 ${macaddress}= Split String ${destmacaddr} ${SPACE}
299 ${destmacaddr}= Get from List ${macaddress} ${index}
300 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
302 ${result} Read Until mininet>
303 Should Contain ${result} ${sourcemacaddress}
304 Should Contain ${result} ${destmacaddress}
307 [Arguments] ${cond_name} ${flowcond_data}
308 [Documentation] Create a flowcondition for a interface of a vbridge
309 ${json_data}= json.dumps ${flowcond_data}
310 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
311 Should Be Equal As Strings ${resp.status_code} 201
313 Delete a flowcondition
314 [Arguments] ${cond_name}
315 [Documentation] Delete a flowcondition for a interface of a vbridge
316 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/flowconditions/${cond_name}
317 Should Be Equal As Strings ${resp.status_code} 200
320 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
321 [Documentation] Create a flowfilter for a vtn
322 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
323 Should Be Equal As Strings ${resp.status_code} 201
326 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
327 [Documentation] Create a flowfilter for a vtn
328 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
329 Should Be Equal As Strings ${resp.status_code} 201
332 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
333 [Documentation] Create a flowfilter for a vbr
334 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
335 Should Be Equal As Strings ${resp.status_code} 201
338 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
339 [Documentation] Create a flowfilter for a vtn
340 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
341 Should Be Equal As Strings ${resp.status_code} 200
343 Add a flowfilter for drop
344 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
345 [Documentation] Create a flowfilter for a vtn
346 ${resp}= RequestsLibrary.Put 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 Verify Flow Entry for Inet Flowfilter
350 [Documentation] Verify switch flow entry using flowfilter for a vtn
351 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
352 Should Not Be Equal As Strings ${booleanValue} True
354 Verify Removed Flow Entry for Inet Drop Flowfilter
355 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
356 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
357 Should Be Equal As Strings ${booleanValue} True
359 Verify Actions on Flow Entry
360 write ${DUMPFLOWS_OF13}
361 ${result} Read Until mininet>
362 : FOR ${flowElement} IN @{FLOWELMENTS}
363 \ should Contain ${result} ${flowElement}
365 Add a flowcondition In Restconfig
366 [Documentation] Create a flowcondition using Restconfig Api
367 ${resp}= RequestsLibrary.Post session restconf/operations/vtn-flow-condition:set-flow-condition data=${flowcond_restconfigdata}
368 Should Be Equal As Strings ${resp.status_code} 200
370 Get flowconditions In Restconfig
371 [Documentation] Retrieve the list of flowconditions created
372 ${resp}= RequestsLibrary.Get session restconf/operational/vtn-flow-condition:vtn-flow-conditions
373 Should Be Equal As Strings ${resp.status_code} 200
375 Get flowcondition In Restconfig
376 [Arguments] ${flowcond_name} ${retrieve}
377 [Documentation] Retrieve the flowcondition by name
378 ${resp}= RequestsLibrary.Get session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
379 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
380 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
382 Remove flowcondition In Restconfig
383 [Arguments] ${flowcond_name}
384 [Documentation] Remove the flowcondition by name
385 ${resp}= RequestsLibrary.Post session restconf/operations/vtn-flow-condition:remove-flow-condition {"input": {"name": "${flowcond_name}"}}
386 Should Be Equal As Strings ${resp.status_code} 200