blob: c4fcfa0cc5a9077bbbb1602b23fa37d14e4d9417 [file] [log] [blame]
Kailash Khalasi80b82182015-06-26 22:58:40 +00001*** Settings ***
2Documentation ONOS Sanity Test Suite
3Suite Setup ONOS Suite Setup ${CONTROLLER_IP} ${CONTROLLER_USER}
4Suite Teardown ONOS Suite Teardown
5Library SSHLibrary
6Library Collections
7Library OperatingSystem
8Library String
9Library RequestsLibrary
10Library HttpLibrary.HTTP
11
12*** Variables ***
Kailash Khalasi4d7ba022015-06-30 03:11:14 +000013##Grab the environment variables sources from your "cell"
Kailash Khalasi80b82182015-06-26 22:58:40 +000014${CONTROLLER_IP} %{OC1}
15${MININET_IP} %{OCN}
16${CONTROLLER_USER} %{ONOS_USER}
17${MININET_USER} %{ONOS_USER}
Kailash Khalasi4d7ba022015-06-30 03:11:14 +000018##USER_HOME used for public key
Kailash Khalasi80b82182015-06-26 22:58:40 +000019${USER_HOME} /home/fedora
Kailash Khalasi4d7ba022015-06-30 03:11:14 +000020##ONOS_HOME is where the onos dist will be deployed on the controller vm
Kailash Khalasi80b82182015-06-26 22:58:40 +000021${ONOS_HOME} /opt/onos
22${RESTCONFPORT} 8181
23${LINUX_PROMPT} $
Kailash Khalasi4d7ba022015-06-30 03:11:14 +000024##SWITCHES_RESULT_FILE and JENKINS_WORKSPACE can be configurable...read overriding variables in README
Kailash Khalasi80b82182015-06-26 22:58:40 +000025${SWITCHES_RESULT_FILE} ${USER_HOME}/workspace/tools/switches.csv
26${JENKINS_WORKSPACE} ${USER_HOME}/workspace/ONOS-Stable/
27${prompt_timeout} 30s
28${start} 10
29${end} 100
30${increments} 10
Kailash Khalasi4d7ba022015-06-30 03:11:14 +000031##Number of nodes in cluster. To add more nodes, create CONTROLLER_IP2/3/4 etc. variables above and change this cluster variable
Kailash Khalasi80b82182015-06-26 22:58:40 +000032${cluster} 1
33
34*** Test Cases ***
35Find Max Switches By Scaling
36 [Documentation] Find the max number of switches from ${start} until reaching ${end} in steps of ${increments}. The following checks are made through REST APIs:
37 ... -\ Verify device count is correct
38 ... -\ Verify device status is available
39 ... -\ Verify device roles are MASTER (default role in case of standalone controller)
40 ... -\ Verify topology recognizes corret number of devices (Through api "/topology")
41 ... -\ Observe each device individually
42 ... -\ Observe links, hosts, and flows through the controller
43 ... -\ Observe device info at lower level on mininet (Written for PoC). Shows flows, links, and ports. Checks can be easily implemented at that level as well
44 ... -\ STOP Mininet Topo
45 ... -\ Verify device count is zero
46 ... -\ Verify topology sees no devices (Through api "/topology")
47 [Tags] done
48 Append To File ${SWITCHES_RESULT_FILE} Max Switches Linear Topo\n
49 ${max}= Find Max Switches ${start} ${end} ${increments}
50 Log ${max}
51 Append To File ${SWITCHES_RESULT_FILE} ${max}\n
52
53*** Keywords ***
54ONOS Suite Setup
55 [Arguments] ${controller} ${user}
56 [Documentation] Transfers the ONOS dist over to the test vm and start the controller. We will leverage the bash script, "onos-install" to do this.
57 Create Controller IP List
58 ${rc}= Run and Return RC onos-package
59 Should Be Equal As Integers ${rc} 0
60 : FOR ${ip} IN @{controller_list}
61 \ ${rc}= Run and Return RC onos-install -f ${ip}
62 \ Should Be Equal As Integers ${rc} 0
63 Create HTTP Sessions
64 Wait Until Keyword Succeeds 60s 2s Verify All Controller are up
65 #If creating a cluster, create a keyword and call it here
66
67ONOS Suite Teardown
68 [Documentation] Stop ONOS on Controller VMs and grabs karaf logs on each controller (put them in /tmp)
69 ${rc}= Run and Return RC onos-kill
70 #Should Be Equal As Integers ${rc} 0
71 ${rc}= Run and Return RC cp ${SWITCHES_RESULT_FILE} ${JENKINS_WORKSPACE}
72 Should Be Equal As Integers ${rc} 0
73 ${rc}= Run and Return RC rm ${SWITCHES_RESULT_FILE}
74 Should Be Equal As Integers ${rc} 0
75 Clean Mininet System
76 : FOR ${ip} IN @{controller_list}
77 \ Get Karaf Logs ${ip}
78
79Create Controller IP List
80 [Documentation] Creates a list of controller ips for a cluster. When creating a cluster, be sure to set each variable to %{OC} env vars in the variables section
81 @{controller_list}= Create List ${CONTROLLER_IP}
82 Set Suite Variable @{controller_list}
83
84Create HTTP Sessions
85 [Documentation] Creates an http session with all controllers in the cluster. Session names are set to respective ips.
86 ${HEADERS}= Create Dictionary Content-Type application/json
87 : FOR ${ip} IN @{controller_list}
88 \ Create Session ${ip} http://${ip}:${RESTCONFPORT} headers=${HEADERS}
89
90Find Max Switches
91 [Arguments] ${start} ${stop} ${step}
92 [Documentation] Will find out max switches starting from ${start} till reaching ${stop} and in steps defined by ${step}
93 ${max-switches} Set Variable ${0}
94 ${start} Convert to Integer ${start}
95 ${stop} Convert to Integer ${stop}
96 ${step} Convert to Integer ${step}
97 : FOR ${switches} IN RANGE ${start} ${stop+1} ${step}
98 \ Start Mininet Linear ${switches}
99 \ ${status} ${result} Run Keyword And Ignore Error Verify Controllers are Not Dead
100 \ Exit For Loop If '${status}' == 'FAIL'
101 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
102 \ ... Ensure Switch Count ${switches}
103 \ Exit For Loop If '${status}' == 'FAIL'
104 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
105 \ ... Ensure Switches are Available
106 \ Exit For Loop If '${status}' == 'FAIL'
107 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
108 \ ... Ensure Switch Role MASTER
109 \ Exit For Loop If '${status}' == 'FAIL'
110 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
111 \ ... Ensure Topology ${switches} ${cluster}
112 \ Exit For Loop If '${status}' == 'FAIL'
113 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
114 \ ... Experiment Links, Hosts, and Flows
115 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
116 \ ... Check Each Switch Individually
117 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
118 \ ... Check Mininet at Lower Level
119 \ Stop Mininet
120 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
121 \ ... Ensure No Switches are Available
122 \ Exit For Loop If '${status}' == 'FAIL'
123 \ ${status} ${result} Run Keyword And Ignore Error Wait Until Keyword Succeeds ${switches*2} 2s
124 \ ... Ensure No Switches in Topology ${cluster}
125 \ Exit For Loop If '${status}' == 'FAIL'
126 \ ${max-switches} Convert To String ${switches}
127 [Return] ${max-switches}
128
129Run Command On Remote System
130 [Arguments] ${remote_system} ${cmd} ${user}=${CONTROLLER_USER} ${prompt}=${LINUX_PROMPT} ${prompt_timeout}=30s
131 [Documentation] Reduces the common work of running a command on a remote system to a single higher level robot keyword,
132 ... taking care to log in with a public key and the command given is written and the output returned. No test conditions
133 ... are checked.
134 Log Attempting to execute ${cmd} on ${remote_system}
135 ${conn_id}= SSHLibrary.Open Connection ${remote_system} prompt=${prompt} timeout=${prompt_timeout}
136 Login With Public Key ${user} ${USER_HOME}/.ssh/id_rsa any
137 SSHLibrary.Write ${cmd}
138 ${output}= SSHLibrary.Read Until ${LINUX_PROMPT}
139 SSHLibrary.Close Connection
140 Log ${output}
141 [Return] ${output}
142
143Start Mininet Linear
144 [Arguments] ${switches}
145 [Documentation] Start mininet linear topology with ${switches} nodes
146 Log To Console \n
147 Log To Console Starting mininet linear ${switches}
148 ${mininet_conn_id}= Open Connection ${MININET_IP} prompt=${LINUX_PROMPT} timeout=${switches*3}
149 Set Suite Variable ${mininet_conn_id}
150 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
151 Write sudo mn --controller=remote,ip=${CONTROLLER_IP} --topo linear,${switches} --switch ovsk,protocols=OpenFlow13
152 Read Until mininet>
153 Sleep 6
154
155Stop Mininet
156 [Documentation] Stop mininet topology
157 Log To Console Stopping Mininet
158 Switch Connection ${mininet_conn_id}
159 Read
160 Write exit
161 Read Until ${LINUX_PROMPT}
162 Close Connection
163
164Check Mininet at Lower Level
165 [Documentation] PoC for executing mininet commands at the lower level
166 Switch Connection ${mininet_conn_id}
167 Read
168 Write dpctl dump-flows -O OpenFlow13
169 ${output}= Read Until mininet>
170 Log ${output}
171 Write dump
172 ${output}= Read Until mininet>
173 Log ${output}
174 Write links
175 ${output}= Read Until mininet>
176 Log ${output}
177 Write ports
178 ${output}= Read Until mininet>
179 Log ${output}
180
181Clean Mininet System
182 [Arguments] ${mininet_system}=${MININET_IP}
183 [Documentation] Cleans the mininet environment (sudo mn -c)
184 Run Command On Remote System ${mininet_system} sudo mn -c ${CONTROLLER_USER} ${LINUX_PROMPT} 600s
185
186Verify All Controller are up
187 [Documentation] Verifies each controller is up by issuing a rest call and getting a 200
188 : FOR ${ip} IN @{controller_list}
189 \ ${resp}= ONOS Get ${ip} devices
190 \ Should Be Equal As Strings ${resp.status_code} 200
191
192Verify Controllers are Not Dead
193 [Documentation] Verifies each controller is not dead by making sure karaf log does not contain "OutOfMemoryError" and rest call still returns 200
194 : FOR ${ip} IN @{controller_list}
195 \ Verify Controller Is Not Dead ${ip}
196
197Verify Controller Is Not Dead
198 [Arguments] ${controller}
199 ${response}= Run Command On Remote System ${controller} grep java.lang.OutOfMemoryError /opt/onos/log/karaf.log
200 Should Not Contain ${response} OutOfMemoryError
201 ${resp} RequestsLibrary.Get ${controller} /onos/v1/devices
202 Log ${resp.content}
203 Should Be Equal As Strings ${resp.status_code} 200
204
205Experiment Links, Hosts, and Flows
206 [Documentation] Currently this only returns the information the controller has on links, hosts, and flows. Checks can easily be implemented
207 : FOR ${ip} IN @{controller_list}
208 \ ${resp}= ONOS Get ${ip} links
209 \ ${jsondata} To JSON ${resp.content}
210 \ ${length}= Get Length ${jsondata['links']}
211 \ Log ${resp.content}
212 \ ${resp}= ONOS Get ${ip} flows
213 \ ${jsondata} To JSON ${resp.content}
214 \ ${length}= Get Length ${jsondata['flows']}
215 \ Log ${resp.content}
216 \ ${resp}= ONOS Get ${ip} hosts
217 \ ${jsondata} To JSON ${resp.content}
218 \ ${length}= Get Length ${jsondata['hosts']}
219 \ Log ${resp.content}
220
221Ensure Topology
222 [Arguments] ${device_count} ${cluster_count}
223 [Documentation] Verifies the devices count through /topoplogy api. Currently, cluster count is inconsistent (Possible bug, will look into it), so the check on that is ignored, but logged
224 : FOR ${ip} IN @{controller_list}
225 \ ${resp}= ONOS Get ${ip} topology
226 \ Log ${resp.content}
227 \ ${devices}= Get Json Value ${resp.content} /devices
228 \ ${clusters}= Get Json Value ${resp.content} /clusters
229 \ Should Be Equal As Strings ${devices} ${device_count}
230 \ #Should Be Equal As Strings ${clusters} ${cluster_count}
231
232Ensure No Switches in Topology
233 [Arguments] ${cluster_count}
234 [Documentation] Verifies the topology sees no devices
235 : FOR ${ip} IN @{controller_list}
236 \ ${resp}= ONOS Get ${ip} topology
237 \ Log ${resp.content}
238 \ ${devices}= Get Json Value ${resp.content} /devices
239 \ ${clusters}= Get Json Value ${resp.content} /clusters
240 \ Should Be Equal As Strings ${devices} 0
241 \ #Should Be Equal As Strings ${clusters} ${cluster_count}
242
243ONOS Get
244 [Arguments] ${session} ${noun}
245 [Documentation] Common keyword to issue GET requests to the controller. Arguments are the session (controller ip) and api path
246 ${resp} RequestsLibrary.Get ${session} /onos/v1/${noun}
247 Log ${resp.content}
248 [Return] ${resp}
249
250Ensure Switch Count
251 [Arguments] ${switch_count}
252 [Documentation] Verfies the device count (passed in as arg) on each controller is accurate.
253 : FOR ${ip} IN @{controller_list}
254 \ ${resp} ONOS Get ${ip} devices
255 \ Log ${resp.content}
256 \ Should Be Equal As Strings ${resp.status_code} 200
257 \ Should Not Be Empty ${resp.content}
258 \ ${jsondata} To JSON ${resp.content}
259 \ ${length}= Get Length ${jsondata['devices']}
260 \ Should Be Equal As Integers ${length} ${switch_count}
261
262Ensure Switches are Available
263 [Documentation] Verifies that the switch's availability state is true on all switches through all controllers
264 : FOR ${ip} IN @{controller_list}
265 \ ${resp} ONOS Get ${ip} devices
266 \ Log ${resp.content}
267 \ Should Be Equal As Strings ${resp.status_code} 200
268 \ Should Not Be Empty ${resp.content}
269 \ ${jsondata} To JSON ${resp.content}
270 \ #Robot tweak to do a nested for loop
271 \ Check Each Switch Status ${jsondata} True
272
273Check Each Switch Status
274 [Arguments] ${jdata} ${bool}
275 ${length}= Get Length ${jdata['devices']}
276 : FOR ${INDEX} IN RANGE 0 ${length}
277 \ ${data}= Get From List ${jdata['devices']} ${INDEX}
278 \ ${status}= Get From Dictionary ${data} available
279 \ Should Be Equal As Strings ${status} ${bool}
280
281Ensure No Switches are Available
282 [Documentation] Verifies that the switch's availability state is false on all switches through all controllers
283 : FOR ${ip} IN @{controller_list}
284 \ ${resp} ONOS Get ${ip} devices
285 \ Log ${resp.content}
286 \ Should Be Equal As Strings ${resp.status_code} 200
287 \ Should Not Be Empty ${resp.content}
288 \ ${jsondata} To JSON ${resp.content}
289 \ Check Each Switch Status ${jsondata} False
290
291Check Each Switch Individually
292 [Documentation] Currently just observe each information the device has. Checks can easily be implemented
293 : FOR ${ip} IN @{controller_list}
294 \ ${resp} ONOS Get ${ip} devices
295 \ Should Be Equal As Strings ${resp.status_code} 200
296 \ ${jsondata} To JSON ${resp.content}
297 \ #Robot tweak to do a nested for loop
298 \ Check Each Switch ${jsondata}
299
300Check Each Switch
301 [Arguments] ${jdata}
302 ${length}= Get Length ${jdata['devices']}
303 @{dpid_list}= Create List
304 : FOR ${INDEX} IN RANGE 0 ${length}
305 \ ${devicedata}= Get From List ${jdata['devices']} ${INDEX}
306 \ ${id}= Get From Dictionary ${devicedata} id
307 \ Append To List ${dpid_list} ${id}
308 \ Log ${dpid_list}
309 ${length}= Get Length ${dpid_list}
310 : FOR ${i} IN @{dpid_list}
311 \ ${resp} ONOS Get ${ip} devices/${i}
312 \ Log ${resp.content}
313
314Ensure Switch Role
315 [Arguments] ${role}
316 [Documentation] Verifies that the controller's role for each switch is MASTER (default in standalone mode)
317 : FOR ${ip} IN @{controller_list}
318 \ ${resp} ONOS Get ${ip} devices
319 \ Log ${resp.content}
320 \ Should Be Equal As Strings ${resp.status_code} 200
321 \ Should Not Be Empty ${resp.content}
322 \ ${jsondata} To JSON ${resp.content}
323 \ Ensure Role ${jsondata} ${role}
324
325Ensure Role
326 [Arguments] ${jdata} ${role}
327 ${length}= Get Length ${jdata['devices']}
328 : FOR ${INDEX} IN RANGE 0 ${length}
329 \ ${data}= Get From List ${jdata['devices']} ${INDEX}
330 \ ${status}= Get From Dictionary ${data} role
331 \ Should Be Equal As Strings ${status} ${role}
332
333Get Karaf Logs
334 [Arguments] ${controller}
335 [Documentation] Compresses all the karaf log files on each controler and puts them on your pybot execution machine (in /tmp)
336 Run Command On Remote System ${controller} tar -zcvf /tmp/${SUITE NAME}.${controller}.tar.gz ${ONOS_HOME}/log
337 SSHLibrary.Open Connection ${controller} prompt=${LINUX_PROMPT} timeout=${prompt_timeout}
338 Login With Public Key ${CONTROLLER_USER} ${USER_HOME}/.ssh/id_rsa any
339 SSHLibrary.Get File /tmp/${SUITE NAME}.${controller}.tar.gz /tmp/
340 SSHLibrary.Close Connection