blob: 4aa278b25cbde03a269eb7673491c1d69b4d4b02 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class TimsDeathTest:
3
4 def __init__(self) :
5 self.default = ''
6
7 def CASE1(self,main) :
8 '''
9 First case is to simply check if ONOS, ZK, and Cassandra are all running properly.
10 If ONOS if not running properly, it will restart ONOS once before continuing.
11 It will then check if the ONOS has a view of all the switches and links as defined in the params file.
12 The test will only pass if ONOS is running properly, and has a full view of all topology elements.
13 '''
14 import time
15 main.log.report("Checking is startup was clean")
16 main.case("Checking if the startup was clean...")
17 main.step("Testing startup Zookeeper")
18 main.ONOS1.get_version()
19 data = main.Zookeeper1.isup()
20 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
21 main.step("Testing startup Cassandra")
22 data = main.Cassandra1.isup()
23 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
24 main.step("Testing startup ONOS")
25 main.ONOS1.start()
26 main.ONOS2.start()
27 main.ONOS3.start()
28 main.ONOS4.start()
29 main.ONOS1.start_rest()
30 main.ONOS2.start_rest()
31 main.ONOS3.start_rest()
32 main.ONOS4.start_rest()
33 data = main.ONOS1.isup()
34 if data == main.FALSE:
35 main.log.info("Something is funny... restarting ONOS")
36 main.ONOS1.stop()
37 time.sleep(3)
38 main.ONOS1.start()
39 time.sleep(5)
40 data = main.ONOS1.isup()
41 topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
42 if topoview == main.TRUE & data == main.TRUE :
43 data = main.TRUE
44 else:
45 data = main.FALSE
46
47 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running and has full view of topology",onfail="ONOS didn't start or has fragmented view of topology...")
48
49 def CASE2(self,main) :
50 '''
51 Second case is to time the convergence time of a topology for ONOS.
52 It shuts down the ONOS, drops keyspace, starts ONOS...
53 Then it points all the mininet switches at the ONOS node and times how long it take for the ONOS rest call to reflect the correct count of switches and links.
54 '''
55 import time
56 main.log.report("Time convergence for switches -> single ONOS node in cluster")
57 main.case("Timing Onos Convergence for switch -> a single ONOS node in the cluster")
58 main.step("Bringing ONOS down...")
59 main.log.info("all switch no controllers")
60 main.Mininet1.ctrl_none()
61 main.log.info("bringing ONOS down")
62 main.ONOS1.stop()
63 main.ONOS2.stop()
64 main.ONOS3.stop()
65 main.ONOS4.stop()
66 main.log.info("Dropping keyspace...")
67 main.ONOS1.drop_keyspace()
68 time.sleep(5)
69 main.log.info("Bringing ONOS up")
70 main.ONOS1.start()
71 time.sleep(5)
72 main.ONOS2.start()
73 main.ONOS3.start()
74 main.ONOS4.start()
75 onosup = main.ONOS1.isup()
76 onosup = onosup & main.ONOS2.isup()
77 onosup = onosup & main.ONOS3.isup()
78 onosup = onosup & main.ONOS4.isup()
79 onosup = onosup & main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
80 utilities.assert_equals(expect=main.TRUE,actual=onosup,onpass="ONOS is up and running and has full view of topology",onfail="ONOS could not even start properly...")
81
82 def CASE3(self, main) :
83 import time
84 main.log.report("Pointing the Switches at ONE controller...")
85 main.case("Point the switches to ONOS, ONOS must discover ")
86 main.Mininet1.ctrl_divide()
87 time.sleep( 10 )
88 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
89 if result == 1 :
90 test = main.TRUE
91 else :
92 test = main.FALSE
93 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="ONOS converged",onfail="ONOS did not converge")
94
95 def CASE4(self,main) :
96 import time
97 main.log.report("Test Convergence again")
98 main.case("Test Convergence again")
99 time.sleep( 5 )
100 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
101 if result == 1 :
102 test = main.TRUE
103 else :
104 test = main.FALSE
105 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="ONOS converged",onfail="ONOS did not converge")
106
107 def CASE5(self,main) :
108 import time
109 main.log.report("Test Convergence again")
110 main.case("Test Convergence again")
111 time.sleep( 5 )
112 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
113 if result == 1 :
114 test = main.TRUE
115 else :
116 test = main.FALSE
117 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="ONOS converged",onfail="ONOS did not converge, moving on with the test")
118
119 def CASE6(self,main) :
120 '''
121 This Test case:
122 - Clears out any leftover flows
123 - Adds new flows into ONOS
124 - Checks flows up to 10 times waiting for each flow to be caluculated and no "NOT" statements inte get_flow
125 '''
126 import time
127 main.log.report("Deleting and adding flows")
128 main.case("Taking care of these flows!")
129 main.step("Cleaning out any leftover flows...")
130 main.log.info("deleting...")
131 main.ONOS1.delete_flow("all")
132 main.log.info("adding...")
133 t1 = time.time()
134 main.ONOS1.add_flow(main.params['FLOWDEF'])
135 main.log.info("Checking...")
admin315a0582013-08-02 15:23:37 -0700136 for i in range(8):
adminbae64d82013-08-01 10:50:15 -0700137 result = main.ONOS1.check_flow()
138 if result == main.TRUE:
139 t2 = time.time()
140 main.log.info( 'Adding flows took %0.3f ms' % ((t2-t1)*1000.0))
141 break
142 time.sleep(2)
143 main.log.info("Checking Flows again...")
144 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="flows are good",onfail="FLOWS not correct")
145
146 def CASE7(self,main) :
147 '''
148 First major stir of the network...
149 '''
150 main.log.report("bring down links and test pings")
151 main.case("bring down links and test pings")
152 main.step("Links down")
153 for link in main.params['SET1']['begin']:
154 main.log.info(str(main.params['SET1']['begin'][link]))
155 main.Mininet1.link(END1=main.params['SET1']['begin'][link],END2=main.params['SET1']['end'][link],OPTION="down")
156
157 main.step("Testing ping")
158 success = 0
159 main.log.info("starting loops")
admin315a0582013-08-02 15:23:37 -0700160 result = main.Mininet1.fpingHost(src="h9",target="h33")
adminbae64d82013-08-01 10:50:15 -0700161 for j in range(23) :
admin315a0582013-08-02 15:23:37 -0700162 result = result & main.Mininet1.fpingHost(src="h"+str((10+j)),target="h"+str((34+j)))
adminbae64d82013-08-01 10:50:15 -0700163 main.log.info("result updated")
164 if result == main.TRUE:
165 success = success + 1
166 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700167 result = result & main.Mininet1.fpingHost(src="h"+str((33+j)),target="h"+str((57+j)))
adminbae64d82013-08-01 10:50:15 -0700168 if result == main.TRUE:
169 success = success + 1
170 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700171 result = result & main.Mininet1.fpingHost(src="h"+str((57+j)),target="h"+str((81+j)))
adminbae64d82013-08-01 10:50:15 -0700172 if result == main.TRUE:
173 success = success + 1
174 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700175 result = result & main.Mininet1.fpingHost(src="h"+str((81+j)),target="h"+str((9+j)))
adminbae64d82013-08-01 10:50:15 -0700176 if result == main.TRUE:
177 success = success + 1
178 main.log.info("%d/98 Pings Good" % success)
179 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED")
180
181 def CASE8(self,main) :
182 '''
183 Continued ping checking
184 '''
185 main.log.report("Testing flow re-route with ping")
186 main.case("Testing ping")
187 result = main.TRUE
188 success = 0
189 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700190 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700191 if result == main.TRUE:
192 success = success + 1
193 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700194 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700195 if result == main.TRUE:
196 success = success + 1
197 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700198 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700199 if result == main.TRUE:
200 success = success + 1
201 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700202 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700203 if result == main.TRUE:
204 success = success + 1
205 main.log.info("%d/98 Pings Good" % success)
206 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED")
207
208 def CASE9(self,main) :
209 '''
210 Continued ping checking
211 '''
212 main.log.report("Testing flow re-route with ping")
213 main.case("Testing ping")
214 result = main.TRUE
215 success = 0
216 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700217 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700218 if result == main.TRUE:
219 success = success + 1
220 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700221 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700222 if result == main.TRUE:
223 success = success + 1
224 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700225 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700226 if result == main.TRUE:
227 success = success + 1
228 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700229 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700230 if result == main.TRUE:
231 success = success + 1
232 main.log.info("%d/98 Pings Good" % success)
233 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED, moving on... ")
234
235 def CASE10(self,main) :
236 '''
237 Links back, up check pings.
238 '''
239 main.log.report("bring up links and test pings")
240 main.case("bring up links and test pings")
241 main.step("Links up")
242 for link in main.params['SET1']['begin']:
243 main.log.info(str(main.params['SET1']['begin'][link]))
244 main.Mininet1.link(END1=main.params['SET1']['begin'][link],END2=main.params['SET1']['end'][link],OPTION="up")
245
246 main.step("Testing ping")
247 result = main.TRUE
248 success = 0
249 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700250 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700251 if result == main.TRUE:
252 success = success + 1
253 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700254 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700255 if result == main.TRUE:
256 success = success + 1
257 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700258 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700259 if result == main.TRUE:
260 success = success + 1
261 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700262 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700263 if result == main.TRUE:
264 success = success + 1
265 main.log.info("%d/98 Pings Good" % success)
266 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good ",onfail="Pings are bad")
267
268 def CASE11(self,main) :
269 '''
270 Assign all switches to all Controllers, then kill 3 / 4 of the controllers
271 '''
272 import time
273 main.log.report("Assign all switches to all Controllers, then kill 3 / 4 of the controllers")
274 main.case("Assign all switches to all Controllers, then kill 3 / 4 of the controllers")
275 main.step("Assign all switches to all Controllers...")
276 main.Mininet1.ctrl_all()
277 time.sleep( 5 ) # Sleep for 5 sec because of my immense generosity
278 main.step("Kill ONOS 1, 3, 4")
279 main.ONOS1.stop()
280 main.ONOS3.stop()
281 main.ONOS4.stop()
282
283 time.sleep( 10 ) # Sleep again... failover failover failover failover...
284 topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
285 utilities.assert_equals(expect=main.TRUE,actual=topoview,onpass="ONOS has full view of topology",onfail="ONOS has fragmented view of topology...")
286
287 def CASE12(self,main) :
288 '''
289 Check Convergance
290 '''
291 import time
292 main.log.report("Still checking convergance")
293 main.case("Call the rest call, check all switches")
294 time.sleep( 10 ) # Sleep again... failover failover failover failover...
295 topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
296 utilities.assert_equals(expect=main.TRUE,actual=topoview,onpass="ONOS has full view of topology",onfail="ONOS has fragmented view of topology...")
297
298 def CASE13(self,main) :
299 '''
300 Check Convergance
301 '''
302 import time
303 main.log.report("Still checking convergance")
304 main.case("Call the rest call, check all switches")
305 time.sleep( 10 ) # Sleep again... failover failover failover failover...
306 topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
307 utilities.assert_equals(expect=main.TRUE,actual=topoview,onpass="ONOS has full view of topology",onfail="ONOS has fragmented view of topology...")
308
309 def CASE14(self,main) :
310 '''
311 Bring ONOS nodes back to a good state and check health
312 '''
313 main.log.report("Bringing ONOS nodes back up and checking if they're healthy")
314 main.case("Bring up ONOS nodes")
315 import time
316 main.ONOS1.start()
317 main.ONOS3.start()
318 main.ONOS4.start()
319 onosup = main.ONOS1.isup()
320 onosup = onosup & main.ONOS2.isup()
321 onosup = onosup & main.ONOS3.isup()
322 onosup = onosup & main.ONOS4.isup()
323 onosup = onosup & main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
324 utilities.assert_equals(expect=main.TRUE,actual=onosup,onpass="ONOS is up and running and has full view of topology",onfail="ONOS could not even start properly...")
325
326 def CASE15(self,main):
327 '''
328 Make a major churn in the network again...
329 '''
330 import time
331 main.log.report("Maked a major churn in the network")
332 main.case("Churning the network")
333 main.step("Links down")
334 for link in main.params['SET2']['begin']:
335 main.log.info(str(main.params['SET2']['begin'][link]))
336 main.Mininet1.link(END1=main.params['SET2']['begin'][link],END2=main.params['SET2']['end'][link],OPTION="down")
337 main.step("ONOS nodes down")
338 main.ONOS2.stop()
339 main.ONOS3.stop()
340 main.ONOS4.stop()
341 time.sleep( 10 )
342 main.step("First ping check")
343 result = main.TRUE
344 success = 0
345 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700346 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700347 if result == main.TRUE:
348 success = success + 1
349 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700350 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700351 if result == main.TRUE:
352 success = success + 1
353 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700354 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700355 if result == main.TRUE:
356 success = success + 1
357 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700358 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700359 if result == main.TRUE:
360 success = success + 1
361 main.log.info("%d/98 Pings Good" % success)
362 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED ")
363
364 def CASE16(self,main) :
365 '''
366 Continued ping checking
367 '''
368 main.log.report("Testing flow re-route with ping")
369 main.case("Testing ping")
370 main.step("Second ping check")
371 result = main.TRUE
372 success = 0
373 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700374 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700375 if result == main.TRUE:
376 success = success + 1
377 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700378 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700379 if result == main.TRUE:
380 success = success + 1
381 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700382 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700383 if result == main.TRUE:
384 success = success + 1
385 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700386 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700387 if result == main.TRUE:
388 success = success + 1
389 main.log.info("%d/98 Pings Good" % success)
390 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED")
391
392 def CASE17(self,main) :
393 '''
394 Continued ping checking
395 '''
396 main.log.report("Testing flow re-route with ping")
397 main.case("Testing ping")
398 main.step("Third ping check")
399 result = main.TRUE
400 success = 0
401 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700402 result = result & main.Mininet1.fpingHost(src="h%d"%(9+j),target="h%d"%(33+j))
adminbae64d82013-08-01 10:50:15 -0700403 if result == main.TRUE:
404 success = success + 1
405 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700406 result = result & main.Mininet1.fpingHost(src="h%d"%(33+j),target="h%d"%(57+j))
adminbae64d82013-08-01 10:50:15 -0700407 if result == main.TRUE:
408 success = success + 1
409 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700410 result = result & main.Mininet1.fpingHost(src="h%d"%(57+j),target="h%d"%(81+j))
adminbae64d82013-08-01 10:50:15 -0700411 if result == main.TRUE:
412 success = success + 1
413 for j in range(24) :
admin315a0582013-08-02 15:23:37 -0700414 result = result & main.Mininet1.fpingHost(src="h%d"%(81+j),target="h%d"%(9+j))
adminbae64d82013-08-01 10:50:15 -0700415 if result == main.TRUE:
416 success = success + 1
417 main.log.info("%d/98 Pings Good" % success)
418 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Pings are good, flow re-route: SUCCESS",onfail="Pings are bad. flow re-route: FAILED")