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] ${topo_wait}
88 [Documentation] Add a topology wait to complete all Inter-switch link connection of switches
89 ${resp}= RequestsLibrary.Put Request session restconf/config/vtn-config:vtn-config data={"vtn-config": {"topology-wait":${topo_wait}, "host-tracking": "true"}}
90 Should Be Equal As Strings ${resp.status_code} 200
93 [Arguments] ${vtn_name}
94 [Documentation] Create a vtn with specified parameters.
95 ${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}}
96 Should Be Equal As Strings ${resp.status_code} 200
99 [Arguments] ${vtn_name} ${vbr_name}
100 [Documentation] Create a vBridge in a VTN
101 ${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"}}
102 Should Be Equal As Strings ${resp.status_code} 200
105 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
106 [Documentation] Create a interface into a vBridge of a VTN
107 ${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}}}
108 Should Be Equal As Strings ${resp.status_code} 200
111 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
112 [Documentation] Create a portmap for a interface of a vbridge
113 ${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}"}}
114 Should Be Equal As Strings ${resp.status_code} 200
117 [Arguments] ${vtn_name}
118 [Documentation] Delete a vtn with specified parameters.
119 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
120 Should Be Equal As Strings ${resp.status_code} 200
123 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
124 [Documentation] Create a vlanmap
125 ${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}}}
126 Should Be Equal As Strings ${resp.status_code} 200
129 [Arguments] ${vtn_name} ${vBridge_name}
130 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
131 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
132 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
133 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
134 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
135 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
137 Start PathSuiteVtnMaTest
138 [Documentation] Start VTN Manager Test Suite and Mininet
140 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
142 Start PathSuiteVtnMaTestOF10
143 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
145 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
147 Stop PathSuiteVtnMaTest
148 [Documentation] Cleanup/Shutdown work at the completion of all tests.
150 Stop Mininet ${mininet_conn_id}
153 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
154 [Documentation] Verify whether the required attributes exists.
155 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
156 \ should Contain ${resp.content} ${dataflowElement}
159 [Arguments] ${pathmap_data}
160 [Documentation] Create a pathmap for a vtn
161 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
162 Should Be Equal As Strings ${resp.status_code} 200
165 [Documentation] Get a pathmap for a vtn.
166 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
167 : FOR ${pathElement} IN @{PATHMAP_ATTR}
168 \ should Contain ${resp.content} ${pathElement}
171 [Arguments] ${pathpolicy_data}
172 [Documentation] Create a pathpolicy for a vtn
173 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
174 Should Be Equal As Strings ${resp.status_code} 200
177 [Arguments] ${pathpolicy_id}
178 [Documentation] Get a pathpolicy for a vtn.
179 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
180 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
181 \ should Contain ${resp.content} ${pathpolicyElement}
184 [Arguments] ${tenant_path}
185 [Documentation] Remove a pathmap for a vtn
186 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
187 Should Be Equal As Strings ${resp.status_code} 200
190 [Arguments] ${policy_id}
191 [Documentation] Delete a pathpolicy for a vtn
192 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
193 Should Be Equal As Strings ${resp.status_code} 200
195 Verify flowEntryPathPolicy
196 [Arguments] ${of_version} ${port} ${output}
197 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
198 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
200 ${result} Read Until mininet>
201 Should Contain ${result} in_port=${port} actions=${output}
204 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
205 [Documentation] Create a macmap for a vbridge
206 ${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}"}}
207 Should Be Equal As Strings ${resp.status_code} 200
209 Get DynamicMacAddress
211 [Documentation] Get Dynamic mac address of Host
212 write ${h} ifconfig -a | grep HWaddr
213 ${source} Read Until mininet>
214 ${HWaddress}= Split String ${source} ${SPACE}
215 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
216 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
217 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
219 Mininet Ping Should Succeed
220 [Arguments] ${host1} ${host2}
221 [Documentation] Ping hosts to check connectivity
222 Write ${host1} ping -c 1 ${host2}
223 ${result} Read Until mininet>
224 Should Contain ${result} 64 bytes
226 Mininet Ping Should Not Succeed
227 [Arguments] ${host1} ${host2}
228 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
229 Write ${host1} ping -c 3 ${host2}
230 ${result} Read Until mininet>
231 Should Not Contain ${result} 64 bytes
235 [Documentation] Create custom topology for vlan functionality
236 Install Package On Ubuntu System vlan
237 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
238 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
241 [Arguments] ${vtn_name}
242 [Documentation] Get data flow.
243 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
244 Should Be Equal As Strings ${resp.status_code} 200
247 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
248 [Documentation] Remove a portmap for a interface of a vbridge
249 ${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}}}
250 Should Be Equal As Strings ${resp.status_code} 200
252 Verify FlowMacAddress
253 [Arguments] ${host1} ${host2} ${OF_VERSION}
254 [Documentation] Verify the source and destination mac address.
255 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
256 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
258 Verify Flows On OpenFlow
259 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
260 [Documentation] Verify the mac addresses on the specified open flow.
261 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
262 Should Be Equal As Strings ${booleanValue} True
264 Verify RemovedFlowMacAddress
265 [Arguments] ${host1} ${host2} ${OF_VERSION}
266 [Documentation] Verify the removed source and destination mac address.
267 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
268 ... ELSE Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
270 Verify Removed Flows On OpenFlow
271 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
272 [Documentation] Verify the removed mac addresses on the specified open flow.
273 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
274 Should Not Be Equal As Strings ${booleanValue} True
277 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
278 [Documentation] Verify the source and destination mac address after ping in the dumpflows
279 write ${host1} ifconfig -a | grep HWaddr
280 ${sourcemacaddr} Read Until mininet>
281 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
282 ${sourcemacaddr}= Get from List ${macaddress} ${index}
283 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
284 write ${host2} ifconfig -a | grep HWaddr
285 ${destmacaddr} Read Until mininet>
286 ${macaddress}= Split String ${destmacaddr} ${SPACE}
287 ${destmacaddr}= Get from List ${macaddress} ${index}
288 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
290 ${result} Read Until mininet>
291 Should Contain ${result} ${sourcemacaddress}
292 Should Contain ${result} ${destmacaddress}
295 [Arguments] ${actions} ${DUMPFLOWS}
296 [Documentation] Verify the flowfilter actions after ping in the dumpflows
298 ${result} Read Until mininet>
299 Should Contain ${result} ${actions}
302 [Arguments] ${vtn_name} ${vtnflowfilter_data}
303 [Documentation] Create a flowfilter for a vtn
304 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
305 Should Be Equal As Strings ${resp.status_code} 200
307 Remove a vtn flowfilter
308 [Arguments] ${vtn_name} ${filter_index}
309 [Documentation] Delete a vtn flowfilter
310 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
311 Should Be Equal As Strings ${resp.status_code} 200
314 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
315 [Documentation] Create a flowfilter for a vbr
316 ${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}}}
317 Should Be Equal As Strings ${resp.status_code} 200
319 Remove a vbr flowfilter
320 [Arguments] ${vtn_name} ${vBridge_name} ${filter_index}
321 [Documentation] Delete a vbr flowfilter
322 ${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}"}}
323 Should Be Equal As Strings ${resp.status_code} 200
325 Add a vbrif flowfilter
326 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
327 [Documentation] Create a flowfilter for a vbrif
328 ${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}}}
329 Should Be Equal As Strings ${resp.status_code} 200
331 Remove a vbrif flowfilter
332 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${filter_index}
333 [Documentation] Delete a vbrif flowfilter
334 ${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}"}}
335 Should Be Equal As Strings ${resp.status_code} 200
338 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${id} ${node_id} ${port_id}
339 [Documentation] Create a portmap for a interface of a vbridge
340 ${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}"}}
341 Should Be Equal As Strings ${resp.status_code} 200
343 Verify Flow Entries for Flowfilter
344 [Arguments] ${dumpflows} @{flowfilter_actions}
345 [Documentation] Verify switch flow entry using flowfilter 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 Removed Flow Entry for Inet Drop Flowfilter
350 [Arguments] ${dumpflows} @{flowfilter_actions}
351 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
352 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
353 Should Be Equal As Strings ${booleanValue} True
355 Verify Actions on Flow Entry
356 [Arguments] ${dumpflows} @{flowfilter_actions}
357 [Documentation] check flow action elements by giving dumpflows in mininet
359 ${result} Read Until mininet>
360 : FOR ${flowElement} IN @{flowfilter_actions}
361 \ should Contain ${result} ${flowElement}
364 [Arguments] ${flowcond_name} ${flowconditiondata}
365 [Documentation] Create a flowcondition using Restconfig Api
366 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
367 Should Be Equal As Strings ${resp.status_code} 200
370 [Documentation] Retrieve the list of flowconditions created
371 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
372 Should Be Equal As Strings ${resp.status_code} 200
375 [Arguments] ${flowcond_name} ${retrieve}
376 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
377 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
378 ${resp}= RequestsLibrary.Get Request 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
383 [Arguments] ${flowcond_name}
384 [Documentation] Remove the flowcondition by name
385 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
386 Should Be Equal As Strings ${resp.status_code} 200