blob: d7c493fda60ce0dc0da9f22dde488edbb7e9a8ea [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 Hall5a8aac62014-06-03 09:30:21 -070084 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.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()
Jon Hall5a8aac62014-06-03 09:30:21 -070098 time.sleep(5)
99 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
100
101
admin733ae0a2014-04-09 15:01:12 -0700102 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
103 main.step("Testing startup ONOS")
Jon Hall5a8aac62014-06-03 09:30:21 -0700104 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
adminaef00552014-05-08 09:18:36 -0700105 for i in range(3):
106 if data == main.FALSE:
107 #main.log.report("Something is funny... restarting ONOS")
108 #main.ONOS1.stop()
109 time.sleep(3)
110 #main.ONOS1.start()
111 #time.sleep(5)
Jon Hall5a8aac62014-06-03 09:30:21 -0700112 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
adminaef00552014-05-08 09:18:36 -0700113 else:
114 break
admin733ae0a2014-04-09 15:01:12 -0700115 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 -0700116 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700117
118#**********************************************************************************************************************************************************************************************
119#Assign Controllers
120#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>).
121#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
122#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
123# the controllers already assigned to the switch are not specified.
124
125 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
126 import time
127 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
128 main.case("Checking if one MN host exists")
129 main.step("Host IP Checking using checkIP")
130 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
131 main.step("Verifying the result")
132 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
133 main.step("assigning ONOS controllers to switches")
134 for i in range(25):
135 if i < 3:
136 j=i+1
137 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
138 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700139 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 -0700140 elif i >= 3 and i < 5:
141 j=i+1
142 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
143 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700144 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 -0700145 elif i >= 5 and i < 15:
146 j=i+1
147 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
148 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700149 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 -0700150 else:
151 j=i+16
152 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
153 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700154 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 -0700155 main.Mininet1.get_sw_controller("s1")
156
157# **********************************************************************************************************************************************************************************************
158#Add Flows
159#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
160#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
161
162 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
163 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
164 import time
165 main.case("Taking care of these flows!")
166 main.step("Cleaning out any leftover flows...")
adminc6cfc1c2014-04-21 13:55:21 -0700167 #main.ONOS1.delete_flow("all")
admin733ae0a2014-04-09 15:01:12 -0700168 strtTime = time.time()
adminc6cfc1c2014-04-21 13:55:21 -0700169 main.ONOS1.rm_flow()
170 print("world")
171 main.ONOS1.ad_flow()
Jon Halle80ef8c2014-04-29 15:29:13 -0700172 time.sleep(2)
173 main.ONOS1.ad_flow()
174 print("hello")
adminc6cfc1c2014-04-21 13:55:21 -0700175 # 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 -0700176 main.case("Checking flows")
adminc6cfc1c2014-04-21 13:55:21 -0700177
admin733ae0a2014-04-09 15:01:12 -0700178 count = 1
179 i = 6
180 while i < 16 :
181 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
182 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
183 if ping == main.FALSE and count < 9:
184 count = count + 1
185 i = 6
186 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
187 time.sleep(2)
188 elif ping == main.FALSE and count ==9:
189 main.log.error("Ping test failed")
190 i = 17
191 result = main.FALSE
192 elif ping == main.TRUE:
193 i = i + 1
194 result = main.TRUE
195 endTime = time.time()
196 if result == main.TRUE:
197 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
198 else:
199 main.log.report("\tFlows failed check")
200
201 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
202 main.step("Verifying the result")
203 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
204
205#**********************************************************************************************************************************************************************************************
206#This test case removes Controllers 2,3, and 4 then performs a ping test.
207#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
208#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.
209#If the ping test fails 6 times, then the test case will return false
210 def CASE41(self,main) :
211 main.log.report("Testing Removal")
212 main.ONOS2.stop()
213 main.ONOS3.stop()
214 main.ONOS4.stop()
215 strtTime = time.time()
216 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
217 for i in range(10):
218 if result == main.FALSE:
219 time.sleep(5)
220 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
221 else:
222 break
223
224 count = 1
225 i = 6
226 while i < 16 :
227 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
228 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
229 if ping == main.FALSE and count < 6:
230 count = count + 1
231 i = 6
232 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
233 time.sleep(2)
234 elif ping == main.FALSE and count ==6:
235 main.log.error("Ping test failed")
236 i = 17
237 result = main.FALSE
238 elif ping == main.TRUE:
239 i = i + 1
240 result = main.TRUE
241 endTime = time.time()
242 if result == main.TRUE:
243 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
244 else:
245 main.log.report("\tPING TEST FAIL")
246 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
247 time.sleep(10)
248 main.ONOS2.start()
249 main.ONOS3.start()
250 main.ONOS4.start()
251 time.sleep(10)
252
253
254 def CASE4(self,main) :
255 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
256 import time
257 for i in range(25):
258 if i < 15:
259 j=i+1
260 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
261 else:
262 j=i+16
263 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
264
265 strtTime = time.time()
266 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
267 for i in range(10):
268 if result == main.FALSE:
269 time.sleep(5)
270 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
271 else:
272 break
273
274 count = 1
275 i = 6
276 while i < 16 :
277 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
278 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
279 if ping == main.FALSE and count < 6:
280 count = count + 1
281 i = 6
282 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
283 time.sleep(2)
284 elif ping == main.FALSE and count ==6:
285 main.log.error("Ping test failed")
286 i = 17
287 result = main.FALSE
288 elif ping == main.TRUE:
289 i = i + 1
290 result = main.TRUE
291 endTime = time.time()
292 if result == main.TRUE:
293 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
294 else:
295 main.log.report("\tPING TEST FAIL")
296 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
297 time.sleep(10)
298
299# **********************************************************************************************************************************************************************************************
300#This test case restores the controllers removed by Case 4 then performs a ping test.
301
302 def CASE5(self,main) :
303 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
304 import time
305 for i in range(25):
306 if i < 15:
307 j=i+1
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700308 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 -0700309 else:
310 j=i+16
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700311 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 -0700312
313 strtTime = time.time()
314 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
adminaef00552014-05-08 09:18:36 -0700315 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700316 if result == main.FALSE:
317 time.sleep(5)
318 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
319 else:
320 break
321
322 count = 1
323 i = 6
324 while i < 16 :
325 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
326 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
327 if ping == main.FALSE and count < 6:
328 count = count + 1
329 i = 6
330 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
331 time.sleep(2)
332 elif ping == main.FALSE and count ==6:
333 main.log.error("Ping test failed")
334 i = 17
335 result = main.FALSE
336 elif ping == main.TRUE:
337 i = i + 1
338 result = main.TRUE
339 endTime = time.time()
340 if result == main.TRUE:
341 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
342 else:
343 main.log.report("\tPING TEST FAILED")
344 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
345
346# **********************************************************************************************************************************************************************************************
347#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
348
349 def CASE6(self,main) :
350 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
351 import time
352 main.case("Bringing Link down... ")
353 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
354 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
355
356 strtTime = time.time()
357 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 -0700358 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700359 if result == main.FALSE:
360 time.sleep(5)
361 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
362 else:
363 break
364
365 count = 1
366 i = 6
367 while i < 16 :
368 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
369 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
370 if ping == main.FALSE and count < 10:
371 count = count + 1
372 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
373 i = 6
374 time.sleep(2)
375 elif ping == main.FALSE and count == 10:
376 main.log.error("Ping test failed")
377 i = 17
378 result = main.FALSE
379 elif ping == main.TRUE:
380 i = i + 1
381 result = main.TRUE
382 endTime = time.time()
383 if result == main.TRUE:
384 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
385 else:
386 main.log.report("\tPING TEST FAILED")
387 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
388
389# **********************************************************************************************************************************************************************************************
390#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
391
392 def CASE7(self,main) :
393 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
394 import time
395 main.case("Bringing Link up... ")
Jon Hall5a8aac62014-06-03 09:30:21 -0700396 result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down")
admin733ae0a2014-04-09 15:01:12 -0700397 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
398 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
Jon Hall5a8aac62014-06-03 09:30:21 -0700399 time.sleep(10)
admin733ae0a2014-04-09 15:01:12 -0700400 strtTime = time.time()
Jon Hall5a8aac62014-06-03 09:30:21 -0700401 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
402 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700403 if result == main.FALSE:
Jon Hall5a8aac62014-06-03 09:30:21 -0700404 time.sleep(15)
admin733ae0a2014-04-09 15:01:12 -0700405 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
406 else:
407 break
408
409 strtTime = time.time()
410 count = 1
411 i = 6
412 while i < 16 :
413 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
414 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
415 if ping == main.FALSE and count < 10:
416 count = count + 1
417 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
418 i = 6
419 time.sleep(2)
420 elif ping == main.FALSE and count ==10:
421 main.log.error("Ping test failed")
422 i = 17
423 result = main.FALSE
424 elif ping == main.TRUE:
425 i = i + 1
426 result = main.TRUE
427 endTime = time.time()
428 if result == main.TRUE:
429 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
430 else:
431 main.log.report("\tPING TESTS FAILED")
Jon Hall5a8aac62014-06-03 09:30:21 -0700432 result = main.Mininet1.link(END1='s1',END2='s3',OPTION="up")
admin733ae0a2014-04-09 15:01:12 -0700433 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
434
435
436# ******************************************************************************************************************************************************************
437# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
438
439 def CASE21(self,main) :
440 import json
admin733ae0a2014-04-09 15:01:12 -0700441 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.")
442 main.log.report("Check initially hostMAC/IP exist on the mininet...")
443 host = main.params['YANK']['hostname']
444 mac = main.params['YANK']['hostmac']
admin733ae0a2014-04-09 15:01:12 -0700445 RestIP1 = main.params['RESTCALL']['restIP1']
446 RestPort = main.params['RESTCALL']['restPort']
447 url = main.params['RESTCALL']['restURL']
448
449 t_topowait = 0
450 t_restwait = 10
451 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
452 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
453 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
454 time.sleep(t_topowait)
Jon Hall208b3a22014-04-16 11:30:24 -0700455 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 -0700456 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
457 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700458 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
459 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700460 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700461 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 -0700462 result1 = main.TRUE
463 elif Reststatus > 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700464 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
admin733ae0a2014-04-09 15:01:12 -0700465 main.log.report("switches are: " + "; ".join(Switch))
466 main.log.report("Ports are: " + "; ".join(Port))
admin733ae0a2014-04-09 15:01:12 -0700467 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700468 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700469 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
470 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700471 else:# check if rest server is working
472 main.log.error("Issue with find host")
473 result1 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700474
475
476 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
477
478 main.log.report("Yank out s1-eth1")
479 main.case("Yankout s6-eth1 (link to h1) from s1")
480 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
481 time.sleep(t_topowait)
482 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
483
Jon Hall208b3a22014-04-16 11:30:24 -0700484 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 -0700485 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
486 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700487 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700488
Jon Hall1c4d2742014-05-22 10:57:05 -0700489 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700490 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700491 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
admin733ae0a2014-04-09 15:01:12 -0700492 result2 = main.FALSE
493 elif Reststatus > 1:
494 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
495 main.log.report("switches are: " + "; ".join(Switch))
496 main.log.report("Ports are: " + "; ".join(Port))
497 main.log.report("MACs are: " + "; ".join(MAC))
498 result2 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700499 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700500 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.")
501 result2 = main.TRUE
Jon Hall208b3a22014-04-16 11:30:24 -0700502 else:# check if rest server is working
503 main.log.error("Issue with find host")
504 result2 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700505
506 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
507 main.log.report("Plug s1-eth1 into s6")
508 main.case("Plug s1-eth1 to s6")
509 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
510 time.sleep(t_topowait)
511 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700512 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 -0700513
514 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
515 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700516 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700517
Jon Hall1c4d2742014-05-22 10:57:05 -0700518 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700519 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700520 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700521 result3 = main.TRUE
522 elif Reststatus > 1:
523 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
524 main.log.report("switches are: " + "; ".join(Switch))
525 main.log.report("Ports are: " + "; ".join(Port))
526 main.log.report("MACs are: " + "; ".join(MAC))
527 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700528 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700529 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
530 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700531 else:# check if rest server is working
532 main.log.error("Issue with find host")
533 result3 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700534
535 ###### Step to put interface "s1-eth1" back to s1"#####
536 main.log.report("Move s1-eth1 back on to s1")
537 main.case("Move s1-eth1 back to s1")
538 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
539 time.sleep(t_topowait)
540 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
541 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 -0700542 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 -0700543
544 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
545 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700546 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700547
548 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
549 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700550 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700551 result4 = main.TRUE
552 elif Reststatus > 1:
553 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
554 main.log.report("switches are: " + "; ".join(Switch))
555 main.log.report("Ports are: " + "; ".join(Port))
556 main.log.report("MACs are: " + "; ".join(MAC))
557 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700558 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700559 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
560 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700561 else:# check if rest server is working
562 main.log.error("Issue with find host")
563 result4 = main.FALSE
Jon Hall5a8aac62014-06-03 09:30:21 -0700564 time.sleep(20)
Jon Hall1c4d2742014-05-22 10:57:05 -0700565 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
566 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
567 if Reststatus ==1:
568 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
569 elif Reststatus>1:
570 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
571 elif Reststatus==0:
572 main.log.report("\t PASSED - Device cleared after timeout")
admin733ae0a2014-04-09 15:01:12 -0700573
574 result = result1 and result2 and result3 and result4
575 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
576
577# Run a pure ping test.
578
579 def CASE31(self, main):
580 main.log.report("Performing Ping Test")
581 count = 1
582 i = 6
583 while i < 16 :
584 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
585 strtTime = time.time()
586 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
587 if ping == main.FALSE and count < 6:
588 count = count + 1
589 i = 6
590 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
591 time.sleep(2)
592 elif ping == main.FALSE and count ==6:
593 main.log.error("Ping test failed")
594 i = 17
595 result = main.FALSE
596 elif ping == main.TRUE:
597 i = i + 1
598 result = main.TRUE
599 endTime = time.time()
600 if result == main.TRUE:
601 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
602 else:
603 main.log.report("\tPING TEST FAIL")
604 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
605
admin1723f1c2014-05-19 16:08:39 -0700606
SeanCorcoran29b70542014-05-14 14:53:42 -0700607 def CASE66(self, main):
608 main.log.report("Checking ONOS logs for exceptions")
admin1723f1c2014-05-19 16:08:39 -0700609 count = 0
610 check1 = main.ONOS1.check_exceptions()
611 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
612 check2 = main.ONOS2.check_exceptions()
613 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
614 check3 = main.ONOS3.check_exceptions()
615 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
616 check4 = main.ONOS4.check_exceptions()
617 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
Jon Hall1c4d2742014-05-22 10:57:05 -0700618 result = main.TRUE
admin1723f1c2014-05-19 16:08:39 -0700619 if (check1 or check2 or check3 or check4):
Jon Hall1c4d2742014-05-22 10:57:05 -0700620 result = main.FALSE
admin1723f1c2014-05-19 16:08:39 -0700621 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
Jon Hall1c4d2742014-05-22 10:57:05 -0700622 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 -0700623
SeanCorcoran29b70542014-05-14 14:53:42 -0700624