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 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
51 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
55 [Documentation] Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
56 Issue Command On Karaf Console log:set TRACE org.opendaylight.vtn
57 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
58 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
62 [Documentation] Start VTN Manager Test Suite
63 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_YANG_JSON}
66 [Documentation] Stop VTN Manager Test Suite
70 [Documentation] Stop VTN Manager Test Suite
74 [Documentation] Check if VTN Manager is up.
75 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
76 Should Be Equal As Strings ${resp.status_code} 200
78 Fetch vtn switch inventory
79 [Arguments] ${sw_name}
80 [Documentation] Check if Switch is detected.
81 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
82 Should Be Equal As Strings ${resp.status_code} 200
85 [Arguments] ${vtn_name}
86 [Documentation] Create a vtn with specified parameters.
87 ${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}}
88 Should Be Equal As Strings ${resp.status_code} 200
91 [Arguments] ${vtn_name} ${vbr_name}
92 [Documentation] Create a vBridge in a VTN
93 ${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"}}
94 Should Be Equal As Strings ${resp.status_code} 200
97 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
98 [Documentation] Create a interface into a vBridge of a VTN
99 ${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}}}
100 Should Be Equal As Strings ${resp.status_code} 200
103 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
104 [Documentation] Create a portmap for a interface of a vbridge
105 ${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}"}}
106 Should Be Equal As Strings ${resp.status_code} 200
109 [Arguments] ${vtn_name}
110 [Documentation] Delete a vtn with specified parameters.
111 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
112 Should Be Equal As Strings ${resp.status_code} 200
115 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
116 [Documentation] Create a vlanmap
117 ${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}}}
118 Should Be Equal As Strings ${resp.status_code} 200
121 [Arguments] ${vtn_name} ${vBridge_name}
122 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
123 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
124 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
125 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
126 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
127 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
129 Start PathSuiteVtnMaTest
130 [Documentation] Start VTN Manager Test Suite and Mininet
132 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
134 Start PathSuiteVtnMaTestOF10
135 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
137 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
139 Stop PathSuiteVtnMaTest
140 [Documentation] Cleanup/Shutdown work at the completion of all tests.
142 Stop Mininet ${mininet_conn_id}
145 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
146 [Documentation] Verify whether the required attributes exists.
147 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
148 \ should Contain ${resp.content} ${dataflowElement}
151 [Arguments] ${pathmap_data}
152 [Documentation] Create a pathmap for a vtn
153 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
154 Should Be Equal As Strings ${resp.status_code} 200
157 [Documentation] Get a pathmap for a vtn.
158 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
159 : FOR ${pathElement} IN @{PATHMAP_ATTR}
160 \ should Contain ${resp.content} ${pathElement}
163 [Arguments] ${pathpolicy_data}
164 [Documentation] Create a pathpolicy for a vtn
165 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
166 Should Be Equal As Strings ${resp.status_code} 200
169 [Arguments] ${pathpolicy_id}
170 [Documentation] Get a pathpolicy for a vtn.
171 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
172 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
173 \ should Contain ${resp.content} ${pathpolicyElement}
176 [Arguments] ${tenant_path}
177 [Documentation] Remove a pathmap for a vtn
178 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
179 Should Be Equal As Strings ${resp.status_code} 200
182 [Arguments] ${policy_id}
183 [Documentation] Delete a pathpolicy for a vtn
184 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
185 Should Be Equal As Strings ${resp.status_code} 200
187 Verify flowEntryPathPolicy
188 [Arguments] ${of_version} ${port} ${output}
189 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
190 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
192 ${result} Read Until mininet>
193 Should Contain ${result} in_port=${port} actions=${output}
196 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
197 [Documentation] Create a macmap for a vbridge
198 ${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}"}}
199 Should Be Equal As Strings ${resp.status_code} 200
201 Get DynamicMacAddress
203 [Documentation] Get Dynamic mac address of Host
204 write ${h} ifconfig -a | grep HWaddr
205 ${source} Read Until mininet>
206 ${HWaddress}= Split String ${source} ${SPACE}
207 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
208 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
209 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
211 Mininet Ping Should Succeed
212 [Arguments] ${host1} ${host2}
213 [Documentation] Ping hosts to check connectivity
214 Write ${host1} ping -c 1 ${host2}
215 ${result} Read Until mininet>
216 Should Contain ${result} 64 bytes
218 Mininet Ping Should Not Succeed
219 [Arguments] ${host1} ${host2}
220 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
221 Write ${host1} ping -c 3 ${host2}
222 ${result} Read Until mininet>
223 Should Not Contain ${result} 64 bytes
227 [Documentation] Create custom topology for vlan functionality
228 Install Package On Ubuntu System vlan
229 Run Keyword If '${OF}' == 'OF13' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_13} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
230 ... ELSE IF '${OF}' == 'OF10' Start Mininet ${TOOLS_SYSTEM_IP} ${vlan_topo_10} ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
233 [Arguments] ${vtn_name}
234 [Documentation] Get data flow.
235 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
236 Should Be Equal As Strings ${resp.status_code} 200
239 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
240 [Documentation] Remove a portmap for a interface of a vbridge
241 ${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}}}
242 Should Be Equal As Strings ${resp.status_code} 200
244 Verify FlowMacAddress
245 [Arguments] ${host1} ${host2} ${OF_VERSION}
246 [Documentation] Verify the source and destination mac address.
247 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
248 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
250 Verify Flows On OpenFlow
251 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
252 [Documentation] Verify the mac addresses on the specified open flow.
253 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
254 Should Be Equal As Strings ${booleanValue} True
256 Verify RemovedFlowMacAddress
257 [Arguments] ${host1} ${host2} ${OF_VERSION}
258 [Documentation] Verify the removed source and destination mac address.
259 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF10}
260 ... ELSE Verify Removed Flows On OpenFlow ${host1} ${host2} ${FF_DUMPFLOWS_OF13}
262 Verify Removed Flows On OpenFlow
263 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
264 [Documentation] Verify the removed mac addresses on the specified open flow.
265 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
266 Should Not Be Equal As Strings ${booleanValue} True
269 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
270 [Documentation] Verify the source and destination mac address after ping in the dumpflows
271 write ${host1} ifconfig -a | grep HWaddr
272 ${sourcemacaddr} Read Until mininet>
273 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
274 ${sourcemacaddr}= Get from List ${macaddress} ${index}
275 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
276 write ${host2} ifconfig -a | grep HWaddr
277 ${destmacaddr} Read Until mininet>
278 ${macaddress}= Split String ${destmacaddr} ${SPACE}
279 ${destmacaddr}= Get from List ${macaddress} ${index}
280 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
282 ${result} Read Until mininet>
283 Should Contain ${result} ${sourcemacaddress}
284 Should Contain ${result} ${destmacaddress}
287 [Arguments] ${actions} ${DUMPFLOWS}
288 [Documentation] Verify the flowfilter actions after ping in the dumpflows
290 ${result} Read Until mininet>
291 Should Contain ${result} ${actions}
294 [Arguments] ${vtn_name} ${vtnflowfilter_data}
295 [Documentation] Create a flowfilter for a vtn
296 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
297 Should Be Equal As Strings ${resp.status_code} 200
299 Remove a vtn flowfilter
300 [Arguments] ${vtn_name} ${filter_index}
301 [Documentation] Delete a vtn flowfilter
302 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:remove-flow-filter data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
303 Should Be Equal As Strings ${resp.status_code} 200
306 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
307 [Documentation] Create a flowfilter for a vbr
308 ${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}}}
309 Should Be Equal As Strings ${resp.status_code} 200
311 Remove a vbr flowfilter
312 [Arguments] ${vtn_name} ${vBridge_name} ${filter_index}
313 [Documentation] Delete a vbr flowfilter
314 ${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}"}}
315 Should Be Equal As Strings ${resp.status_code} 200
317 Add a vbrif flowfilter
318 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
319 [Documentation] Create a flowfilter for a vbrif
320 ${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}}}
321 Should Be Equal As Strings ${resp.status_code} 200
323 Remove a vbrif flowfilter
324 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${filter_index}
325 [Documentation] Delete a vbrif flowfilter
326 ${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}"}}
327 Should Be Equal As Strings ${resp.status_code} 200
330 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${id} ${node_id} ${port_id}
331 [Documentation] Create a portmap for a interface of a vbridge
332 ${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}"}}
333 Should Be Equal As Strings ${resp.status_code} 200
335 Verify Flow Entries for Flowfilter
336 [Arguments] ${dumpflows} @{flowfilter_actions}
337 [Documentation] Verify switch flow entry using flowfilter for a vtn
338 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
339 Should Be Equal As Strings ${booleanValue} True
341 Verify Removed Flow Entry for Inet Drop Flowfilter
342 [Arguments] ${dumpflows} @{flowfilter_actions}
343 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
344 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
345 Should Be Equal As Strings ${booleanValue} True
347 Verify Actions on Flow Entry
348 [Arguments] ${dumpflows} @{flowfilter_actions}
349 [Documentation] check flow action elements by giving dumpflows in mininet
351 ${result} Read Until mininet>
352 : FOR ${flowElement} IN @{flowfilter_actions}
353 \ should Contain ${result} ${flowElement}
356 [Arguments] ${flowcond_name} ${flowconditiondata}
357 [Documentation] Create a flowcondition using Restconfig Api
358 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
359 Should Be Equal As Strings ${resp.status_code} 200
362 [Documentation] Retrieve the list of flowconditions created
363 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
364 Should Be Equal As Strings ${resp.status_code} 200
367 [Arguments] ${flowcond_name} ${retrieve}
368 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
369 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
370 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
371 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
372 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
375 [Arguments] ${flowcond_name}
376 [Documentation] Remove the flowcondition by name
377 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
378 Should Be Equal As Strings ${resp.status_code} 200