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 ${vlanmap_bridge1} {"vlan": "200"}
21 ${vlanmap_bridge2} {"vlan": "300"}
22 ${pathpolicy_topo} sudo mn --controller=remote,ip=${CONTROLLER} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
23 @{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
25 @{PATHPOLICY_ATTR} "id":"1" "type":"OF" "name":"s4-eth2"
26 ${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
30 [Documentation] Start VTN Manager Init Test Suite
31 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
32 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
36 [Documentation] Stop VTN Manager Test Suite
41 [Documentation] Start VTN Manager Test Suite
42 Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
45 [Documentation] Stop VTN Manager Test Suite
49 [Documentation] Check if VTN Manager is up.
50 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}
51 Should Be Equal As Strings ${resp.status_code} 200
53 Fetch vtn switch inventory
54 [Arguments] ${sw_name}
55 [Documentation] Check if Switch is detected.
56 ${resp}= RequestsLibrary.Get session ${VTN_INVENTORY}/vtn-inventory:vtn-node/${sw_name}
57 Should Be Equal As Strings ${resp.status_code} 200
60 [Arguments] ${vtn_name} ${vtn_data}
61 [Documentation] Create a vtn with specified parameters.
62 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name} data=${vtn_data}
63 Should Be Equal As Strings ${resp.status_code} 201
66 [Arguments] ${vtn_name}
67 [Documentation] Create a vtn with specified parameters.
68 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}
69 Should Be Equal As Strings ${resp.status_code} 200
72 [Arguments] ${vtn_name} ${vBridge_name} ${vBridge_data}
73 [Documentation] Create a vBridge in a VTN
74 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name} data=${vBridge_data}
75 Should Be Equal As Strings ${resp.status_code} 201
78 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${interface_data}
79 [Documentation] Create a interface into a vBridge of a VTN
80 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name} data=${interface_data}
81 Should Be Equal As Strings ${resp.status_code} 201
84 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
85 [Documentation] Create a portmap for a interface of a vbridge
86 ${json_data}= json.dumps ${portmap_data}
87 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
88 Should Be Equal As Strings ${resp.status_code} 200
91 [Arguments] ${pathmap_data}
92 [Documentation] Create a pathmap for a vtn
93 ${json_data}= json.dumps ${pathmap_data}
94 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
95 Should Be Equal As Strings ${resp.status_code} 201
98 [Documentation] Get a pathmap for a vtn.
99 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
100 : FOR ${pathElement} IN @{PATHMAP_ATTR}
101 \ should Contain ${resp.content} ${pathElement}
104 [Arguments] ${pathpolicy_data}
105 [Documentation] Create a pathpolicy for a vtn
106 ${json_data}= json.dumps ${pathpolicy_data}
107 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
108 Should Be Equal As Strings ${resp.status_code} 201
111 [Documentation] Get a pathpolicy for a vtn.
112 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
113 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
114 \ should Contain ${resp.content} ${pathpolicyElement}
116 Verify flowEntryBeforePathPolicy
117 [Documentation] Checking Flows on switch S1 and switch S3 before applying path policy
119 ${result} Read Until mininet>
120 @{list_to_verify} Create List in_port=1 actions=output:2 actions=output:3
121 : FOR ${flowverifyElement} IN @{list_to_verify}
122 \ should Contain ${result} ${flowverifyElement}
124 Verify flowEntryAfterPathPolicy
125 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
127 ${result} Read Until mininet>
128 @{list_to_verify} Create List in_port=1 actions=output:3 in_port=2
129 : FOR ${flowverifyElement} IN @{list_to_verify}
130 \ should Contain ${result} ${flowverifyElement}
132 Start PathSuiteVtnMaTest
133 [Documentation] Start VTN Manager Test Suite and Mininet
135 Start Mininet ${MININET} ${pathpolicy_topo} ${custom}
137 Stop PathSuiteVtnMaTest
138 [Documentation] Cleanup/Shutdown work at the completion of all tests.
140 Stop Mininet ${mininet_conn_id}
143 [Documentation] Delete a pathmap for a vtn
144 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathmaps/1
145 Should Be Equal As Strings ${resp.status_code} 200
147 Get a pathmap after delete
148 [Documentation] Get a pathmap for a vtn.
149 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
150 : FOR ${pathElement} IN @{PATHMAP_ATTR}
151 \ should Not Contain ${resp.content} ${pathElement}
154 [Documentation] Delete a pathpolicy for a vtn
155 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathpolicies/1
156 Should Be Equal As Strings ${resp.status_code} 200
158 Get a pathpolicy after delete
159 [Documentation] Get a pathpolicy for a vtn after delete.
160 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
161 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
162 \ should Not Contain ${resp.content} ${pathpolicyElement}
165 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
166 [Documentation] Create a macmap for a vbridge
167 ${json_data}= json.dumps ${macmap_data}
168 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/macmap/allow data=${macmap_data} headers=${HEADERS}
169 Should Be Equal As Strings ${resp.status_code} 201
171 Mininet Ping Should Succeed
172 [Arguments] ${host1} ${host2}
173 Write ${host1} ping -c 10 ${host2}
174 ${result} Read Until mininet>
175 Should Contain ${result} 64 bytes
177 Mininet Ping Should Not Succeed
178 [Arguments] ${host1} ${host2}
179 Write ${host1} ping -c 10 ${host2}
180 ${result} Read Until mininet>
181 Should Not Contain ${result} 64 bytes
184 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
185 [Documentation] Delete a interface with specified parameters.
186 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}
187 Should Be Equal As Strings ${resp.status_code} 200
191 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
192 Set Suite Variable ${mininet_conn_id1}
193 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
194 Execute Command sudo ovs-vsctl set-manager ptcp:6644
195 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
197 ${result} Read Until mininet>
200 [Arguments] ${vtn_name} ${vBridge_name} ${vlanmap_data}
201 [Documentation] Create a vlanmap
202 ${resp}= RequestsLibrary.Post session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/vlanmaps/ data=${vlanmap_data} headers=${HEADERS}
203 Should Be Equal As Strings ${resp.status_code} 201
206 [Arguments] ${vtn_name}
207 [Documentation] Get data flow.
208 ${resp}= RequestsLibrary.Get session ${REST_CONTEXT_VTNS}/${vtn_name}/flows/detail
209 Should Be Equal As Strings ${resp.status_code} 200
212 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${portmap_data}
213 [Documentation] Remove a portmap for a interface of a vbridge
214 ${json_data}= json.dumps ${portmap_data}
215 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
216 Should Be Equal As Strings ${resp.status_code} 200
218 Verify FlowMacAddress
219 [Arguments] ${host1} ${host2}
220 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
221 Should Be Equal As Strings ${booleanValue} True
223 Verify RemovedFlowMacAddress
224 [Arguments] ${host1} ${host2}
225 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2}
226 Should Not Be Equal As Strings ${booleanValue} True
229 [Arguments] ${host1} ${host2}
230 write ${host1} ifconfig -a | grep HWaddr
231 ${sourcemacaddr} Read Until mininet>
232 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
233 ${sourcemacaddr}= Get from List ${macaddress} ${index}
234 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
235 write ${host2} ifconfig -a | grep HWaddr
236 ${destmacaddr} Read Until mininet>
237 ${macaddress}= Split String ${destmacaddr} ${SPACE}
238 ${destmacaddr}= Get from List ${macaddress} ${index}
239 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
241 ${result} Read Until mininet>
242 Should Contain ${result} ${sourcemacaddress}
243 Should Contain ${result} ${destmacaddress}
246 [Arguments] ${cond_name} ${flowcond_data}
247 [Documentation] Create a flowcondition for a interface of a vbridge
248 ${json_data}= json.dumps ${flowcond_data}
249 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/flowconditions/${cond_name} data=${json_data} headers=${HEADERS}
250 Should Be Equal As Strings ${resp.status_code} 201
252 Delete a flowcondition
253 [Arguments] ${cond_name}
254 [Documentation] Delete a flowcondition for a interface of a vbridge
255 ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/flowconditions/${cond_name}
256 Should Be Equal As Strings ${resp.status_code} 200
259 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
260 [Documentation] Create a flowfilter for a vtn
261 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
262 Should Be Equal As Strings ${resp.status_code} 201
265 [Arguments] ${vtn_name} ${flowfilter_data} ${ff_index}
266 [Documentation] Create a flowfilter for a vtn
267 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/flowfilters/${ff_index} data=${flowfilter_data} headers=${HEADERS}
268 Should Be Equal As Strings ${resp.status_code} 201
271 [Arguments] ${vtn_name} ${vBridge_name} ${flowfilter_data} ${ff_index}
272 [Documentation] Create a flowfilter for a vbr
273 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
274 Should Be Equal As Strings ${resp.status_code} 201
277 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
278 [Documentation] Create a flowfilter for a vtn
279 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
280 Should Be Equal As Strings ${resp.status_code} 200
282 Add a flowfilter for drop
283 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${flowfilter_data} ${ff_index}
284 [Documentation] Create a flowfilter for a vtn
285 ${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/flowfilters/IN/${ff_index} data=${flowfilter_data} headers=${HEADERS}
286 Should Be Equal As Strings ${resp.status_code} 200
288 Verify Flow Entry for Inet Flowfilter
289 [Documentation] Verify switch flow entry using flowfilter for a vtn
290 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
291 Should Not Be Equal As Strings ${booleanValue} True
293 Verify Removed Flow Entry for Inet Drop Flowfilter
294 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
295 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
296 Should Be Equal As Strings ${booleanValue} True
298 Verify Actions on Flow Entry
300 ${result} Read Until mininet>
301 : FOR ${flowElement} IN @{FLOWELMENTS}
302 \ should Contain ${result} ${flowElement}