blob: 2964fd12e1284cc4fa907698ad5abc49c732f33e [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()
test1265a4b2013-09-26 22:17:18 -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)
test1265a4b2013-09-26 22:17:18 -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")
test1265a4b2013-09-26 22:17:18 -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()
71 main.ONOS1.tcpdump()
72 main.ONOS2.tcpdump()
73 main.ONOS3.tcpdump()
74 main.ONOS4.tcpdump()
adminbae64d82013-08-01 10:50:15 -070075 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
76
77#**********************************************************************************************************************************************************************************************
78#Assign Controllers
79#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>).
80#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
81#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
82# the controllers already assigned to the switch are not specified.
83
84 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
85 import time
86 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
87 main.case("Checking if one MN host exists")
88 main.step("Host IP Checking using checkIP")
89 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
90 main.step("Verifying the result")
91 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
92 main.step("assigning ONOS controllers to switches")
93 for i in range(25):
94 if i < 3:
95 j=i+1
admin530b4c92013-08-14 16:54:35 -070096 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
97 time.sleep(1)
98 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 -070099 elif i >= 3 and i < 5:
100 j=i+1
admin530b4c92013-08-14 16:54:35 -0700101 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
102 time.sleep(1)
103 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 -0700104 elif i >= 5 and i < 15:
105 j=i+1
admin530b4c92013-08-14 16:54:35 -0700106 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
107 time.sleep(1)
108 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 -0700109 else:
110 j=i+16
admin530b4c92013-08-14 16:54:35 -0700111 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
112 time.sleep(1)
113 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 -0700114 main.Mininet1.get_sw_controller("s1")
test1265a4b2013-09-26 22:17:18 -0700115
116 for i in range(9):
117 if result == main.FALSE:
118 time.sleep(3)
119 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
120 else:
121 break
adminbae64d82013-08-01 10:50:15 -0700122
123# **********************************************************************************************************************************************************************************************
124#Add Flows
125#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
126#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
127
128 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
129 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
130 import time
test1265a4b2013-09-26 22:17:18 -0700131
132 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
133 for i in range(9):
134 if result == main.FALSE:
135 time.sleep(3)
136 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
137 else:
138 break
139
adminbae64d82013-08-01 10:50:15 -0700140 main.case("Taking care of these flows!")
141 main.step("Cleaning out any leftover flows...")
142 main.ONOS1.delete_flow("all")
143 time.sleep(5)
144 strtTime = time.time()
145 main.ONOS1.add_flow(main.params['FLOWDEF'])
146 main.case("Checking flows")
147 tmp = main.FALSE
148 count = 1
admine0ae8202013-08-28 11:51:43 -0700149 main.log.info("Wait for flows to be pushed to the switches, then check")
adminbae64d82013-08-01 10:50:15 -0700150 while tmp == main.FALSE:
151 main.step("Waiting")
152 time.sleep(10)
153 main.step("Checking")
154 tmp = main.ONOS1.check_flow()
155 if tmp == main.FALSE and count < 6:
156 count = count + 1
157 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
158 elif tmp == main.FALSE and count == 6:
admin530b4c92013-08-14 16:54:35 -0700159 result1 = main.FALSE
adminbae64d82013-08-01 10:50:15 -0700160 break
161 else:
admin530b4c92013-08-14 16:54:35 -0700162 result1 = main.TRUE
adminbae64d82013-08-01 10:50:15 -0700163 break
164 endTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700165 if result1 == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700166 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700167 else:
168 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700169
admin530b4c92013-08-14 16:54:35 -0700170 count = 1
171 i = 6
172 while i < 16 :
173 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
174 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
175 if ping == main.FALSE and count < 3:
176 count = count + 1
177 i = 6
test1265a4b2013-09-26 22:17:18 -0700178 main.log.report("Ping failed, making attempt number "+str(count)+" in 10 seconds")
admin530b4c92013-08-14 16:54:35 -0700179 time.sleep(10)
180 elif ping == main.FALSE and count ==3:
181 main.log.error("Ping test failed")
182 i = 17
183 result2 = main.FALSE
184 elif ping == main.TRUE:
185 i = i + 1
186 result2 = main.TRUE
admin530b4c92013-08-14 16:54:35 -0700187 if result2 == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700188 main.log.info("Flows successfully added")
admin530b4c92013-08-14 16:54:35 -0700189 else:
190 main.log.report("\tPING TEST FAIL")
191
admin530b4c92013-08-14 16:54:35 -0700192 main.step("Verifying the result")
test1265a4b2013-09-26 22:17:18 -0700193 utilities.assert_equals(expect=main.TRUE,actual=result1 and result2,onpass="Flow check PASS",onfail="Flow check FAIL")
adminbae64d82013-08-01 10:50:15 -0700194
195#**********************************************************************************************************************************************************************************************
196#This test case removes Controllers 2,3, and 4 then performs a ping test.
197#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 -0700198#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 -0700199#If the ping test fails 6 times, then the test case will return false
200
201 def CASE4(self,main) :
test1265a4b2013-09-26 22:17:18 -0700202 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 -0700203 import time
204 for i in range(25):
205 if i < 15:
206 j=i+1
test1265a4b2013-09-26 22:17:18 -0700207 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 -0700208 else:
209 j=i+16
test1265a4b2013-09-26 22:17:18 -0700210 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
211
212 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700213 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
test1265a4b2013-09-26 22:17:18 -0700214 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700215 if result == main.FALSE:
test1265a4b2013-09-26 22:17:18 -0700216 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700217 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
218 else:
219 break
220
adminbae64d82013-08-01 10:50:15 -0700221 count = 1
222 i = 6
223 while i < 16 :
224 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
225 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
226 if ping == main.FALSE and count < 6:
227 count = count + 1
228 i = 6
test1265a4b2013-09-26 22:17:18 -0700229 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin530b4c92013-08-14 16:54:35 -0700230 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700231 elif ping == main.FALSE and count ==6:
232 main.log.error("Ping test failed")
233 i = 17
234 result = main.FALSE
235 elif ping == main.TRUE:
236 i = i + 1
237 result = main.TRUE
238 endTime = time.time()
239 if result == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700240 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700241 else:
242 main.log.report("\tPING TEST FAIL")
243 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
244
245# **********************************************************************************************************************************************************************************************
246#This test case restores the controllers removed by Case 4 then performs a ping test.
247
248 def CASE5(self,main) :
249 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
250 import time
251 for i in range(25):
252 if i < 15:
253 j=i+1
admin530b4c92013-08-14 16:54:35 -0700254 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 -0700255 else:
256 j=i+16
admin530b4c92013-08-14 16:54:35 -0700257 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'])
test1265a4b2013-09-26 22:17:18 -0700258
259 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700260 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
test1265a4b2013-09-26 22:17:18 -0700261 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700262 if result == main.FALSE:
test1265a4b2013-09-26 22:17:18 -0700263 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700264 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
265 else:
266 break
267
adminbae64d82013-08-01 10:50:15 -0700268 count = 1
269 i = 6
270 while i < 16 :
271 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
272 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
273 if ping == main.FALSE and count < 6:
274 count = count + 1
275 i = 6
test1265a4b2013-09-26 22:17:18 -0700276 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
admin530b4c92013-08-14 16:54:35 -0700277 time.sleep(5)
adminbae64d82013-08-01 10:50:15 -0700278 elif ping == main.FALSE and count ==6:
279 main.log.error("Ping test failed")
280 i = 17
281 result = main.FALSE
282 elif ping == main.TRUE:
283 i = i + 1
284 result = main.TRUE
285 endTime = time.time()
286 if result == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700287 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700288 else:
289 main.log.report("\tPING TEST FAILED")
290 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
291
292# **********************************************************************************************************************************************************************************************
293#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
294
295 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700296 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 -0700297 import time
298 main.case("Bringing Link down... ")
299 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700300 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700301
test1265a4b2013-09-26 22:17:18 -0700302 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700303 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
test1265a4b2013-09-26 22:17:18 -0700304 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700305 if result == main.FALSE:
test1265a4b2013-09-26 22:17:18 -0700306 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700307 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
308 else:
309 break
310
adminbae64d82013-08-01 10:50:15 -0700311 count = 1
312 i = 6
313 while i < 16 :
314 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
315 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700316 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700317 count = count + 1
test1265a4b2013-09-26 22:17:18 -0700318 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700319 i = 6
admin530b4c92013-08-14 16:54:35 -0700320 time.sleep(5)
admine0ae8202013-08-28 11:51:43 -0700321 elif ping == main.FALSE and count == 10:
adminbae64d82013-08-01 10:50:15 -0700322 main.log.error("Ping test failed")
323 i = 17
324 result = main.FALSE
325 elif ping == main.TRUE:
326 i = i + 1
327 result = main.TRUE
328 endTime = time.time()
329 if result == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700330 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700331 else:
332 main.log.report("\tPING TEST FAILED")
333 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
334
335# **********************************************************************************************************************************************************************************************
336#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
337
338 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700339 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 -0700340 import time
admin530b4c92013-08-14 16:54:35 -0700341 main.case("Bringing Link up... ")
342 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
admin530b4c92013-08-14 16:54:35 -0700343 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
test1265a4b2013-09-26 22:17:18 -0700344
345 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700346 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
test1265a4b2013-09-26 22:17:18 -0700347 for i in range(9):
admin530b4c92013-08-14 16:54:35 -0700348 if result == main.FALSE:
test1265a4b2013-09-26 22:17:18 -0700349 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700350 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
351 else:
352 break
353
adminbae64d82013-08-01 10:50:15 -0700354 strtTime = time.time()
355 count = 1
356 i = 6
357 while i < 16 :
358 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
359 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admine0ae8202013-08-28 11:51:43 -0700360 if ping == main.FALSE and count < 10:
adminbae64d82013-08-01 10:50:15 -0700361 count = count + 1
test1265a4b2013-09-26 22:17:18 -0700362 main.log.report("Ping failed, making attempt number "+str(count)+" in 5 seconds")
adminbae64d82013-08-01 10:50:15 -0700363 i = 6
admin530b4c92013-08-14 16:54:35 -0700364 time.sleep(5)
test1265a4b2013-09-26 22:17:18 -0700365 elif ping == main.FALSE and count ==10:
adminbae64d82013-08-01 10:50:15 -0700366 main.log.error("Ping test failed")
367 i = 17
368 result = main.FALSE
369 elif ping == main.TRUE:
370 i = i + 1
371 result = main.TRUE
372 endTime = time.time()
373 if result == main.TRUE:
test1265a4b2013-09-26 22:17:18 -0700374 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700375 else:
376 main.log.report("\tPING TESTS FAILED")
377 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
378
admin530b4c92013-08-14 16:54:35 -0700379
380# ******************************************************************************************************************************************************************
381# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
382
383 def CASE21(self,main) :
384 import json
385 from drivers.common.api.onosrestapidriver import *
386 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
387 main.log.report("Check initially hostMAC exist on the mininet...")
388 host = main.params['YANK']['hostname']
389 mac = main.params['YANK']['hostmac']
390 RestIP1 = main.params['RESTCALL']['restIP1']
391 RestIP2 = main.params['RESTCALL']['restIP2']
392 RestPort = main.params['RESTCALL']['restPort']
393 url = main.params['RESTCALL']['restURL']
394 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
395
396 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" )
397 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
398 restcall = OnosRestApiDriver()
399 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
400 try:
401 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
test1265a4b2013-09-26 22:17:18 -0700402 ip_found = Hoststatus[0]['ipv4'][0]
403 except:
admin530b4c92013-08-14 16:54:35 -0700404 Reststatus = 0
test1265a4b2013-09-26 22:17:18 -0700405
admin530b4c92013-08-14 16:54:35 -0700406 if Reststatus == 1:
407 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
test1265a4b2013-09-26 22:17:18 -0700408 if ip_found != None:
409 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
410 result = main.TRUE
411 else:
412 main.log.report("\t Found host attached to switch, but no IP address discovered.")
413 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700414 else:
415 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
416 result = main.FALSE
417
418 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
419
420 main.log.report("Yank out s1-eth1")
421 main.case("Yankout s6-eth1 (link to h1) from s1")
422 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
423 time.sleep(3)
424 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
425 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
426 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
427 try:
428 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
test1265a4b2013-09-26 22:17:18 -0700429 except:
admin530b4c92013-08-14 16:54:35 -0700430 Reststatus = 0
431 if Reststatus == 0:
432 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
433 result = main.TRUE
434 else:
435 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
436 result = main.FALSE
437
438 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
439 main.log.report("Plug s1-eth1 into s6")
440 main.case("Plug s1-eth1 to s6")
441 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
442 time.sleep(3)
443 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
444 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
445 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
446 try:
447 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
test1265a4b2013-09-26 22:17:18 -0700448 ip_found = Hoststatus[0]['ipv4'][0]
449 except:
admin530b4c92013-08-14 16:54:35 -0700450 Reststatus = 0
451 if Reststatus == 0:
452 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
453 result = main.FALSE
454 elif attachedSW == "00:00:00:00:00:00:00:06":
455 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
test1265a4b2013-09-26 22:17:18 -0700456 if ip_found != None:
457 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
458 result = main.TRUE
459 else:
460 main.log.report("\t Found host attached to switch, but no IP address discovered.")
461 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700462 else:
463 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
464 result = main.FALSE
465
466 ###### Step to put interface "s1-eth1" back to s1"#####
467 main.log.report("Move s1-eth1 back on to s1")
468 main.case("Move s1-eth1 back to s1")
469 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
470 time.sleep(3)
471 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
472 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
473 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
474 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
475 try:
476 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
test1265a4b2013-09-26 22:17:18 -0700477 ip_found = Hoststatus[0]['ipv4'][0]
478 except:
admin530b4c92013-08-14 16:54:35 -0700479 Reststatus = 0
480 if Reststatus == 0:
481 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
482 result = main.FALSE
483 elif attachedSW == "00:00:00:00:00:00:00:01":
484 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
test1265a4b2013-09-26 22:17:18 -0700485 if ip_found != None:
486 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
487 result = main.TRUE
488 else:
489 main.log.report("\t Found host attached to switch, but no IP address discovered.")
490 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700491 else:
492 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
493 result = main.FALSE
494
495 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
496
497
test1265a4b2013-09-26 22:17:18 -0700498
499