blob: 6eada7655bb0798a2b2dc79fa39c65bedab8d7db [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()
admin68453302013-12-16 15:40:04 -080016 main.ONOS1.git_pull()
17 main.ONOS2.git_pull()
18 main.ONOS3.git_pull()
19 main.ONOS4.git_pull()
admin4a58db92013-09-30 12:04:54 -070020 main.Cassandra1.start()
21 main.Cassandra2.start()
22 main.Cassandra3.start()
23 main.Cassandra4.start()
24 time.sleep(20)
25 main.ONOS1.drop_keyspace()
26 main.ONOS1.start()
admin68453302013-12-16 15:40:04 -080027 time.sleep(30)
admin4a58db92013-09-30 12:04:54 -070028 main.ONOS2.start()
29 main.ONOS3.start()
30 main.ONOS4.start()
admin68453302013-12-16 15:40:04 -080031 time.sleep(20)
admin4a58db92013-09-30 12:04:54 -070032 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()
admin68453302013-12-16 15:40:04 -080066 time.sleep(30)
admin4a58db92013-09-30 12:04:54 -070067 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")
admin4a58db92013-09-30 12:04:54 -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
admin4a58db92013-09-30 12:04:54 -0700131
132 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800133 for counter in range(9):
admin4a58db92013-09-30 12:04:54 -0700134 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")
admin530b4c92013-08-14 16:54:35 -0700147
admin68453302013-12-16 15:40:04 -0800148 pingAttempts = main.params['pingAttempts']
149 pingSleep = main.params['pingSleep']
150
admin530b4c92013-08-14 16:54:35 -0700151 count = 1
152 i = 6
153 while i < 16 :
154 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
155 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800156 if ping == main.FALSE and count < int(pingAttempts):
admin530b4c92013-08-14 16:54:35 -0700157 count = count + 1
158 i = 6
admin68453302013-12-16 15:40:04 -0800159 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
160 time.sleep(int(pingSleep))
161 elif ping == main.FALSE and count == int(pingAttempts):
admin530b4c92013-08-14 16:54:35 -0700162 main.log.error("Ping test failed")
163 i = 17
admin68453302013-12-16 15:40:04 -0800164 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700165 elif ping == main.TRUE:
166 i = i + 1
admin68453302013-12-16 15:40:04 -0800167 result = main.TRUE
168 endTime = time.time()
169 if result == main.TRUE:
170 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin530b4c92013-08-14 16:54:35 -0700171 else:
admin68453302013-12-16 15:40:04 -0800172 main.log.report("\tFlows failed check")
admin530b4c92013-08-14 16:54:35 -0700173
admin530b4c92013-08-14 16:54:35 -0700174 main.step("Verifying the result")
admin68453302013-12-16 15:40:04 -0800175 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
adminbae64d82013-08-01 10:50:15 -0700176
177#**********************************************************************************************************************************************************************************************
178#This test case removes Controllers 2,3, and 4 then performs a ping test.
179#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 -0700180#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 -0700181#If the ping test fails 6 times, then the test case will return false
182
183 def CASE4(self,main) :
admin4a58db92013-09-30 12:04:54 -0700184 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 -0700185 import time
admine0ae8202013-08-28 11:51:43 -0700186 import random
187
188 random.seed(None)
189
admin4a58db92013-09-30 12:04:54 -0700190 num = random.randint(1,4)
191 if num == 1:
admine0ae8202013-08-28 11:51:43 -0700192 ip = main.params['CTRL']['ip1']
193 port = main.params['CTRL']['port1']
admin4a58db92013-09-30 12:04:54 -0700194 elif num == 2:
admine0ae8202013-08-28 11:51:43 -0700195 ip = main.params['CTRL']['ip2']
196 port = main.params['CTRL']['port2']
admin4a58db92013-09-30 12:04:54 -0700197 elif num == 3:
admine0ae8202013-08-28 11:51:43 -0700198 ip = main.params['CTRL']['ip3']
199 port = main.params['CTRL']['port3']
admin4a58db92013-09-30 12:04:54 -0700200 else:
admine0ae8202013-08-28 11:51:43 -0700201 ip = main.params['CTRL']['ip4']
202 port = main.params['CTRL']['port4']
203
admin4a58db92013-09-30 12:04:54 -0700204 main.log.report("ONOS"+str(num)+" will be the sole controller")
adminbae64d82013-08-01 10:50:15 -0700205 for i in range(25):
206 if i < 15:
207 j=i+1
admin68453302013-12-16 15:40:04 -0800208 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 -0700209 else:
210 j=i+16
admine0ae8202013-08-28 11:51:43 -0700211 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
admin4a58db92013-09-30 12:04:54 -0700212
213 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700214 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800215 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700216 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700217 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700218 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
219 else:
220 break
221
admin68453302013-12-16 15:40:04 -0800222 pingAttempts = main.params['pingAttempts']
223 pingSleep = main.params['pingSleep']
224
adminbae64d82013-08-01 10:50:15 -0700225 count = 1
226 i = 6
227 while i < 16 :
228 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
229 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800230 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700231 count = count + 1
232 i = 6
admin68453302013-12-16 15:40:04 -0800233 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
234 time.sleep(int(pingSleep))
235 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700236 main.log.error("Ping test failed")
237 i = 17
238 result = main.FALSE
239 elif ping == main.TRUE:
240 i = i + 1
241 result = main.TRUE
242 endTime = time.time()
243 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700244 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700245 else:
246 main.log.report("\tPING TEST FAIL")
247 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
248
249# **********************************************************************************************************************************************************************************************
250#This test case restores the controllers removed by Case 4 then performs a ping test.
251
252 def CASE5(self,main) :
253 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
254 import time
255 for i in range(25):
256 if i < 15:
257 j=i+1
admin530b4c92013-08-14 16:54:35 -0700258 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 -0700259 else:
260 j=i+16
admin530b4c92013-08-14 16:54:35 -0700261 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 -0700262
263 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700264 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800265 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700266 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700267 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700268 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
269 else:
270 break
271
admin68453302013-12-16 15:40:04 -0800272 pingAttempts = main.params['pingAttempts']
273 pingSleep = main.params['pingSleep']
274
adminbae64d82013-08-01 10:50:15 -0700275 count = 1
276 i = 6
277 while i < 16 :
278 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
279 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800280 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700281 count = count + 1
282 i = 6
admin68453302013-12-16 15:40:04 -0800283 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
284 time.sleep(int(pingSleep))
285 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700286 main.log.error("Ping test failed")
287 i = 17
288 result = main.FALSE
289 elif ping == main.TRUE:
290 i = i + 1
291 result = main.TRUE
292 endTime = time.time()
293 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700294 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700295 else:
296 main.log.report("\tPING TEST FAILED")
297 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
298
299# **********************************************************************************************************************************************************************************************
300#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
301
302 def CASE6(self,main) :
admine0ae8202013-08-28 11:51:43 -0700303 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 -0700304 import time
305 main.case("Bringing Link down... ")
306 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
adminbae64d82013-08-01 10:50:15 -0700307 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admine0ae8202013-08-28 11:51:43 -0700308
admin4a58db92013-09-30 12:04:54 -0700309 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700310 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 -0800311 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700312 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700313 time.sleep(3)
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))
315 else:
316 break
317
admin68453302013-12-16 15:40:04 -0800318 pingAttempts = main.params['pingAttempts']
319 pingSleep = main.params['pingSleep']
320
adminbae64d82013-08-01 10:50:15 -0700321 count = 1
322 i = 6
323 while i < 16 :
324 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
325 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800326 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700327 count = count + 1
admin68453302013-12-16 15:40:04 -0800328 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
adminbae64d82013-08-01 10:50:15 -0700329 i = 6
admin68453302013-12-16 15:40:04 -0800330 time.sleep(int(pingSleep))
331 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700332 main.log.error("Ping test failed")
333 i = 17
334 result = main.FALSE
335 elif ping == main.TRUE:
336 i = i + 1
337 result = main.TRUE
338 endTime = time.time()
339 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700340 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700341 else:
342 main.log.report("\tPING TEST FAILED")
343 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
344
345# **********************************************************************************************************************************************************************************************
346#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
347
348 def CASE7(self,main) :
admine0ae8202013-08-28 11:51:43 -0700349 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 -0700350 import time
admin530b4c92013-08-14 16:54:35 -0700351 main.case("Bringing Link up... ")
352 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
admin530b4c92013-08-14 16:54:35 -0700353 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admin4a58db92013-09-30 12:04:54 -0700354
355 strtTime = time.time()
admin530b4c92013-08-14 16:54:35 -0700356 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin68453302013-12-16 15:40:04 -0800357 for counter in range(9):
admin530b4c92013-08-14 16:54:35 -0700358 if result == main.FALSE:
admin4a58db92013-09-30 12:04:54 -0700359 time.sleep(3)
admin530b4c92013-08-14 16:54:35 -0700360 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
361 else:
362 break
363
admin68453302013-12-16 15:40:04 -0800364 pingAttempts = main.params['pingAttempts']
365 pingSleep = main.params['pingSleep']
366
adminbae64d82013-08-01 10:50:15 -0700367 strtTime = time.time()
368 count = 1
369 i = 6
370 while i < 16 :
371 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
372 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin68453302013-12-16 15:40:04 -0800373 if ping == main.FALSE and count < int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700374 count = count + 1
admin68453302013-12-16 15:40:04 -0800375 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
adminbae64d82013-08-01 10:50:15 -0700376 i = 6
admin68453302013-12-16 15:40:04 -0800377 time.sleep(int(pingSleep))
378 elif ping == main.FALSE and count == int(pingAttempts):
adminbae64d82013-08-01 10:50:15 -0700379 main.log.error("Ping test failed")
380 i = 17
381 result = main.FALSE
382 elif ping == main.TRUE:
383 i = i + 1
384 result = main.TRUE
385 endTime = time.time()
386 if result == main.TRUE:
admin4a58db92013-09-30 12:04:54 -0700387 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
adminbae64d82013-08-01 10:50:15 -0700388 else:
389 main.log.report("\tPING TESTS FAILED")
390 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
391
admin530b4c92013-08-14 16:54:35 -0700392
393# ******************************************************************************************************************************************************************
394# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
395
396 def CASE21(self,main) :
397 import json
398 from drivers.common.api.onosrestapidriver import *
399 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
400 main.log.report("Check initially hostMAC exist on the mininet...")
401 host = main.params['YANK']['hostname']
402 mac = main.params['YANK']['hostmac']
403 RestIP1 = main.params['RESTCALL']['restIP1']
404 RestIP2 = main.params['RESTCALL']['restIP2']
405 RestPort = main.params['RESTCALL']['restPort']
406 url = main.params['RESTCALL']['restURL']
407 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
408
409 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" )
410 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
411 restcall = OnosRestApiDriver()
412 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
413 try:
414 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700415 ip_found = Hoststatus[0]['ipv4'][0]
416 except:
admin530b4c92013-08-14 16:54:35 -0700417 Reststatus = 0
admin4a58db92013-09-30 12:04:54 -0700418
admin530b4c92013-08-14 16:54:35 -0700419 if Reststatus == 1:
420 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
admin4a58db92013-09-30 12:04:54 -0700421 if ip_found != None:
422 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
423 result = main.TRUE
424 else:
425 main.log.report("\t Found host attached to switch, but no IP address discovered.")
426 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700427 else:
428 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
429 result = main.FALSE
430
431 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
432
433 main.log.report("Yank out s1-eth1")
434 main.case("Yankout s6-eth1 (link to h1) from s1")
435 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
436 time.sleep(3)
437 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
438 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
439 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
440 try:
441 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700442 except:
admin530b4c92013-08-14 16:54:35 -0700443 Reststatus = 0
444 if Reststatus == 0:
445 main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully")
446 result = main.TRUE
447 else:
448 main.log.report("Attempt to yank out s1-eht1 from s1 failed.")
449 result = main.FALSE
450
451 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
452 main.log.report("Plug s1-eth1 into s6")
453 main.case("Plug s1-eth1 to s6")
454 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
455 time.sleep(3)
456 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
457 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
458 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
459 try:
460 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700461 ip_found = Hoststatus[0]['ipv4'][0]
462 except:
admin530b4c92013-08-14 16:54:35 -0700463 Reststatus = 0
464 if Reststatus == 0:
465 main.log.report("Attempt to plug s1-eth1 to s6 FAILED")
466 result = main.FALSE
467 elif attachedSW == "00:00:00:00:00:00:00:06":
468 main.log.report("Attempt to plug s1-eht1 to s6 succeded.")
admin4a58db92013-09-30 12:04:54 -0700469 if ip_found != None:
470 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
471 result = main.TRUE
472 else:
473 main.log.report("\t Found host attached to switch, but no IP address discovered.")
474 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700475 else:
476 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
477 result = main.FALSE
478
479 ###### Step to put interface "s1-eth1" back to s1"#####
480 main.log.report("Move s1-eth1 back on to s1")
481 main.case("Move s1-eth1 back to s1")
482 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
483 time.sleep(3)
484 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
485 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
486 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
487 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
488 try:
489 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
admin4a58db92013-09-30 12:04:54 -0700490 ip_found = Hoststatus[0]['ipv4'][0]
491 except:
admin530b4c92013-08-14 16:54:35 -0700492 Reststatus = 0
493 if Reststatus == 0:
494 main.log.report("Attempt to plug s1-eth1 back to s1 FAILED")
495 result = main.FALSE
496 elif attachedSW == "00:00:00:00:00:00:00:01":
497 main.log.report("Attempt to plug s1-eht1 back to s1 succeded.")
admin4a58db92013-09-30 12:04:54 -0700498 if ip_found != None:
499 main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).")
500 result = main.TRUE
501 else:
502 main.log.report("\t Found host attached to switch, but no IP address discovered.")
503 result = main.FALSE
admin530b4c92013-08-14 16:54:35 -0700504 else:
505 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
506 result = main.FALSE
507
508 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
509
510
admin4a58db92013-09-30 12:04:54 -0700511
512