blob: c1057d11ac1074e3985530cb62b202e448588e93 [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 Halle80ef8c2014-04-29 15:29:13 -070012 main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
13 main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
14 main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
15 main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
16
Jon Hall0955bc92014-04-16 17:00:19 -070017 main.Zookeeper1.start()
Jon Halle80ef8c2014-04-29 15:29:13 -070018 main.Zookeeper2.start()
19 main.Zookeeper3.start()
20 main.Zookeeper4.start()
21 main.RamCloud1.stop_coor()
22 main.RamCloud1.stop_serv()
23 main.RamCloud2.stop_serv()
24 main.RamCloud3.stop_serv()
25 main.RamCloud4.stop_serv()
adminaef00552014-05-08 09:18:36 -070026 time.sleep(10)
27 main.ONOS1.handle.sendline("~/ONOS/onos.sh rc deldb")
28 main.ONOS2.handle.sendline("~/ONOS/onos.sh rc deldb")
29 main.ONOS3.handle.sendline("~/ONOS/onos.sh rc deldb")
30 main.ONOS4.handle.sendline("~/ONOS/onos.sh rc deldb")
31 time.sleep(10)
admin733ae0a2014-04-09 15:01:12 -070032 main.log.report("Pulling latest code from github to all nodes")
admin21211792014-04-15 15:42:39 -070033 for i in range(2):
34 uptodate = main.ONOS1.git_pull()
35 main.ONOS2.git_pull()
36 main.ONOS3.git_pull()
37 main.ONOS4.git_pull()
38 ver1 = main.ONOS1.get_version()
39 ver2 = main.ONOS4.get_version()
40 if ver1==ver2:
41 break
42 elif i==1:
43 main.ONOS2.git_pull("ONOS1 master")
44 main.ONOS3.git_pull("ONOS1 master")
45 main.ONOS4.git_pull("ONOS1 master")
Jon Halle80ef8c2014-04-29 15:29:13 -070046 #if uptodate==0
47 if 1:
admin21211792014-04-15 15:42:39 -070048 main.ONOS1.git_compile()
49 main.ONOS2.git_compile()
50 main.ONOS3.git_compile()
51 main.ONOS4.git_compile()
Jon Hall364f37a2014-04-17 10:29:35 -070052 main.ONOS1.print_version()
admin733ae0a2014-04-09 15:01:12 -070053 # main.RamCloud1.git_pull()
54 # main.RamCloud2.git_pull()
55 # main.RamCloud3.git_pull()
56 # main.RamCloud4.git_pull()
57 # main.ONOS1.get_version()
58 # main.ONOS2.get_version()
59 # main.ONOS3.get_version()
60 # main.ONOS4.get_version()
61 main.RamCloud1.start_coor()
Jon Halle80ef8c2014-04-29 15:29:13 -070062 time.sleep(1)
admin733ae0a2014-04-09 15:01:12 -070063 main.RamCloud1.start_serv()
64 main.RamCloud2.start_serv()
65 main.RamCloud3.start_serv()
66 main.RamCloud4.start_serv()
admin733ae0a2014-04-09 15:01:12 -070067 main.ONOS1.start()
Jon Halle80ef8c2014-04-29 15:29:13 -070068 time.sleep(5)
admin733ae0a2014-04-09 15:01:12 -070069 main.ONOS2.start()
70 main.ONOS3.start()
71 main.ONOS4.start()
72 main.ONOS1.start_rest()
Jon Halle80ef8c2014-04-29 15:29:13 -070073 time.sleep(10)
admin733ae0a2014-04-09 15:01:12 -070074 test= main.ONOS1.rest_status()
75 if test == main.FALSE:
76 main.ONOS1.start_rest()
77 main.ONOS1.get_version()
78 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
79 main.case("Checking if the startup was clean...")
80 main.step("Testing startup Zookeeper")
81 data = main.Zookeeper1.isup()
82 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
83 main.step("Testing startup RamCloud")
Jon Halle80ef8c2014-04-29 15:29:13 -070084 data = main.RamCloud1.status_serv()
admin733ae0a2014-04-09 15:01:12 -070085 if data == main.FALSE:
86 main.RamCloud1.stop_coor()
87 main.RamCloud1.stop_serv()
88 main.RamCloud2.stop_serv()
89 main.RamCloud3.stop_serv()
90 main.RamCloud4.stop_serv()
91
92 time.sleep(5)
93 main.RamCloud1.start_coor()
94 main.RamCloud1.start_serv()
95 main.RamCloud2.start_serv()
96 main.RamCloud3.start_serv()
97 main.RamCloud4.start_serv()
98 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
99 main.step("Testing startup ONOS")
100 data = main.ONOS1.isup()
adminaef00552014-05-08 09:18:36 -0700101 for i in range(3):
102 if data == main.FALSE:
103 #main.log.report("Something is funny... restarting ONOS")
104 #main.ONOS1.stop()
105 time.sleep(3)
106 #main.ONOS1.start()
107 #time.sleep(5)
108 data = main.ONOS1.isup()
109 else:
110 break
admin733ae0a2014-04-09 15:01:12 -0700111 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
adminaef00552014-05-08 09:18:36 -0700112 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700113
114#**********************************************************************************************************************************************************************************************
115#Assign Controllers
116#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>).
117#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
118#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
119# the controllers already assigned to the switch are not specified.
120
121 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
122 import time
123 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
124 main.case("Checking if one MN host exists")
125 main.step("Host IP Checking using checkIP")
126 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
127 main.step("Verifying the result")
128 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
129 main.step("assigning ONOS controllers to switches")
130 for i in range(25):
131 if i < 3:
132 j=i+1
133 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
134 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700135 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 -0700136 elif i >= 3 and i < 5:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
139 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700140 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 -0700141 elif i >= 5 and i < 15:
142 j=i+1
143 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
144 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700145 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 -0700146 else:
147 j=i+16
148 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
149 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700150 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 -0700151 main.Mininet1.get_sw_controller("s1")
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...")
adminc6cfc1c2014-04-21 13:55:21 -0700163 #main.ONOS1.delete_flow("all")
admin733ae0a2014-04-09 15:01:12 -0700164 strtTime = time.time()
adminc6cfc1c2014-04-21 13:55:21 -0700165 main.ONOS1.rm_flow()
166 print("world")
167 main.ONOS1.ad_flow()
Jon Halle80ef8c2014-04-29 15:29:13 -0700168 time.sleep(2)
169 main.ONOS1.ad_flow()
170 print("hello")
adminc6cfc1c2014-04-21 13:55:21 -0700171 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
admin733ae0a2014-04-09 15:01:12 -0700172 main.case("Checking flows")
adminc6cfc1c2014-04-21 13:55:21 -0700173
admin733ae0a2014-04-09 15:01:12 -0700174 count = 1
175 i = 6
176 while i < 16 :
177 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
178 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
179 if ping == main.FALSE and count < 9:
180 count = count + 1
181 i = 6
182 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
183 time.sleep(2)
184 elif ping == main.FALSE and count ==9:
185 main.log.error("Ping test failed")
186 i = 17
187 result = main.FALSE
188 elif ping == main.TRUE:
189 i = i + 1
190 result = main.TRUE
191 endTime = time.time()
192 if result == main.TRUE:
193 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
194 else:
195 main.log.report("\tFlows failed check")
196
197 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
198 main.step("Verifying the result")
199 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
200
201#**********************************************************************************************************************************************************************************************
202#This test case removes Controllers 2,3, and 4 then performs a ping test.
203#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
204#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.
205#If the ping test fails 6 times, then the test case will return false
206 def CASE41(self,main) :
207 main.log.report("Testing Removal")
208 main.ONOS2.stop()
209 main.ONOS3.stop()
210 main.ONOS4.stop()
211 strtTime = time.time()
212 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
213 for i in range(10):
214 if result == main.FALSE:
215 time.sleep(5)
216 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
217 else:
218 break
219
220 count = 1
221 i = 6
222 while i < 16 :
223 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
224 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
225 if ping == main.FALSE and count < 6:
226 count = count + 1
227 i = 6
228 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
229 time.sleep(2)
230 elif ping == main.FALSE and count ==6:
231 main.log.error("Ping test failed")
232 i = 17
233 result = main.FALSE
234 elif ping == main.TRUE:
235 i = i + 1
236 result = main.TRUE
237 endTime = time.time()
238 if result == main.TRUE:
239 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
240 else:
241 main.log.report("\tPING TEST FAIL")
242 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
243 time.sleep(10)
244 main.ONOS2.start()
245 main.ONOS3.start()
246 main.ONOS4.start()
247 time.sleep(10)
248
249
250 def CASE4(self,main) :
251 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
252 import time
253 for i in range(25):
254 if i < 15:
255 j=i+1
256 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
257 else:
258 j=i+16
259 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
260
261 strtTime = time.time()
262 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
263 for i in range(10):
264 if result == main.FALSE:
265 time.sleep(5)
266 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
267 else:
268 break
269
270 count = 1
271 i = 6
272 while i < 16 :
273 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
274 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
275 if ping == main.FALSE and count < 6:
276 count = count + 1
277 i = 6
278 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
279 time.sleep(2)
280 elif ping == main.FALSE and count ==6:
281 main.log.error("Ping test failed")
282 i = 17
283 result = main.FALSE
284 elif ping == main.TRUE:
285 i = i + 1
286 result = main.TRUE
287 endTime = time.time()
288 if result == main.TRUE:
289 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
290 else:
291 main.log.report("\tPING TEST FAIL")
292 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
293 time.sleep(10)
294
295# **********************************************************************************************************************************************************************************************
296#This test case restores the controllers removed by Case 4 then performs a ping test.
297
298 def CASE5(self,main) :
299 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
300 import time
301 for i in range(25):
302 if i < 15:
303 j=i+1
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700304 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 -0700305 else:
306 j=i+16
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700307 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 -0700308
309 strtTime = time.time()
310 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
adminaef00552014-05-08 09:18:36 -0700311 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700312 if result == main.FALSE:
313 time.sleep(5)
314 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
315 else:
316 break
317
318 count = 1
319 i = 6
320 while i < 16 :
321 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
322 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
323 if ping == main.FALSE and count < 6:
324 count = count + 1
325 i = 6
326 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
327 time.sleep(2)
328 elif ping == main.FALSE and count ==6:
329 main.log.error("Ping test failed")
330 i = 17
331 result = main.FALSE
332 elif ping == main.TRUE:
333 i = i + 1
334 result = main.TRUE
335 endTime = time.time()
336 if result == main.TRUE:
337 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
338 else:
339 main.log.report("\tPING TEST FAILED")
340 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
341
342# **********************************************************************************************************************************************************************************************
343#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
344
345 def CASE6(self,main) :
346 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
347 import time
348 main.case("Bringing Link down... ")
349 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
350 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
351
352 strtTime = time.time()
353 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
adminaef00552014-05-08 09:18:36 -0700354 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700355 if result == main.FALSE:
356 time.sleep(5)
357 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
358 else:
359 break
360
361 count = 1
362 i = 6
363 while i < 16 :
364 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
365 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
366 if ping == main.FALSE and count < 10:
367 count = count + 1
368 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
369 i = 6
370 time.sleep(2)
371 elif ping == main.FALSE and count == 10:
372 main.log.error("Ping test failed")
373 i = 17
374 result = main.FALSE
375 elif ping == main.TRUE:
376 i = i + 1
377 result = main.TRUE
378 endTime = time.time()
379 if result == main.TRUE:
380 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
381 else:
382 main.log.report("\tPING TEST FAILED")
383 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
384
385# **********************************************************************************************************************************************************************************************
386#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
387
388 def CASE7(self,main) :
389 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
390 import time
391 main.case("Bringing Link up... ")
392 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
393 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
Jon Halle80ef8c2014-04-29 15:29:13 -0700394 time.sleep(5)
admin733ae0a2014-04-09 15:01:12 -0700395 strtTime = time.time()
396 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
397 for i in range(2):
398 if result == main.FALSE:
399 time.sleep(5)
400 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
401 else:
402 break
403
404 strtTime = time.time()
405 count = 1
406 i = 6
407 while i < 16 :
408 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
409 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
410 if ping == main.FALSE and count < 10:
411 count = count + 1
412 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
413 i = 6
414 time.sleep(2)
415 elif ping == main.FALSE and count ==10:
416 main.log.error("Ping test failed")
417 i = 17
418 result = main.FALSE
419 elif ping == main.TRUE:
420 i = i + 1
421 result = main.TRUE
422 endTime = time.time()
423 if result == main.TRUE:
424 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
425 else:
426 main.log.report("\tPING TESTS FAILED")
427 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
428
429
430# ******************************************************************************************************************************************************************
431# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
432
433 def CASE21(self,main) :
434 import json
admin733ae0a2014-04-09 15:01:12 -0700435 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.")
436 main.log.report("Check initially hostMAC/IP exist on the mininet...")
437 host = main.params['YANK']['hostname']
438 mac = main.params['YANK']['hostmac']
439 hostip = main.params['YANK']['hostip']
440 RestIP1 = main.params['RESTCALL']['restIP1']
441 RestPort = main.params['RESTCALL']['restPort']
442 url = main.params['RESTCALL']['restURL']
443
444 t_topowait = 0
445 t_restwait = 10
446 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
447 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
448 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
449 time.sleep(t_topowait)
Jon Hall208b3a22014-04-16 11:30:24 -0700450 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 -0700451 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
452 time.sleep(t_restwait)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700453 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin733ae0a2014-04-09 15:01:12 -0700454 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
455 if Reststatus == 1:
456 main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
457 result1 = main.TRUE
458 elif Reststatus > 1:
459 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
460 main.log.report("switches are: " + "; ".join(Switch))
461 main.log.report("Ports are: " + "; ".join(Port))
462 main.log.report("MACs are: " + "; ".join(MAC))
463 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700464 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700465 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
466 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700467 else:# check if rest server is working
468 main.log.error("Issue with find host")
469 result1 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700470
471
472 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
473
474 main.log.report("Yank out s1-eth1")
475 main.case("Yankout s6-eth1 (link to h1) from s1")
476 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
477 time.sleep(t_topowait)
478 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
479
Jon Hall208b3a22014-04-16 11:30:24 -0700480 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 -0700481 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
482 time.sleep(t_restwait)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700483 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin733ae0a2014-04-09 15:01:12 -0700484
485 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
486 if Reststatus == 1:
487 main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
488 result2 = main.FALSE
489 elif Reststatus > 1:
490 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
491 main.log.report("switches are: " + "; ".join(Switch))
492 main.log.report("Ports are: " + "; ".join(Port))
493 main.log.report("MACs are: " + "; ".join(MAC))
494 result2 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700495 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700496 main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
497 result2 = main.TRUE
Jon Hall208b3a22014-04-16 11:30:24 -0700498 else:# check if rest server is working
499 main.log.error("Issue with find host")
500 result2 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700501
502 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
503 main.log.report("Plug s1-eth1 into s6")
504 main.case("Plug s1-eth1 to s6")
505 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
506 time.sleep(t_topowait)
507 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700508 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 -0700509
510 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
511 time.sleep(t_restwait)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700512 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin733ae0a2014-04-09 15:01:12 -0700513
514 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
515 if Reststatus == 1:
516 main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
517 result3 = main.TRUE
518 elif Reststatus > 1:
519 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
520 main.log.report("switches are: " + "; ".join(Switch))
521 main.log.report("Ports are: " + "; ".join(Port))
522 main.log.report("MACs are: " + "; ".join(MAC))
523 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700524 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700525 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
526 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700527 else:# check if rest server is working
528 main.log.error("Issue with find host")
529 result3 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700530
531 ###### Step to put interface "s1-eth1" back to s1"#####
532 main.log.report("Move s1-eth1 back on to s1")
533 main.case("Move s1-eth1 back to s1")
534 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
535 time.sleep(t_topowait)
536 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
537 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700538 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 -0700539
540 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
541 time.sleep(t_restwait)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700542 Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip)
admin733ae0a2014-04-09 15:01:12 -0700543
544 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
545 if Reststatus == 1:
546 main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
547 result4 = main.TRUE
548 elif Reststatus > 1:
549 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
550 main.log.report("switches are: " + "; ".join(Switch))
551 main.log.report("Ports are: " + "; ".join(Port))
552 main.log.report("MACs are: " + "; ".join(MAC))
553 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700554 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700555 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
556 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700557 else:# check if rest server is working
558 main.log.error("Issue with find host")
559 result4 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700560
561 result = result1 and result2 and result3 and result4
562 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
563
564# Run a pure ping test.
565
566 def CASE31(self, main):
567 main.log.report("Performing Ping Test")
568 count = 1
569 i = 6
570 while i < 16 :
571 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
572 strtTime = time.time()
573 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
574 if ping == main.FALSE and count < 6:
575 count = count + 1
576 i = 6
577 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
578 time.sleep(2)
579 elif ping == main.FALSE and count ==6:
580 main.log.error("Ping test failed")
581 i = 17
582 result = main.FALSE
583 elif ping == main.TRUE:
584 i = i + 1
585 result = main.TRUE
586 endTime = time.time()
587 if result == main.TRUE:
588 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
589 else:
590 main.log.report("\tPING TEST FAIL")
591 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
592