blob: f8fc49810cfd100f60c2f4db6c3ccd9457482182 [file] [log] [blame]
admincb593912014-04-14 10:34:41 -07001
2class RCOnosPerf4nodes:
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 RamCloud 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.ONOS1.stop()
16 main.ONOS2.stop()
17 main.ONOS3.stop()
18 main.ONOS4.stop()
adminaef00552014-05-08 09:18:36 -070019 main.RamCloud1.stop_coor()
20 main.RamCloud1.stop_serv()
21 main.RamCloud2.stop_serv()
22 main.RamCloud3.stop_serv()
23 main.RamCloud4.stop_serv()
24 main.ONOS1.handle.sendline("~/ONOS/onos.sh rc deldb")
25 main.ONOS2.handle.sendline("~/ONOS/onos.sh rc deldb")
26 main.ONOS3.handle.sendline("~/ONOS/onos.sh rc deldb")
27 main.ONOS4.handle.sendline("~/ONOS/onos.sh rc deldb")
28 time.sleep(10)
admincb593912014-04-14 10:34:41 -070029 main.RamCloud1.start_coor()
30 main.RamCloud1.start_serv()
31 main.RamCloud2.start_serv()
32 main.RamCloud3.start_serv()
33 main.RamCloud4.start_serv()
admincb593912014-04-14 10:34:41 -070034 main.ONOS1.start()
35 time.sleep(10)
36 main.ONOS2.start()
37 main.ONOS3.start()
38 main.ONOS4.start()
39 main.ONOS1.start_rest()
40 time.sleep(5)
41 test= main.ONOS1.rest_status()
42 if test == main.FALSE:
43 main.ONOS1.start_rest()
44 main.ONOS1.get_version()
45 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
46 main.case("Checking if the startup was clean...")
47 main.step("Testing startup Zookeeper")
48 data = main.Zookeeper1.isup()
49 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
50 main.step("Testing startup RamCloud")
Jon Halle80ef8c2014-04-29 15:29:13 -070051 data = main.RamCloud1.server_status()
admincb593912014-04-14 10:34:41 -070052 if data == main.FALSE:
53 main.RamCloud1.stop_coor()
54 main.RamCloud1.stop_serv()
55 main.RamCloud2.stop_serv()
56 main.RamCloud3.stop_serv()
57 main.RamCloud4.stop_serv()
58
59 time.sleep(5)
60 main.RamCloud1.start_coor()
61 main.RamCloud1.start_serv()
62 main.RamCloud2.start_serv()
63 main.RamCloud3.start_serv()
64 main.RamCloud4.start_serv()
65 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
66 main.step("Testing startup ONOS")
67 data = main.ONOS1.isup()
68 data = data and main.ONOS2.isup()
69 data = data and main.ONOS3.isup()
70 data = data and main.ONOS4.isup()
71 if data == main.FALSE:
72 main.log.report("Something is funny... restarting ONOS")
73 main.ONOS1.stop()
74 main.ONOS2.stop()
75 main.ONOS3.stop()
76 main.ONOS4.stop()
77 time.sleep(5)
78 main.ONOS1.start()
79 time.sleep(10)
80 main.ONOS2.start()
81 main.ONOS3.start()
82 main.ONOS4.start()
83 data = main.ONOS1.isup()
84 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
85
86 def CASE2(self,main) :
87 '''
88 Makes sure that the HW links are all up
89 Verifies that at least one mininet host exists.
90 Proves that there is actually a mininet that we are working with
91 '''
92 import time
93 main.step("Checking if MN switches exist")
94 main.log.report("Check if MN switches exist")
95 #result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
96 #for i in range(2):
97 # if result == main.FALSE:
98 # time.sleep(5)
99 # result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
100 # else:
101 # break
102 #main.step("Verifying the result")
103 #utilities.assert_equals(expect=main.TRUE,actual=result,onpass="MN switches exist",onfail="MN is missing switches and or links...")
104
105 main.step("assigning ONOS controllers to switches")
106 for i in range(25):
107 if i < 3:
108 j=i+1
109 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
110 time.sleep(1)
111 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
112 elif i >= 3 and i < 5:
113 j=i+1
114 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
115 time.sleep(1)
116 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
117 elif i >= 5 and i < 15:
118 j=i+1
119 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
120 time.sleep(1)
121 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
122 else:
123 j=i+16
124 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
125 time.sleep(1)
126 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'])
127 main.Mininet1.get_sw_controller("s1")
128 time.sleep(5)
129
130 def CASE3(self,main) :
131 '''
132 Verifies that ONOS sees the right topology...
133 '''
134 import time
135 main.log.report("checking if ONOS sees the right topo...")
136 main.case("TOPO check")
137 main.step("calling rest calls")
138 for i in range(4):
139 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
140 time.sleep(5)
141 if result == 1:
142 break
143 if result == 0:
144 main.ONOS1.start()
145 main.ONOS2.start()
146 main.ONOS3.start()
147 main.ONOS4.start()
148 time.sleep(45)
149 for i in range(4):
150 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
151 time.sleep(5)
152 if result == 1:
153 break
154 utilities.assert_equals(expect=1,actual=result)
155
156 def CASE4(self,main) :
157 '''
158 This Test case:
159 - Clears out any leftover flows
160 - Adds new flows into ONOS
161 - Checks flows up to 10 times waiting for each flow to be caluculated and no "NOT" statements inte get_flow
162 '''
163 import time
164 main.log.report("Deleting and adding flows")
165 main.case("Taking care of these flows!")
166 main.step("Cleaning out any leftover flows...")
167 main.log.info("deleting...")
Jon Halle80ef8c2014-04-29 15:29:13 -0700168 main.ONOS1.rm_flow()
169 # main.ONOS1.delete_flow("all")
admincb593912014-04-14 10:34:41 -0700170 main.log.info("adding...")
171 t1 = time.time()
Jon Halle80ef8c2014-04-29 15:29:13 -0700172 main.ONOS1.ad_flow()
173 # main.ONOS1.add_flow(main.params['FLOWDEF'])
admincb593912014-04-14 10:34:41 -0700174 main.log.info("Checking...")
175 for i in range(15):
176 result = main.ONOS1.check_flow()
177 if result == main.TRUE:
178 t2 = time.time()
179 main.log.info( 'Adding flows took %0.3f s' % (t2-t1))
180 break
181 time.sleep(5)
182 main.log.info("Checking Flows again...")
183
184 strtTime = time.time()
185 count = 1
186 i = 6
187 while i < 16 :
188 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
189 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
190 if ping == main.FALSE and count < 3:
191 count = count + 1
192 i = 6
193 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
194 time.sleep(10)
195 elif ping == main.FALSE and count ==3:
196 main.log.error("Ping test failed")
197 i = 17
198 result = main.FALSE
199 elif ping == main.TRUE:
200 i = i + 1
201 result = main.TRUE
202 endTime = time.time()
203 if result == main.TRUE:
204 main.log.info("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
205 else:
206 main.log.info("\tPING TEST FAIL")
207
208 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="flows are good",onfail="FLOWS not correct")
209
210 main.log.report("checking if ONOS sees the right topo...")
211 main.case("TOPO check")
212 main.step("calling rest calls")
213 for i in range(3):
214 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
215 time.sleep(5)
216 if result == 1:
217 break
218
219 def CASE5(self,main) :
220 '''
221 Tests a single ping
222 '''
223 main.log.report("Testing a single ping")
224 main.case("Testing ping...")
225 ping_result = main.Mininet4.pingHost(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
226 utilities.assert_equals(expect=main.TRUE,actual=ping_result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
227
228
229 def CASE6(self,main) :
230 '''
231 Starts continuous pings on the Mininet nodes
232 '''
233 main.log.report("Starting continuous ping, then toggle a single link in the center triangle")
234 import time
235 import os
236 main.case("Starting long ping... ")
237 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
238 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
239 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
240 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
241 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
242 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
243 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
244 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
245 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
246 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
247 main.step("Check that the pings are going")
248 result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
249 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
250 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source3'])
251 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source4'])
252 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source5'])
253 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source6'])
254 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source7'])
255 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source8'])
256 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source9'])
257 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source10'])
258 main.step( "Link down number of iterations: " + main.params['Iterations'] )
259 for i in range(int(main.params['Iterations'])):
260 main.log.info("Bringing Link down... ")
261 main.Mininet1.link(END1="s1",END2="s2",OPTION="down")
262 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
263 time.sleep( int(main.params['WaitTime']) )
264 main.log.info("Bringing Link up... ")
265 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
266 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
267 time.sleep( int(main.params['WaitTime']) )
268 main.case("Killing remote ping processes ")
269 result = result & main.Mininet4.pingKill()
270 utilities.assert_equals(expect=main.TRUE,actual=result)
271
272
273 def CASE7(self,main) :
274 '''
275 Processes all of the ping data and outputs raw data and an overall average
276 '''
277 import os
278 import time
279 main.log.report("Process ping data (Fail is time is >20 seconds)")
280 main.case("Processing Ping data")
281 time.sleep(3)
282 #result=os.popen("/home/admin/tools/shell.sh " + main.params['Iterations']).read()
283 try:
284 result=os.popen("/home/admin/ONLabTest/TestON/scripts/get_reroute_times.py").read()
285 average=result.split(":")[1]
286 main.log.info( "Reroute times are... " )
287 main.log.report( result + " seconds" )
288 try:
289 if float(average) < float(main.params['TargetTime']) :
290 test=main.TRUE
291 else:
292 test=main.FALSE
293 except ValueError:
294 main.log.error("Data is corrupted")
295 test=main.FALSE
296 except:
297 main.log.report("No data")
298 test=main.FALSE
299 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="Average is less then the target time!",onfail="Average is worse then target time... ")
300
301 def CASE8(self,main) :
302 '''
303 Starts continuous pings on the Mininet nodes
304 '''
305 main.log.report("Start continuous pings, then toggle multiple links in center triangle")
306 import time
307 import os
308 time.sleep(20)
309 main.case("Starting long ping... ")
310 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
311 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
312 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
313 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
314 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
315 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
316 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
317 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
318 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
319 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
320 main.step("Check that the pings are going")
321 result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
322 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
323 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source3'])
324 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source4'])
325 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source5'])
326 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source6'])
327 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source7'])
328 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source8'])
329 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source9'])
330 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source10'])
331 main.step( "Making topo change while flows are rerouting")
332 main.step( "Link down number of iterations: " + main.params['Iterations'] )
333 for i in range(int(main.params['Iterations'])):
334 main.log.info("s1-s2 link down")
335 main.Mininet1.link(END1="s1",END2="s2",OPTION="down")
336 main.Mininet1.link(END1="s1",END2="s3",OPTION="up")
337 main.Mininet1.link(END1="s2",END2="s3",OPTION="up")
338
339 time.sleep(5)
340
341 main.log.info("s1-s2 link up | s1-s3 link down | s2-s3 link down")
342 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
343 main.Mininet1.link(END1="s1",END2="s3",OPTION="down")
344 main.Mininet1.link(END1="s2",END2="s3",OPTION="down")
345
346 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
347 time.sleep( int(main.params['WaitTime']) + 60 )
348
349 main.case("Killing remote ping processes ")
350 result = result & main.Mininet4.pingKill()
351 utilities.assert_equals(expect=main.TRUE,actual=result)
352 main.log.info("Make sure all links in triangle are up")
353 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
354 main.Mininet1.link(END1="s1",END2="s3",OPTION="up")
355 main.Mininet1.link(END1="s2",END2="s3",OPTION="up")
356
357 def CASE9(self,main) :
358 '''
359 Starts continuous pings on the Mininet nodes
360 '''
361 main.log.report("Start continuous pings, then toggle one link in center triangle and start/stop 1 ONOS node")
362 import time
363 import os
364
365 time.sleep(20)
366 main.case("Starting long ping... ")
367 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
368 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
369 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
370 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
371 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
372 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
373 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
374 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
375 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
376 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
377 main.step("Check that the pings are going")
378 result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
379 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
380 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source3'])
381 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source4'])
382 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source5'])
383 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source6'])
384 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source7'])
385 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source8'])
386 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source9'])
387 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source10'])
388 main.step( "Making topo change while flows are rerouting")
389 main.step( "Link down number of iterations: " + main.params['Iterations'] )
390 for i in range(int(main.params['Iterations'])):
391 main.log.info("s1-s2 link down | Onos 1 down")
392 main.Mininet1.link(END1="s1",END2="s2",OPTION="down")
393 if i % 4 == 0:
394 main.ONOS1.stop()
395 elif i % 4 == 1:
396 main.ONOS2.stop()
397 elif i % 4 == 2:
398 main.ONOS3.stop()
399 else:
400 main.ONOS4.stop()
401
402 time.sleep(5)
403
404 main.log.info("s1-s2 link up | Onos 1 back up")
405 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
406 if i % 4 == 0:
407 main.ONOS1.start()
408 main.ONOS1.isup()
409 elif i % 4 == 1:
410 main.ONOS2.start()
411 main.ONOS2.isup()
412 elif i % 4 == 2:
413 main.ONOS3.start()
414 main.ONOS3.isup()
415 else:
416 main.ONOS4.start()
417 main.ONOS4.isup()
418
419 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
420 time.sleep( int(main.params['WaitTime']) )
421
422 main.case("Killing remote ping processes ")
423 result = result & main.Mininet4.pingKill()
424 utilities.assert_equals(expect=main.TRUE,actual=result)
425