blob: a5e95bda73050168cab75d9fc3f120ebdb41b620 [file] [log] [blame]
admin9529d112013-11-22 15:00:05 -08001
2class OnosPerfTest:
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...")
17 main.ONOS1.stop()
18 main.ONOS2.stop()
19 main.ONOS3.stop()
20 main.ONOS4.stop()
21 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 main.Cassandra1.start()
27 main.Cassandra2.start()
28 main.Cassandra3.start()
29 main.Cassandra4.start()
30 data = main.Cassandra1.isup()
31 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
32 main.ONOS1.drop_keyspace()
33 time.sleep(5)
34 main.ONOS1.start()
35 time.sleep(5)
36 main.ONOS2.start()
37 main.ONOS3.start()
38 main.ONOS4.start()
39 main.step("Testing startup ONOS")
40 data = main.ONOS1.isup()
41 if data == main.FALSE:
42 main.log.info("Something is funny... restarting ONOS")
43 main.ONOS1.stop()
44 time.sleep(3)
45 main.ONOS1.start()
46 time.sleep(5)
47 data = main.ONOS1.isup()
48 data = data & main.ONOS2.isup()
49 data = data & main.ONOS3.isup()
50 data = data & main.ONOS4.isup()
51 main.ONOS1.start_rest()
52 #topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
53
54 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running ",onfail="ONOS didn't start ...")
55
56 def CASE2(self,main) :
57 '''
58 Makes sure that the HW links are all up
59 Verifies that at least one mininet host exists.
60 Proves that there is actually a mininet that we are working with
61 '''
62 import time
63 main.step("Checking if MN switches exist")
64 main.log.report("Check if MN switches exist")
65 #result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
66 #for i in range(2):
67 # if result == main.FALSE:
68 # time.sleep(5)
69 # result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
70 # else:
71 # break
72 #main.step("Verifying the result")
73 #utilities.assert_equals(expect=main.TRUE,actual=result,onpass="MN switches exist",onfail="MN is missing switches and or links...")
74
75 main.step("assigning ONOS controllers to switches")
76 for i in range(25):
77 if i < 3:
78 j=i+1
79 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
80 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070081 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
admin9529d112013-11-22 15:00:05 -080082 elif i >= 3 and i < 5:
83 j=i+1
84 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
85 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070086 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
admin9529d112013-11-22 15:00:05 -080087 elif i >= 5 and i < 15:
88 j=i+1
89 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
90 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070091 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
admin9529d112013-11-22 15:00:05 -080092 else:
93 j=i+16
94 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
95 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -070096 main.Mininet1.assign_sw_controller(sw=str(j),count=4,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'])
admin9529d112013-11-22 15:00:05 -080097 main.Mininet1.get_sw_controller("s1")
98
99 def CASE3(self,main) :
100 '''
101 Verifies that ONOS sees the right topology...
102 '''
103 import time
104 main.log.report("checking if ONOS sees the right topo...")
105 main.case("TOPO check")
106 main.step("calling rest calls")
107 for i in range(9):
108 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
109 time.sleep(5)
110 if result == 1:
111 break
112 if result == 0:
113 main.ONOS1.start()
114 main.ONOS2.start()
115 main.ONOS3.start()
116 main.ONOS4.start()
117 for i in range(9):
118 result = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
119 time.sleep(5)
120 if result == 1:
121 break
122 utilities.assert_equals(expect=1,actual=result)
123
124 def CASE4(self,main) :
125 '''
126 This Test case:
127 - Clears out any leftover flows
128 - Adds new flows into ONOS
129 - Checks flows up to 10 times waiting for each flow to be caluculated and no "NOT" statements inte get_flow
130 '''
131 import time
132 main.log.report("Deleting and adding flows")
133 main.case("Taking care of these flows!")
134 main.step("Cleaning out any leftover flows...")
135 main.log.info("deleting...")
136 main.ONOS1.delete_flow("all")
137 main.log.info("adding...")
138 t1 = time.time()
139 main.ONOS1.add_flow(main.params['FLOWDEF'])
140 main.log.info("Checking...")
141 for i in range(15):
142 result = main.ONOS1.check_flow()
143 if result == main.TRUE:
144 t2 = time.time()
145 main.log.info( 'Adding flows took %0.3f s' % (t2-t1))
146 break
147 time.sleep(5)
148 main.log.info("Checking Flows again...")
149
150 strtTime = time.time()
151 count = 1
152 i = 6
153 while i < 16 :
154 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
155 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
156 if ping == main.FALSE and count < 3:
157 count = count + 1
158 i = 6
159 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
160 time.sleep(10)
161 elif ping == main.FALSE and count ==3:
162 main.log.error("Ping test failed")
163 i = 17
164 result = main.FALSE
165 elif ping == main.TRUE:
166 i = i + 1
167 result = main.TRUE
168 endTime = time.time()
169 if result == main.TRUE:
170 main.log.info("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
171 else:
172 main.log.info("\tPING TEST FAIL")
173
174 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="flows are good",onfail="FLOWS not correct")
175
176
177 def CASE5(self,main) :
178 '''
179 Tests a single ping
180 '''
181 main.log.report("Testing a single ping")
182 main.case("Testing ping...")
183 ping_result = main.Mininet4.pingHost(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
184 utilities.assert_equals(expect=main.TRUE,actual=ping_result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
185
186
187 def CASE6(self,main) :
188 '''
189 Starts continuous pings on the Mininet nodes
190 '''
191 main.log.report("Start continuous pings, then toggle links in center triangle")
192 import time
193 import os
194
195 main.case("Starting long ping... ")
196 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
197 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
198 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
199 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
200 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
201 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
202 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
203 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
204 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
205 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
206 main.step("Check that the pings are going")
207 result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
208 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
209 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source3'])
210 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source4'])
211 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source5'])
212 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source6'])
213 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source7'])
214 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source8'])
215 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source9'])
216 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source10'])
217 main.step( "Making topo change while flows are rerouting")
218
219 for i in range(int(main.params['Iterations'])):
220 main.log.info("s1-s2 link down")
221 main.Mininet1.link(END1="s1",END2="s2",OPTION="down")
222
223 time.sleep(3)
224
225 main.log.info("s1-s2 link up | s1-s3 link down | s2-s3 link down")
226 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
227 main.Mininet1.link(END1="s1",END2="s3",OPTION="down")
228 main.Mininet1.link(END1="s2",END2="s3",OPTION="down")
229
230 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
231 time.sleep( int(main.params['WaitTime']) )
232
233 main.case("Killing remote ping processes ")
234 result = result & main.Mininet4.pingKill()
235 utilities.assert_equals(expect=main.TRUE,actual=result)
236
237
238 def CASE7(self,main) :
239 '''
240 Processes all of the ping data and outputs raw data and an overall average
241 '''
242 import os
243 import time
244 main.log.report("Process ping data")
245 main.case("Processing Ping data")
246 time.sleep(3)
247 #result=os.popen("/home/admin/tools/shell.sh " + main.params['Iterations']).read()
248 result=os.popen("/home/admin/get_reroute_times.py").read()
249 average=result.split(":")[1]
250 main.log.info( "Reroute times are... " )
251 main.log.report( result )
252 try:
253 if float(average) < float(main.params['TargetTime']) :
254 test=main.TRUE
255 else:
256 test=main.FALSE
257 except ValueError:
258 main.log.error("Data is corrupted")
259 test=main.FALSE
260 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="Average is less then the target time!",onfail="Average is worse then target time... ")
261
262 def CASE8(self,main) :
263 '''
264 Starts continuous pings on the Mininet nodes
265 '''
266 main.log.report("Start continuous pings, then toggle links in center triangle")
267 import time
268 import os
269
270 main.case("Starting long ping... ")
271 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
272 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
273 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
274 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
275 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
276 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
277 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
278 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
279 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
280 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
281 main.step("Check that the pings are going")
282 result = main.Mininet4.pingstatus(src=main.params['PING']['source1'])
283 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source2'])
284 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source3'])
285 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source4'])
286 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source5'])
287 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source6'])
288 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source7'])
289 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source8'])
290 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source9'])
291 result = result & main.Mininet4.pingstatus(src=main.params['PING']['source10'])
292 main.step( "Making topo change while flows are rerouting")
293
294 for i in range(int(main.params['Iterations'])):
295 main.log.info("s1-s2 link down | Onos 1 down")
296 main.Mininet1.link(END1="s1",END2="s2",OPTION="down")
297 main.ONOS1.stop()
298
299 time.sleep(3)
300
301 main.log.info("s1-s2 link up | Onos 1 back up")
302 main.Mininet1.link(END1="s1",END2="s2",OPTION="up")
303 main.ONOS1.start()
304 main.ONOS1.isup()
305
306 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
307 time.sleep( int(main.params['WaitTime']) )
308
309 main.case("Killing remote ping processes ")
310 result = result & main.Mininet4.pingKill()
311 utilities.assert_equals(expect=main.TRUE,actual=result)
312
313
314 def CASE9(self,main) :
315 '''
316 Processes all of the ping data and outputs raw data and an overall average
317 '''
318 import os
319 import time
320 main.log.report("Process ping data")
321 main.case("Processing Ping data")
322 time.sleep(3)
323 #result=os.popen("/home/admin/tools/shell.sh " + main.params['Iterations']).read()
324 result=os.popen("/home/admin/get_reroute_times.py").read()
325 average=result.split(":")[1]
326 main.log.info( "Reroute times are... " )
327 main.log.report( result )
328 try:
329 if float(average) < float(main.params['TargetTime']) :
330 test=main.TRUE
331 else:
332 test=main.FALSE
333 except ValueError:
334 main.log.error("Data is corrupted")
335 test=main.FALSE
336 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="Average is less then the target time!",onfail="Average is worse then target time... ")
337