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
23 ${DROP_OUT_DUMPFLOWS_OF10} sh ovs-ofctl dump-flows -OOpenFlow10 s3
24 ${DROP_OUT_DUMPFLOWS_OF13} sh ovs-ofctl dump-flows -OOpenFlow13 s3
25 ${FF_OUT_DUMPFLOWS_OF10} sh ovs-ofctl dump-flows -OOpenFlow10 s2
26 ${FF_OUT_DUMPFLOWS_OF13} sh ovs-ofctl dump-flows -OOpenFlow13 s2
28 @{inet_actions} mod_nw_src:192.0.0.1 mod_nw_dst:192.0.0.2
29 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1" "interface-name":"if2"
30 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2" "interface-name":"if3"
31 ${vlanmap_bridge1} 200
32 ${vlanmap_bridge2} 300
33 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1_vlan"
34 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2_vlan"
35 ${out_before_pathpolicy} output:2
36 ${out_after_pathpolicy} output:3
37 ${pathpolicy_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
38 ${pathpolicy_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow10
39 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
43 @{inet_action} set_field:192.0.0.1->ip_src set_field:192.0.0.2->ip_dst
44 ${dscp_action} set_field:32->nw_tos_shifted
45 ${dscp_flow} mod_nw_tos:128
46 @{icmp_action} mod_tp_dst:1 mod_tp_src:3
47 ${drop_action} actions=drop
48 ${vlanpcp_action} mod_vlan_pcp:6
49 ${vlanpcp_actions} set_field:6->vlan_pcp
50 ${dlsrc_action} mod_dl_src:00:00:00:00:00:11
51 ${dlsrc_actions} set_field:00:00:00:00:00:11->eth_src
52 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
53 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
57 [Documentation] Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
58 Issue Command On Karaf Console log:set TRACE org.opendaylight.vtn
59 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
60 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
64 [Documentation] Start VTN Manager Test Suite
65 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
68 [Documentation] Stop VTN Manager Test Suite
72 [Documentation] Stop VTN Manager Test Suite
76 [Documentation] Check if VTN Manager is up.
77 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
78 Should Be Equal As Strings ${resp.status_code} 200
80 Fetch vtn switch inventory
81 [Arguments] ${sw_name}
82 [Documentation] Check if Switch is detected.
83 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
84 Should Be Equal As Strings ${resp.status_code} 200
87 [Arguments] ${vtn_name}
88 [Documentation] Create a vtn with specified parameters.
89 ${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}}
90 Should Be Equal As Strings ${resp.status_code} 200
93 [Arguments] ${vtn_name} ${vbr_name}
94 [Documentation] Create a vBridge in a VTN
95 ${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"}}
96 Should Be Equal As Strings ${resp.status_code} 200
99 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
100 [Documentation] Create a interface into a vBridge of a VTN
101 ${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}}}
102 Should Be Equal As Strings ${resp.status_code} 200
105 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
106 [Documentation] Create a portmap for a interface of a vbridge
107 ${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}"}}
108 Should Be Equal As Strings ${resp.status_code} 200
111 [Arguments] ${vtn_name}
112 [Documentation] Delete a vtn with specified parameters.
113 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
114 Should Be Equal As Strings ${resp.status_code} 200
117 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
118 [Documentation] Create a vlanmap
119 ${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}}}
120 Should Be Equal As Strings ${resp.status_code} 200
123 [Arguments] ${vtn_name} ${vBridge_name}
124 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
125 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
126 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
127 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
128 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
129 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
131 Start PathSuiteVtnMaTest
132 [Documentation] Start VTN Manager Test Suite and Mininet
134 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
136 Start PathSuiteVtnMaTestOF10
137 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
139 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
141 Stop PathSuiteVtnMaTest
142 [Documentation] Cleanup/Shutdown work at the completion of all tests.
144 Stop Mininet ${mininet_conn_id}
147 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
148 [Documentation] Verify whether the required attributes exists.
149 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
150 \ should Contain ${resp.content} ${dataflowElement}
153 [Arguments] ${pathmap_data}
154 [Documentation] Create a pathmap for a vtn
155 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
156 Should Be Equal As Strings ${resp.status_code} 200
159 [Documentation] Get a pathmap for a vtn.
160 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
161 : FOR ${pathElement} IN @{PATHMAP_ATTR}
162 \ should Contain ${resp.content} ${pathElement}
165 [Arguments] ${pathpolicy_data}
166 [Documentation] Create a pathpolicy for a vtn
167 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
168 Should Be Equal As Strings ${resp.status_code} 200
171 [Arguments] ${pathpolicy_id}
172 [Documentation] Get a pathpolicy for a vtn.
173 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
174 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
175 \ should Contain ${resp.content} ${pathpolicyElement}
178 [Arguments] ${tenant_path}
179 [Documentation] Remove a pathmap for a vtn
180 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
181 Should Be Equal As Strings ${resp.status_code} 200
184 [Arguments] ${policy_id}
185 [Documentation] Delete a pathpolicy for a vtn
186 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
187 Should Be Equal As Strings ${resp.status_code} 200
189 Verify flowEntryPathPolicy
190 [Arguments] ${of_version} ${port} ${output}
191 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
192 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
194 ${result} Read Until mininet>
195 Should Contain ${result} in_port=${port} actions=${output}
198 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
199 [Documentation] Create a macmap for a vbridge
200 ${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}"}}
201 Should Be Equal As Strings ${resp.status_code} 200
203 Get DynamicMacAddress
205 [Documentation] Get Dynamic mac address of Host
206 write ${h} ifconfig -a | grep HWaddr
207 ${source} Read Until mininet>
208 ${HWaddress}= Split String ${source} ${SPACE}
209 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
210 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
211 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
213 Mininet Ping Should Succeed
214 [Arguments] ${host1} ${host2}
215 [Documentation] Ping hosts to check connectivity
216 Write ${host1} ping -c 1 ${host2}
217 ${result} Read Until mininet>
218 Should Contain ${result} 64 bytes
220 Mininet Ping Should Not Succeed
221 [Arguments] ${host1} ${host2}
222 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
223 Write ${host1} ping -c 3 ${host2}
224 ${result} Read Until mininet>
225 Should Not Contain ${result} 64 bytes
229 [Documentation] Create custom topology for vlan functionality
230 Install Package On Ubuntu System vlan
231 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
232 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
235 [Arguments] ${vtn_name}
236 [Documentation] Get data flow.
237 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
238 Should Be Equal As Strings ${resp.status_code} 200
241 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
242 [Documentation] Remove a portmap for a interface of a vbridge
243 ${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}}}
244 Should Be Equal As Strings ${resp.status_code} 200
246 Verify FlowMacAddress
247 [Arguments] ${host1} ${host2} ${OF_VERSION}
248 [Documentation] Verify the source and destination mac address.
249 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
250 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
252 Verify Flows On OpenFlow
253 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
254 [Documentation] Verify the mac addresses on the specified open flow.
255 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
256 Should Be Equal As Strings ${booleanValue} True
258 Verify RemovedFlowMacAddress
259 [Arguments] ${host1} ${host2} ${OF_VERSION}
260 [Documentation] Verify the removed source and destination mac address.
261 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
262 ... ELSE Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
264 Verify Removed Flows On OpenFlow
265 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
266 [Documentation] Verify the removed mac addresses on the specified open flow.
267 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
268 Should Not Be Equal As Strings ${booleanValue} True
271 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
272 [Documentation] Verify the source and destination mac address after ping in the dumpflows
273 write ${host1} ifconfig -a | grep HWaddr
274 ${sourcemacaddr} Read Until mininet>
275 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
276 ${sourcemacaddr}= Get from List ${macaddress} ${index}
277 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
278 write ${host2} ifconfig -a | grep HWaddr
279 ${destmacaddr} Read Until mininet>
280 ${macaddress}= Split String ${destmacaddr} ${SPACE}
281 ${destmacaddr}= Get from List ${macaddress} ${index}
282 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
284 ${result} Read Until mininet>
285 Should Contain ${result} ${sourcemacaddress}
286 Should Contain ${result} ${destmacaddress}
289 [Arguments] ${actions} ${DUMPFLOWS}
290 [Documentation] Verify the flowfilter actions after ping in the dumpflows
292 ${result} Read Until mininet>
293 Should Contain ${result} ${actions}
296 [Arguments] ${vtn_name} ${vtnflowfilter_data}
297 [Documentation] Create a flowfilter for a vtn
298 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
299 Should Be Equal As Strings ${resp.status_code} 200
301 Remove a vtn flowfilter
302 [Arguments] ${vtn_name} ${filter_index}
303 [Documentation] Delete a vtn flowfilter
304 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
305 Should Be Equal As Strings ${resp.status_code} 200
308 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
309 [Documentation] Create a flowfilter for a vbr
310 ${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}}}
311 Should Be Equal As Strings ${resp.status_code} 200
313 Remove a vbr flowfilter
314 [Arguments] ${vtn_name} ${vBridge_name} ${filter_index}
315 [Documentation] Delete a vbr flowfilter
316 ${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}"}}
317 Should Be Equal As Strings ${resp.status_code} 200
319 Add a vbrif flowfilter
320 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
321 [Documentation] Create a flowfilter for a vbrif
322 ${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}}}
323 Should Be Equal As Strings ${resp.status_code} 200
325 Remove a vbrif flowfilter
326 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${filter_index}
327 [Documentation] Delete a vbrif flowfilter
328 ${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}"}}
329 Should Be Equal As Strings ${resp.status_code} 200
332 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${id} ${node_id} ${port_id}
333 [Documentation] Create a portmap for a interface of a vbridge
334 ${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}, "vlan-id": ${id}, "node":"${node_id}", "port-name":"${port_id}"}}
335 Should Be Equal As Strings ${resp.status_code} 200
337 Verify Flow Entries for Flowfilter
338 [Arguments] ${dumpflows} @{flowfilter_actions}
339 [Documentation] Verify switch flow entry using flowfilter for a vtn
340 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
341 Should Be Equal As Strings ${booleanValue} True
343 Verify Removed Flow Entry for Inet Drop Flowfilter
344 [Arguments] ${dumpflows} @{flowfilter_actions}
345 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
346 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
347 Should Be Equal As Strings ${booleanValue} True
349 Verify Actions on Flow Entry
350 [Arguments] ${dumpflows} @{flowfilter_actions}
351 [Documentation] check flow action elements by giving dumpflows in mininet
353 ${result} Read Until mininet>
354 : FOR ${flowElement} IN @{flowfilter_actions}
355 \ should Contain ${result} ${flowElement}
358 [Arguments] ${flowcond_name} ${flowconditiondata}
359 [Documentation] Create a flowcondition using Restconfig Api
360 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
361 Should Be Equal As Strings ${resp.status_code} 200
364 [Documentation] Retrieve the list of flowconditions created
365 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
366 Should Be Equal As Strings ${resp.status_code} 200
369 [Arguments] ${flowcond_name} ${retrieve}
370 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
371 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
372 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
373 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
374 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
377 [Arguments] ${flowcond_name}
378 [Documentation] Remove the flowcondition by name
379 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
380 Should Be Equal As Strings ${resp.status_code} 200