blob: 01c1169eb5e138a7b9079e66362b3e8b7eb09c34 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
admin530b4c92013-08-14 16:54:35 -07002class OnosDD_PARP :
adminbae64d82013-08-01 10:50:15 -07003
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
11 import time
12 main.log.report("Pulling latest code from github to all nodes")
13 main.ONOS1.git_pull()
14 main.ONOS2.git_pull()
15 main.ONOS3.git_pull()
16 main.ONOS4.git_pull()
17 main.ONOS1.drop_keyspace()
18 main.ONOS1.start()
19 time.sleep(10)
20 main.ONOS2.start()
21 main.ONOS3.start()
22 main.ONOS4.start()
23 main.ONOS1.start_rest()
24 main.ONOS1.get_version()
25 main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections")
26 main.case("Checking if the startup was clean...")
27 main.step("Testing startup Zookeeper")
28 data = main.Zookeeper1.isup()
29 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
30 main.step("Testing startup Cassandra")
31 data = main.Cassandra1.isup()
32 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
33 main.step("Testing startup ONOS")
34 data = main.ONOS1.isup()
35 if data == main.FALSE:
36 main.log.report("Something is funny... restarting ONOS")
37 main.ONOS1.stop()
38 time.sleep(3)
39 main.ONOS1.start()
40 time.sleep(5)
41 data = main.ONOS1.isup()
42 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
43
44#**********************************************************************************************************************************************************************************************
45#Assign Controllers
46#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>).
47#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
48#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
49# the controllers already assigned to the switch are not specified.
50
51 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
52 import time
53 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
54 main.case("Checking if one MN host exists")
55 main.step("Host IP Checking using checkIP")
56 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
57 main.step("Verifying the result")
58 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
59 main.step("assigning ONOS controllers to switches")
60 for i in range(25):
61 if i < 3:
62 j=i+1
admin530b4c92013-08-14 16:54:35 -070063 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -070064 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070065 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 -070066 time.sleep(1)
67 elif i >= 3 and i < 5:
68 j=i+1
admin530b4c92013-08-14 16:54:35 -070069 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
adminbae64d82013-08-01 10:50:15 -070070 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070071 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 -070072 time.sleep(1)
73 elif i >= 5 and i < 15:
74 j=i+1
admin530b4c92013-08-14 16:54:35 -070075 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
adminbae64d82013-08-01 10:50:15 -070076 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070077 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 -070078 time.sleep(1)
79 else:
80 j=i+16
admin530b4c92013-08-14 16:54:35 -070081 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminbae64d82013-08-01 10:50:15 -070082 time.sleep(1)
admin530b4c92013-08-14 16:54:35 -070083 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 -070084 time.sleep(1)
85 main.Mininet1.get_sw_controller("s1")
86
87# **********************************************************************************************************************************************************************************************
88#Add Flows
89#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
90#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
91
92 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
93 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
94 import time
95 main.case("Taking care of these flows!")
96 main.step("Cleaning out any leftover flows...")
97 main.ONOS1.delete_flow("all")
98 time.sleep(5)
99 strtTime = time.time()
100 main.ONOS1.add_flow(main.params['FLOWDEF'])
101 main.case("Checking flows")
102 tmp = main.FALSE
103 count = 1
104 main.log.info("Wait for flows to settle, then check")
105 while tmp == main.FALSE:
106 main.step("Waiting")
107 time.sleep(10)
108 main.step("Checking")
109 tmp = main.ONOS1.check_flow()
110 if tmp == main.FALSE and count < 6:
111 count = count + 1
112 main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count))
113 elif tmp == main.FALSE and count == 6:
114 result = main.FALSE
115 break
116 else:
117 result = main.TRUE
118 break
119 endTime = time.time()
120 if result == main.TRUE:
121 main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
122 else:
123 main.log.report("\tFlows failed check")
124 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
125
126#**********************************************************************************************************************************************************************************************
127#This test case removes Controllers 2,3, and 4 then performs a ping test.
128#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
129#The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 10 seconds before trying again.
130#If the ping test fails 6 times, then the test case will return false
131
132 def CASE4(self,main) :
133 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 3 attempts")
134 import time
135 for i in range(25):
136 if i < 15:
137 j=i+1
admin530b4c92013-08-14 16:54:35 -0700138 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 -0700139 time.sleep(1)
140 else:
141 j=i+16
admin530b4c92013-08-14 16:54:35 -0700142 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
adminbae64d82013-08-01 10:50:15 -0700143 time.sleep(1)
144 strtTime = time.time()
145 count = 1
146 i = 6
147 while i < 16 :
148 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
149 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
150 if ping == main.FALSE and count < 3:
151 count = count + 1
152 i = 6
153 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
154 time.sleep(10)
155 elif ping == main.FALSE and count ==3:
156 main.log.error("Ping test failed")
157 i = 17
158 result = main.FALSE
159 elif ping == main.TRUE:
160 i = i + 1
161 result = main.TRUE
162 endTime = time.time()
163 if result == main.TRUE:
164 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
165 else:
166 main.log.report("\tPING TEST FAIL")
167 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
168
169# **********************************************************************************************************************************************************************************************
170#This test case restores the controllers removed by Case 4 then performs a ping test.
171
172 def CASE5(self,main) :
173 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 3 attempts")
174 import time
175 for i in range(25):
176 if i < 15:
177 j=i+1
admin530b4c92013-08-14 16:54:35 -0700178 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 -0700179 time.sleep(1)
180 else:
181 j=i+16
admin530b4c92013-08-14 16:54:35 -0700182 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 -0700183 time.sleep(1)
184 strtTime = time.time()
185 count = 1
186 i = 6
187 while i < 16 :
188 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
189 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
190 if ping == main.FALSE and count < 3:
191 count = count + 1
192 i = 6
193 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
194 time.sleep(10)
195 elif ping == main.FALSE and count ==3:
196 main.log.error("Ping test failed")
197 i = 17
198 result = main.FALSE
199 elif ping == main.TRUE:
200 i = i + 1
201 result = main.TRUE
202 endTime = time.time()
203 if result == main.TRUE:
204 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
205 else:
206 main.log.report("\tPING TEST FAILED")
207 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
208
209# **********************************************************************************************************************************************************************************************
210#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
211
212 def CASE6(self,main) :
213 main.log.report("Bring Link between s1 and s2 down, wait 20 seconds, then ping until all hosts are reachable or fail after 3 attempts")
214 import time
215 main.case("Bringing Link down... ")
216 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
217 time.sleep(20)
218 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
219 strtTime = time.time()
220 count = 1
221 i = 6
222 while i < 16 :
223 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
224 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
225 if ping == main.FALSE and count < 3:
226 count = count + 1
227 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
228 i = 6
229 time.sleep(10)
230 elif ping == main.FALSE and count ==3:
231 main.log.error("Ping test failed")
232 i = 17
233 result = main.FALSE
234 elif ping == main.TRUE:
235 i = i + 1
236 result = main.TRUE
237 endTime = time.time()
238 if result == main.TRUE:
239 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
240 else:
241 main.log.report("\tPING TEST FAILED")
242 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
243
244# **********************************************************************************************************************************************************************************************
245#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
246
247 def CASE7(self,main) :
248 main.log.report("Bring Link between s1 and s2 up, wait 20 seconds, then ping until all hosts are reachable or fail after 3 attempts")
249 import time
250 main.case("Bringing Link up... ")
251 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
252 time.sleep(20)
253 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
254 strtTime = time.time()
255 count = 1
256 i = 6
257 while i < 16 :
258 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
259 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
260 if ping == main.FALSE and count < 3:
261 count = count + 1
262 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
263 i = 6
264 time.sleep(10)
265 elif ping == main.FALSE and count ==3:
266 main.log.error("Ping test failed")
267 i = 17
268 result = main.FALSE
269 elif ping == main.TRUE:
270 i = i + 1
271 result = main.TRUE
272 endTime = time.time()
273 if result == main.TRUE:
274 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
275 else:
276 main.log.report("\tPING TESTS FAILED")
277 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
278
admin530b4c92013-08-14 16:54:35 -0700279
280
281# **********************************************************************************************************************************************************************************************
282# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
283
284 def CASE21(self,main) :
285 import json
286 from drivers.common.api.onosrestapidriver import *
287 main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.")
288 main.log.report("Check initially hostMAC exist on the mininet...")
289 host = main.params['YANK']['hostname']
290 mac = main.params['YANK']['hostmac']
291 RestIP1 = main.params['RESTCALL']['restIP1']
292 RestIP2 = main.params['RESTCALL']['restIP2']
293 RestPort = main.params['RESTCALL']['restPort']
294 url = main.params['RESTCALL']['restURL']
295 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
296
297 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" )
298 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
299 restcall = OnosRestApiDriver()
300 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
301 try:
302 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
303 except IndexError:
304 Reststatus = 0
305 if Reststatus == 1:
306 main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW)
307 result = main.TRUE
308 else:
309 main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
310 result = main.FALSE
311
312 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
313
314 main.log.report("Yank out s1-eth1")
315 main.case("Yankout s6-eth1 (link to h1) from s1")
316 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
317 time.sleep(3)
318 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
319 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
320 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
321 try:
322 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
323 except IndexError:
324 Reststatus = 0
325 if Reststatus == 0:
326 main.log.report("Attemp to yank out s1-eth1 from s1 sucessfully")
327 result = main.TRUE
328 else:
329 main.log.report("Attemp to yank out s1-eht1 from s1 failed.")
330 result = main.FALSE
331
332 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
333 main.log.report("Plug s1-eth1 into s6")
334 main.case("Plug s1-eth1 to s6")
335 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
336 time.sleep(3)
337 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
338 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
339 Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac)
340 try:
341 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
342 except IndexError:
343 Reststatus = 0
344 if Reststatus == 0:
345 main.log.report("Attemp to plug s1-eth1 to s6 FAILED")
346 result = main.FALSE
347 elif attachedSW == "00:00:00:00:00:00:00:06":
348 main.log.report("Attemp to plug s1-eht1 to s6 succeded.")
349 result = main.TRUE
350 else:
351 main.log.report( "FAILED to attach s1-eth1 to s6 correctly!")
352 result = main.FALSE
353
354 ###### Step to put interface "s1-eth1" back to s1"#####
355 main.log.report("Move s1-eth1 back on to s1")
356 main.case("Move s1-eth1 back to s1")
357 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
358 time.sleep(3)
359 retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
360 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
361 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
362 Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac)
363 try:
364 attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID']
365 except IndexError:
366 Reststatus = 0
367 if Reststatus == 0:
368 main.log.report("Attemp to plug s1-eth1 back to s1 FAILED")
369 result = main.FALSE
370 elif attachedSW == "00:00:00:00:00:00:00:01":
371 main.log.report("Attemp to plug s1-eht1 back to s1 succeded.")
372 result = main.TRUE
373 else:
374 main.log.report( "FAIL to attach s1-eth1 to s1 correctly!")
375 result = main.FALSE
376
377 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DIVICE DISCOVERY TEST FAILED")
378