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