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 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
49 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
53 [Documentation] Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
54 Issue Command On Karaf Console log:set TRACE org.opendaylight.vtn
55 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
56 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
60 [Documentation] Start VTN Manager Test Suite
61 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
64 [Documentation] Stop VTN Manager Test Suite
68 [Documentation] Stop VTN Manager Test Suite
72 [Documentation] Check if VTN Manager is up.
73 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
74 Should Be Equal As Strings ${resp.status_code} 200
76 Fetch vtn switch inventory
77 [Arguments] ${sw_name}
78 [Documentation] Check if Switch is detected.
79 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
80 Should Be Equal As Strings ${resp.status_code} 200
83 [Arguments] ${vtn_name}
84 [Documentation] Create a vtn with specified parameters.
85 ${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}}
86 Should Be Equal As Strings ${resp.status_code} 200
89 [Arguments] ${vtn_name} ${vbr_name}
90 [Documentation] Create a vBridge in a VTN
91 ${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"}}
92 Should Be Equal As Strings ${resp.status_code} 200
95 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
96 [Documentation] Create a interface into a vBridge of a VTN
97 ${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}}}
98 Should Be Equal As Strings ${resp.status_code} 200
101 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
102 [Documentation] Create a portmap for a interface of a vbridge
103 ${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}"}}
104 Should Be Equal As Strings ${resp.status_code} 200
107 [Arguments] ${vtn_name}
108 [Documentation] Delete a vtn with specified parameters.
109 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
110 Should Be Equal As Strings ${resp.status_code} 200
113 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
114 [Documentation] Create a vlanmap
115 ${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}}}
116 Should Be Equal As Strings ${resp.status_code} 200
119 [Arguments] ${vtn_name} ${vBridge_name}
120 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
121 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
122 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
123 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
124 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
125 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
127 Start PathSuiteVtnMaTest
128 [Documentation] Start VTN Manager Test Suite and Mininet
130 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
132 Start PathSuiteVtnMaTestOF10
133 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
135 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
137 Stop PathSuiteVtnMaTest
138 [Documentation] Cleanup/Shutdown work at the completion of all tests.
140 Stop Mininet ${mininet_conn_id}
143 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
144 [Documentation] Verify whether the required attributes exists.
145 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
146 \ should Contain ${resp.content} ${dataflowElement}
149 [Arguments] ${pathmap_data}
150 [Documentation] Create a pathmap for a vtn
151 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
152 Should Be Equal As Strings ${resp.status_code} 200
155 [Documentation] Get a pathmap for a vtn.
156 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
157 : FOR ${pathElement} IN @{PATHMAP_ATTR}
158 \ should Contain ${resp.content} ${pathElement}
161 [Arguments] ${pathpolicy_data}
162 [Documentation] Create a pathpolicy for a vtn
163 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
164 Should Be Equal As Strings ${resp.status_code} 200
167 [Arguments] ${pathpolicy_id}
168 [Documentation] Get a pathpolicy for a vtn.
169 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
170 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
171 \ should Contain ${resp.content} ${pathpolicyElement}
174 [Arguments] ${tenant_path}
175 [Documentation] Remove a pathmap for a vtn
176 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
177 Should Be Equal As Strings ${resp.status_code} 200
180 [Arguments] ${policy_id}
181 [Documentation] Delete a pathpolicy for a vtn
182 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
183 Should Be Equal As Strings ${resp.status_code} 200
185 Verify flowEntryPathPolicy
186 [Arguments] ${of_version} ${port} ${output}
187 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
188 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
190 ${result} Read Until mininet>
191 Should Contain ${result} in_port=${port} actions=${output}
194 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
195 [Documentation] Create a macmap for a vbridge
196 ${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}"}}
197 Should Be Equal As Strings ${resp.status_code} 200
199 Get DynamicMacAddress
201 [Documentation] Get Dynamic mac address of Host
202 write ${h} ifconfig -a | grep HWaddr
203 ${source} Read Until mininet>
204 ${HWaddress}= Split String ${source} ${SPACE}
205 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
206 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
207 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
209 Mininet Ping Should Succeed
210 [Arguments] ${host1} ${host2}
211 [Documentation] Ping hosts to check connectivity
212 Write ${host1} ping -c 1 ${host2}
213 ${result} Read Until mininet>
214 Should Contain ${result} 64 bytes
216 Mininet Ping Should Not Succeed
217 [Arguments] ${host1} ${host2}
218 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
219 Write ${host1} ping -c 3 ${host2}
220 ${result} Read Until mininet>
221 Should Not Contain ${result} 64 bytes
225 [Documentation] Create custom topology for vlan functionality
226 Install Package On Ubuntu System vlan
227 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
228 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
231 [Arguments] ${vtn_name}
232 [Documentation] Get data flow.
233 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
234 Should Be Equal As Strings ${resp.status_code} 200
237 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
238 [Documentation] Remove a portmap for a interface of a vbridge
239 ${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}}}
240 Should Be Equal As Strings ${resp.status_code} 200
242 Verify FlowMacAddress
243 [Arguments] ${host1} ${host2} ${OF_VERSION}
244 [Documentation] Verify the source and destination mac address.
245 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
246 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
248 Verify Flows On OpenFlow
249 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
250 [Documentation] Verify the mac addresses on the specified open flow.
251 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
252 Should Be Equal As Strings ${booleanValue} True
254 Verify RemovedFlowMacAddress
255 [Arguments] ${host1} ${host2} ${OF_VERSION}
256 [Documentation] Verify the removed source and destination mac address.
257 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
258 ... ELSE Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
260 Verify Removed Flows On OpenFlow
261 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
262 [Documentation] Verify the removed mac addresses on the specified open flow.
263 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
264 Should Not Be Equal As Strings ${booleanValue} True
267 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
268 [Documentation] Verify the source and destination mac address after ping in the dumpflows
269 write ${host1} ifconfig -a | grep HWaddr
270 ${sourcemacaddr} Read Until mininet>
271 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
272 ${sourcemacaddr}= Get from List ${macaddress} ${index}
273 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
274 write ${host2} ifconfig -a | grep HWaddr
275 ${destmacaddr} Read Until mininet>
276 ${macaddress}= Split String ${destmacaddr} ${SPACE}
277 ${destmacaddr}= Get from List ${macaddress} ${index}
278 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
280 ${result} Read Until mininet>
281 Should Contain ${result} ${sourcemacaddress}
282 Should Contain ${result} ${destmacaddress}
285 [Arguments] ${actions} ${DUMPFLOWS}
286 [Documentation] Verify the flowfilter actions after ping in the dumpflows
288 ${result} Read Until mininet>
289 Should Contain ${result} ${actions}
292 [Arguments] ${vtn_name} ${vtnflowfilter_data}
293 [Documentation] Create a flowfilter for a vtn
294 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
295 Should Be Equal As Strings ${resp.status_code} 200
297 Remove a vtn flowfilter
298 [Arguments] ${vtn_name} ${filter_index}
299 [Documentation] Delete a vtn flowfilter
300 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
301 Should Be Equal As Strings ${resp.status_code} 200
304 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
305 [Documentation] Create a flowfilter for a vbr
306 ${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}}}
307 Should Be Equal As Strings ${resp.status_code} 200
309 Remove a vbr flowfilter
310 [Arguments] ${vtn_name} ${vBridge_name} ${filter_index}
311 [Documentation] Delete a vbr flowfilter
312 ${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}"}}
313 Should Be Equal As Strings ${resp.status_code} 200
315 Add a vbrif flowfilter
316 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
317 [Documentation] Create a flowfilter for a vbrif
318 ${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}}}
319 Should Be Equal As Strings ${resp.status_code} 200
321 Remove a vbrif flowfilter
322 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${filter_index}
323 [Documentation] Delete a vbrif flowfilter
324 ${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}"}}
325 Should Be Equal As Strings ${resp.status_code} 200
327 Verify Flow Entries for Flowfilter
328 [Arguments] ${dumpflows} @{flowfilter_actions}
329 [Documentation] Verify switch flow entry using flowfilter for a vtn
330 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
331 Should Be Equal As Strings ${booleanValue} True
333 Verify Removed Flow Entry for Inet Drop Flowfilter
334 [Arguments] ${dumpflows} @{flowfilter_actions}
335 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
336 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
337 Should Be Equal As Strings ${booleanValue} True
339 Verify Actions on Flow Entry
340 [Arguments] ${dumpflows} @{flowfilter_actions}
341 [Documentation] check flow action elements by giving dumpflows in mininet
343 ${result} Read Until mininet>
344 : FOR ${flowElement} IN @{flowfilter_actions}
345 \ should Contain ${result} ${flowElement}
348 [Arguments] ${flowcond_name} ${flowconditiondata}
349 [Documentation] Create a flowcondition using Restconfig Api
350 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
351 Should Be Equal As Strings ${resp.status_code} 200
354 [Documentation] Retrieve the list of flowconditions created
355 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
356 Should Be Equal As Strings ${resp.status_code} 200
359 [Arguments] ${flowcond_name} ${retrieve}
360 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
361 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
362 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
363 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
364 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
367 [Arguments] ${flowcond_name}
368 [Documentation] Remove the flowcondition by name
369 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
370 Should Be Equal As Strings ${resp.status_code} 200