blob: 1027e35f0155e12feed6198a003532bebc25c3c4 [file] [log] [blame]
admin12bae622014-06-05 09:44:30 -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
12 main.Zookeeper1.stop()
13 main.Zookeeper2.stop()
14 main.Zookeeper3.stop()
15 main.Zookeeper4.stop()
16 main.RamCloud1.stop_coor()
17 main.RamCloud1.stop_serv()
18 main.RamCloud2.stop_serv()
19 main.RamCloud3.stop_serv()
20 main.RamCloud4.stop_serv()
21
22 main.ONOS1.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
23 main.ONOS2.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
24 main.ONOS3.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
25 main.ONOS4.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
26
27 main.Zookeeper1.start()
28 main.Zookeeper2.start()
29 main.Zookeeper3.start()
30 main.Zookeeper4.start()
31 time.sleep(3)
32 main.RamCloud1.del_db()
33 main.RamCloud2.del_db()
34 main.RamCloud3.del_db()
35 main.RamCloud4.del_db()
36 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")
49 #if uptodate==0:
50 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()
64 '''
65 main.RamCloud1.start_coor()
66 time.sleep(1)
67 main.RamCloud1.start_serv()
68 main.RamCloud2.start_serv()
69 main.RamCloud3.start_serv()
70 main.RamCloud4.start_serv()
71 main.ONOS1.start()
72 time.sleep(5)
73 main.ONOS2.start()
74 main.ONOS3.start()
75 main.ONOS4.start()
76 main.ONOS2.start_rest()
77 time.sleep(5)
78 '''
79 main.ONOS1.start_all()
80 main.ONOS2.start_all()
81 main.ONOS3.start_all()
82 main.ONOS4.start_all()
83 test= main.ONOS2.rest_status()
84 if test == main.FALSE:
85 main.ONOS2.start_rest()
86 main.ONOS1.get_version()
87 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
88 main.case("Checking if the startup was clean...")
89 main.step("Testing startup Zookeeper")
90 data = main.Zookeeper1.isup()
91 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
92 main.step("Testing startup RamCloud")
93 data = main.RamCloud1.status_serv()
94 if data == main.FALSE:
95 main.RamCloud1.stop_coor()
96 main.RamCloud1.stop_serv()
97 main.RamCloud2.stop_serv()
98 main.RamCloud3.stop_serv()
99 main.RamCloud4.stop_serv()
100
101 time.sleep(5)
102 main.RamCloud1.start_coor()
103 main.RamCloud1.start_serv()
104 main.RamCloud2.start_serv()
105 main.RamCloud3.start_serv()
106 main.RamCloud4.start_serv()
107 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
108 main.step("Testing startup ONOS")
109 data = main.ONOS1.isup()
110 if data == main.FALSE:
111 main.log.report("Something is funny... restarting ONOS")
112 # main.ONOS1.stop()
113 time.sleep(3)
114 # main.ONOS1.start()
115 # time.sleep(5)
116 data = main.ONOS1.isup()
117 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
118
119#**********************************************************************************************************************************************************************************************
120#Assign Controllers
121#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>).
122#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
123#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
124# the controllers already assigned to the switch are not specified.
125
126 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
127 import time
128 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
129 main.case("Checking if one MN host exists")
130 main.step("Host IP Checking using checkIP")
131 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
132 main.step("Verifying the result")
133 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
134 main.step("assigning ONOS controllers to switches")
135 for i in range(25):
136 if i < 3:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
139 time.sleep(1)
140 main.Mininet1.get_sw_controller("s"+str(j))
141 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'])
142 main.Mininet1.get_sw_controller("s"+str(j))
143
144 elif i >= 3 and i < 5:
145 j=i+1
146 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
147 time.sleep(1)
148 main.Mininet1.get_sw_controller("s"+str(j))
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("s"+str(j))
151 elif i >= 5 and i < 15:
152 j=i+1
153 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
154 main.Mininet1.get_sw_controller("s"+str(j))
155 time.sleep(1)
156 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'])
157 main.Mininet1.get_sw_controller("s"+str(j))
158 else:
159 j=i+16
160 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
161 main.Mininet1.get_sw_controller("s"+str(j))
162 time.sleep(1)
163 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'])
164 main.Mininet1.get_sw_controller("s"+str(j))
165 main.Mininet1.get_sw_controller("s1")
166 time.sleep(10)
167
168# **********************************************************************************************************************************************************************************************
169#Add Flows
170#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
171#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
172
173 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
174 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
175 import time
176 main.case("Taking care of these flows!")
177 main.step("Cleaning out any leftover flows...")
178 #main.ONOS1.delete_flow("all")
179 strtTime = time.time()
180 print("hello")
Jon Hallbd795bf2014-06-18 09:46:32 -0700181 main.ONOS1.rm_intents()
admin12bae622014-06-05 09:44:30 -0700182 print("world")
Jon Hallbd795bf2014-06-18 09:46:32 -0700183 main.ONOS1.add_intents()
admin12bae622014-06-05 09:44:30 -0700184 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
185 main.case("Checking flows")
186
187 count = 1
188 i = 6
189 while i < 16 :
190 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
191 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
192 if ping == main.FALSE and count < 9:
193 count = count + 1
194 i = 6
195 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
196 time.sleep(2)
197 elif ping == main.FALSE and count ==9:
198 main.log.error("Ping test failed")
199 i = 17
200 result = main.FALSE
201 elif ping == main.TRUE:
202 i = i + 1
203 result = main.TRUE
204 endTime = time.time()
205 if result == main.TRUE:
206 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
207 else:
208 main.log.report("\tFlows failed check")
209
210 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
211 main.step("Verifying the result")
212 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
213
214#**********************************************************************************************************************************************************************************************
215#This test case removes Controllers 2,3, and 4 then performs a ping test.
216#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
217#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.
218#If the ping test fails 6 times, then the test case will return false
219 def CASE41(self,main) :
220 main.log.report("Testing Removal")
221 main.ONOS2.stop()
222 main.ONOS3.stop()
223 main.ONOS4.stop()
224 strtTime = time.time()
225 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
226 for i in range(10):
227 if result == main.FALSE:
228 time.sleep(5)
229 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
230 else:
231 break
232
233 count = 1
234 i = 6
235 while i < 16 :
236 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
237 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
238 if ping == main.FALSE and count < 6:
239 count = count + 1
240 i = 6
241 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
242 time.sleep(2)
243 elif ping == main.FALSE and count ==6:
244 main.log.error("Ping test failed")
245 i = 17
246 result = main.FALSE
247 elif ping == main.TRUE:
248 i = i + 1
249 result = main.TRUE
250 endTime = time.time()
251 if result == main.TRUE:
252 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
253 else:
254 main.log.report("\tPING TEST FAIL")
255 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
256 time.sleep(10)
257 main.ONOS2.start()
258 main.ONOS3.start()
259 main.ONOS4.start()
260 time.sleep(10)
261
262
263 def CASE4(self,main) :
264 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
265 import time
266 for i in range(25):
267 if i < 15:
268 j=i+1
269 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
270 else:
271 j=i+16
272 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
273
274 strtTime = time.time()
275 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
276 for i in range(10):
277 if result == main.FALSE:
278 time.sleep(5)
279 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
280 else:
281 break
282
283 count = 1
284 i = 6
285 while i < 16 :
286 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
287 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
288 if ping == main.FALSE and count < 6:
289 count = count + 1
290 i = 6
291 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
292 time.sleep(2)
293 elif ping == main.FALSE and count ==6:
294 main.log.error("Ping test failed")
295 i = 17
296 result = main.FALSE
297 elif ping == main.TRUE:
298 i = i + 1
299 result = main.TRUE
300 endTime = time.time()
301 if result == main.TRUE:
302 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
303 else:
304 main.log.report("\tPING TEST FAIL")
305 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
306 time.sleep(10)
307
308# **********************************************************************************************************************************************************************************************
309#This test case restores the controllers removed by Case 4 then performs a ping test.
310
311 def CASE5(self,main) :
312 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
313 import time
314 for i in range(25):
315 if i < 15:
316 j=i+1
317 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'])
318 else:
319 j=i+16
320 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'])
321
322 strtTime = time.time()
323 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
324 for i in range(2):
325 if result == main.FALSE:
326 time.sleep(5)
327 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
328 else:
329 break
330
331 count = 1
332 i = 6
333 while i < 16 :
334 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
335 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
336 if ping == main.FALSE and count < 6:
337 count = count + 1
338 i = 6
339 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
340 time.sleep(2)
341 elif ping == main.FALSE and count ==6:
342 main.log.error("Ping test failed")
343 i = 17
344 result = main.FALSE
345 elif ping == main.TRUE:
346 i = i + 1
347 result = main.TRUE
348 endTime = time.time()
349 if result == main.TRUE:
350 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
351 else:
352 main.log.report("\tPING TEST FAILED")
353 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
354
355# **********************************************************************************************************************************************************************************************
356#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
357
358 def CASE6(self,main) :
359 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
360 import time
361 main.case("Bringing Link down... ")
362 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
363 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
364
365 strtTime = time.time()
366 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
367 for i in range(2):
368 if result == main.FALSE:
369 time.sleep(5)
370 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
371 else:
372 break
373
374 count = 1
375 i = 6
376 while i < 16 :
377 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
378 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
379 if ping == main.FALSE and count < 10:
380 count = count + 1
381 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
382 i = 6
383 time.sleep(2)
384 elif ping == main.FALSE and count == 10:
385 main.log.error("Ping test failed")
386 i = 17
387 result = main.FALSE
388 elif ping == main.TRUE:
389 i = i + 1
390 result = main.TRUE
391 endTime = time.time()
392 if result == main.TRUE:
393 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
394 else:
395 main.log.report("\tPING TEST FAILED")
396 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
397
398# **********************************************************************************************************************************************************************************************
399#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
400
401 def CASE7(self,main) :
402 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
403 import time
404 main.case("Bringing Link up... ")
405 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
406 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
407 time.sleep(5)
408 strtTime = time.time()
409 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
410 for i in range(2):
411 if result == main.FALSE:
412 time.sleep(5)
413 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
414 else:
415 break
416
417 strtTime = time.time()
418 count = 1
419 i = 6
420 while i < 16 :
421 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
422 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
423 if ping == main.FALSE and count < 10:
424 count = count + 1
425 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
426 i = 6
427 time.sleep(2)
428 elif ping == main.FALSE and count ==10:
429 main.log.error("Ping test failed")
430 i = 17
431 result = main.FALSE
432 elif ping == main.TRUE:
433 i = i + 1
434 result = main.TRUE
435 endTime = time.time()
436 if result == main.TRUE:
437 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
438 else:
439 main.log.report("\tPING TESTS FAILED")
440 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
441
442
443# ******************************************************************************************************************************************************************
444# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
445
446 def CASE21(self,main) :
447 import json
448 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.")
449 main.log.report("Check initially hostMAC/IP exist on the mininet...")
450 host = main.params['YANK']['hostname']
451 mac = main.params['YANK']['hostmac']
452 RestIP1 = main.params['RESTCALL']['restIP1']
453 RestPort = main.params['RESTCALL']['restPort']
454 url = main.params['RESTCALL']['restURL']
455
456 t_topowait = 0
457 t_restwait = 10
458 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
459 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
460 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
461 time.sleep(t_topowait)
462 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" )
463 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
464 time.sleep(t_restwait)
465 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
466 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
467 if Reststatus == 1:
468 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
469 result1 = main.TRUE
470 elif Reststatus > 1:
471 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
472 main.log.report("switches are: " + "; ".join(Switch))
473 main.log.report("Ports are: " + "; ".join(Port))
474 result1 = main.FALSE
475 elif Reststatus == 0 and Switch == []:
476 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
477 result1 = main.FALSE
478 else:# check if rest server is working
479 main.log.error("Issue with find host")
480 result1 = main.FALSE
481
482
483 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
484
485 main.log.report("Yank out s1-eth1")
486 main.case("Yankout s6-eth1 (link to h1) from s1")
487 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
488 time.sleep(t_topowait)
489 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
490
491 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" )
492 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
493 time.sleep(t_restwait)
494 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
495
496 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
497 if Reststatus == 1:
498 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
499 result2 = main.FALSE
500 elif Reststatus > 1:
501 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
502 main.log.report("switches are: " + "; ".join(Switch))
503 main.log.report("Ports are: " + "; ".join(Port))
504 main.log.report("MACs are: " + "; ".join(MAC))
505 result2 = main.FALSE
506 elif Reststatus == 0 and Switch == []:
507 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.")
508 result2 = main.TRUE
509 else:# check if rest server is working
510 main.log.error("Issue with find host")
511 result2 = main.FALSE
512
513 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
514 main.log.report("Plug s1-eth1 into s6")
515 main.case("Plug s1-eth1 to s6")
516 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
517 time.sleep(t_topowait)
518 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
519 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" )
520
521 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
522 time.sleep(t_restwait)
523 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
524
525 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
526 if Reststatus == 1:
527 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
528 result3 = main.TRUE
529 elif Reststatus > 1:
530 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
531 main.log.report("switches are: " + "; ".join(Switch))
532 main.log.report("Ports are: " + "; ".join(Port))
533 main.log.report("MACs are: " + "; ".join(MAC))
534 result3 = main.FALSE
535 elif Reststatus == 0 and Switch == []:
536 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
537 result3 = main.FALSE
538 else:# check if rest server is working
539 main.log.error("Issue with find host")
540 result3 = main.FALSE
541
542 ###### Step to put interface "s1-eth1" back to s1"#####
543 main.log.report("Move s1-eth1 back on to s1")
544 main.case("Move s1-eth1 back to s1")
545 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
546 time.sleep(t_topowait)
547 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
548 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
549 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" )
550
551 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
552 time.sleep(t_restwait)
553 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
554
555 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
556 if Reststatus == 1:
557 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
558 result4 = main.TRUE
559 elif Reststatus > 1:
560 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
561 main.log.report("switches are: " + "; ".join(Switch))
562 main.log.report("Ports are: " + "; ".join(Port))
563 main.log.report("MACs are: " + "; ".join(MAC))
564 result4 = main.FALSE
565 elif Reststatus == 0 and Switch == []:
566 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
567 result4 = main.FALSE
568 else:# check if rest server is working
569 main.log.error("Issue with find host")
570 result4 = main.FALSE
571
572 result = result1 and result2 and result3 and result4
573 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
574
575
576# Run a pure ping test.
577
578 def CASE31(self, main):
579 main.log.report("Performing Ping Test")
580 count = 1
581 i = 6
582 while i < 16 :
583 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
584 strtTime = time.time()
585 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
586 if ping == main.FALSE and count < 6:
587 count = count + 1
588 i = 6
589 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
590 time.sleep(2)
591 elif ping == main.FALSE and count ==6:
592 main.log.error("Ping test failed")
593 i = 17
594 result = main.FALSE
595 elif ping == main.TRUE:
596 i = i + 1
597 result = main.TRUE
598 endTime = time.time()
599 if result == main.TRUE:
600 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
601 else:
602 main.log.report("\tPING TEST FAIL")
603 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
604
605 def CASE66(self, main):
606 main.log.report("Checking ONOS logs for exceptions")
607 count = 0
608 check1 = main.ONOS1.check_exceptions()
609 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
610 check2 = main.ONOS2.check_exceptions()
611 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
612 check3 = main.ONOS3.check_exceptions()
613 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
614 check4 = main.ONOS4.check_exceptions()
615 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
616 result = main.TRUE
617 if (check1 or check2 or check3 or check4):
618 result = main.FALSE
619 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
620 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
621
622