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 ${VERSION_VTN} controller/nb/v2/vtn/version
15 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
16 ${DUMPFLOWS_OF10} dpctl dump-flows -O OpenFlow10
17 ${DUMPFLOWS_OF13} dpctl dump-flows -O OpenFlow13
19 @{inet_actions} nw_src=10.0.0.1 nw_dst=10.0.0.3
20 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1" "interface-name":"if2"
21 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2" "interface-name":"if3"
22 ${vlanmap_bridge1} 200
23 ${vlanmap_bridge2} 300
24 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1_vlan"
25 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2_vlan"
26 ${out_before_pathpolicy} output:2
27 ${out_after_pathpolicy} output:3
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"
33 ${dscp_action} set_field:32->nw_tos_shifted
34 ${dscp_flow} mod_nw_tos:128
35 @{icmp_action} nw_src=10.0.0.1 nw_dst=10.0.0.3
36 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
37 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
41 [Documentation] Start VTN Manager Rest Config Api Test Suite
42 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
43 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
47 [Documentation] Start VTN Manager Test Suite
48 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
51 [Documentation] Stop VTN Manager Test Suite
56 [Documentation] Stop VTN Manager Test Suite
60 [Documentation] Check if VTN Manager is up.
61 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
62 Should Be Equal As Strings ${resp.status_code} 200
64 Fetch vtn switch inventory
65 [Arguments] ${sw_name}
66 [Documentation] Check if Switch is detected.
67 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
68 Should Be Equal As Strings ${resp.status_code} 200
71 [Arguments] ${vtn_name}
72 [Documentation] Create a vtn with specified parameters.
73 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:update-vtn data={"input": {"tenant-name":${vtn_name}, "update-mode": "CREATE","operation": "SET", "description": "creating vtn", "idle-timeout":300, "hard-timeout":0}}
74 Should Be Equal As Strings ${resp.status_code} 200
77 [Arguments] ${vtn_name} ${vbr_name}
78 [Documentation] Create a vBridge in a VTN
79 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vbridge:update-vbridge data={"input": {"update-mode": "CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige created"}}
80 Should Be Equal As Strings ${resp.status_code} 200
83 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
84 [Documentation] Create a interface into a vBridge of a VTN
85 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vinterface:update-vinterface data={"input": {"update-mode":"CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige interfacecreated", "enabled":"true", "interface-name": ${interface_name}}}
86 Should Be Equal As Strings ${resp.status_code} 200
89 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
90 [Documentation] Create a portmap for a interface of a vbridge
91 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-port-map:set-port-map data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "node":"${node_id}", "port-name":"${port_id}"}}
92 Should Be Equal As Strings ${resp.status_code} 200
95 [Arguments] ${vtn_name}
96 [Documentation] Delete a vtn with specified parameters.
97 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
98 Should Be Equal As Strings ${resp.status_code} 200
101 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
102 [Documentation] Create a vlanmap
103 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vlan-map:add-vlan-map data={"input": {"tenant-name":${vtn_name},"bridge-name":${vbr_name},"vlan-id":${vlan_id}}}
104 Should Be Equal As Strings ${resp.status_code} 200
107 [Arguments] ${vtn_name} ${vBridge_name}
108 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
109 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
110 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
111 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
112 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
113 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
115 Start PathSuiteVtnMaTest
116 [Documentation] Start VTN Manager Test Suite and Mininet
118 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
120 Start PathSuiteVtnMaTestOF10
121 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
123 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
125 Stop PathSuiteVtnMaTest
126 [Documentation] Cleanup/Shutdown work at the completion of all tests.
128 Stop Mininet ${mininet_conn_id}
131 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
132 [Documentation] Verify whether the required attributes exists.
133 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
134 \ should Contain ${resp.content} ${dataflowElement}
137 [Arguments] ${pathmap_data}
138 [Documentation] Create a pathmap for a vtn
139 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
140 Should Be Equal As Strings ${resp.status_code} 200
143 [Documentation] Get a pathmap for a vtn.
144 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
145 : FOR ${pathElement} IN @{PATHMAP_ATTR}
146 \ should Contain ${resp.content} ${pathElement}
149 [Arguments] ${pathpolicy_data}
150 [Documentation] Create a pathpolicy for a vtn
151 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
152 Should Be Equal As Strings ${resp.status_code} 200
155 [Arguments] ${pathpolicy_id}
156 [Documentation] Get a pathpolicy for a vtn.
157 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
158 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
159 \ should Contain ${resp.content} ${pathpolicyElement}
162 [Arguments] ${tenant_path}
163 [Documentation] Remove a pathmap for a vtn
164 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
165 Should Be Equal As Strings ${resp.status_code} 200
168 [Arguments] ${policy_id}
169 [Documentation] Delete a pathpolicy for a vtn
170 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
171 Should Be Equal As Strings ${resp.status_code} 200
173 Verify flowEntryPathPolicy
174 [Arguments] ${of_version} ${port} ${output}
175 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
176 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
178 ${result} Read Until mininet>
179 Should Contain ${result} in_port=${port} actions=${output}
182 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
183 [Documentation] Create a macmap for a vbridge
184 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-mac-map:set-mac-map data={"input":{"operation":"SET","allowed-hosts":["${dst_add}@0","${src_add}@0"],"tenant-name":"${vtn_name}","bridge-name":"${vBridge_name}"}}
185 Should Be Equal As Strings ${resp.status_code} 200
187 Get DynamicMacAddress
189 [Documentation] Get Dynamic mac address of Host
190 write ${h} ifconfig -a | grep HWaddr
191 ${source} Read Until mininet>
192 ${HWaddress}= Split String ${source} ${SPACE}
193 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
194 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
195 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
197 Mininet Ping Should Succeed
198 [Arguments] ${host1} ${host2}
199 [Documentation] Ping hosts to check connectivity
200 Write ${host1} ping -c 1 ${host2}
201 ${result} Read Until mininet>
202 Should Contain ${result} 64 bytes
204 Mininet Ping Should Not Succeed
205 [Arguments] ${host1} ${host2}
206 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
207 Write ${host1} ping -c 3 ${host2}
208 ${result} Read Until mininet>
209 Should Not Contain ${result} 64 bytes
213 [Documentation] Create custom topology for vlan functionality
215 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
216 Set Suite Variable ${mininet_conn_id1}
217 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
218 Execute Command sudo ovs-vsctl set-manager ptcp:6644
219 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
220 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
221 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
222 ${result} Read Until mininet>
225 [Arguments] ${vtn_name}
226 [Documentation] Get data flow.
227 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
228 Should Be Equal As Strings ${resp.status_code} 200
231 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
232 [Documentation] Remove a portmap for a interface of a vbridge
233 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-port-map:remove-port-map data={"input": {"tenant-name":${vtn_name},"bridge-name":${vBridge_name},"interface-name":${interface_name}}}
234 Should Be Equal As Strings ${resp.status_code} 200
236 Verify FlowMacAddress
237 [Arguments] ${host1} ${host2} ${OF_VERSION}
238 [Documentation] Verify the source and destination mac address.
239 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
240 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
242 Verify Flows On OpenFlow
243 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
244 [Documentation] Verify the mac addresses on the specified open flow.
245 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
246 Should Be Equal As Strings ${booleanValue} True
248 Verify RemovedFlowMacAddress
249 [Arguments] ${host1} ${host2} ${OF_VERSION}
250 [Documentation] Verify the removed source and destination mac address.
251 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
252 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
254 Verify Removed Flows On OpenFlow
255 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
256 [Documentation] Verify the removed mac addresses on the specified open flow.
257 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
258 Should Not Be Equal As Strings ${booleanValue} True
261 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
262 [Documentation] Verify the source and destination mac address after ping in the dumpflows
263 write ${host1} ifconfig -a | grep HWaddr
264 ${sourcemacaddr} Read Until mininet>
265 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
266 ${sourcemacaddr}= Get from List ${macaddress} ${index}
267 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
268 write ${host2} ifconfig -a | grep HWaddr
269 ${destmacaddr} Read Until mininet>
270 ${macaddress}= Split String ${destmacaddr} ${SPACE}
271 ${destmacaddr}= Get from List ${macaddress} ${index}
272 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
274 ${result} Read Until mininet>
275 Should Contain ${result} ${sourcemacaddress}
276 Should Contain ${result} ${destmacaddress}
279 [Arguments] ${actions} ${DUMPFLOWS}
280 [Documentation] Verify the flowfilter actions after ping in the dumpflows
282 ${result} Read Until mininet>
283 Should Contain ${result} ${actions}
286 [Arguments] ${vtn_name} ${vtnflowfilter_data}
287 [Documentation] Create a flowfilter for a vtn
288 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
289 Should Be Equal As Strings ${resp.status_code} 200
292 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
293 [Documentation] Create a flowfilter for a vbr
294 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}", "bridge-name": "${vBridge_name}", ${vbrflowfilter_data}}}
295 Should Be Equal As Strings ${resp.status_code} 200
297 Add a vbrif flowfilter
298 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
299 [Documentation] Create a flowfilter for a vbrif
300 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": ${vtn_name}, "bridge-name": "${vBridge_name}","interface-name":"${interface_name}",${vbrif_flowfilter_data}}}
301 Should Be Equal As Strings ${resp.status_code} 200
303 Verify Flow Entries for Flowfilter
304 [Arguments] ${dumpflows} @{flowfilter_actions}
305 [Documentation] Verify switch flow entry using flowfilter for a vtn
306 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
307 Should Be Equal As Strings ${booleanValue} True
309 Verify Removed Flow Entry for Inet Drop Flowfilter
310 [Arguments] ${dumpflows} @{flowfilter_actions}
311 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
312 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
313 Should Be Equal As Strings ${booleanValue} True
315 Verify Actions on Flow Entry
316 [Arguments] ${dumpflows} @{flowfilter_actions}
317 [Documentation] check flow action elements by giving dumpflows in mininet
319 ${result} Read Until mininet>
320 : FOR ${flowElement} IN @{flowfilter_actions}
321 \ should Contain ${result} ${flowElement}
324 [Arguments] ${flowcond_name} ${flowconditiondata}
325 [Documentation] Create a flowcondition using Restconfig Api
326 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
327 Should Be Equal As Strings ${resp.status_code} 200
330 [Documentation] Retrieve the list of flowconditions created
331 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
332 Should Be Equal As Strings ${resp.status_code} 200
335 [Arguments] ${flowcond_name} ${retrieve}
336 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
337 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
338 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
339 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
340 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
343 [Arguments] ${flowcond_name}
344 [Documentation] Remove the flowcondition by name
345 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
346 Should Be Equal As Strings ${resp.status_code} 200