blob: 8f30b10ee637dac72ddf5f6d1f3351424d066d59 [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
Jon Hallf89c8552014-04-02 13:14:06 -070012 main.Zookeeper1.start()
13 main.Zookeeper2.start()
14 main.Zookeeper3.start()
15 main.Zookeeper4.start()
admin530b4c92013-08-14 16:54:35 -070016 main.ONOS1.stop()
17 main.ONOS2.stop()
18 main.ONOS3.stop()
19 main.ONOS4.stop()
admin68453302013-12-16 15:40:04 -080020 main.ONOS1.git_pull()
21 main.ONOS2.git_pull()
22 main.ONOS3.git_pull()
23 main.ONOS4.git_pull()
admin4a58db92013-09-30 12:04:54 -070024 main.Cassandra1.start()
25 main.Cassandra2.start()
26 main.Cassandra3.start()
27 main.Cassandra4.start()
28 time.sleep(20)
29 main.ONOS1.drop_keyspace()
30 main.ONOS1.start()
admin68453302013-12-16 15:40:04 -080031 time.sleep(30)
admin4a58db92013-09-30 12:04:54 -070032 main.ONOS2.start()
33 main.ONOS3.start()
34 main.ONOS4.start()
admin68453302013-12-16 15:40:04 -080035 time.sleep(20)
admin4a58db92013-09-30 12:04:54 -070036 main.ONOS1.get_version()
37 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
38 main.case("Checking if the startup was clean...")
39 main.step("Testing startup Zookeeper")
40 data = main.Zookeeper1.isup()
41 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
42 main.step("Testing startup Cassandra")
43 data = main.Cassandra1.isup()
admin530b4c92013-08-14 16:54:35 -070044 if data == main.FALSE:
45 main.Cassandra1.stop()
46 main.Cassandra2.stop()
47 main.Cassandra3.stop()
48 main.Cassandra4.stop()
49
50 time.sleep(5)
admin4a58db92013-09-30 12:04:54 -070051
admin530b4c92013-08-14 16:54:35 -070052 main.Cassandra1.start()
53 main.Cassandra2.start()
54 main.Cassandra3.start()
55 main.Cassandra4.start()
adminbae64d82013-08-01 10:50:15 -070056 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
57 main.step("Testing startup ONOS")
admin4a58db92013-09-30 12:04:54 -070058 data = main.ONOS1.isup()
59 data = data and main.ONOS2.isup()
60 data = data and main.ONOS3.isup()
61 data = data and main.ONOS4.isup()
62 if data == main.FALSE:
63 main.log.report("Something is funny... restarting ONOS")
64 main.ONOS1.stop()
65 main.ONOS2.stop()
66 main.ONOS3.stop()
67 main.ONOS4.stop()
68 time.sleep(5)
69 main.ONOS1.start()
admin68453302013-12-16 15:40:04 -080070 time.sleep(30)
admin4a58db92013-09-30 12:04:54 -070071 main.ONOS2.start()
72 main.ONOS3.start()
73 main.ONOS4.start()
74 data = main.ONOS1.isup()
75 #main.ONOS1.tcpdump()
76 #main.ONOS2.tcpdump()
77 #main.ONOS3.tcpdump()
78 #main.ONOS4.tcpdump()
adminbae64d82013-08-01 10:50:15 -070079 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
80
81#**********************************************************************************************************************************************************************************************
82#Assign Controllers
83#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>).
84#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
85#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
86# the controllers already assigned to the switch are not specified.
87
88 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
89 import time
90 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
91 main.case("Checking if one MN host exists")
92 main.step("Host IP Checking using checkIP")
93 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
94 main.step("Verifying the result")
95 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
96 main.step("assigning ONOS controllers to switches")
97 for i in range(25):
98 if i < 3:
99 j=i+1
admin530b4c92013-08-14 16:54:35 -0700100 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
101 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700102 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'])
adminbae64d82013-08-01 10:50:15 -0700103 elif i >= 3 and i < 5:
104 j=i+1
admin530b4c92013-08-14 16:54:35 -0700105 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
106 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700107 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'])
adminbae64d82013-08-01 10:50:15 -0700108 elif i >= 5 and i < 15:
109 j=i+1
admin530b4c92013-08-14 16:54:35 -0700110 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
111 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700112 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'])
adminbae64d82013-08-01 10:50:15 -0700113 else:
114 j=i+16
admin530b4c92013-08-14 16:54:35 -0700115 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
116 time.sleep(1)
Jon Hallf89c8552014-04-02 13:14:06 -0700117 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'])
adminbae64d82013-08-01 10:50:15 -0700118 main.Mininet1.get_sw_controller("s1")
admin4a58db92013-09-30 12:04:54 -0700119
120 for i in range(9):
121 if result == main.FALSE:
122 time.sleep(3)
123 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
124 else:
125 break
adminbae64d82013-08-01 10:50:15 -0700126
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
admin4a58db92013-09-30 12:04:54 -0700135
136 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800137 for counter in range(9):
admin4a58db92013-09-30 12:04:54 -0700138 if result == main.FALSE:
139 time.sleep(3)
140 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
141 else:
142 break
143
adminbae64d82013-08-01 10:50:15 -0700144 main.case("Taking care of these flows!")
145 main.step("Cleaning out any leftover flows...")
146 main.ONOS1.delete_flow("all")
147 time.sleep(5)
148 strtTime = time.time()
149 main.ONOS1.add_flow(main.params['FLOWDEF'])
150 main.case("Checking flows")
admin530b4c92013-08-14 16:54:35 -0700151
admin68453302013-12-16 15:40:04 -0800152 pingAttempts = main.params['pingAttempts']
153 pingSleep = main.params['pingSleep']
154
admin530b4c92013-08-14 16:54:35 -0700155 count = 1
156 i = 6
157 while i < 16 :
158 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
159 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800160 if ping == main.FALSE and count < int(pingAttempts):
admin530b4c92013-08-14 16:54:35 -0700161 count = count + 1
162 i = 6
admin68453302013-12-16 15:40:04 -0800163 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
164 time.sleep(int(pingSleep))
165 elif ping == main.FALSE and count == int(pingAttempts):
admin530b4c92013-08-14 16:54:35 -0700166 main.log.error("Ping test failed")
167 i = 17
admin68453302013-12-16 15:40:04 -0800168 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700169 elif ping == main.TRUE:
170 i = i + 1
admin68453302013-12-16 15:40:04 -0800171 result = main.TRUE
172 endTime = time.time()
173 if result == main.TRUE:
174 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin530b4c92013-08-14 16:54:35 -0700175 else:
admin68453302013-12-16 15:40:04 -0800176 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700177
admin530b4c92013-08-14 16:54:35 -0700178 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800179 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
adminbae64d82013-08-01 10:50:15 -0700180
181#**********************************************************************************************************************************************************************************************
182#This test case removes Controllers 2,3, and 4 then performs a ping test.
183#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 -0700184#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 -0700185#If the ping test fails 6 times, then the test case will return false
186
187 def CASE4(self,main) :
admin4a58db92013-09-30 12:04:54 -0700188 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 -0700189 import time
admine0ae8202013-08-28 11:51:43 -0700190 import random
191
192 random.seed(None)
193
admin4a58db92013-09-30 12:04:54 -0700194 num = random.randint(1,4)
195 if num == 1:
admine0ae8202013-08-28 11:51:43 -0700196 ip = main.params['CTRL']['ip1']
197 port = main.params['CTRL']['port1']
admin4a58db92013-09-30 12:04:54 -0700198 elif num == 2:
admine0ae8202013-08-28 11:51:43 -0700199 ip = main.params['CTRL']['ip2']
200 port = main.params['CTRL']['port2']
admin4a58db92013-09-30 12:04:54 -0700201 elif num == 3:
admine0ae8202013-08-28 11:51:43 -0700202 ip = main.params['CTRL']['ip3']
203 port = main.params['CTRL']['port3']
admin4a58db92013-09-30 12:04:54 -0700204 else:
admine0ae8202013-08-28 11:51:43 -0700205 ip = main.params['CTRL']['ip4']
206 port = main.params['CTRL']['port4']
207
admin4a58db92013-09-30 12:04:54 -0700208 main.log.report("ONOS"+str(num)+" will be the sole controller")
adminbae64d82013-08-01 10:50:15 -0700209 for i in range(25):
210 if i < 15:
211 j=i+1
admin68453302013-12-16 15:40:04 -0800212 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers
adminbae64d82013-08-01 10:50:15 -0700213 else:
214 j=i+16
admine0ae8202013-08-28 11:51:43 -0700215 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
admin4a58db92013-09-30 12:04:54 -0700216
217 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700218 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800219 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700220 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700221 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700222 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
223 else:
224 break
225
admin68453302013-12-16 15:40:04 -0800226 pingAttempts = main.params['pingAttempts']
227 pingSleep = main.params['pingSleep']
228
adminbae64d82013-08-01 10:50:15 -0700229 count = 1
230 i = 6
231 while i < 16 :
232 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
233 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800234 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700235 count = count + 1
236 i = 6
admin68453302013-12-16 15:40:04 -0800237 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
238 time.sleep(int(pingSleep))
239 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700240 main.log.error("Ping test failed")
241 i = 17
242 result = main.FALSE
243 elif ping == main.TRUE:
244 i = i + 1
245 result = main.TRUE
246 endTime = time.time()
247 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700248 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700249 else:
250 main.log.report("\tPING TEST FAIL")
251 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
252
253# **********************************************************************************************************************************************************************************************
254#This test case restores the controllers removed by Case 4 then performs a ping test.
255
256 def CASE5(self,main) :
257 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
258 import time
259 for i in range(25):
260 if i < 15:
261 j=i+1
Jon Hallf89c8552014-04-02 13:14:06 -0700262 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'])
adminbae64d82013-08-01 10:50:15 -0700263 else:
264 j=i+16
Jon Hallf89c8552014-04-02 13:14:06 -0700265 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'])
admin4a58db92013-09-30 12:04:54 -0700266
267 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700268 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800269 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700270 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700271 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700272 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
273 else:
274 break
275
admin68453302013-12-16 15:40:04 -0800276 pingAttempts = main.params['pingAttempts']
277 pingSleep = main.params['pingSleep']
278
adminbae64d82013-08-01 10:50:15 -0700279 count = 1
280 i = 6
281 while i < 16 :
282 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
283 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800284 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700285 count = count + 1
286 i = 6
admin68453302013-12-16 15:40:04 -0800287 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
288 time.sleep(int(pingSleep))
289 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700290 main.log.error("Ping test failed")
291 i = 17
292 result = main.FALSE
293 elif ping == main.TRUE:
294 i = i + 1
295 result = main.TRUE
296 endTime = time.time()
297 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700298 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700299 else:
300 main.log.report("\tPING TEST FAILED")
301 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
302
303# **********************************************************************************************************************************************************************************************
304#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
305
306 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700307 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 -0700308 import time
309 main.case("Bringing Link down... ")
310 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700311 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700312
admin4a58db92013-09-30 12:04:54 -0700313 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700314 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admin68453302013-12-16 15:40:04 -0800315 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700316 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700317 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700318 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
319 else:
320 break
321
admin68453302013-12-16 15:40:04 -0800322 pingAttempts = main.params['pingAttempts']
323 pingSleep = main.params['pingSleep']
324
adminbae64d82013-08-01 10:50:15 -0700325 count = 1
326 i = 6
327 while i < 16 :
328 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
329 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800330 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700331 count = count + 1
admin68453302013-12-16 15:40:04 -0800332 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
adminbae64d82013-08-01 10:50:15 -0700333 i = 6
admin68453302013-12-16 15:40:04 -0800334 time.sleep(int(pingSleep))
335 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700336 main.log.error("Ping test failed")
337 i = 17
338 result = main.FALSE
339 elif ping == main.TRUE:
340 i = i + 1
341 result = main.TRUE
342 endTime = time.time()
343 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700344 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700345 else:
346 main.log.report("\tPING TEST FAILED")
347 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
348
349# **********************************************************************************************************************************************************************************************
350#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
351
352 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700353 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 -0700354 import time
admin530b4c92013-08-14 16:54:35 -0700355 main.case("Bringing Link up... ")
356 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
admin530b4c92013-08-14 16:54:35 -0700357 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admin4a58db92013-09-30 12:04:54 -0700358
359 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700360 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800361 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700362 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700363 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700364 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
365 else:
366 break
367
admin68453302013-12-16 15:40:04 -0800368 pingAttempts = main.params['pingAttempts']
369 pingSleep = main.params['pingSleep']
370
adminbae64d82013-08-01 10:50:15 -0700371 strtTime = time.time()
372 count = 1
373 i = 6
374 while i < 16 :
375 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
376 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800377 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700378 count = count + 1
admin68453302013-12-16 15:40:04 -0800379 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
adminbae64d82013-08-01 10:50:15 -0700380 i = 6
admin68453302013-12-16 15:40:04 -0800381 time.sleep(int(pingSleep))
382 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700383 main.log.error("Ping test failed")
384 i = 17
385 result = main.FALSE
386 elif ping == main.TRUE:
387 i = i + 1
388 result = main.TRUE
389 endTime = time.time()
390 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700391 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700392 else:
393 main.log.report("\tPING TESTS FAILED")
394 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
395
admin530b4c92013-08-14 16:54:35 -0700396
397# ******************************************************************************************************************************************************************
398# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
399
400 def CASE21(self,main) :
401 import json
admin530b4c92013-08-14 16:54:35 -0700402 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
403 main.log.report("Check initially hostMAC exist on the mininet...")
404 host = main.params['YANK']['hostname']
405 mac = main.params['YANK']['hostmac']
406 RestIP1 = main.params['RESTCALL']['restIP1']
407 RestIP2 = main.params['RESTCALL']['restIP2']
408 RestPort = main.params['RESTCALL']['restPort']
409 url = main.params['RESTCALL']['restURL']
410 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
411
412 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" )
413 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf89c8552014-04-02 13:14:06 -0700414 Reststatus, Hoststatus =main.ONOS1.find_host(RestIP1,RestPort,url,mac)
admin530b4c92013-08-14 16:54:35 -0700415 try:
416 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700417 ip_found = Hoststatus[0]['ipv4'][0]
418 except:
admin530b4c92013-08-14 16:54:35 -0700419 Reststatus = 0
admin4a58db92013-09-30 12:04:54 -0700420
admin530b4c92013-08-14 16:54:35 -0700421 if Reststatus == 1:
422 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admin4a58db92013-09-30 12:04:54 -0700423 if ip_found != None:
424 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
425 result = main.TRUE
426 else:
427 main.log.report("\t Found host attached to switch, but no IP address discovered.")
428 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700429 else:
430 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
431 result = main.FALSE
432
433 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
434
435 main.log.report("Yank out s1-eth1")
436 main.case("Yankout s6-eth1 (link to h1) from s1")
437 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
438 time.sleep(3)
439 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
440 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf89c8552014-04-02 13:14:06 -0700441 Reststatus, Hoststatus = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
admin530b4c92013-08-14 16:54:35 -0700442 try:
443 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700444 except:
admin530b4c92013-08-14 16:54:35 -0700445 Reststatus = 0
446 if Reststatus == 0:
447 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
448 result = main.TRUE
449 else:
450 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
451 result = main.FALSE
452
453 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
454 main.log.report("Plug s1-eth1 into s6")
455 main.case("Plug s1-eth1 to s6")
456 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
457 time.sleep(3)
458 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
459 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf89c8552014-04-02 13:14:06 -0700460 Reststatus, Hoststatus =main.ONOS1.find_host(RestIP2,RestPort,url,mac)
admin530b4c92013-08-14 16:54:35 -0700461 try:
462 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700463 ip_found = Hoststatus[0]['ipv4'][0]
464 except:
admin530b4c92013-08-14 16:54:35 -0700465 Reststatus = 0
466 if Reststatus == 0:
467 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
468 result = main.FALSE
469 elif attachedSW == "00:00:00:00:00:00:00:06":
470 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
admin4a58db92013-09-30 12:04:54 -0700471 if ip_found != None:
472 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
473 result = main.TRUE
474 else:
475 main.log.report("\t Found host attached to switch, but no IP address discovered.")
476 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700477 else:
478 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
479 result = main.FALSE
480
481 ###### Step to put interface "s1-eth1" back to s1"#####
482 main.log.report("Move s1-eth1 back on to s1")
483 main.case("Move s1-eth1 back to s1")
484 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
485 time.sleep(3)
486 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
487 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
488 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallf89c8552014-04-02 13:14:06 -0700489 Reststatus, Hoststatus = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
admin530b4c92013-08-14 16:54:35 -0700490 try:
491 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700492 ip_found = Hoststatus[0]['ipv4'][0]
493 except:
admin530b4c92013-08-14 16:54:35 -0700494 Reststatus = 0
495 if Reststatus == 0:
496 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
497 result = main.FALSE
498 elif attachedSW == "00:00:00:00:00:00:00:01":
499 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
admin4a58db92013-09-30 12:04:54 -0700500 if ip_found != None:
501 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
502 result = main.TRUE
503 else:
504 main.log.report("\t Found host attached to switch, but no IP address discovered.")
505 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700506 else:
507 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
508 result = main.FALSE
509
510 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
511
512
admin4a58db92013-09-30 12:04:54 -0700513
514