7 Library RequestsLibrary
8 Variables ../variables/Variables.py
10 Resource ./KarafKeywords.robot
13 ${vlan_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom vlan_vtn_test.py --topo vlantopo
14 ${vlan_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom vlan_vtn_test.py --topo vlantopo --switch ovsk,protocols=OpenFlow13
15 ${VERSION_VTN} controller/nb/v2/vtn/version
16 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
17 ${DUMPFLOWS_OF10} dpctl dump-flows -OOpenFlow10
18 ${DUMPFLOWS_OF13} dpctl dump-flows -OOpenFlow13
19 ${FF_DUMPFLOWS_OF10} sh ovs-ofctl dump-flows -OOpenFlow10 s3
20 ${FF_DUMPFLOWS_OF13} sh ovs-ofctl dump-flows -OOpenFlow13 s3
21 ${DROP_DUMPFLOWS_OF10} sh ovs-ofctl dump-flows -OOpenFlow10 s2
22 ${DROP_DUMPFLOWS_OF13} sh ovs-ofctl dump-flows -OOpenFlow13 s2
24 @{inet_actions} mod_nw_src:192.0.0.1 mod_nw_dst:192.0.0.2
25 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1" "interface-name":"if2"
26 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2" "interface-name":"if3"
27 ${vlanmap_bridge1} 200
28 ${vlanmap_bridge2} 300
29 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1_vlan"
30 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2_vlan"
31 ${out_before_pathpolicy} output:2
32 ${out_after_pathpolicy} output:3
33 ${pathpolicy_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
34 ${pathpolicy_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow10
35 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
39 @{inet_action} set_field:192.0.0.1->ip_src set_field:192.0.0.2->ip_dst
40 ${dscp_action} set_field:32->nw_tos_shifted
41 ${dscp_flow} mod_nw_tos:128
42 @{icmp_action} mod_tp_dst:1 mod_tp_src:3
43 ${drop_action} actions=drop
44 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
45 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
49 [Documentation] Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
50 Issue Command On Karaf Console log:set TRACE org.opendaylight.vtn
51 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
52 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
56 [Documentation] Start VTN Manager Test Suite
57 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
60 [Documentation] Stop VTN Manager Test Suite
64 [Documentation] Stop VTN Manager Test Suite
68 [Documentation] Check if VTN Manager is up.
69 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
70 Should Be Equal As Strings ${resp.status_code} 200
72 Fetch vtn switch inventory
73 [Arguments] ${sw_name}
74 [Documentation] Check if Switch is detected.
75 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
76 Should Be Equal As Strings ${resp.status_code} 200
79 [Arguments] ${vtn_name}
80 [Documentation] Create a vtn with specified parameters.
81 ${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}}
82 Should Be Equal As Strings ${resp.status_code} 200
85 [Arguments] ${vtn_name} ${vbr_name}
86 [Documentation] Create a vBridge in a VTN
87 ${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"}}
88 Should Be Equal As Strings ${resp.status_code} 200
91 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
92 [Documentation] Create a interface into a vBridge of a VTN
93 ${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}}}
94 Should Be Equal As Strings ${resp.status_code} 200
97 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
98 [Documentation] Create a portmap for a interface of a vbridge
99 ${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}"}}
100 Should Be Equal As Strings ${resp.status_code} 200
103 [Arguments] ${vtn_name}
104 [Documentation] Delete a vtn with specified parameters.
105 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
106 Should Be Equal As Strings ${resp.status_code} 200
109 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
110 [Documentation] Create a vlanmap
111 ${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}}}
112 Should Be Equal As Strings ${resp.status_code} 200
115 [Arguments] ${vtn_name} ${vBridge_name}
116 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
117 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
118 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
119 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
120 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
121 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
123 Start PathSuiteVtnMaTest
124 [Documentation] Start VTN Manager Test Suite and Mininet
126 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
128 Start PathSuiteVtnMaTestOF10
129 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
131 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
133 Stop PathSuiteVtnMaTest
134 [Documentation] Cleanup/Shutdown work at the completion of all tests.
136 Stop Mininet ${mininet_conn_id}
139 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
140 [Documentation] Verify whether the required attributes exists.
141 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
142 \ should Contain ${resp.content} ${dataflowElement}
145 [Arguments] ${pathmap_data}
146 [Documentation] Create a pathmap for a vtn
147 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
148 Should Be Equal As Strings ${resp.status_code} 200
151 [Documentation] Get a pathmap for a vtn.
152 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
153 : FOR ${pathElement} IN @{PATHMAP_ATTR}
154 \ should Contain ${resp.content} ${pathElement}
157 [Arguments] ${pathpolicy_data}
158 [Documentation] Create a pathpolicy for a vtn
159 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
160 Should Be Equal As Strings ${resp.status_code} 200
163 [Arguments] ${pathpolicy_id}
164 [Documentation] Get a pathpolicy for a vtn.
165 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
166 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
167 \ should Contain ${resp.content} ${pathpolicyElement}
170 [Arguments] ${tenant_path}
171 [Documentation] Remove a pathmap for a vtn
172 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
173 Should Be Equal As Strings ${resp.status_code} 200
176 [Arguments] ${policy_id}
177 [Documentation] Delete a pathpolicy for a vtn
178 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
179 Should Be Equal As Strings ${resp.status_code} 200
181 Verify flowEntryPathPolicy
182 [Arguments] ${of_version} ${port} ${output}
183 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
184 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
186 ${result} Read Until mininet>
187 Should Contain ${result} in_port=${port} actions=${output}
190 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
191 [Documentation] Create a macmap for a vbridge
192 ${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}"}}
193 Should Be Equal As Strings ${resp.status_code} 200
195 Get DynamicMacAddress
197 [Documentation] Get Dynamic mac address of Host
198 write ${h} ifconfig -a | grep HWaddr
199 ${source} Read Until mininet>
200 ${HWaddress}= Split String ${source} ${SPACE}
201 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
202 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
203 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
205 Mininet Ping Should Succeed
206 [Arguments] ${host1} ${host2}
207 [Documentation] Ping hosts to check connectivity
208 Write ${host1} ping -c 1 ${host2}
209 ${result} Read Until mininet>
210 Should Contain ${result} 64 bytes
212 Mininet Ping Should Not Succeed
213 [Arguments] ${host1} ${host2}
214 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
215 Write ${host1} ping -c 3 ${host2}
216 ${result} Read Until mininet>
217 Should Not Contain ${result} 64 bytes
221 [Documentation] Create custom topology for vlan functionality
222 Install Package On Ubuntu System vlan
223 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
224 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
227 [Arguments] ${vtn_name}
228 [Documentation] Get data flow.
229 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
230 Should Be Equal As Strings ${resp.status_code} 200
233 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
234 [Documentation] Remove a portmap for a interface of a vbridge
235 ${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}}}
236 Should Be Equal As Strings ${resp.status_code} 200
238 Verify FlowMacAddress
239 [Arguments] ${host1} ${host2} ${OF_VERSION}
240 [Documentation] Verify the source and destination mac address.
241 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
242 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
244 Verify Flows On OpenFlow
245 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
246 [Documentation] Verify the mac addresses on the specified open flow.
247 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
248 Should Be Equal As Strings ${booleanValue} True
250 Verify RemovedFlowMacAddress
251 [Arguments] ${host1} ${host2} ${OF_VERSION}
252 [Documentation] Verify the removed source and destination mac address.
253 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
254 ... ELSE Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
256 Verify Removed Flows On OpenFlow
257 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
258 [Documentation] Verify the removed mac addresses on the specified open flow.
259 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
260 Should Not Be Equal As Strings ${booleanValue} True
263 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
264 [Documentation] Verify the source and destination mac address after ping in the dumpflows
265 write ${host1} ifconfig -a | grep HWaddr
266 ${sourcemacaddr} Read Until mininet>
267 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
268 ${sourcemacaddr}= Get from List ${macaddress} ${index}
269 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
270 write ${host2} ifconfig -a | grep HWaddr
271 ${destmacaddr} Read Until mininet>
272 ${macaddress}= Split String ${destmacaddr} ${SPACE}
273 ${destmacaddr}= Get from List ${macaddress} ${index}
274 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
276 ${result} Read Until mininet>
277 Should Contain ${result} ${sourcemacaddress}
278 Should Contain ${result} ${destmacaddress}
281 [Arguments] ${actions} ${DUMPFLOWS}
282 [Documentation] Verify the flowfilter actions after ping in the dumpflows
284 ${result} Read Until mininet>
285 Should Contain ${result} ${actions}
288 [Arguments] ${vtn_name} ${vtnflowfilter_data}
289 [Documentation] Create a flowfilter for a vtn
290 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
291 Should Be Equal As Strings ${resp.status_code} 200
293 Remove a vtn flowfilter
294 [Arguments] ${vtn_name} ${filter_index}
295 [Documentation] Delete a vtn flowfilter
296 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
297 Should Be Equal As Strings ${resp.status_code} 200
300 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
301 [Documentation] Create a flowfilter for a vbr
302 ${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}}}
303 Should Be Equal As Strings ${resp.status_code} 200
305 Remove a vbr flowfilter
306 [Arguments] ${vtn_name} ${vBridge_name} ${filter_index}
307 [Documentation] Delete a vbr flowfilter
308 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}"}}
309 Should Be Equal As Strings ${resp.status_code} 200
311 Add a vbrif flowfilter
312 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
313 [Documentation] Create a flowfilter for a vbrif
314 ${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}}}
315 Should Be Equal As Strings ${resp.status_code} 200
317 Remove a vbrif flowfilter
318 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${filter_index}
319 [Documentation] Delete a vbrif flowfilter
320 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}","interface-name": "${interface_name}"}}
321 Should Be Equal As Strings ${resp.status_code} 200
323 Verify Flow Entries for Flowfilter
324 [Arguments] ${dumpflows} @{flowfilter_actions}
325 [Documentation] Verify switch flow entry using flowfilter for a vtn
326 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
327 Should Be Equal As Strings ${booleanValue} True
329 Verify Removed Flow Entry for Inet Drop Flowfilter
330 [Arguments] ${dumpflows} @{flowfilter_actions}
331 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
332 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
333 Should Be Equal As Strings ${booleanValue} True
335 Verify Actions on Flow Entry
336 [Arguments] ${dumpflows} @{flowfilter_actions}
337 [Documentation] check flow action elements by giving dumpflows in mininet
339 ${result} Read Until mininet>
340 : FOR ${flowElement} IN @{flowfilter_actions}
341 \ should Contain ${result} ${flowElement}
344 [Arguments] ${flowcond_name} ${flowconditiondata}
345 [Documentation] Create a flowcondition using Restconfig Api
346 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
347 Should Be Equal As Strings ${resp.status_code} 200
350 [Documentation] Retrieve the list of flowconditions created
351 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
352 Should Be Equal As Strings ${resp.status_code} 200
355 [Arguments] ${flowcond_name} ${retrieve}
356 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
357 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
358 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
359 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
360 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
363 [Arguments] ${flowcond_name}
364 [Documentation] Remove the flowcondition by name
365 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
366 Should Be Equal As Strings ${resp.status_code} 200