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