7 Library RequestsLibrary
8 Variables ../variables/Variables.py
12 ${vlan_topo} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
13 ${REST_CONTEXT_VTNS} controller/nb/v2/vtn/default/vtns
14 ${REST_CONTEXT} controller/nb/v2/vtn/default
15 ${VERSION_VTN} controller/nb/v2/vtn/version
16 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
17 ${DUMPFLOWS} dpctl dump-flows -O OpenFlow13
19 @{FLOWELMENTS} nw_src=10.0.0.1 nw_dst=10.0.0.3 actions=drop
20 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1","interface":"if2"}
21 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2","interface":"if3"}
22 ${vlanmap_bridge1} {"vlan": "200"}
23 ${vlanmap_bridge2} {"vlan": "300"}
24 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge1_vlan"}
25 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "path":{"tenant":"Tenant1","bridge":"vBridge2_vlan"}
26 ${pathpolicy_topo} sudo mn --controller=remote,ip=${CONTROLLER} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
27 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
29 @{PATHPOLICY_ATTR} "id":"1" "type":"OF" "name":"s4-eth2"
30 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
34 [Documentation] Start VTN Manager Init Test Suite
35 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
36 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
40 [Documentation] Stop VTN Manager Test Suite
45 [Documentation] Start VTN Manager Test Suite
46 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
49 [Documentation] Stop VTN Manager Test Suite
53 [Documentation] Check if VTN Manager is up.
54 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}
55 Should Be Equal As Strings ${resp.status_code} 200
57 Fetch vtn switch inventory
58 [Arguments] ${sw_name}
59 [Documentation] Check if Switch is detected.
60 ${resp}= RequestsLibrary.Get session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
61 Should Be Equal As Strings ${resp.status_code} 200
64 [Arguments] ${vtn_name} ${vtn_data}
65 [Documentation] Create a vtn with specified parameters.
66 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
67 Should Be Equal As Strings ${resp.status_code} 201
70 [Arguments] ${vtn_name}
71 [Documentation] Create a vtn with specified parameters.
72 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}
73 Should Be Equal As Strings ${resp.status_code} 200
76 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
77 [Documentation] Create a vBridge in a VTN
78 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
79 Should Be Equal As Strings ${resp.status_code} 201
82 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
83 [Documentation] Create a interface into a vBridge of a VTN
84 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
85 Should Be Equal As Strings ${resp.status_code} 201
88 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
89 [Documentation] Create a portmap for a interface of a vbridge
90 ${json_data}= json.dumps ${portmap_data}
91 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
92 Should Be Equal As Strings ${resp.status_code} 200
95 [Arguments] ${vtn_name} ${vBridge_name}
96 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
97 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
98 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
99 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
100 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
101 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
104 [Documentation] Verify whether the required attributes exists.
105 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
106 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
107 \ should Contain ${resp.content} ${dataflowElement}
110 [Arguments] ${pathmap_data}
111 [Documentation] Create a pathmap for a vtn
112 ${json_data}= json.dumps ${pathmap_data}
113 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
114 Should Be Equal As Strings ${resp.status_code} 201
117 [Documentation] Get a pathmap for a vtn.
118 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
119 : FOR ${pathElement} IN @{PATHMAP_ATTR}
120 \ should Contain ${resp.content} ${pathElement}
123 [Arguments] ${pathpolicy_data}
124 [Documentation] Create a pathpolicy for a vtn
125 ${json_data}= json.dumps ${pathpolicy_data}
126 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
127 Should Be Equal As Strings ${resp.status_code} 201
130 [Documentation] Get a pathpolicy for a vtn.
131 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
132 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
133 \ should Contain ${resp.content} ${pathpolicyElement}
135 Verify flowEntryBeforePathPolicy
136 [Documentation] Checking Flows on switch S1 and switch S3 before applying path policy
138 ${result} Read Until mininet>
139 @{list_to_verify} Create List in_port=1 actions=output:2 actions=output:3
140 : FOR ${flowverifyElement} IN @{list_to_verify}
141 \ should Contain ${result} ${flowverifyElement}
143 Verify flowEntryAfterPathPolicy
144 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
146 ${result} Read Until mininet>
147 @{list_to_verify} Create List in_port=1 actions=output:3 in_port=2
148 : FOR ${flowverifyElement} IN @{list_to_verify}
149 \ should Contain ${result} ${flowverifyElement}
151 Start PathSuiteVtnMaTest
152 [Documentation] Start VTN Manager Test Suite and Mininet
154 Start Mininet ${MININET} ${pathpolicy_topo} ${custom}
156 Stop PathSuiteVtnMaTest
157 [Documentation] Cleanup/Shutdown work at the completion of all tests.
159 Stop Mininet ${mininet_conn_id}
162 [Documentation] Delete a pathmap for a vtn
163 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathmaps/1
164 Should Be Equal As Strings ${resp.status_code} 200
166 Get a pathmap after delete
167 [Documentation] Get a pathmap for a vtn.
168 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
169 : FOR ${pathElement} IN @{PATHMAP_ATTR}
170 \ should Not Contain ${resp.content} ${pathElement}
173 [Documentation] Delete a pathpolicy for a vtn
174 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathpolicies/1
175 Should Be Equal As Strings ${resp.status_code} 200
177 Get a pathpolicy after delete
178 [Documentation] Get a pathpolicy for a vtn after delete.
179 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
180 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
181 \ should Not Contain ${resp.content} ${pathpolicyElement}
184 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
185 [Documentation] Create a macmap for a vbridge
186 ${json_data}= json.dumps ${macmap_data}
187 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
188 Should Be Equal As Strings ${resp.status_code} 201
190 Mininet Ping Should Succeed
191 [Arguments] ${host1} ${host2}
192 Write ${host1} ping -c 10 ${host2}
193 ${result} Read Until mininet>
194 Should Contain ${result} 64 bytes
196 Mininet Ping Should Not Succeed
197 [Arguments] ${host1} ${host2}
198 Write ${host1} ping -c 10 ${host2}
199 ${result} Read Until mininet>
200 Should Not Contain ${result} 64 bytes
203 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
204 [Documentation] Delete a interface with specified parameters.
205 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
206 Should Be Equal As Strings ${resp.status_code} 200
210 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
211 Set Suite Variable ${mininet_conn_id1}
212 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
213 Execute Command sudo ovs-vsctl set-manager ptcp:6644
214 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
216 ${result} Read Until mininet>
219 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
220 [Documentation] Create a vlanmap
221 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
222 Should Be Equal As Strings ${resp.status_code} 201
225 [Arguments] ${vtn_name}
226 [Documentation] Get data flow.
227 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
228 Should Be Equal As Strings ${resp.status_code} 200
231 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
232 [Documentation] Remove a portmap for a interface of a vbridge
233 ${json_data}= json.dumps ${portmap_data}
234 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
235 Should Be Equal As Strings ${resp.status_code} 200
237 Verify FlowMacAddress
238 [Arguments] ${host1} ${host2}
239 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
240 Should Be Equal As Strings ${booleanValue} True
242 Verify RemovedFlowMacAddress
243 [Arguments] ${host1} ${host2}
244 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
245 Should Not Be Equal As Strings ${booleanValue} True
248 [Arguments] ${host1} ${host2}
249 write ${host1} ifconfig -a | grep HWaddr
250 ${sourcemacaddr} Read Until mininet>
251 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
252 ${sourcemacaddr}= Get from List ${macaddress} ${index}
253 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
254 write ${host2} ifconfig -a | grep HWaddr
255 ${destmacaddr} Read Until mininet>
256 ${macaddress}= Split String ${destmacaddr} ${SPACE}
257 ${destmacaddr}= Get from List ${macaddress} ${index}
258 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
260 ${result} Read Until mininet>
261 Should Contain ${result} ${sourcemacaddress}
262 Should Contain ${result} ${destmacaddress}
265 [Arguments] ${cond_name} ${flowcond_data}
266 [Documentation] Create a flowcondition for a interface of a vbridge
267 ${json_data}= json.dumps ${flowcond_data}
268 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
269 Should Be Equal As Strings ${resp.status_code} 201
271 Delete a flowcondition
272 [Arguments] ${cond_name}
273 [Documentation] Delete a flowcondition for a interface of a vbridge
274 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/flowconditions/${cond_name}
275 Should Be Equal As Strings ${resp.status_code} 200
278 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
279 [Documentation] Create a flowfilter for a vtn
280 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
281 Should Be Equal As Strings ${resp.status_code} 201
284 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
285 [Documentation] Create a flowfilter for a vtn
286 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
287 Should Be Equal As Strings ${resp.status_code} 201
290 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
291 [Documentation] Create a flowfilter for a vbr
292 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
293 Should Be Equal As Strings ${resp.status_code} 201
296 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
297 [Documentation] Create a flowfilter for a vtn
298 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
299 Should Be Equal As Strings ${resp.status_code} 200
301 Add a flowfilter for drop
302 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
303 [Documentation] Create a flowfilter for a vtn
304 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
305 Should Be Equal As Strings ${resp.status_code} 200
307 Verify Flow Entry for Inet Flowfilter
308 [Documentation] Verify switch flow entry using flowfilter for a vtn
309 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
310 Should Not Be Equal As Strings ${booleanValue} True
312 Verify Removed Flow Entry for Inet Drop Flowfilter
313 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
314 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
315 Should Be Equal As Strings ${booleanValue} True
317 Verify Actions on Flow Entry
319 ${result} Read Until mininet>
320 : FOR ${flowElement} IN @{FLOWELMENTS}
321 \ should Contain ${result} ${flowElement}