blob: e5804d13a09ac4c51ac7f52c4cc25bc52ef0fae4 [file] [log] [blame]
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001
2class RCOnosCHO4nodes :
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 Hallf7947982014-05-22 10:44:45 -070012 main.ONOS1.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
13 main.ONOS2.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
14 main.ONOS3.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
15 main.ONOS4.handle.sendline("cp ~/onos.properties.reactive ~/ONOS/conf/onos.properties")
Jon Hall010f5412014-05-21 15:10:12 -070016
SeanCorcoranf4ee2582014-04-16 17:12:30 -070017 main.Zookeeper1.start()
SeanCorcoranf4ee2582014-04-16 17:12:30 -070018 main.Zookeeper2.start()
19 main.Zookeeper3.start()
20 main.Zookeeper4.start()
Jon Hall010f5412014-05-21 15:10:12 -070021 main.RamCloud1.stop_coor()
22 main.RamCloud1.stop_serv()
23 main.RamCloud2.stop_serv()
24 main.RamCloud3.stop_serv()
25 main.RamCloud4.stop_serv()
26 time.sleep(10)
27 main.RamCloud1.del_db()
28 main.RamCloud2.del_db()
29 main.RamCloud3.del_db()
30 main.RamCloud4.del_db()
31 time.sleep(10)
Jon Hall0e09e6a2014-04-25 13:42:15 -070032 main.log.report("Pulling latest code from github to all nodes")
33 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 Hall010f5412014-05-21 15:10:12 -070046 #if uptodate==0
47 if 1:
Jon Hall0e09e6a2014-04-25 13:42:15 -070048 main.ONOS1.git_compile()
49 main.ONOS2.git_compile()
50 main.ONOS3.git_compile()
51 main.ONOS4.git_compile()
52 main.ONOS1.print_version()
Jon Hall010f5412014-05-21 15:10: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()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070061 main.RamCloud1.start_coor()
Jon Hall010f5412014-05-21 15:10:12 -070062 time.sleep(1)
SeanCorcoranc3ed7432014-04-09 16:32:27 -070063 main.RamCloud1.start_serv()
64 main.RamCloud2.start_serv()
65 main.RamCloud3.start_serv()
Jon Hall010f5412014-05-21 15:10:12 -070066 main.RamCloud4.start_serv()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070067 main.ONOS1.start()
Jon Hall010f5412014-05-21 15:10:12 -070068 time.sleep(5)
SeanCorcoranc3ed7432014-04-09 16:32:27 -070069 main.ONOS2.start()
70 main.ONOS3.start()
71 main.ONOS4.start()
Jon Hall010f5412014-05-21 15:10:12 -070072 main.ONOS1.start_rest()
73 time.sleep(10)
74 test= main.ONOS1.rest_status()
75 if test == main.FALSE:
76 main.ONOS1.start_rest()
77 main.ONOS1.get_version()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070078 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
79 main.case("Checking if the startup was clean...")
Jon Hall010f5412014-05-21 15:10:12 -070080 main.step("Testing startup Zookeeper")
SeanCorcoranc3ed7432014-04-09 16:32:27 -070081 data = main.Zookeeper1.isup()
82 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
Jon Hall010f5412014-05-21 15:10:12 -070083 main.step("Testing startup RamCloud")
84 data = main.RamCloud1.status_serv()
SeanCorcoranc3ed7432014-04-09 16:32:27 -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)
SeanCorcoranc3ed7432014-04-09 16:32:27 -070093 main.RamCloud1.start_coor()
94 main.RamCloud1.start_serv()
95 main.RamCloud2.start_serv()
96 main.RamCloud3.start_serv()
Jon Hall010f5412014-05-21 15:10:12 -070097 main.RamCloud4.start_serv()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070098 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
Jon Hall010f5412014-05-21 15:10:12 -070099 main.step("Testing startup ONOS")
100 data = main.ONOS1.isup()
101 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
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700111 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
Jon Hall010f5412014-05-21 15:10:12 -0700112 time.sleep(20)
113
114
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700115#**********************************************************************************************************************************************************************************************
116#Assign Controllers
117#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>).
118#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
119#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
120# the controllers already assigned to the switch are not specified.
121
122 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
123 import time
124 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
125 main.case("Checking if one MN host exists")
126 main.step("Host IP Checking using checkIP")
127 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
128 main.step("Verifying the result")
129 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
130 main.step("assigning ONOS controllers to switches")
131 for i in range(25):
132 if i < 3:
133 j=i+1
134 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
135 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700136 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700137 elif i >= 3 and i < 5:
138 j=i+1
139 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
140 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700141 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700142 elif i >= 5 and i < 15:
143 j=i+1
144 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
145 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700146 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700147 else:
148 j=i+16
149 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
150 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700151 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700152 main.Mininet1.get_sw_controller("s1")
153
154 for i in range(9):
155 if result == main.FALSE:
156 time.sleep(3)
157 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
158 else:
159 break
160
161# **********************************************************************************************************************************************************************************************
162#Add Flows
163#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
164#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
165
166 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
Jon Hall010f5412014-05-21 15:10:12 -0700167 main.log.report("Delete any flows from previous tests, then add flows using intents and wait for switch flow tables to update")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700168 import time
169
170 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
171 for counter in range(9):
172 if result == main.FALSE:
173 time.sleep(3)
174 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
175 else:
176 break
177
178 main.case("Taking care of these flows!")
179 main.step("Cleaning out any leftover flows...")
Jon Hall0e09e6a2014-04-25 13:42:15 -0700180 #main.ONOS1.delete_flow("all")
181 main.ONOS1.rm_flow()
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700182 time.sleep(5)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700183 main.ONOS1.purge()
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700184 strtTime = time.time()
Jon Hall0e09e6a2014-04-25 13:42:15 -0700185 main.ONOS1.ad_flow()
Jon Hallf7947982014-05-22 10:44:45 -0700186 main.case("Checking flows with pings")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700187
188 pingAttempts = main.params['pingAttempts']
189 pingSleep = main.params['pingSleep']
190
191 count = 1
192 i = 6
193 while i < 16 :
194 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
195 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
196 if ping == main.FALSE and count < int(pingAttempts):
197 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700198 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700199 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
200 time.sleep(int(pingSleep))
201 elif ping == main.FALSE and count == int(pingAttempts):
202 main.log.error("Ping test failed")
203 i = 17
204 result = main.FALSE
205 elif ping == main.TRUE:
206 i = i + 1
207 result = main.TRUE
208 endTime = time.time()
209 if result == main.TRUE:
Jon Hall010f5412014-05-21 15:10:12 -0700210 main.log.report("\n\t\t\t\tTime from pushing intents to successful ping test: "+str(round(endTime-strtTime,2))+" seconds")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700211 else:
212 main.log.report("\tFlows failed check")
213
214 main.step("Verifying the result")
215 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
216
217#**********************************************************************************************************************************************************************************************
218#This test case removes Controllers 2,3, and 4 then performs a ping test.
219#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
220#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.
221#If the ping test fails 6 times, then the test case will return false
222
223 def CASE4(self,main) :
224 main.log.report("Remove all but one ONOS then ping until all hosts are reachable or fail after 6 attempts")
225 import time
226 import random
227
228 random.seed(None)
229
230 num = random.randint(1,4)
231 if num == 1:
232 ip = main.params['CTRL']['ip1']
233 port = main.params['CTRL']['port1']
234 elif num == 2:
235 ip = main.params['CTRL']['ip2']
236 port = main.params['CTRL']['port2']
237 elif num == 3:
238 ip = main.params['CTRL']['ip3']
239 port = main.params['CTRL']['port3']
240 else:
241 ip = main.params['CTRL']['ip4']
242 port = main.params['CTRL']['port4']
243
244 main.log.report("ONOS"+str(num)+" will be the sole controller")
245 for i in range(25):
246 if i < 15:
247 j=i+1
248 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers
249 else:
250 j=i+16
251 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
252
253 strtTime = time.time()
254 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
255 for counter in range(9):
256 if result == main.FALSE:
257 time.sleep(3)
258 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
259 else:
260 break
261
262 pingAttempts = main.params['pingAttempts']
263 pingSleep = main.params['pingSleep']
264
265 count = 1
266 i = 6
267 while i < 16 :
268 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
269 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
270 if ping == main.FALSE and count < int(pingAttempts):
271 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700272 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700273 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
274 time.sleep(int(pingSleep))
275 elif ping == main.FALSE and count == int(pingAttempts):
276 main.log.error("Ping test failed")
277 i = 17
278 result = main.FALSE
279 elif ping == main.TRUE:
280 i = i + 1
281 result = main.TRUE
282 endTime = time.time()
283 if result == main.TRUE:
284 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
285 else:
286 main.log.report("\tPING TEST FAIL")
287 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
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),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),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 counter in range(9):
306 if result == main.FALSE:
307 time.sleep(3)
308 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
309 else:
310 break
311
312 pingAttempts = main.params['pingAttempts']
313 pingSleep = main.params['pingSleep']
314
315 count = 1
316 i = 6
317 while i < 16 :
318 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
319 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
320 if ping == main.FALSE and count < int(pingAttempts):
321 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700322 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700323 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
324 time.sleep(int(pingSleep))
325 elif ping == main.FALSE and count == int(pingAttempts):
326 main.log.error("Ping test failed")
327 i = 17
328 result = main.FALSE
329 elif ping == main.TRUE:
330 i = i + 1
331 result = main.TRUE
332 endTime = time.time()
333 if result == main.TRUE:
334 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
335 else:
336 main.log.report("\tPING TEST FAILED")
337 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
338
339# **********************************************************************************************************************************************************************************************
340#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
341
342 def CASE6(self,main) :
343 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
344 import time
345 main.case("Bringing Link down... ")
346 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
347 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
348
349 strtTime = time.time()
350 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
351 for counter in range(9):
352 if result == main.FALSE:
353 time.sleep(3)
354 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
355 else:
356 break
357
358 pingAttempts = main.params['pingAttempts']
359 pingSleep = main.params['pingSleep']
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 < int(pingAttempts):
367 count = count + 1
368 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
Jon Hall0e09e6a2014-04-25 13:42:15 -0700369 #i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700370 time.sleep(int(pingSleep))
371 elif ping == main.FALSE and count == int(pingAttempts):
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...")
394
395 strtTime = time.time()
396 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
397 for counter in range(9):
398 if result == main.FALSE:
399 time.sleep(3)
400 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
401 else:
402 break
403
404 pingAttempts = main.params['pingAttempts']
405 pingSleep = main.params['pingSleep']
406
407 strtTime = time.time()
408 count = 1
409 i = 6
410 while i < 16 :
411 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
412 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
413 if ping == main.FALSE and count < int(pingAttempts):
414 count = count + 1
415 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
Jon Hall010f5412014-05-21 15:10:12 -0700416 #i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700417 time.sleep(int(pingSleep))
418 elif ping == main.FALSE and count == int(pingAttempts):
419 main.log.error("Ping test failed")
420 i = 17
421 result = main.FALSE
422 elif ping == main.TRUE:
423 i = i + 1
424 result = main.TRUE
425 endTime = time.time()
426 if result == main.TRUE:
427 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
428 else:
429 main.log.report("\tPING TESTS FAILED")
Jon Hall010f5412014-05-21 15:10:12 -0700430
431 main.ONOS1.check_exceptions()
432 main.ONOS2.check_exceptions()
433 main.ONOS3.check_exceptions()
434 main.ONOS4.check_exceptions()
435
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700436 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
437
438
Jon Hallf7947982014-05-22 10:44:45 -0700439# **********************************************************************************************************************************************************************************************
440# Runs reactive ping test
441 def CASE8(self,main) :
442 main.log.report("Reactive flow ping test:ping until the routes are active or fail after 10 attempts")
443 import time
444
445 strtTime = time.time()
446 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
447 for counter in range(9):
448 if result == main.FALSE:
449 time.sleep(3)
450 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
451 else:
452 break
453
454 pingAttempts = main.params['pingAttempts']
455 pingSleep = main.params['pingSleep']
456
457 strtTime = time.time()
458 count = 1
459 i = 6
460 while i < 16 :
461 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
462 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
463 if ping == main.FALSE and count < int(pingAttempts):
464 count = count + 1
465 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
466 #i = 6
467 time.sleep(int(pingSleep))
468 elif ping == main.FALSE and count == int(pingAttempts):
469 main.log.error("Ping test failed")
470 i = 17
471 result = main.FALSE
472 elif ping == main.TRUE:
473 i = i + 1
474 result = main.TRUE
475 endTime = time.time()
476 if result == main.TRUE:
477 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
478 else:
479 main.log.report("\tPING TESTS FAILED")
480
481 main.ONOS1.check_exceptions()
482 main.ONOS2.check_exceptions()
483 main.ONOS3.check_exceptions()
484 main.ONOS4.check_exceptions()
485
486 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
487
488
489
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700490# ******************************************************************************************************************************************************************
491# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
492
493 def CASE21(self,main) :
494 import json
495 from drivers.common.api.onosrestapidriver import *
496 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
497 main.log.report("Check initially hostMAC exist on the mininet...")
498 host = main.params['YANK']['hostname']
499 mac = main.params['YANK']['hostmac']
500 RestIP1 = main.params['RESTCALL']['restIP1']
501 RestIP2 = main.params['RESTCALL']['restIP2']
502 RestPort = main.params['RESTCALL']['restPort']
503 url = main.params['RESTCALL']['restURL']
504 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
505
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 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
508 restcall = OnosRestApiDriver()
509 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
510 try:
511 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
512 ip_found = Hoststatus[0]['ipv4'][0]
513 except:
514 Reststatus = 0
515
516 if Reststatus == 1:
517 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
518 if ip_found != None:
519 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
520 result = main.TRUE
521 else:
522 main.log.report("\t Found host attached to switch, but no IP address discovered.")
523 result = main.FALSE
524 else:
525 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
526 result = main.FALSE
527
528 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
529
530 main.log.report("Yank out s1-eth1")
531 main.case("Yankout s6-eth1 (link to h1) from s1")
532 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
533 time.sleep(3)
534 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
535 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
536 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
537 try:
538 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
539 except:
540 Reststatus = 0
541 if Reststatus == 0:
542 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
543 result = main.TRUE
544 else:
545 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
546 result = main.FALSE
547
548 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
549 main.log.report("Plug s1-eth1 into s6")
550 main.case("Plug s1-eth1 to s6")
551 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
552 time.sleep(3)
553 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
554 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
555 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
556 try:
557 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
558 ip_found = Hoststatus[0]['ipv4'][0]
559 except:
560 Reststatus = 0
561 if Reststatus == 0:
562 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
563 result = main.FALSE
564 elif attachedSW == "00:00:00:00:00:00:00:06":
565 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
566 if ip_found != None:
567 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
568 result = main.TRUE
569 else:
570 main.log.report("\t Found host attached to switch, but no IP address discovered.")
571 result = main.FALSE
572 else:
573 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
574 result = main.FALSE
575
576 ###### Step to put interface "s1-eth1" back to s1"#####
577 main.log.report("Move s1-eth1 back on to s1")
578 main.case("Move s1-eth1 back to s1")
579 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
580 time.sleep(3)
581 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
582 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
583 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
584 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
585 try:
586 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
587 ip_found = Hoststatus[0]['ipv4'][0]
588 except:
589 Reststatus = 0
590 if Reststatus == 0:
591 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
592 result = main.FALSE
593 elif attachedSW == "00:00:00:00:00:00:00:01":
594 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
595 if ip_found != None:
596 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
597 result = main.TRUE
598 else:
599 main.log.report("\t Found host attached to switch, but no IP address discovered.")
600 result = main.FALSE
601 else:
602 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
603 result = main.FALSE
604
605 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
606
607
608
609