blob: e7a5fa0c717e320087fcd805194b88ca699eecb1 [file] [log] [blame]
admin733ae0a2014-04-09 15:01:12 -07001
2class RCOnosSanity4nodesJ :
3
4 def __init__(self) :
5 self.default = ''
6
7#*****************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
10 def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
11 import time
Jon Halle80ef8c2014-04-29 15:29:13 -070012 main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
13 main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
14 main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
15 main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
16
Jon Hall0955bc92014-04-16 17:00:19 -070017 main.Zookeeper1.start()
Jon Halle80ef8c2014-04-29 15:29:13 -070018 main.Zookeeper2.start()
19 main.Zookeeper3.start()
20 main.Zookeeper4.start()
21 main.RamCloud1.stop_coor()
22 main.RamCloud1.stop_serv()
23 main.RamCloud2.stop_serv()
24 main.RamCloud3.stop_serv()
25 main.RamCloud4.stop_serv()
adminaef00552014-05-08 09:18:36 -070026 time.sleep(10)
admin6c96b8e2014-05-15 11:11:58 -070027 main.RamCloud1.del_db()
28 main.RamCloud2.del_db()
29 main.RamCloud3.del_db()
30 main.RamCloud4.del_db()
adminaef00552014-05-08 09:18:36 -070031 time.sleep(10)
admin733ae0a2014-04-09 15:01:12 -070032 main.log.report("Pulling latest code from github to all nodes")
admin21211792014-04-15 15:42:39 -070033 for i in range(2):
34 uptodate = main.ONOS1.git_pull()
35 main.ONOS2.git_pull()
36 main.ONOS3.git_pull()
37 main.ONOS4.git_pull()
38 ver1 = main.ONOS1.get_version()
39 ver2 = main.ONOS4.get_version()
40 if ver1==ver2:
41 break
42 elif i==1:
43 main.ONOS2.git_pull("ONOS1 master")
44 main.ONOS3.git_pull("ONOS1 master")
45 main.ONOS4.git_pull("ONOS1 master")
Jon Halle80ef8c2014-04-29 15:29:13 -070046 #if uptodate==0
47 if 1:
admin21211792014-04-15 15:42:39 -070048 main.ONOS1.git_compile()
49 main.ONOS2.git_compile()
50 main.ONOS3.git_compile()
51 main.ONOS4.git_compile()
Jon Hall364f37a2014-04-17 10:29:35 -070052 main.ONOS1.print_version()
admin733ae0a2014-04-09 15:01:12 -070053 # main.RamCloud1.git_pull()
54 # main.RamCloud2.git_pull()
55 # main.RamCloud3.git_pull()
56 # main.RamCloud4.git_pull()
57 # main.ONOS1.get_version()
58 # main.ONOS2.get_version()
59 # main.ONOS3.get_version()
60 # main.ONOS4.get_version()
61 main.RamCloud1.start_coor()
Jon Halle80ef8c2014-04-29 15:29:13 -070062 time.sleep(1)
admin733ae0a2014-04-09 15:01:12 -070063 main.RamCloud1.start_serv()
64 main.RamCloud2.start_serv()
65 main.RamCloud3.start_serv()
66 main.RamCloud4.start_serv()
admin733ae0a2014-04-09 15:01:12 -070067 main.ONOS1.start()
Jon Halle80ef8c2014-04-29 15:29:13 -070068 time.sleep(5)
admin733ae0a2014-04-09 15:01:12 -070069 main.ONOS2.start()
70 main.ONOS3.start()
71 main.ONOS4.start()
72 main.ONOS1.start_rest()
Jon Halle80ef8c2014-04-29 15:29:13 -070073 time.sleep(10)
admin733ae0a2014-04-09 15:01:12 -070074 test= main.ONOS1.rest_status()
75 if test == main.FALSE:
76 main.ONOS1.start_rest()
77 main.ONOS1.get_version()
78 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
79 main.case("Checking if the startup was clean...")
80 main.step("Testing startup Zookeeper")
81 data = main.Zookeeper1.isup()
82 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
83 main.step("Testing startup RamCloud")
Jon Halle80ef8c2014-04-29 15:29:13 -070084 data = main.RamCloud1.status_serv()
admin733ae0a2014-04-09 15:01:12 -070085 if data == main.FALSE:
86 main.RamCloud1.stop_coor()
87 main.RamCloud1.stop_serv()
88 main.RamCloud2.stop_serv()
89 main.RamCloud3.stop_serv()
90 main.RamCloud4.stop_serv()
91
92 time.sleep(5)
93 main.RamCloud1.start_coor()
94 main.RamCloud1.start_serv()
95 main.RamCloud2.start_serv()
96 main.RamCloud3.start_serv()
97 main.RamCloud4.start_serv()
98 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
99 main.step("Testing startup ONOS")
100 data = main.ONOS1.isup()
adminaef00552014-05-08 09:18:36 -0700101 for i in range(3):
102 if data == main.FALSE:
103 #main.log.report("Something is funny... restarting ONOS")
104 #main.ONOS1.stop()
105 time.sleep(3)
106 #main.ONOS1.start()
107 #time.sleep(5)
108 data = main.ONOS1.isup()
109 else:
110 break
admin733ae0a2014-04-09 15:01:12 -0700111 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
adminaef00552014-05-08 09:18:36 -0700112 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700113
114#**********************************************************************************************************************************************************************************************
115#Assign Controllers
116#This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined in Params as <CASE1><destination>).
117#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
118#NOTE: The reason why all four controllers are assigned although one was already assigned as the master is due to the 'ovs-vsctl set-controller' command erases all present controllers if
119# the controllers already assigned to the switch are not specified.
120
121 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
122 import time
123 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
124 main.case("Checking if one MN host exists")
125 main.step("Host IP Checking using checkIP")
126 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
127 main.step("Verifying the result")
128 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
129 main.step("assigning ONOS controllers to switches")
130 for i in range(25):
131 if i < 3:
132 j=i+1
133 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
134 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700135 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'])
admin733ae0a2014-04-09 15:01:12 -0700136 elif i >= 3 and i < 5:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
139 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700140 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'])
admin733ae0a2014-04-09 15:01:12 -0700141 elif i >= 5 and i < 15:
142 j=i+1
143 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
144 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700145 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'])
admin733ae0a2014-04-09 15:01:12 -0700146 else:
147 j=i+16
148 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
149 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700150 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'])
admin733ae0a2014-04-09 15:01:12 -0700151 main.Mininet1.get_sw_controller("s1")
152
153# **********************************************************************************************************************************************************************************************
154#Add Flows
155#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
156#NOTE: THE FLOWDEF FILE MUST BE PRESENT ON TESTON VM!!! TestON will copy the file from its home machine into /tmp/flowtmp on the machine the ONOS instance is present on
157
158 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
159 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
160 import time
161 main.case("Taking care of these flows!")
162 main.step("Cleaning out any leftover flows...")
adminc6cfc1c2014-04-21 13:55:21 -0700163 #main.ONOS1.delete_flow("all")
admin733ae0a2014-04-09 15:01:12 -0700164 strtTime = time.time()
adminc6cfc1c2014-04-21 13:55:21 -0700165 main.ONOS1.rm_flow()
166 print("world")
167 main.ONOS1.ad_flow()
Jon Halle80ef8c2014-04-29 15:29:13 -0700168 time.sleep(2)
169 main.ONOS1.ad_flow()
170 print("hello")
adminc6cfc1c2014-04-21 13:55:21 -0700171 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
admin733ae0a2014-04-09 15:01:12 -0700172 main.case("Checking flows")
adminc6cfc1c2014-04-21 13:55:21 -0700173
admin733ae0a2014-04-09 15:01:12 -0700174 count = 1
175 i = 6
176 while i < 16 :
177 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
178 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
179 if ping == main.FALSE and count < 9:
180 count = count + 1
181 i = 6
182 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
183 time.sleep(2)
184 elif ping == main.FALSE and count ==9:
185 main.log.error("Ping test failed")
186 i = 17
187 result = main.FALSE
188 elif ping == main.TRUE:
189 i = i + 1
190 result = main.TRUE
191 endTime = time.time()
192 if result == main.TRUE:
193 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
194 else:
195 main.log.report("\tFlows failed check")
196
197 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
198 main.step("Verifying the result")
199 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
200
201#**********************************************************************************************************************************************************************************************
202#This test case removes Controllers 2,3, and 4 then performs a ping test.
203#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
204#The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 5 seconds before trying again.
205#If the ping test fails 6 times, then the test case will return false
206 def CASE41(self,main) :
207 main.log.report("Testing Removal")
208 main.ONOS2.stop()
209 main.ONOS3.stop()
210 main.ONOS4.stop()
211 strtTime = time.time()
212 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
213 for i in range(10):
214 if result == main.FALSE:
215 time.sleep(5)
216 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
217 else:
218 break
219
220 count = 1
221 i = 6
222 while i < 16 :
223 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
224 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
225 if ping == main.FALSE and count < 6:
226 count = count + 1
227 i = 6
228 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
229 time.sleep(2)
230 elif ping == main.FALSE and count ==6:
231 main.log.error("Ping test failed")
232 i = 17
233 result = main.FALSE
234 elif ping == main.TRUE:
235 i = i + 1
236 result = main.TRUE
237 endTime = time.time()
238 if result == main.TRUE:
239 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
240 else:
241 main.log.report("\tPING TEST FAIL")
242 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
243 time.sleep(10)
244 main.ONOS2.start()
245 main.ONOS3.start()
246 main.ONOS4.start()
247 time.sleep(10)
248
249
250 def CASE4(self,main) :
251 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
252 import time
253 for i in range(25):
254 if i < 15:
255 j=i+1
256 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers
257 else:
258 j=i+16
259 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
260
261 strtTime = time.time()
262 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
263 for i in range(10):
264 if result == main.FALSE:
265 time.sleep(5)
266 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
267 else:
268 break
269
270 count = 1
271 i = 6
272 while i < 16 :
273 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
274 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
275 if ping == main.FALSE and count < 6:
276 count = count + 1
277 i = 6
278 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
279 time.sleep(2)
280 elif ping == main.FALSE and count ==6:
281 main.log.error("Ping test failed")
282 i = 17
283 result = main.FALSE
284 elif ping == main.TRUE:
285 i = i + 1
286 result = main.TRUE
287 endTime = time.time()
288 if result == main.TRUE:
289 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
290 else:
291 main.log.report("\tPING TEST FAIL")
292 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
293 time.sleep(10)
294
295# **********************************************************************************************************************************************************************************************
296#This test case restores the controllers removed by Case 4 then performs a ping test.
297
298 def CASE5(self,main) :
299 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
300 import time
301 for i in range(25):
302 if i < 15:
303 j=i+1
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700304 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'])
admin733ae0a2014-04-09 15:01:12 -0700305 else:
306 j=i+16
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700307 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'])
admin733ae0a2014-04-09 15:01:12 -0700308
309 strtTime = time.time()
310 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
adminaef00552014-05-08 09:18:36 -0700311 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700312 if result == main.FALSE:
313 time.sleep(5)
314 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
315 else:
316 break
317
318 count = 1
319 i = 6
320 while i < 16 :
321 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
322 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
323 if ping == main.FALSE and count < 6:
324 count = count + 1
325 i = 6
326 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
327 time.sleep(2)
328 elif ping == main.FALSE and count ==6:
329 main.log.error("Ping test failed")
330 i = 17
331 result = main.FALSE
332 elif ping == main.TRUE:
333 i = i + 1
334 result = main.TRUE
335 endTime = time.time()
336 if result == main.TRUE:
337 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
338 else:
339 main.log.report("\tPING TEST FAILED")
340 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
341
342# **********************************************************************************************************************************************************************************************
343#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
344
345 def CASE6(self,main) :
346 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
347 import time
348 main.case("Bringing Link down... ")
349 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
350 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
351
352 strtTime = time.time()
353 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
adminaef00552014-05-08 09:18:36 -0700354 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700355 if result == main.FALSE:
356 time.sleep(5)
357 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
358 else:
359 break
360
361 count = 1
362 i = 6
363 while i < 16 :
364 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
365 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
366 if ping == main.FALSE and count < 10:
367 count = count + 1
368 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
369 i = 6
370 time.sleep(2)
371 elif ping == main.FALSE and count == 10:
372 main.log.error("Ping test failed")
373 i = 17
374 result = main.FALSE
375 elif ping == main.TRUE:
376 i = i + 1
377 result = main.TRUE
378 endTime = time.time()
379 if result == main.TRUE:
380 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
381 else:
382 main.log.report("\tPING TEST FAILED")
383 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
384
385# **********************************************************************************************************************************************************************************************
386#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
387
388 def CASE7(self,main) :
389 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
390 import time
391 main.case("Bringing Link up... ")
392 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
393 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
Jon Halle80ef8c2014-04-29 15:29:13 -0700394 time.sleep(5)
admin733ae0a2014-04-09 15:01:12 -0700395 strtTime = time.time()
396 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
397 for i in range(2):
398 if result == main.FALSE:
399 time.sleep(5)
400 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
401 else:
402 break
403
404 strtTime = time.time()
405 count = 1
406 i = 6
407 while i < 16 :
408 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
409 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
410 if ping == main.FALSE and count < 10:
411 count = count + 1
412 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
413 i = 6
414 time.sleep(2)
415 elif ping == main.FALSE and count ==10:
416 main.log.error("Ping test failed")
417 i = 17
418 result = main.FALSE
419 elif ping == main.TRUE:
420 i = i + 1
421 result = main.TRUE
422 endTime = time.time()
423 if result == main.TRUE:
424 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
425 else:
426 main.log.report("\tPING TESTS FAILED")
427 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
428
429
430# ******************************************************************************************************************************************************************
431# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
432
433 def CASE21(self,main) :
434 import json
admin733ae0a2014-04-09 15:01:12 -0700435 main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
436 main.log.report("Check initially hostMAC/IP exist on the mininet...")
437 host = main.params['YANK']['hostname']
438 mac = main.params['YANK']['hostmac']
admin733ae0a2014-04-09 15:01:12 -0700439 RestIP1 = main.params['RESTCALL']['restIP1']
440 RestPort = main.params['RESTCALL']['restPort']
441 url = main.params['RESTCALL']['restURL']
442
443 t_topowait = 0
444 t_restwait = 10
445 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
446 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
447 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
448 time.sleep(t_topowait)
Jon Hall208b3a22014-04-16 11:30:24 -0700449 main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
admin733ae0a2014-04-09 15:01:12 -0700450 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
451 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700452 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
453 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700454 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700455 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700456 result1 = main.TRUE
457 elif Reststatus > 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700458 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
admin733ae0a2014-04-09 15:01:12 -0700459 main.log.report("switches are: " + "; ".join(Switch))
460 main.log.report("Ports are: " + "; ".join(Port))
admin733ae0a2014-04-09 15:01:12 -0700461 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700462 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700463 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
464 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700465 else:# check if rest server is working
466 main.log.error("Issue with find host")
467 result1 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700468
469
470 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
471
472 main.log.report("Yank out s1-eth1")
473 main.case("Yankout s6-eth1 (link to h1) from s1")
474 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
475 time.sleep(t_topowait)
476 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
477
Jon Hall208b3a22014-04-16 11:30:24 -0700478 main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
admin733ae0a2014-04-09 15:01:12 -0700479 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
480 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700481 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700482
Jon Hall1c4d2742014-05-22 10:57:05 -0700483 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700484 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700485 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
admin733ae0a2014-04-09 15:01:12 -0700486 result2 = main.FALSE
487 elif Reststatus > 1:
488 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
489 main.log.report("switches are: " + "; ".join(Switch))
490 main.log.report("Ports are: " + "; ".join(Port))
491 main.log.report("MACs are: " + "; ".join(MAC))
492 result2 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700493 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700494 main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
495 result2 = main.TRUE
Jon Hall208b3a22014-04-16 11:30:24 -0700496 else:# check if rest server is working
497 main.log.error("Issue with find host")
498 result2 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700499
500 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
501 main.log.report("Plug s1-eth1 into s6")
502 main.case("Plug s1-eth1 to s6")
503 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
504 time.sleep(t_topowait)
505 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700506 main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
admin733ae0a2014-04-09 15:01:12 -0700507
508 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
509 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700510 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700511
Jon Hall1c4d2742014-05-22 10:57:05 -0700512 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700513 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700514 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700515 result3 = main.TRUE
516 elif Reststatus > 1:
517 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
518 main.log.report("switches are: " + "; ".join(Switch))
519 main.log.report("Ports are: " + "; ".join(Port))
520 main.log.report("MACs are: " + "; ".join(MAC))
521 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700522 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700523 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
524 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700525 else:# check if rest server is working
526 main.log.error("Issue with find host")
527 result3 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700528
529 ###### Step to put interface "s1-eth1" back to s1"#####
530 main.log.report("Move s1-eth1 back on to s1")
531 main.case("Move s1-eth1 back to s1")
532 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
533 time.sleep(t_topowait)
534 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
535 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700536 main.log.info("\n\t\t\t\t ping issue one ping from " + str(host) + " to generate arp to switch. Ping result is not important" )
admin733ae0a2014-04-09 15:01:12 -0700537
538 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
539 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700540 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700541
542 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
543 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700544 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700545 result4 = main.TRUE
546 elif Reststatus > 1:
547 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
548 main.log.report("switches are: " + "; ".join(Switch))
549 main.log.report("Ports are: " + "; ".join(Port))
550 main.log.report("MACs are: " + "; ".join(MAC))
551 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700552 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700553 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
554 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700555 else:# check if rest server is working
556 main.log.error("Issue with find host")
557 result4 = main.FALSE
Jon Hall1c4d2742014-05-22 10:57:05 -0700558 time.sleep(6)
559 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
560 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
561 if Reststatus ==1:
562 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
563 elif Reststatus>1:
564 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
565 elif Reststatus==0:
566 main.log.report("\t PASSED - Device cleared after timeout")
admin733ae0a2014-04-09 15:01:12 -0700567
568 result = result1 and result2 and result3 and result4
569 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
570
571# Run a pure ping test.
572
573 def CASE31(self, main):
574 main.log.report("Performing Ping Test")
575 count = 1
576 i = 6
577 while i < 16 :
578 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
579 strtTime = time.time()
580 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
581 if ping == main.FALSE and count < 6:
582 count = count + 1
583 i = 6
584 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
585 time.sleep(2)
586 elif ping == main.FALSE and count ==6:
587 main.log.error("Ping test failed")
588 i = 17
589 result = main.FALSE
590 elif ping == main.TRUE:
591 i = i + 1
592 result = main.TRUE
593 endTime = time.time()
594 if result == main.TRUE:
595 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
596 else:
597 main.log.report("\tPING TEST FAIL")
598 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
599
admin1723f1c2014-05-19 16:08:39 -0700600
SeanCorcoran29b70542014-05-14 14:53:42 -0700601 def CASE66(self, main):
602 main.log.report("Checking ONOS logs for exceptions")
admin1723f1c2014-05-19 16:08:39 -0700603 count = 0
604 check1 = main.ONOS1.check_exceptions()
605 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
606 check2 = main.ONOS2.check_exceptions()
607 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
608 check3 = main.ONOS3.check_exceptions()
609 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
610 check4 = main.ONOS4.check_exceptions()
611 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
Jon Hall1c4d2742014-05-22 10:57:05 -0700612 result = main.TRUE
admin1723f1c2014-05-19 16:08:39 -0700613 if (check1 or check2 or check3 or check4):
Jon Hall1c4d2742014-05-22 10:57:05 -0700614 result = main.FALSE
admin1723f1c2014-05-19 16:08:39 -0700615 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
Jon Hall1c4d2742014-05-22 10:57:05 -0700616 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
admin1723f1c2014-05-19 16:08:39 -0700617
SeanCorcoran29b70542014-05-14 14:53:42 -0700618