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
223 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
224 Set Suite Variable ${mininet_conn_id1}
225 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
226 Execute Command sudo ovs-vsctl set-manager ptcp:6644
227 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
228 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
229 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
230 ${result} Read Until mininet>
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
329 Verify Flow Entries for Flowfilter
330 [Arguments] ${dumpflows} @{flowfilter_actions}
331 [Documentation] Verify switch flow entry using flowfilter 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 Removed Flow Entry for Inet Drop Flowfilter
336 [Arguments] ${dumpflows} @{flowfilter_actions}
337 [Documentation] Verify removed switch flow entry using flowfilter drop 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 Actions on Flow Entry
342 [Arguments] ${dumpflows} @{flowfilter_actions}
343 [Documentation] check flow action elements by giving dumpflows in mininet
345 ${result} Read Until mininet>
346 : FOR ${flowElement} IN @{flowfilter_actions}
347 \ should Contain ${result} ${flowElement}
350 [Arguments] ${flowcond_name} ${flowconditiondata}
351 [Documentation] Create a flowcondition using Restconfig Api
352 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
353 Should Be Equal As Strings ${resp.status_code} 200
356 [Documentation] Retrieve the list of flowconditions created
357 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
358 Should Be Equal As Strings ${resp.status_code} 200
361 [Arguments] ${flowcond_name} ${retrieve}
362 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
363 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
364 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
365 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
366 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
369 [Arguments] ${flowcond_name}
370 [Documentation] Remove the flowcondition by name
371 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
372 Should Be Equal As Strings ${resp.status_code} 200