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 -O OpenFlow10
18 ${DUMPFLOWS_OF13} dpctl dump-flows -O OpenFlow13
20 @{inet_actions} nw_src=10.0.0.1 nw_dst=10.0.0.3
21 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1" "interface-name":"if2"
22 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2" "interface-name":"if3"
23 ${vlanmap_bridge1} 200
24 ${vlanmap_bridge2} 300
25 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge1_vlan"
26 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "tenant-name":"Tenant1" "bridge-name":"vBridge2_vlan"
27 ${out_before_pathpolicy} output:2
28 ${out_after_pathpolicy} output:3
29 ${pathpolicy_topo_13} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
30 ${pathpolicy_topo_10} sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow10
31 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
34 ${dscp_action} set_field:32->nw_tos_shifted
35 ${dscp_flow} mod_nw_tos:128
36 @{icmp_action} nw_src=10.0.0.1 nw_dst=10.0.0.3
37 @{PATHPOLICY_ATTR} "id":1 "port-desc":"openflow:4,2,s4-eth2"
38 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
42 [Documentation] Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
43 Issue Command On Karaf Console log:set TRACE org.opendaylight.vtn
44 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
45 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
49 [Documentation] Start VTN Manager Test Suite
50 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
53 [Documentation] Stop VTN Manager Test Suite
57 [Documentation] Stop VTN Manager Test Suite
61 [Documentation] Check if VTN Manager is up.
62 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
63 Should Be Equal As Strings ${resp.status_code} 200
65 Fetch vtn switch inventory
66 [Arguments] ${sw_name}
67 [Documentation] Check if Switch is detected.
68 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
69 Should Be Equal As Strings ${resp.status_code} 200
72 [Arguments] ${vtn_name}
73 [Documentation] Create a vtn with specified parameters.
74 ${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}}
75 Should Be Equal As Strings ${resp.status_code} 200
78 [Arguments] ${vtn_name} ${vbr_name}
79 [Documentation] Create a vBridge in a VTN
80 ${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"}}
81 Should Be Equal As Strings ${resp.status_code} 200
84 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
85 [Documentation] Create a interface into a vBridge of a VTN
86 ${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}}}
87 Should Be Equal As Strings ${resp.status_code} 200
90 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
91 [Documentation] Create a portmap for a interface of a vbridge
92 ${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}"}}
93 Should Be Equal As Strings ${resp.status_code} 200
96 [Arguments] ${vtn_name}
97 [Documentation] Delete a vtn with specified parameters.
98 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
99 Should Be Equal As Strings ${resp.status_code} 200
102 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
103 [Documentation] Create a vlanmap
104 ${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}}}
105 Should Be Equal As Strings ${resp.status_code} 200
108 [Arguments] ${vtn_name} ${vBridge_name}
109 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
110 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow:get-data-flow data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
111 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
112 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
113 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
114 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
116 Start PathSuiteVtnMaTest
117 [Documentation] Start VTN Manager Test Suite and Mininet
119 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_13} ${custom}
121 Start PathSuiteVtnMaTestOF10
122 [Documentation] Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
124 Start Mininet ${TOOLS_SYSTEM_IP} ${pathpolicy_topo_10} ${custom}
126 Stop PathSuiteVtnMaTest
127 [Documentation] Cleanup/Shutdown work at the completion of all tests.
129 Stop Mininet ${mininet_conn_id}
132 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
133 [Documentation] Verify whether the required attributes exists.
134 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
135 \ should Contain ${resp.content} ${dataflowElement}
138 [Arguments] ${pathmap_data}
139 [Documentation] Create a pathmap for a vtn
140 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
141 Should Be Equal As Strings ${resp.status_code} 200
144 [Documentation] Get a pathmap for a vtn.
145 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
146 : FOR ${pathElement} IN @{PATHMAP_ATTR}
147 \ should Contain ${resp.content} ${pathElement}
150 [Arguments] ${pathpolicy_data}
151 [Documentation] Create a pathpolicy for a vtn
152 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
153 Should Be Equal As Strings ${resp.status_code} 200
156 [Arguments] ${pathpolicy_id}
157 [Documentation] Get a pathpolicy for a vtn.
158 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
159 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
160 \ should Contain ${resp.content} ${pathpolicyElement}
163 [Arguments] ${tenant_path}
164 [Documentation] Remove a pathmap for a vtn
165 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:remove-path-map data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
166 Should Be Equal As Strings ${resp.status_code} 200
169 [Arguments] ${policy_id}
170 [Documentation] Delete a pathpolicy for a vtn
171 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input":{"id":"${policy_id}"}}
172 Should Be Equal As Strings ${resp.status_code} 200
174 Verify flowEntryPathPolicy
175 [Arguments] ${of_version} ${port} ${output}
176 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
177 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
179 ${result} Read Until mininet>
180 Should Contain ${result} in_port=${port} actions=${output}
183 [Arguments] ${vtn_name} ${vBridge_name} ${src_add} ${dst_add}
184 [Documentation] Create a macmap for a vbridge
185 ${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}"}}
186 Should Be Equal As Strings ${resp.status_code} 200
188 Get DynamicMacAddress
190 [Documentation] Get Dynamic mac address of Host
191 write ${h} ifconfig -a | grep HWaddr
192 ${source} Read Until mininet>
193 ${HWaddress}= Split String ${source} ${SPACE}
194 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
195 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
196 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
198 Mininet Ping Should Succeed
199 [Arguments] ${host1} ${host2}
200 [Documentation] Ping hosts to check connectivity
201 Write ${host1} ping -c 1 ${host2}
202 ${result} Read Until mininet>
203 Should Contain ${result} 64 bytes
205 Mininet Ping Should Not Succeed
206 [Arguments] ${host1} ${host2}
207 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
208 Write ${host1} ping -c 3 ${host2}
209 ${result} Read Until mininet>
210 Should Not Contain ${result} 64 bytes
214 [Documentation] Create custom topology for vlan functionality
216 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
217 Set Suite Variable ${mininet_conn_id1}
218 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
219 Execute Command sudo ovs-vsctl set-manager ptcp:6644
220 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
221 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
222 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
223 ${result} Read Until mininet>
226 [Arguments] ${vtn_name}
227 [Documentation] Get data flow.
228 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
229 Should Be Equal As Strings ${resp.status_code} 200
232 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
233 [Documentation] Remove a portmap for a interface of a vbridge
234 ${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}}}
235 Should Be Equal As Strings ${resp.status_code} 200
237 Verify FlowMacAddress
238 [Arguments] ${host1} ${host2} ${OF_VERSION}
239 [Documentation] Verify the source and destination mac address.
240 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
241 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
243 Verify Flows On OpenFlow
244 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
245 [Documentation] Verify the mac addresses on the specified open flow.
246 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
247 Should Be Equal As Strings ${booleanValue} True
249 Verify RemovedFlowMacAddress
250 [Arguments] ${host1} ${host2} ${OF_VERSION}
251 [Documentation] Verify the removed source and destination mac address.
252 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
253 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
255 Verify Removed Flows On OpenFlow
256 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
257 [Documentation] Verify the removed mac addresses on the specified open flow.
258 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
259 Should Not Be Equal As Strings ${booleanValue} True
262 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
263 [Documentation] Verify the source and destination mac address after ping in the dumpflows
264 write ${host1} ifconfig -a | grep HWaddr
265 ${sourcemacaddr} Read Until mininet>
266 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
267 ${sourcemacaddr}= Get from List ${macaddress} ${index}
268 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
269 write ${host2} ifconfig -a | grep HWaddr
270 ${destmacaddr} Read Until mininet>
271 ${macaddress}= Split String ${destmacaddr} ${SPACE}
272 ${destmacaddr}= Get from List ${macaddress} ${index}
273 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
275 ${result} Read Until mininet>
276 Should Contain ${result} ${sourcemacaddress}
277 Should Contain ${result} ${destmacaddress}
280 [Arguments] ${actions} ${DUMPFLOWS}
281 [Documentation] Verify the flowfilter actions after ping in the dumpflows
283 ${result} Read Until mininet>
284 Should Contain ${result} ${actions}
287 [Arguments] ${vtn_name} ${vtnflowfilter_data}
288 [Documentation] Create a flowfilter for a vtn
289 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
290 Should Be Equal As Strings ${resp.status_code} 200
293 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
294 [Documentation] Create a flowfilter for a vbr
295 ${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}}}
296 Should Be Equal As Strings ${resp.status_code} 200
298 Add a vbrif flowfilter
299 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
300 [Documentation] Create a flowfilter for a vbrif
301 ${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}}}
302 Should Be Equal As Strings ${resp.status_code} 200
304 Verify Flow Entries for Flowfilter
305 [Arguments] ${dumpflows} @{flowfilter_actions}
306 [Documentation] Verify switch flow entry using flowfilter for a vtn
307 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
308 Should Be Equal As Strings ${booleanValue} True
310 Verify Removed Flow Entry for Inet Drop Flowfilter
311 [Arguments] ${dumpflows} @{flowfilter_actions}
312 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
313 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry ${dumpflows} @{flowfilter_actions}
314 Should Be Equal As Strings ${booleanValue} True
316 Verify Actions on Flow Entry
317 [Arguments] ${dumpflows} @{flowfilter_actions}
318 [Documentation] check flow action elements by giving dumpflows in mininet
320 ${result} Read Until mininet>
321 : FOR ${flowElement} IN @{flowfilter_actions}
322 \ should Contain ${result} ${flowElement}
325 [Arguments] ${flowcond_name} ${flowconditiondata}
326 [Documentation] Create a flowcondition using Restconfig Api
327 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
328 Should Be Equal As Strings ${resp.status_code} 200
331 [Documentation] Retrieve the list of flowconditions created
332 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
333 Should Be Equal As Strings ${resp.status_code} 200
336 [Arguments] ${flowcond_name} ${retrieve}
337 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
338 ... since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
339 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
340 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
341 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
344 [Arguments] ${flowcond_name}
345 [Documentation] Remove the flowcondition by name
346 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition data={"input":{"name":"${flowcond_name}"}}
347 Should Be Equal As Strings ${resp.status_code} 200