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