blob: 82410d2cf2497b98b51157d5183dfc6150eb191c [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosCHO4nodes :
3
4 def __init__(self) :
5 self.default = ''
6
7#**********************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, Cassandra1, 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
adminbae64d82013-08-01 10:50:15 -070011 import time
admin530b4c92013-08-14 16:54:35 -070012 main.ONOS1.stop()
13 main.ONOS2.stop()
14 main.ONOS3.stop()
15 main.ONOS4.stop()
admin4a58db92013-09-30 12:04:54 -070016 main.Cassandra1.start()
17 main.Cassandra2.start()
18 main.Cassandra3.start()
19 main.Cassandra4.start()
20 time.sleep(20)
21 main.ONOS1.drop_keyspace()
22 main.ONOS1.start()
23 time.sleep(10)
24 main.ONOS2.start()
25 main.ONOS3.start()
26 main.ONOS4.start()
27 main.ONOS1.start_rest()
28 time.sleep(5)
29 test= main.ONOS1.rest_status()
30 if test == main.FALSE:
31 main.ONOS1.start_rest()
32 main.ONOS1.get_version()
33 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
34 main.case("Checking if the startup was clean...")
35 main.step("Testing startup Zookeeper")
36 data = main.Zookeeper1.isup()
37 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
38 main.step("Testing startup Cassandra")
39 data = main.Cassandra1.isup()
admin530b4c92013-08-14 16:54:35 -070040 if data == main.FALSE:
41 main.Cassandra1.stop()
42 main.Cassandra2.stop()
43 main.Cassandra3.stop()
44 main.Cassandra4.stop()
45
46 time.sleep(5)
admin4a58db92013-09-30 12:04:54 -070047
admin530b4c92013-08-14 16:54:35 -070048 main.Cassandra1.start()
49 main.Cassandra2.start()
50 main.Cassandra3.start()
51 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070052 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
53 main.step("Testing startup ONOS")
admin4a58db92013-09-30 12:04:54 -070054 data = main.ONOS1.isup()
55 data = data and main.ONOS2.isup()
56 data = data and main.ONOS3.isup()
57 data = data and main.ONOS4.isup()
58 if data == main.FALSE:
59 main.log.report("Something is funny... restarting ONOS")
60 main.ONOS1.stop()
61 main.ONOS2.stop()
62 main.ONOS3.stop()
63 main.ONOS4.stop()
64 time.sleep(5)
65 main.ONOS1.start()
66 time.sleep(10)
67 main.ONOS2.start()
68 main.ONOS3.start()
69 main.ONOS4.start()
70 data = main.ONOS1.isup()
admin7aed4dc2013-11-22 15:05:48 -080071<<<<<<< HEAD
admin4a58db92013-09-30 12:04:54 -070072 #main.ONOS1.tcpdump()
73 #main.ONOS2.tcpdump()
74 #main.ONOS3.tcpdump()
75 #main.ONOS4.tcpdump()
admin7aed4dc2013-11-22 15:05:48 -080076=======
test1265a4b2013-09-26 22:17:18 -070077 main.ONOS1.tcpdump()
78 main.ONOS2.tcpdump()
79 main.ONOS3.tcpdump()
80 main.ONOS4.tcpdump()
admin7aed4dc2013-11-22 15:05:48 -080081>>>>>>> f580d10d359eabad08530e06fb8339390b47fba0
adminbae64d82013-08-01 10:50:15 -070082 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
83
84#**********************************************************************************************************************************************************************************************
85#Assign Controllers
86#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>).
87#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
88#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
89# the controllers already assigned to the switch are not specified.
90
91 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
92 import time
93 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
94 main.case("Checking if one MN host exists")
95 main.step("Host IP Checking using checkIP")
96 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
97 main.step("Verifying the result")
98 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
99 main.step("assigning ONOS controllers to switches")
100 for i in range(25):
101 if i < 3:
102 j=i+1
admin530b4c92013-08-14 16:54:35 -0700103 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
104 time.sleep(1)
105 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'])
adminbae64d82013-08-01 10:50:15 -0700106 elif i >= 3 and i < 5:
107 j=i+1
admin530b4c92013-08-14 16:54:35 -0700108 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
109 time.sleep(1)
110 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'])
adminbae64d82013-08-01 10:50:15 -0700111 elif i >= 5 and i < 15:
112 j=i+1
admin530b4c92013-08-14 16:54:35 -0700113 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
114 time.sleep(1)
115 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'])
adminbae64d82013-08-01 10:50:15 -0700116 else:
117 j=i+16
admin530b4c92013-08-14 16:54:35 -0700118 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
119 time.sleep(1)
120 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'])
adminbae64d82013-08-01 10:50:15 -0700121 main.Mininet1.get_sw_controller("s1")
admin4a58db92013-09-30 12:04:54 -0700122
123 for i in range(9):
124 if result == main.FALSE:
125 time.sleep(3)
126 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
127 else:
128 break
adminbae64d82013-08-01 10:50:15 -0700129
130# **********************************************************************************************************************************************************************************************
131#Add Flows
132#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
133#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
134
135 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
136 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
137 import time
admin4a58db92013-09-30 12:04:54 -0700138
139 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
140 for i in range(9):
141 if result == main.FALSE:
142 time.sleep(3)
143 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
144 else:
145 break
146
adminbae64d82013-08-01 10:50:15 -0700147 main.case("Taking care of these flows!")
148 main.step("Cleaning out any leftover flows...")
149 main.ONOS1.delete_flow("all")
150 time.sleep(5)
151 strtTime = time.time()
152 main.ONOS1.add_flow(main.params['FLOWDEF'])
153 main.case("Checking flows")
154 tmp = main.FALSE
155 count = 1
admine0ae8202013-08-28 11:51:43 -0700156 main.log.info("Wait for flows to be pushed to the switches, then check")
adminbae64d82013-08-01 10:50:15 -0700157 while tmp == main.FALSE:
158 main.step("Waiting")
159 time.sleep(10)
160 main.step("Checking")
161 tmp = main.ONOS1.check_flow()
162 if tmp == main.FALSE and count < 6:
163 count = count + 1
164 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
165 elif tmp == main.FALSE and count == 6:
admin530b4c92013-08-14 16:54:35 -0700166 result1 = main.FALSE
adminbae64d82013-08-01 10:50:15 -0700167 break
168 else:
admin530b4c92013-08-14 16:54:35 -0700169 result1 = main.TRUE
adminbae64d82013-08-01 10:50:15 -0700170 break
171 endTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700172 if result1 == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700173 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700174 else:
175 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700176
admin530b4c92013-08-14 16:54:35 -0700177 count = 1
178 i = 6
179 while i < 16 :
180 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
181 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
182 if ping == main.FALSE and count < 3:
183 count = count + 1
184 i = 6
admin4a58db92013-09-30 12:04:54 -0700185 main.log.report("Ping failed, making attempt number "+str(count)+" in 10 seconds")
admin530b4c92013-08-14 16:54:35 -0700186 time.sleep(10)
187 elif ping == main.FALSE and count ==3:
188 main.log.error("Ping test failed")
189 i = 17
190 result2 = main.FALSE
191 elif ping == main.TRUE:
192 i = i + 1
193 result2 = main.TRUE
admin530b4c92013-08-14 16:54:35 -0700194 if result2 == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700195 main.log.info("Flows successfully added")
admin530b4c92013-08-14 16:54:35 -0700196 else:
197 main.log.report("\tPING TEST FAIL")
198
admin530b4c92013-08-14 16:54:35 -0700199 main.step("Verifying the result")
admin4a58db92013-09-30 12:04:54 -0700200 utilities.assert_equals(expect=main.TRUE,actual=result1 and result2,onpass="Flow check PASS",onfail="Flow check FAIL")
adminbae64d82013-08-01 10:50:15 -0700201
202#**********************************************************************************************************************************************************************************************
203#This test case removes Controllers 2,3, and 4 then performs a ping test.
204#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
admin530b4c92013-08-14 16:54:35 -0700205#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.
adminbae64d82013-08-01 10:50:15 -0700206#If the ping test fails 6 times, then the test case will return false
207
208 def CASE4(self,main) :
admin7aed4dc2013-11-22 15:05:48 -0800209<<<<<<< HEAD
admin4a58db92013-09-30 12:04:54 -0700210 main.log.report("Remove all but one ONOS then ping until all hosts are reachable or fail after 6 attempts")
adminbae64d82013-08-01 10:50:15 -0700211 import time
admine0ae8202013-08-28 11:51:43 -0700212 import random
213
214 random.seed(None)
215
admin4a58db92013-09-30 12:04:54 -0700216 num = random.randint(1,4)
217 if num == 1:
admine0ae8202013-08-28 11:51:43 -0700218 ip = main.params['CTRL']['ip1']
219 port = main.params['CTRL']['port1']
admin4a58db92013-09-30 12:04:54 -0700220 elif num == 2:
admine0ae8202013-08-28 11:51:43 -0700221 ip = main.params['CTRL']['ip2']
222 port = main.params['CTRL']['port2']
admin4a58db92013-09-30 12:04:54 -0700223 elif num == 3:
admine0ae8202013-08-28 11:51:43 -0700224 ip = main.params['CTRL']['ip3']
225 port = main.params['CTRL']['port3']
admin4a58db92013-09-30 12:04:54 -0700226 else:
admine0ae8202013-08-28 11:51:43 -0700227 ip = main.params['CTRL']['ip4']
228 port = main.params['CTRL']['port4']
229
admin4a58db92013-09-30 12:04:54 -0700230 main.log.report("ONOS"+str(num)+" will be the sole controller")
admin7aed4dc2013-11-22 15:05:48 -0800231=======
test1265a4b2013-09-26 22:17:18 -0700232 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
adminbae64d82013-08-01 10:50:15 -0700233 import time
admin7aed4dc2013-11-22 15:05:48 -0800234>>>>>>> f580d10d359eabad08530e06fb8339390b47fba0
adminbae64d82013-08-01 10:50:15 -0700235 for i in range(25):
236 if i < 15:
237 j=i+1
test1265a4b2013-09-26 22:17:18 -0700238 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
adminbae64d82013-08-01 10:50:15 -0700239 else:
240 j=i+16
admin7aed4dc2013-11-22 15:05:48 -0800241<<<<<<< HEAD
admine0ae8202013-08-28 11:51:43 -0700242 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
admin7aed4dc2013-11-22 15:05:48 -0800243=======
test1265a4b2013-09-26 22:17:18 -0700244 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admin7aed4dc2013-11-22 15:05:48 -0800245>>>>>>> f580d10d359eabad08530e06fb8339390b47fba0
admin4a58db92013-09-30 12:04:54 -0700246
247 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700248 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin4a58db92013-09-30 12:04:54 -0700249 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700250 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700251 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700252 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
253 else:
254 break
255
adminbae64d82013-08-01 10:50:15 -0700256 count = 1
257 i = 6
258 while i < 16 :
259 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
260 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
261 if ping == main.FALSE and count < 6:
262 count = count + 1
263 i = 6
admin4a58db92013-09-30 12:04:54 -0700264 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin530b4c92013-08-14 16:54:35 -0700265 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700266 elif ping == main.FALSE and count ==6:
267 main.log.error("Ping test failed")
268 i = 17
269 result = main.FALSE
270 elif ping == main.TRUE:
271 i = i + 1
272 result = main.TRUE
273 endTime = time.time()
274 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700275 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700276 else:
277 main.log.report("\tPING TEST FAIL")
278 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
279
280# **********************************************************************************************************************************************************************************************
281#This test case restores the controllers removed by Case 4 then performs a ping test.
282
283 def CASE5(self,main) :
284 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
285 import time
286 for i in range(25):
287 if i < 15:
288 j=i+1
admin530b4c92013-08-14 16:54:35 -0700289 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'])
adminbae64d82013-08-01 10:50:15 -0700290 else:
291 j=i+16
admin530b4c92013-08-14 16:54:35 -0700292 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'])
admin4a58db92013-09-30 12:04:54 -0700293
294 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700295 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin4a58db92013-09-30 12:04:54 -0700296 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700297 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700298 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700299 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
300 else:
301 break
302
adminbae64d82013-08-01 10:50:15 -0700303 count = 1
304 i = 6
305 while i < 16 :
306 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
307 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
308 if ping == main.FALSE and count < 6:
309 count = count + 1
310 i = 6
admin4a58db92013-09-30 12:04:54 -0700311 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin530b4c92013-08-14 16:54:35 -0700312 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700313 elif ping == main.FALSE and count ==6:
314 main.log.error("Ping test failed")
315 i = 17
316 result = main.FALSE
317 elif ping == main.TRUE:
318 i = i + 1
319 result = main.TRUE
320 endTime = time.time()
321 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700322 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700323 else:
324 main.log.report("\tPING TEST FAILED")
325 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
326
327# **********************************************************************************************************************************************************************************************
328#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
329
330 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700331 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
adminbae64d82013-08-01 10:50:15 -0700332 import time
333 main.case("Bringing Link down... ")
334 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700335 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700336
admin4a58db92013-09-30 12:04:54 -0700337 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700338 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admin4a58db92013-09-30 12:04:54 -0700339 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700340 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700341 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700342 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
343 else:
344 break
345
adminbae64d82013-08-01 10:50:15 -0700346 count = 1
347 i = 6
348 while i < 16 :
349 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
350 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700351 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700352 count = count + 1
admin4a58db92013-09-30 12:04:54 -0700353 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700354 i = 6
admin530b4c92013-08-14 16:54:35 -0700355 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700356 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700357 main.log.error("Ping test failed")
358 i = 17
359 result = main.FALSE
360 elif ping == main.TRUE:
361 i = i + 1
362 result = main.TRUE
363 endTime = time.time()
364 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700365 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700366 else:
367 main.log.report("\tPING TEST FAILED")
368 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
369
370# **********************************************************************************************************************************************************************************************
371#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
372
373 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700374 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
adminbae64d82013-08-01 10:50:15 -0700375 import time
admin530b4c92013-08-14 16:54:35 -0700376 main.case("Bringing Link up... ")
377 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
admin530b4c92013-08-14 16:54:35 -0700378 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admin4a58db92013-09-30 12:04:54 -0700379
380 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700381 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin4a58db92013-09-30 12:04:54 -0700382 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700383 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700384 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700385 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
386 else:
387 break
388
adminbae64d82013-08-01 10:50:15 -0700389 strtTime = time.time()
390 count = 1
391 i = 6
392 while i < 16 :
393 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
394 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700395 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700396 count = count + 1
admin4a58db92013-09-30 12:04:54 -0700397 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700398 i = 6
admin530b4c92013-08-14 16:54:35 -0700399 time.sleep(5)
admin4a58db92013-09-30 12:04:54 -0700400 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700401 main.log.error("Ping test failed")
402 i = 17
403 result = main.FALSE
404 elif ping == main.TRUE:
405 i = i + 1
406 result = main.TRUE
407 endTime = time.time()
408 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700409 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700410 else:
411 main.log.report("\tPING TESTS FAILED")
412 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
413
admin530b4c92013-08-14 16:54:35 -0700414
415# ******************************************************************************************************************************************************************
416# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
417
418 def CASE21(self,main) :
419 import json
420 from drivers.common.api.onosrestapidriver import *
421 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
422 main.log.report("Check initially hostMAC exist on the mininet...")
423 host = main.params['YANK']['hostname']
424 mac = main.params['YANK']['hostmac']
425 RestIP1 = main.params['RESTCALL']['restIP1']
426 RestIP2 = main.params['RESTCALL']['restIP2']
427 RestPort = main.params['RESTCALL']['restPort']
428 url = main.params['RESTCALL']['restURL']
429 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
430
431 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" )
432 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
433 restcall = OnosRestApiDriver()
434 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
435 try:
436 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700437 ip_found = Hoststatus[0]['ipv4'][0]
438 except:
admin530b4c92013-08-14 16:54:35 -0700439 Reststatus = 0
admin4a58db92013-09-30 12:04:54 -0700440
admin530b4c92013-08-14 16:54:35 -0700441 if Reststatus == 1:
442 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admin4a58db92013-09-30 12:04:54 -0700443 if ip_found != None:
444 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
445 result = main.TRUE
446 else:
447 main.log.report("\t Found host attached to switch, but no IP address discovered.")
448 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700449 else:
450 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
451 result = main.FALSE
452
453 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
454
455 main.log.report("Yank out s1-eth1")
456 main.case("Yankout s6-eth1 (link to h1) from s1")
457 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
458 time.sleep(3)
459 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
460 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
461 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
462 try:
463 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700464 except:
admin530b4c92013-08-14 16:54:35 -0700465 Reststatus = 0
466 if Reststatus == 0:
467 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
468 result = main.TRUE
469 else:
470 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
471 result = main.FALSE
472
473 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
474 main.log.report("Plug s1-eth1 into s6")
475 main.case("Plug s1-eth1 to s6")
476 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
477 time.sleep(3)
478 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
479 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
480 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
481 try:
482 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700483 ip_found = Hoststatus[0]['ipv4'][0]
484 except:
admin530b4c92013-08-14 16:54:35 -0700485 Reststatus = 0
486 if Reststatus == 0:
487 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
488 result = main.FALSE
489 elif attachedSW == "00:00:00:00:00:00:00:06":
490 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
admin4a58db92013-09-30 12:04:54 -0700491 if ip_found != None:
492 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
493 result = main.TRUE
494 else:
495 main.log.report("\t Found host attached to switch, but no IP address discovered.")
496 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700497 else:
498 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
499 result = main.FALSE
500
501 ###### Step to put interface "s1-eth1" back to s1"#####
502 main.log.report("Move s1-eth1 back on to s1")
503 main.case("Move s1-eth1 back to s1")
504 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
505 time.sleep(3)
506 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
507 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
508 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
509 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
510 try:
511 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700512 ip_found = Hoststatus[0]['ipv4'][0]
513 except:
admin530b4c92013-08-14 16:54:35 -0700514 Reststatus = 0
515 if Reststatus == 0:
516 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
517 result = main.FALSE
518 elif attachedSW == "00:00:00:00:00:00:00:01":
519 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
admin4a58db92013-09-30 12:04:54 -0700520 if ip_found != None:
521 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
522 result = main.TRUE
523 else:
524 main.log.report("\t Found host attached to switch, but no IP address discovered.")
525 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700526 else:
527 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
528 result = main.FALSE
529
530 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
531
532
admin4a58db92013-09-30 12:04:54 -0700533
534