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