blob: be801e6c41c5d57212672afec6d81e3d5324ef3d [file] [log] [blame]
adminf0713ab2014-04-29 10:43:35 -07001
2class RRCOnosSanity4nodesJ :
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 Hallbd795bf2014-06-18 09:46:32 -070012 main.case("Initial Setup")
13 main.step("stop onos")
adminf0713ab2014-04-29 10:43:35 -070014 main.ONOS1.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
15 main.ONOS2.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
16 main.ONOS3.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
17 main.ONOS4.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
admin12bae622014-06-05 09:44:30 -070018 main.ONOS1.stop_all()
19 main.ONOS2.stop_all()
20 main.ONOS3.stop_all()
Jon Hallbd795bf2014-06-18 09:46:32 -070021 main.ONOS4.stop_all()
22 main.step("Start tcpdump on mn")
23 main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
admin41d6b772014-06-24 15:59:50 -070024# main.step("Start tcpdump on mn")
25# main.Mininet1.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
Jon Hallbd795bf2014-06-18 09:46:32 -070026 main.step("start ONOS")
adminf0713ab2014-04-29 10:43:35 -070027 main.Zookeeper1.start()
28 main.Zookeeper2.start()
29 main.Zookeeper3.start()
30 main.Zookeeper4.start()
admin1723f1c2014-05-19 16:08:39 -070031 main.RamCloud1.del_db()
32 main.RamCloud2.del_db()
33 main.RamCloud3.del_db()
34 main.RamCloud4.del_db()
Jon Hall5a8aac62014-06-03 09:30:21 -070035 main.log.report("Pulling latest code from github to all nodes")
adminf0713ab2014-04-29 10:43:35 -070036 for i in range(2):
37 uptodate = main.ONOS1.git_pull()
38 main.ONOS2.git_pull()
39 main.ONOS3.git_pull()
40 main.ONOS4.git_pull()
41 ver1 = main.ONOS1.get_version()
42 ver2 = main.ONOS4.get_version()
43 if ver1==ver2:
44 break
45 elif i==1:
46 main.ONOS2.git_pull("ONOS1 master")
47 main.ONOS3.git_pull("ONOS1 master")
48 main.ONOS4.git_pull("ONOS1 master")
Jon Hall5a8aac62014-06-03 09:30:21 -070049 #if uptodate==0
adminf0713ab2014-04-29 10:43:35 -070050 if 1:
51 main.ONOS1.git_compile()
52 main.ONOS2.git_compile()
53 main.ONOS3.git_compile()
54 main.ONOS4.git_compile()
55 main.ONOS1.print_version()
56 # main.RamCloud1.git_pull()
57 # main.RamCloud2.git_pull()
58 # main.RamCloud3.git_pull()
59 # main.RamCloud4.git_pull()
60 # main.ONOS1.get_version()
61 # main.ONOS2.get_version()
62 # main.ONOS3.get_version()
63 # main.ONOS4.get_version()
admin12bae622014-06-05 09:44:30 -070064 main.ONOS1.start_all()
65 main.ONOS2.start_all()
66 main.ONOS3.start_all()
67 main.ONOS4.start_all()
Jon Hall5a8aac62014-06-03 09:30:21 -070068 main.ONOS2.start_rest()
69 time.sleep(10)
70 test= main.ONOS2.rest_status()
adminf0713ab2014-04-29 10:43:35 -070071 if test == main.FALSE:
Jon Hall5a8aac62014-06-03 09:30:21 -070072 main.ONOS2.start_rest()
adminf0713ab2014-04-29 10:43:35 -070073 main.ONOS1.get_version()
74 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
adminf0713ab2014-04-29 10:43:35 -070075 main.step("Testing startup Zookeeper")
76 data = main.Zookeeper1.isup()
77 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
78 main.step("Testing startup RamCloud")
Jon Hall5a8aac62014-06-03 09:30:21 -070079 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
adminf0713ab2014-04-29 10:43:35 -070080 if data == main.FALSE:
81 main.RamCloud1.stop_coor()
82 main.RamCloud1.stop_serv()
83 main.RamCloud2.stop_serv()
84 main.RamCloud3.stop_serv()
85 main.RamCloud4.stop_serv()
86
87 time.sleep(5)
88 main.RamCloud1.start_coor()
89 main.RamCloud1.start_serv()
90 main.RamCloud2.start_serv()
91 main.RamCloud3.start_serv()
92 main.RamCloud4.start_serv()
Jon Hall5a8aac62014-06-03 09:30:21 -070093 time.sleep(5)
94 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
95
96
adminf0713ab2014-04-29 10:43:35 -070097 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
98 main.step("Testing startup ONOS")
Jon Hall5a8aac62014-06-03 09:30:21 -070099 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
100 for i in range(3):
101 if data == main.FALSE:
102 #main.log.report("Something is funny... restarting ONOS")
103 #main.ONOS1.stop()
104 time.sleep(3)
105 #main.ONOS1.start()
106 #time.sleep(5)
107 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
108 else:
109 break
adminf0713ab2014-04-29 10:43:35 -0700110 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
Jon Hall5a8aac62014-06-03 09:30:21 -0700111 time.sleep(20)
adminf0713ab2014-04-29 10:43:35 -0700112
113#**********************************************************************************************************************************************************************************************
114#Assign Controllers
115#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>).
116#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
117#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
118# the controllers already assigned to the switch are not specified.
119
120 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
121 import time
122 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
123 main.case("Checking if one MN host exists")
124 main.step("Host IP Checking using checkIP")
125 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
126 main.step("Verifying the result")
127 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
128 main.step("assigning ONOS controllers to switches")
129 for i in range(25):
130 if i < 3:
131 j=i+1
132 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
133 time.sleep(1)
134 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'])
135 elif i >= 3 and i < 5:
136 j=i+1
137 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
138 time.sleep(1)
139 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'])
140 elif i >= 5 and i < 15:
141 j=i+1
142 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
143 time.sleep(1)
144 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'])
145 else:
146 j=i+16
147 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
148 time.sleep(1)
149 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'])
150 main.Mininet1.get_sw_controller("s1")
adminf0713ab2014-04-29 10:43:35 -0700151
152# **********************************************************************************************************************************************************************************************
153#Add Flows
154#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
155#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
156
157 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
158 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
159 import time
160 main.case("Taking care of these flows!")
161 main.step("Cleaning out any leftover flows...")
162 #main.ONOS1.delete_flow("all")
163 strtTime = time.time()
Jon Hallbd795bf2014-06-18 09:46:32 -0700164 main.ONOS1.rm_intents()
adminf0713ab2014-04-29 10:43:35 -0700165 print("world")
Jon Hallbd795bf2014-06-18 09:46:32 -0700166 main.ONOS1.add_intents()
Jon Hall5a8aac62014-06-03 09:30:21 -0700167 time.sleep(2)
Jon Hallbd795bf2014-06-18 09:46:32 -0700168 main.ONOS1.add_intents()
Jon Hall5a8aac62014-06-03 09:30:21 -0700169 print("hello")
adminf0713ab2014-04-29 10:43:35 -0700170 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
171 main.case("Checking flows")
172
173 count = 1
174 i = 6
175 while i < 16 :
176 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
177 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
178 if ping == main.FALSE and count < 9:
179 count = count + 1
180 i = 6
181 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
182 time.sleep(2)
183 elif ping == main.FALSE and count ==9:
184 main.log.error("Ping test failed")
185 i = 17
186 result = main.FALSE
187 elif ping == main.TRUE:
188 i = i + 1
189 result = main.TRUE
190 endTime = time.time()
191 if result == main.TRUE:
192 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
193 else:
194 main.log.report("\tFlows failed check")
195
196 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
197 main.step("Verifying the result")
198 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
199
200#**********************************************************************************************************************************************************************************************
201#This test case removes Controllers 2,3, and 4 then performs a ping test.
202#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
203#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.
204#If the ping test fails 6 times, then the test case will return false
205 def CASE41(self,main) :
206 main.log.report("Testing Removal")
207 main.ONOS2.stop()
208 main.ONOS3.stop()
209 main.ONOS4.stop()
210 strtTime = time.time()
211 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
212 for i in range(10):
213 if result == main.FALSE:
214 time.sleep(5)
215 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
216 else:
217 break
218
219 count = 1
220 i = 6
221 while i < 16 :
222 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
223 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
224 if ping == main.FALSE and count < 6:
225 count = count + 1
226 i = 6
227 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
228 time.sleep(2)
229 elif ping == main.FALSE and count ==6:
230 main.log.error("Ping test failed")
231 i = 17
232 result = main.FALSE
233 elif ping == main.TRUE:
234 i = i + 1
235 result = main.TRUE
236 endTime = time.time()
237 if result == main.TRUE:
238 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
239 else:
240 main.log.report("\tPING TEST FAIL")
241 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
242 time.sleep(10)
243 main.ONOS2.start()
244 main.ONOS3.start()
245 main.ONOS4.start()
246 time.sleep(10)
247
248
249 def CASE4(self,main) :
250 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
251 import time
252 for i in range(25):
253 if i < 15:
254 j=i+1
255 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
256 else:
257 j=i+16
258 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
259
260 strtTime = time.time()
261 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
262 for i in range(10):
263 if result == main.FALSE:
264 time.sleep(5)
265 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
266 else:
267 break
268
269 count = 1
270 i = 6
271 while i < 16 :
272 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
273 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
274 if ping == main.FALSE and count < 6:
275 count = count + 1
276 i = 6
277 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
278 time.sleep(2)
279 elif ping == main.FALSE and count ==6:
280 main.log.error("Ping test failed")
281 i = 17
282 result = main.FALSE
283 elif ping == main.TRUE:
284 i = i + 1
285 result = main.TRUE
286 endTime = time.time()
287 if result == main.TRUE:
288 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
289 else:
290 main.log.report("\tPING TEST FAIL")
291 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
292 time.sleep(10)
293
294# **********************************************************************************************************************************************************************************************
295#This test case restores the controllers removed by Case 4 then performs a ping test.
296
297 def CASE5(self,main) :
298 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
299 import time
300 for i in range(25):
301 if i < 15:
302 j=i+1
303 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'])
304 else:
305 j=i+16
306 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'])
307
308 strtTime = time.time()
309 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
Jon Hall5a8aac62014-06-03 09:30:21 -0700310 for i in range(10):
adminf0713ab2014-04-29 10:43:35 -0700311 if result == main.FALSE:
312 time.sleep(5)
313 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
314 else:
315 break
316
317 count = 1
318 i = 6
319 while i < 16 :
320 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
321 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
322 if ping == main.FALSE and count < 6:
323 count = count + 1
324 i = 6
325 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
326 time.sleep(2)
327 elif ping == main.FALSE and count ==6:
328 main.log.error("Ping test failed")
329 i = 17
330 result = main.FALSE
331 elif ping == main.TRUE:
332 i = i + 1
333 result = main.TRUE
334 endTime = time.time()
335 if result == main.TRUE:
336 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
337 else:
338 main.log.report("\tPING TEST FAILED")
339 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
340
341# **********************************************************************************************************************************************************************************************
342#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
343
344 def CASE6(self,main) :
345 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
346 import time
347 main.case("Bringing Link down... ")
348 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
349 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
350
351 strtTime = time.time()
352 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
Jon Hall5a8aac62014-06-03 09:30:21 -0700353 for i in range(10):
adminf0713ab2014-04-29 10:43:35 -0700354 if result == main.FALSE:
355 time.sleep(5)
356 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
357 else:
358 break
359
360 count = 1
361 i = 6
362 while i < 16 :
363 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
364 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
365 if ping == main.FALSE and count < 10:
366 count = count + 1
367 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
368 i = 6
369 time.sleep(2)
370 elif ping == main.FALSE and count == 10:
371 main.log.error("Ping test failed")
372 i = 17
373 result = main.FALSE
374 elif ping == main.TRUE:
375 i = i + 1
376 result = main.TRUE
377 endTime = time.time()
378 if result == main.TRUE:
379 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
380 else:
381 main.log.report("\tPING TEST FAILED")
382 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
383
384# **********************************************************************************************************************************************************************************************
385#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
386
387 def CASE7(self,main) :
388 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
389 import time
390 main.case("Bringing Link up... ")
391 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
392 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
393 time.sleep(5)
394 strtTime = time.time()
395 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
Jon Hall5a8aac62014-06-03 09:30:21 -0700396 for i in range(10):
adminf0713ab2014-04-29 10:43:35 -0700397 if result == main.FALSE:
Jon Hall5a8aac62014-06-03 09:30:21 -0700398 time.sleep(15)
Jon Hallbd795bf2014-06-18 09:46:32 -0700399 main.ONOS2.check_status_report(main.params['RestIP2'],main.params['NR_Switches'],main.params['NR_Links'])
400 main.ONOS3.check_status_report(main.params['RestIP3'],main.params['NR_Switches'],main.params['NR_Links'])
401 main.ONOS4.check_status_report(main.params['RestIP4'],main.params['NR_Switches'],main.params['NR_Links'])
adminf0713ab2014-04-29 10:43:35 -0700402 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
403 else:
404 break
405
406 strtTime = time.time()
407 count = 1
408 i = 6
409 while i < 16 :
410 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
411 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
412 if ping == main.FALSE and count < 10:
413 count = count + 1
414 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
415 i = 6
416 time.sleep(2)
417 elif ping == main.FALSE and count ==10:
418 main.log.error("Ping test failed")
419 i = 17
420 result = main.FALSE
421 elif ping == main.TRUE:
422 i = i + 1
423 result = main.TRUE
424 endTime = time.time()
425 if result == main.TRUE:
426 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
427 else:
428 main.log.report("\tPING TESTS FAILED")
429 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
430
431
432# ******************************************************************************************************************************************************************
433# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
434
435 def CASE21(self,main) :
436 import json
437 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.")
438 main.log.report("Check initially hostMAC/IP exist on the mininet...")
439 host = main.params['YANK']['hostname']
440 mac = main.params['YANK']['hostmac']
adminf0713ab2014-04-29 10:43:35 -0700441 RestIP1 = main.params['RESTCALL']['restIP1']
442 RestPort = main.params['RESTCALL']['restPort']
443 url = main.params['RESTCALL']['restURL']
Jon Hall5a8aac62014-06-03 09:30:21 -0700444
445 t_topowait = 5
admin12bae622014-06-05 09:44:30 -0700446 t_restwait = 5
adminf0713ab2014-04-29 10:43:35 -0700447 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
448 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
449 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
450 time.sleep(t_topowait)
451 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" )
452 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
453 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700454 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
Jon Hall5a8aac62014-06-03 09:30:21 -0700455 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
adminf0713ab2014-04-29 10:43:35 -0700456 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700457 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
Jon Hall5a8aac62014-06-03 09:30:21 -0700458 result1 = main.TRUE
adminf0713ab2014-04-29 10:43:35 -0700459 elif Reststatus > 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700460 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
adminf0713ab2014-04-29 10:43:35 -0700461 main.log.report("switches are: " + "; ".join(Switch))
462 main.log.report("Ports are: " + "; ".join(Port))
adminf0713ab2014-04-29 10:43:35 -0700463 result1 = main.FALSE
464 elif Reststatus == 0 and Switch == []:
465 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
466 result1 = main.FALSE
467 else:# check if rest server is working
468 main.log.error("Issue with find host")
469 result1 = main.FALSE
470
471
Jon Hall5a8aac62014-06-03 09:30:21 -0700472 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
adminf0713ab2014-04-29 10:43:35 -0700473
474 main.log.report("Yank out s1-eth1")
475 main.case("Yankout s6-eth1 (link to h1) from s1")
476 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
477 time.sleep(t_topowait)
478 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
479
480 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" )
481 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
482 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700483 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
adminf0713ab2014-04-29 10:43:35 -0700484
Jon Hall1c4d2742014-05-22 10:57:05 -0700485 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
adminf0713ab2014-04-29 10:43:35 -0700486 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700487 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
Jon Hall5a8aac62014-06-03 09:30:21 -0700488 result2 = main.FALSE
adminf0713ab2014-04-29 10:43:35 -0700489 elif Reststatus > 1:
490 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
491 main.log.report("switches are: " + "; ".join(Switch))
492 main.log.report("Ports are: " + "; ".join(Port))
493 main.log.report("MACs are: " + "; ".join(MAC))
494 result2 = main.FALSE
495 elif Reststatus == 0 and Switch == []:
496 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.")
497 result2 = main.TRUE
498 else:# check if rest server is working
499 main.log.error("Issue with find host")
500 result2 = main.FALSE
Jon Hall5a8aac62014-06-03 09:30:21 -0700501
adminf0713ab2014-04-29 10:43:35 -0700502 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
503 main.log.report("Plug s1-eth1 into s6")
504 main.case("Plug s1-eth1 to s6")
505 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
506 time.sleep(t_topowait)
507 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
508 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" )
509
510 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
511 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700512 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
adminf0713ab2014-04-29 10:43:35 -0700513
Jon Hall1c4d2742014-05-22 10:57:05 -0700514 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
adminf0713ab2014-04-29 10:43:35 -0700515 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700516 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
adminf0713ab2014-04-29 10:43:35 -0700517 result3 = main.TRUE
518 elif Reststatus > 1:
519 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
520 main.log.report("switches are: " + "; ".join(Switch))
521 main.log.report("Ports are: " + "; ".join(Port))
Jon Hall5a8aac62014-06-03 09:30:21 -0700522 main.log.report("MACs are: " + "; ".join(MAC))
adminf0713ab2014-04-29 10:43:35 -0700523 result3 = main.FALSE
524 elif Reststatus == 0 and Switch == []:
525 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
526 result3 = main.FALSE
527 else:# check if rest server is working
528 main.log.error("Issue with find host")
529 result3 = main.FALSE
Jon Hall5a8aac62014-06-03 09:30:21 -0700530
adminf0713ab2014-04-29 10:43:35 -0700531 ###### Step to put interface "s1-eth1" back to s1"#####
532 main.log.report("Move s1-eth1 back on to s1")
533 main.case("Move s1-eth1 back to s1")
534 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
535 time.sleep(t_topowait)
536 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
537 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
538 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" )
539
540 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
541 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700542 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
adminf0713ab2014-04-29 10:43:35 -0700543
544 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
545 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700546 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
adminf0713ab2014-04-29 10:43:35 -0700547 result4 = main.TRUE
548 elif Reststatus > 1:
549 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
550 main.log.report("switches are: " + "; ".join(Switch))
551 main.log.report("Ports are: " + "; ".join(Port))
Jon Hall5a8aac62014-06-03 09:30:21 -0700552 main.log.report("MACs are: " + "; ".join(MAC))
adminf0713ab2014-04-29 10:43:35 -0700553 result4 = main.FALSE
554 elif Reststatus == 0 and Switch == []:
555 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
556 result4 = main.FALSE
557 else:# check if rest server is working
558 main.log.error("Issue with find host")
559 result4 = main.FALSE
Jon Hall5a8aac62014-06-03 09:30:21 -0700560 time.sleep(20)
561 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
562 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
563 if Reststatus ==1:
564 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
565 elif Reststatus>1:
566 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
567 elif Reststatus==0:
568 main.log.report("\t PASSED - Device cleared after timeout")
adminf0713ab2014-04-29 10:43:35 -0700569
570 result = result1 and result2 and result3 and result4
571 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
572
573# Run a pure ping test.
574
575 def CASE31(self, main):
576 main.log.report("Performing Ping Test")
577 count = 1
578 i = 6
579 while i < 16 :
580 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
581 strtTime = time.time()
582 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
583 if ping == main.FALSE and count < 6:
584 count = count + 1
585 i = 6
586 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
587 time.sleep(2)
588 elif ping == main.FALSE and count ==6:
589 main.log.error("Ping test failed")
590 i = 17
591 result = main.FALSE
592 elif ping == main.TRUE:
593 i = i + 1
594 result = main.TRUE
595 endTime = time.time()
596 if result == main.TRUE:
597 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
598 else:
599 main.log.report("\tPING TEST FAIL")
600 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
601
Jon Hall5a8aac62014-06-03 09:30:21 -0700602
admin1723f1c2014-05-19 16:08:39 -0700603 def CASE66(self, main):
604 main.log.report("Checking ONOS logs for exceptions")
Jon Hall1c4d2742014-05-22 10:57:05 -0700605 count = 0
admin1723f1c2014-05-19 16:08:39 -0700606 check1 = main.ONOS1.check_exceptions()
607 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
608 check2 = main.ONOS2.check_exceptions()
609 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
610 check3 = main.ONOS3.check_exceptions()
611 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
612 check4 = main.ONOS4.check_exceptions()
613 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
Jon Hall1c4d2742014-05-22 10:57:05 -0700614 result = main.TRUE
admin1723f1c2014-05-19 16:08:39 -0700615 if (check1 or check2 or check3 or check4):
Jon Hall1c4d2742014-05-22 10:57:05 -0700616 result = main.FALSE
617 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
618 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
Jon Hallbd795bf2014-06-18 09:46:32 -0700619 main.Mininet1.stop_tcpdump()
admin1723f1c2014-05-19 16:08:39 -0700620
621