7 Library RequestsLibrary
8 Variables ../variables/Variables.py
12 ${vlan_topo_10} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
13 ${vlan_topo_13} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo --switch ovsk,protocols=OpenFlow13
14 ${REST_CONTEXT_VTNS} controller/nb/v2/vtn/default/vtns
15 ${REST_CONTEXT} controller/nb/v2/vtn/default
16 ${VERSION_VTN} controller/nb/v2/vtn/version
17 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
18 ${DUMPFLOWS} dpctl dump-flows -O OpenFlow13
20 @{FLOWELMENTS} nw_src=10.0.0.1 nw_dst=10.0.0.3 actions=drop
21 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1","interface":"if2"}
22 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2","interface":"if3"}
23 ${vlanmap_bridge1} {"vlan": "200"}
24 ${vlanmap_bridge2} {"vlan": "300"}
25 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1_vlan"}
26 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2_vlan"}
27 ${pathpolicy_topo} sudo mn --controller=remote,ip=${CONTROLLER} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
28 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
30 @{PATHPOLICY_ATTR} "id":"1" "type":"OF" "name":"s4-eth2"
31 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
35 [Documentation] Start VTN Manager Init Test Suite
36 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
37 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
41 [Documentation] Stop VTN Manager Test Suite
46 [Documentation] Start VTN Manager Test Suite
47 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
50 [Documentation] Stop VTN Manager Test Suite
54 [Documentation] Check if VTN Manager is up.
55 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}
56 Should Be Equal As Strings ${resp.status_code} 200
58 Fetch vtn switch inventory
59 [Arguments] ${sw_name}
60 [Documentation] Check if Switch is detected.
61 ${resp}= RequestsLibrary.Get session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
62 Should Be Equal As Strings ${resp.status_code} 200
65 [Arguments] ${vtn_name} ${vtn_data}
66 [Documentation] Create a vtn with specified parameters.
67 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
68 Should Be Equal As Strings ${resp.status_code} 201
71 [Arguments] ${vtn_name}
72 [Documentation] Create a vtn with specified parameters.
73 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}
74 Should Be Equal As Strings ${resp.status_code} 200
77 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
78 [Documentation] Create a vBridge in a VTN
79 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
80 Should Be Equal As Strings ${resp.status_code} 201
83 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
84 [Documentation] Create a interface into a vBridge of a VTN
85 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
86 Should Be Equal As Strings ${resp.status_code} 201
89 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
90 [Documentation] Create a portmap for a interface of a vbridge
91 ${json_data}= json.dumps ${portmap_data}
92 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
93 Should Be Equal As Strings ${resp.status_code} 200
96 [Arguments] ${vtn_name} ${vBridge_name}
97 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
98 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
99 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
100 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
101 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
102 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
105 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
106 [Documentation] Verify whether the required attributes exists.
107 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
108 \ should Contain ${resp.content} ${dataflowElement}
111 [Arguments] ${pathmap_data}
112 [Documentation] Create a pathmap for a vtn
113 ${json_data}= json.dumps ${pathmap_data}
114 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
115 Should Be Equal As Strings ${resp.status_code} 201
118 [Documentation] Get a pathmap for a vtn.
119 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
120 : FOR ${pathElement} IN @{PATHMAP_ATTR}
121 \ should Contain ${resp.content} ${pathElement}
124 [Arguments] ${pathpolicy_data}
125 [Documentation] Create a pathpolicy for a vtn
126 ${json_data}= json.dumps ${pathpolicy_data}
127 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
128 Should Be Equal As Strings ${resp.status_code} 201
131 [Documentation] Get a pathpolicy for a vtn.
132 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
133 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
134 \ should Contain ${resp.content} ${pathpolicyElement}
136 Verify flowEntryBeforePathPolicy
137 [Documentation] Checking Flows on switch S1 and switch S3 before applying path policy
139 ${result} Read Until mininet>
140 @{list_to_verify} Create List in_port=1 actions=output:2 actions=output:3
141 : FOR ${flowverifyElement} IN @{list_to_verify}
142 \ should Contain ${result} ${flowverifyElement}
144 Verify flowEntryAfterPathPolicy
145 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
147 ${result} Read Until mininet>
148 @{list_to_verify} Create List in_port=1 actions=output:3 in_port=2
149 : FOR ${flowverifyElement} IN @{list_to_verify}
150 \ should Contain ${result} ${flowverifyElement}
152 Start PathSuiteVtnMaTest
153 [Documentation] Start VTN Manager Test Suite and Mininet
155 Start Mininet ${MININET} ${pathpolicy_topo} ${custom}
157 Stop PathSuiteVtnMaTest
158 [Documentation] Cleanup/Shutdown work at the completion of all tests.
160 Stop Mininet ${mininet_conn_id}
163 [Documentation] Delete a pathmap for a vtn
164 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathmaps/1
165 Should Be Equal As Strings ${resp.status_code} 200
167 Get a pathmap after delete
168 [Documentation] Get a pathmap for a vtn.
169 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
170 : FOR ${pathElement} IN @{PATHMAP_ATTR}
171 \ should Not Contain ${resp.content} ${pathElement}
174 [Documentation] Delete a pathpolicy for a vtn
175 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathpolicies/1
176 Should Be Equal As Strings ${resp.status_code} 200
178 Get a pathpolicy after delete
179 [Documentation] Get a pathpolicy for a vtn after delete.
180 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
181 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
182 \ should Not Contain ${resp.content} ${pathpolicyElement}
185 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
186 [Documentation] Create a macmap for a vbridge
187 ${json_data}= json.dumps ${macmap_data}
188 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
189 Should Be Equal As Strings ${resp.status_code} 201
192 Get DynamicMacAddress
194 [Documentation] Get Dynamic mac address of Host
195 write ${h} ifconfig -a | grep HWaddr
196 ${source} Read Until mininet>
197 ${HWaddress}= Split String ${source} ${SPACE}
198 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
199 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
200 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
202 Add a vBridgeMacMapping
203 [Arguments] ${tenant_name} ${Bridge_name} ${bridge_macmap_data}
204 [Documentation] Create a vbridge macmap for a bridge
205 ${json_data}= json.dumps ${bridge_macmap_data}
206 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${tenant_name}/vbridges/${Bridge_name}/macmap/allow data=${json_data} headers=${HEADERS}
207 Should Be Equal As Strings ${resp.status_code} 201
209 Mininet Ping Should Succeed
210 [Arguments] ${host1} ${host2}
211 Write ${host1} ping -c 10 ${host2}
212 ${result} Read Until mininet>
213 Should Contain ${result} 64 bytes
215 Mininet Ping Should Not Succeed
216 [Arguments] ${host1} ${host2}
217 Write ${host1} ping -c 10 ${host2}
218 ${result} Read Until mininet>
219 Should Not Contain ${result} 64 bytes
222 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
223 [Documentation] Delete a interface with specified parameters.
224 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
225 Should Be Equal As Strings ${resp.status_code} 200
230 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
231 Set Suite Variable ${mininet_conn_id1}
232 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
233 Execute Command sudo ovs-vsctl set-manager ptcp:6644
234 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
235 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
236 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
237 ${result} Read Until mininet>
240 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
241 [Documentation] Create a vlanmap
242 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
243 Should Be Equal As Strings ${resp.status_code} 201
246 [Arguments] ${vtn_name}
247 [Documentation] Get data flow.
248 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
249 Should Be Equal As Strings ${resp.status_code} 200
252 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
253 [Documentation] Remove a portmap for a interface of a vbridge
254 ${json_data}= json.dumps ${portmap_data}
255 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
256 Should Be Equal As Strings ${resp.status_code} 200
258 Verify FlowMacAddress
259 [Arguments] ${host1} ${host2}
260 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
261 Should Be Equal As Strings ${booleanValue} True
263 Verify RemovedFlowMacAddress
264 [Arguments] ${host1} ${host2}
265 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
266 Should Not Be Equal As Strings ${booleanValue} True
269 [Arguments] ${host1} ${host2}
270 write ${host1} ifconfig -a | grep HWaddr
271 ${sourcemacaddr} Read Until mininet>
272 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
273 ${sourcemacaddr}= Get from List ${macaddress} ${index}
274 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
275 write ${host2} ifconfig -a | grep HWaddr
276 ${destmacaddr} Read Until mininet>
277 ${macaddress}= Split String ${destmacaddr} ${SPACE}
278 ${destmacaddr}= Get from List ${macaddress} ${index}
279 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
281 ${result} Read Until mininet>
282 Should Contain ${result} ${sourcemacaddress}
283 Should Contain ${result} ${destmacaddress}
286 [Arguments] ${cond_name} ${flowcond_data}
287 [Documentation] Create a flowcondition for a interface of a vbridge
288 ${json_data}= json.dumps ${flowcond_data}
289 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
290 Should Be Equal As Strings ${resp.status_code} 201
292 Delete a flowcondition
293 [Arguments] ${cond_name}
294 [Documentation] Delete a flowcondition for a interface of a vbridge
295 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/flowconditions/${cond_name}
296 Should Be Equal As Strings ${resp.status_code} 200
299 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
300 [Documentation] Create a flowfilter for a vtn
301 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
302 Should Be Equal As Strings ${resp.status_code} 201
305 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
306 [Documentation] Create a flowfilter for a vtn
307 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
308 Should Be Equal As Strings ${resp.status_code} 201
311 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
312 [Documentation] Create a flowfilter for a vbr
313 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
314 Should Be Equal As Strings ${resp.status_code} 201
317 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
318 [Documentation] Create a flowfilter for a vtn
319 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
320 Should Be Equal As Strings ${resp.status_code} 200
322 Add a flowfilter for drop
323 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
324 [Documentation] Create a flowfilter for a vtn
325 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
326 Should Be Equal As Strings ${resp.status_code} 200
328 Verify Flow Entry for Inet Flowfilter
329 [Documentation] Verify switch flow entry using flowfilter for a vtn
330 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
331 Should Not Be Equal As Strings ${booleanValue} True
333 Verify Removed Flow Entry for Inet Drop Flowfilter
334 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
335 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
336 Should Be Equal As Strings ${booleanValue} True
338 Verify Actions on Flow Entry
340 ${result} Read Until mininet>
341 : FOR ${flowElement} IN @{FLOWELMENTS}
342 \ should Contain ${result} ${flowElement}