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