blob: dcb03f351956a0b0d24dd3d5123355574dbb6a9d [file] [log] [blame]
admin844bcb52014-04-15 11:13:14 -07001
admin844bcb52014-04-15 11:13:14 -07002class JamesTest :
3
admin8a30f342014-06-24 15:54:26 -07004
5
admin844bcb52014-04-15 11:13:14 -07006 def __init__(self) :
7 self.default = ''
8
admin8a30f342014-06-24 15:54:26 -07009# def print_hello_world(self,main):
10# print("hello world")
11#*****************************************************************************************************************************************************************************************
12#Test startup
13#Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully
14 def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
15 main.case("Initial setup")
16 main.step("Stop ONOS")
17 import time
18 main.ONOS1.stop_all()
19 main.ONOS2.stop_all()
20 main.ONOS3.stop_all()
21# main.print_hello_world()
22 main.ONOS4.stop_all()
23 main.ONOS2.stop_rest()
24 main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
25 main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
26 main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
27 main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
28 main.step("Start tcpdump on mn")
29# main.Mininet2.start_tcpdump(main.params['tcpdump']['filename'], intf = main.params['tcpdump']['intf'], port = main.params['tcpdump']['port'])
30 main.step("Start ONOS")
31 main.Zookeeper1.start()
32 main.Zookeeper2.start()
33 main.Zookeeper3.start()
34 main.Zookeeper4.start()
35 time.sleep(1)
36 main.RamCloud1.del_db()
37 main.RamCloud2.del_db()
38 main.RamCloud3.del_db()
39 main.RamCloud4.del_db()
40 main.log.report("Pulling latest code from github to all nodes")
admin844bcb52014-04-15 11:13:14 -070041 for i in range(2):
admin844bcb52014-04-15 11:13:14 -070042 uptodate = main.ONOS1.git_pull()
admin844bcb52014-04-15 11:13:14 -070043 main.ONOS2.git_pull()
admin844bcb52014-04-15 11:13:14 -070044 main.ONOS3.git_pull()
admin844bcb52014-04-15 11:13:14 -070045 main.ONOS4.git_pull()
admin8a30f342014-06-24 15:54:26 -070046 ver1 = main.ONOS1.get_version()
admin844bcb52014-04-15 11:13:14 -070047 ver2 = main.ONOS4.get_version()
48 if ver1==ver2:
49 break
50 elif i==1:
admin844bcb52014-04-15 11:13:14 -070051 main.ONOS2.git_pull("ONOS1 master")
52 main.ONOS3.git_pull("ONOS1 master")
53 main.ONOS4.git_pull("ONOS1 master")
54 if uptodate==0:
admin8a30f342014-06-24 15:54:26 -070055 # if 1:
56 main.ONOS1.git_compile()
57 main.ONOS2.git_compile()
58 main.ONOS3.git_compile()
59 main.ONOS4.git_compile()
60 main.ONOS1.print_version()
61 main.ONOS1.start_all()
62 main.ONOS2.start_all()
63 main.ONOS3.start_all()
64 main.ONOS4.start_all()
65 main.ONOS2.start_rest()
66 test= main.ONOS2.rest_status()
67 if test == main.FALSE:
68 main.ONOS1.start_rest()
69 main.ONOS1.get_version()
70 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
71 main.step("Testing startup Zookeeper")
72 data = main.Zookeeper1.isup()
73 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
74 main.step("Testing startup RamCloud")
75 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
76 if data == main.FALSE:
77 main.RamCloud1.stop_coor()
78 main.RamCloud1.stop_serv()
79 main.RamCloud2.stop_serv()
80 main.RamCloud3.stop_serv()
81 main.RamCloud4.stop_serv()
admin844bcb52014-04-15 11:13:14 -070082
admin8a30f342014-06-24 15:54:26 -070083 time.sleep(5)
84 main.RamCloud1.start_coor()
85 main.RamCloud1.start_serv()
86 main.RamCloud2.start_serv()
87 main.RamCloud3.start_serv()
88 main.RamCloud4.start_serv()
89 time.sleep(5)
90 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
91
admin844bcb52014-04-15 11:13:14 -070092
admin8a30f342014-06-24 15:54:26 -070093 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
94 main.step("Testing startup ONOS")
95 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
admin844bcb52014-04-15 11:13:14 -070096 for i in range(3):
admin8a30f342014-06-24 15:54:26 -070097 if data == main.FALSE:
98 #main.log.report("Something is funny... restarting ONOS")
99 #main.ONOS1.stop()
100 time.sleep(3)
101 #main.ONOS1.start()
102 #time.sleep(5)
103 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
admin844bcb52014-04-15 11:13:14 -0700104 else:
105 break
admin8a30f342014-06-24 15:54:26 -0700106 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
107 time.sleep(20)
108
109#**********************************************************************************************************************************************************************************************
110#Assign Controllers
111#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>).
112#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
113#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
114# the controllers already assigned to the switch are not specified.
admin844bcb52014-04-15 11:13:14 -0700115
admin8a30f342014-06-24 15:54:26 -0700116 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
admin844bcb52014-04-15 11:13:14 -0700117 import time
admin8a30f342014-06-24 15:54:26 -0700118 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
119 main.case("Checking if one MN host exists")
120 main.step("Host IP Checking using checkIP")
121 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
122 main.step("Verifying the result")
123 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
124 main.step("assigning ONOS controllers to switches")
125 for i in range(25):
admin844bcb52014-04-15 11:13:14 -0700126 if i < 3:
admin8a30f342014-06-24 15:54:26 -0700127 j=i+1
128 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
admin844bcb52014-04-15 11:13:14 -0700129 time.sleep(1)
admin8a30f342014-06-24 15:54:26 -0700130 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'])
131 elif i >= 3 and i < 5:
132 j=i+1
133 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
admin844bcb52014-04-15 11:13:14 -0700134 time.sleep(1)
admin8a30f342014-06-24 15:54:26 -0700135 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'])
136 elif i >= 5 and i < 15:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
admin844bcb52014-04-15 11:13:14 -0700139 time.sleep(1)
admin8a30f342014-06-24 15:54:26 -0700140 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'])
admin844bcb52014-04-15 11:13:14 -0700141 else:
admin8a30f342014-06-24 15:54:26 -0700142 j=i+16
143 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
admin844bcb52014-04-15 11:13:14 -0700144 time.sleep(2)
admin8a30f342014-06-24 15:54:26 -0700145 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'])
146 main.Mininet1.get_sw_controller("s1")
147 time.sleep(10)
148
149# **********************************************************************************************************************************************************************************************
150#Add Flows
151#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
152#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
admin844bcb52014-04-15 11:13:14 -0700153
admin8a30f342014-06-24 15:54:26 -0700154 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
155 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
admin844bcb52014-04-15 11:13:14 -0700156 import time
admin089a0782014-07-22 15:48:19 -0700157 from subprocess import Popen, PIPE
admin8a30f342014-06-24 15:54:26 -0700158 main.case("Taking care of these flows!")
159 main.step("Cleaning out any leftover flows...")
admin089a0782014-07-22 15:48:19 -0700160 masterSwitches = []
161 masterSwitches2 = []
admin98ad0092014-07-23 16:51:07 -0700162 hello = main.Mininet2.checkForLoss(fileName='/tmp/ping.h10')
163 if hello==main.FALSE:
164 main.log.info("CRAP")
165 else:
166 main.log.info("YAY")
admin089a0782014-07-22 15:48:19 -0700167 for i in range(25):
168 if i < 15:
169 j=i+1
170 else:
171 j=i+16
172 (stdout, stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/registry/switches/json"],stdout=PIPE).communicate()
173 switchDPID1 = main.Mininet1.getSwitchDPID(switch="s"+str(j))
174 sDPID1 = str(switchDPID1)
175 switchDPID2 = sDPID1[:2]+":"+sDPID1[2:4]+":"+sDPID1[4:6]+":"+sDPID1[6:8]+":"+sDPID1[8:10]+":"+sDPID1[10:12]+":"+sDPID1[12:14]+":"+sDPID1[14:]
176 master=main.Zookeeper1.findMaster(switchDPID = switchDPID2, switchList=stdout)
177 masterSwitches.append("s"+str(j)+" " + master)
178
179 for i in range(25):
180 if i < 15:
181 j=i+1
182 else:
183 j=i+16
184 print j
185 (stdout, stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/registry/switches/json"],stdout=PIPE).communicate()
186 switchDPID1 = main.Mininet1.getSwitchDPID(switch="s"+str(j))
187 sDPID1 = str(switchDPID1)
188 switchDPID2 = sDPID1[:2]+":"+sDPID1[2:4]+":"+sDPID1[4:6]+":"+sDPID1[6:8]+":"+sDPID1[8:10]+":"+sDPID1[10:12]+":"+sDPID1[12:14]+":"+sDPID1[14:]
189 master=main.Zookeeper1.findMaster(switchDPID = switchDPID2, switchList=stdout)
190 masterSwitches2.append("s"+str(j)+" " + master)
191
192
193
194
195 print masterSwitches
196 print "\n\n\n"
197 print masterSwitches2
198 print masterSwitches == masterSwitches2
admin8a30f342014-06-24 15:54:26 -0700199 #main.ONOS1.delete_flow("all")
admin844bcb52014-04-15 11:13:14 -0700200 strtTime = time.time()
admin8a30f342014-06-24 15:54:26 -0700201 main.ONOS1.rm_intents()
admin089a0782014-07-22 15:48:19 -0700202 (stdout,stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/intent/high"],stdout=PIPE).communicate()
203 intent1 = stdout
204 print intent1 + "\n\n\n Intent 1 \n\n\n"
admin8a30f342014-06-24 15:54:26 -0700205 main.ONOS1.add_intents()
206 time.sleep(2)
admin089a0782014-07-22 15:48:19 -0700207 (stdout,stderr) = Popen(["curl",main.params['RESTCALL']['restIP1']+":"+main.params['RESTCALL']['restPort']+"/wm/onos/intent/high"],stdout=PIPE).communicate()
208 intent2 = stdout
209 print intent2 + "\n\n\n Intent 2 \n\n\n"
210 changesMade = main.ONOS1.comp_intents(preIntents=intent1,postIntents=intent2)
211 print changesMade
212 if not changesMade:
213 print "Intents were Constant"
214 print changesMade
admin8a30f342014-06-24 15:54:26 -0700215 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
216 main.case("Checking flows")
admin844bcb52014-04-15 11:13:14 -0700217
admin844bcb52014-04-15 11:13:14 -0700218 count = 1
219 i = 6
admin8a30f342014-06-24 15:54:26 -0700220 while i < 16 :
221 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
admin844bcb52014-04-15 11:13:14 -0700222 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
223 if ping == main.FALSE and count < 9:
admin8a30f342014-06-24 15:54:26 -0700224 count = count + 1
admin844bcb52014-04-15 11:13:14 -0700225 i = 6
admin8a30f342014-06-24 15:54:26 -0700226 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
admin844bcb52014-04-15 11:13:14 -0700227 time.sleep(2)
admin8a30f342014-06-24 15:54:26 -0700228 elif ping == main.FALSE and count ==9:
admin844bcb52014-04-15 11:13:14 -0700229 main.log.error("Ping test failed")
230 i = 17
231 result = main.FALSE
232 elif ping == main.TRUE:
admin8a30f342014-06-24 15:54:26 -0700233 i = i + 1
admin844bcb52014-04-15 11:13:14 -0700234 result = main.TRUE
235 endTime = time.time()
236 if result == main.TRUE:
admin8a30f342014-06-24 15:54:26 -0700237 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
admin844bcb52014-04-15 11:13:14 -0700238 else:
239 main.log.report("\tFlows failed check")
admin8a30f342014-06-24 15:54:26 -0700240
admin844bcb52014-04-15 11:13:14 -0700241 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
admin8a30f342014-06-24 15:54:26 -0700242 main.step("Verifying the result")
243 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
244
admin98ad0092014-07-23 16:51:07 -0700245
246 main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=5)
247 main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=5)
248 main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=5)
249 main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=5)
250 main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=5)
251 main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=5)
252 main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=5)
253 main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=5)
254 main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=5)
255 main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=5)
256 main.step("Check that the pings are going")
257 result = main.Mininet2.pingstatus(src=main.params['PING']['source1'])
258 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source2'])
259 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source3'])
260 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source4'])
261 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source5'])
262 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source6'])
263 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source7'])
264 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source8'])
265 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source9'])
266 result = result & main.Mininet2.pingstatus(src=main.params['PING']['source10'])
267 time.sleep(20)
268 main.Mininet2.pingKill()
269 if main.Mininet2.checkForLoss(fileName="/tmp/ping.h10"):
270 main.log.info("LOSS FOUND!!!")
271 else:
272 main.log.info("No Loss of Packets!!!")
273
274
275
276
admin8a30f342014-06-24 15:54:26 -0700277#**********************************************************************************************************************************************************************************************
278#This test case removes Controllers 2,3, and 4 then performs a ping test.
279#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
280#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.
281#If the ping test fails 6 times, then the test case will return false
282 def CASE41(self,main) :
283 main.log.report("Testing Removal")
284 time.sleep(10)
285 main.ONOS2.stop()
286 time.sleep(10)
287 main.ONOS3.stop()
288 time.sleep(10)
289 main.ONOS4.stop()
290 time.sleep(15)
291 strtTime = time.time()
292 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
293 for i in range(10):
294 if result == main.FALSE:
295 time.sleep(5)
296 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
297 else:
298 break
299
300 count = 1
301 i = 6
302 while i < 16 :
303 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
304 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
305 if ping == main.FALSE and count < 6:
306 count = count + 1
307 i = 6
308 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
309 time.sleep(2)
310 elif ping == main.FALSE and count ==6:
311 main.log.error("Ping test failed")
312 i = 17
313 result = main.FALSE
314 elif ping == main.TRUE:
315 i = i + 1
316 result = main.TRUE
317 endTime = time.time()
318 if result == main.TRUE:
319 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
320 else:
321 main.log.report("\tPING TEST FAIL")
322 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
323 time.sleep(10)
324 main.ONOS2.start()
325 main.ONOS3.start()
326 main.ONOS4.start()
327 time.sleep(20)
admin844bcb52014-04-15 11:13:14 -0700328
329
admin8a30f342014-06-24 15:54:26 -0700330 def CASE4(self,main) :
331 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
332 import time
333 for i in range(25):
334 if i < 15:
335 j=i+1
336 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
337 else:
338 j=i+16
339 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
340
341 strtTime = time.time()
342 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
343 for i in range(10):
344 if result == main.FALSE:
345 time.sleep(5)
346 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
347 else:
348 break
admin844bcb52014-04-15 11:13:14 -0700349
admin8a30f342014-06-24 15:54:26 -0700350 count = 1
351 i = 6
352 while i < 16 :
353 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
354 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
355 if ping == main.FALSE and count < 6:
356 count = count + 1
357 i = 6
358 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
359 time.sleep(2)
360 elif ping == main.FALSE and count ==6:
361 main.log.error("Ping test failed")
362 i = 17
363 result = main.FALSE
364 elif ping == main.TRUE:
365 i = i + 1
366 result = main.TRUE
367 endTime = time.time()
368 if result == main.TRUE:
369 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
370 else:
371 main.log.report("\tPING TEST FAIL")
372 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
373 time.sleep(10)
374
375# **********************************************************************************************************************************************************************************************
376#This test case restores the controllers removed by Case 4 then performs a ping test.
377
378 def CASE5(self,main) :
379 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
380 import time
381 for i in range(25):
382 if i < 3:
383 j=i+1
384 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
385 time.sleep(1)
386 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'])
387 elif i >= 3 and i < 5:
388 j=i+1
389 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
390 time.sleep(1)
391 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'])
392 elif i >= 5 and i < 15:
393 j=i+1
394 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
395 time.sleep(1)
396 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'])
397 else:
398 j=i+16
399 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
400 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'])
401 time.sleep(1)
402 strtTime = time.time()
403 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
404 for i in range(10):
405 if result == main.FALSE:
406 time.sleep(5)
407 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
408 else:
409 break
410
411 count = 1
412 i = 6
413 while i < 16 :
414 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
415 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
416 if ping == main.FALSE and count < 6:
417 count = count + 1
418 i = 6
419 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
420 time.sleep(2)
421 elif ping == main.FALSE and count ==6:
422 main.log.error("Ping test failed")
423 i = 17
424 result = main.FALSE
425 elif ping == main.TRUE:
426 i = i + 1
427 result = main.TRUE
428 endTime = time.time()
429 if result == main.TRUE:
430 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
431 else:
432 main.log.report("\tPING TEST FAILED")
433 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
434
435# **********************************************************************************************************************************************************************************************
436#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
437
438 def CASE6(self,main) :
439 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
440 import time
441 main.case("Bringing Link down... ")
442 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
443 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
444 time.sleep(10)
445 strtTime = time.time()
446 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
447 for i in range(10):
448 if result == main.FALSE:
449 time.sleep(5)
450 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
451 else:
452 break
453
454 count = 1
455 i = 6
456 while i < 16 :
457 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
458 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
459 if ping == main.FALSE and count < 10:
460 count = count + 1
461 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
462 i = 6
463 time.sleep(2)
464 elif ping == main.FALSE and count == 10:
465 main.log.error("Ping test failed")
466 i = 17
467 result = main.FALSE
468 elif ping == main.TRUE:
469 i = i + 1
470 result = main.TRUE
471 endTime = time.time()
472 if result == main.TRUE:
473 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
474 else:
475 main.log.report("\tPING TEST FAILED")
476 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
477
478# **********************************************************************************************************************************************************************************************
479#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
480
481 def CASE7(self,main) :
482 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
483 import time
484 main.case("Bringing Link up... ")
485 result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down")
486 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
487 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
488 time.sleep(10)
489 strtTime = time.time()
490 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
491 for i in range(10):
492 if result == main.FALSE:
493 time.sleep(15)
494 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
495 else:
496 break
497
498 strtTime = time.time()
499 count = 1
500 i = 6
501 while i < 16 :
502 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
503 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
504 if ping == main.FALSE and count < 10:
505 count = count + 1
506 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
507 i = 6
508 time.sleep(2)
509 elif ping == main.FALSE and count ==10:
510 main.log.error("Ping test failed")
511 i = 17
512 result = main.FALSE
513 elif ping == main.TRUE:
514 i = i + 1
515 result = main.TRUE
516 endTime = time.time()
517 if result == main.TRUE:
518 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
519 else:
520 main.log.report("\tPING TESTS FAILED")
521 data = main.Mininet1.link(END1='s1',END2='s3',OPTION="up")
522 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
523
524
525# ******************************************************************************************************************************************************************
526# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
527
528 def CASE21(self,main) :
admin844bcb52014-04-15 11:13:14 -0700529 import json
admin8a30f342014-06-24 15:54:26 -0700530 main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
531 main.log.report("Check initially hostMAC/IP exist on the mininet...")
admin844bcb52014-04-15 11:13:14 -0700532 host = main.params['YANK']['hostname']
533 mac = main.params['YANK']['hostmac']
admin844bcb52014-04-15 11:13:14 -0700534 RestIP1 = main.params['RESTCALL']['restIP1']
535 RestPort = main.params['RESTCALL']['restPort']
536 url = main.params['RESTCALL']['restURL']
admin8a30f342014-06-24 15:54:26 -0700537
538 t_topowait = 5
539 t_restwait = 5
540 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
541 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
542 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
543 time.sleep(t_topowait)
544 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" )
admin844bcb52014-04-15 11:13:14 -0700545 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
546 time.sleep(t_restwait)
admin8a30f342014-06-24 15:54:26 -0700547 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
548 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
549 if Reststatus == 1:
550 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
admin844bcb52014-04-15 11:13:14 -0700551 result1 = main.TRUE
admin8a30f342014-06-24 15:54:26 -0700552 elif Reststatus > 1:
553 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
admin844bcb52014-04-15 11:13:14 -0700554 main.log.report("switches are: " + "; ".join(Switch))
555 main.log.report("Ports are: " + "; ".join(Port))
admin844bcb52014-04-15 11:13:14 -0700556 result1 = main.FALSE
admin8a30f342014-06-24 15:54:26 -0700557 elif Reststatus == 0 and Switch == []:
558 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
559 result1 = main.FALSE
560 else:# check if rest server is working
561 main.log.error("Issue with find host")
admin844bcb52014-04-15 11:13:14 -0700562 result1 = main.FALSE
563
admin844bcb52014-04-15 11:13:14 -0700564
admin8a30f342014-06-24 15:54:26 -0700565 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
566
567 main.log.report("Yank out s1-eth1")
568 main.case("Yankout s6-eth1 (link to h1) from s1")
admin844bcb52014-04-15 11:13:14 -0700569 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
570 time.sleep(t_topowait)
571 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
admin8a30f342014-06-24 15:54:26 -0700572
573 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" )
admin844bcb52014-04-15 11:13:14 -0700574 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
575 time.sleep(t_restwait)
admin8a30f342014-06-24 15:54:26 -0700576 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
577
578 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
579 if Reststatus == 1:
580 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
admin844bcb52014-04-15 11:13:14 -0700581 result2 = main.FALSE
admin8a30f342014-06-24 15:54:26 -0700582 elif Reststatus > 1:
admin844bcb52014-04-15 11:13:14 -0700583 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
admin844bcb52014-04-15 11:13:14 -0700584 main.log.report("switches are: " + "; ".join(Switch))
585 main.log.report("Ports are: " + "; ".join(Port))
586 main.log.report("MACs are: " + "; ".join(MAC))
admin8a30f342014-06-24 15:54:26 -0700587 result2 = main.FALSE
588 elif Reststatus == 0 and Switch == []:
589 main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
590 result2 = main.TRUE
591 else:# check if rest server is working
592 main.log.error("Issue with find host")
593 result2 = main.FALSE
594
595 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
596 main.log.report("Plug s1-eth1 into s6")
597 main.case("Plug s1-eth1 to s6")
598 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
admin844bcb52014-04-15 11:13:14 -0700599 time.sleep(t_topowait)
admin8a30f342014-06-24 15:54:26 -0700600 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
601 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" )
602
admin844bcb52014-04-15 11:13:14 -0700603 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
604 time.sleep(t_restwait)
admin8a30f342014-06-24 15:54:26 -0700605 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
606
607 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
608 if Reststatus == 1:
609 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
610 result3 = main.TRUE
611 elif Reststatus > 1:
612 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
613 main.log.report("switches are: " + "; ".join(Switch))
614 main.log.report("Ports are: " + "; ".join(Port))
615 main.log.report("MACs are: " + "; ".join(MAC))
616 result3 = main.FALSE
617 elif Reststatus == 0 and Switch == []:
618 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
619 result3 = main.FALSE
620 else:# check if rest server is working
621 main.log.error("Issue with find host")
622 result3 = main.FALSE
623
624 ###### Step to put interface "s1-eth1" back to s1"#####
625 main.log.report("Move s1-eth1 back on to s1")
626 main.case("Move s1-eth1 back to s1")
627 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
628 time.sleep(t_topowait)
629 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
630 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
631 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" )
632
633 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
634 time.sleep(t_restwait)
635 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin844bcb52014-04-15 11:13:14 -0700636
637 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
638 if Reststatus == 1:
admin8a30f342014-06-24 15:54:26 -0700639 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
640 result4 = main.TRUE
admin844bcb52014-04-15 11:13:14 -0700641 elif Reststatus > 1:
642 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
643 main.log.report("switches are: " + "; ".join(Switch))
644 main.log.report("Ports are: " + "; ".join(Port))
admin8a30f342014-06-24 15:54:26 -0700645 main.log.report("MACs are: " + "; ".join(MAC))
646 result4 = main.FALSE
647 elif Reststatus == 0 and Switch == []:
admin844bcb52014-04-15 11:13:14 -0700648 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
admin8a30f342014-06-24 15:54:26 -0700649 result4 = main.FALSE
650 else:# check if rest server is working
651 main.log.error("Issue with find host")
652 result4 = main.FALSE
653 time.sleep(20)
654 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
655 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
656 if Reststatus ==1:
657 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
658 elif Reststatus>1:
659 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
660 elif Reststatus==0:
661 main.log.report("\t PASSED - Device cleared after timeout")
admin844bcb52014-04-15 11:13:14 -0700662
admin8a30f342014-06-24 15:54:26 -0700663 result = result1 and result2 and result3 and result4
admin844bcb52014-04-15 11:13:14 -0700664 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
665
admin8a30f342014-06-24 15:54:26 -0700666# Run a pure ping test.
667
668 def CASE31(self, main):
669 main.log.report("Performing Ping Test")
admin844bcb52014-04-15 11:13:14 -0700670 count = 1
671 i = 6
admin8a30f342014-06-24 15:54:26 -0700672 while i < 16 :
673 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
674 strtTime = time.time()
admin844bcb52014-04-15 11:13:14 -0700675 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
admin8a30f342014-06-24 15:54:26 -0700676 if ping == main.FALSE and count < 6:
677 count = count + 1
admin844bcb52014-04-15 11:13:14 -0700678 i = 6
admin8a30f342014-06-24 15:54:26 -0700679 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
admin844bcb52014-04-15 11:13:14 -0700680 time.sleep(2)
admin8a30f342014-06-24 15:54:26 -0700681 elif ping == main.FALSE and count ==6:
admin844bcb52014-04-15 11:13:14 -0700682 main.log.error("Ping test failed")
683 i = 17
admin8a30f342014-06-24 15:54:26 -0700684 result = main.FALSE
685 elif ping == main.TRUE:
686 i = i + 1
687 result = main.TRUE
admin844bcb52014-04-15 11:13:14 -0700688 endTime = time.time()
admin8a30f342014-06-24 15:54:26 -0700689 if result == main.TRUE:
690 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
admin844bcb52014-04-15 11:13:14 -0700691 else:
admin8a30f342014-06-24 15:54:26 -0700692 main.log.report("\tPING TEST FAIL")
693 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
admin844bcb52014-04-15 11:13:14 -0700694
695
admin8a30f342014-06-24 15:54:26 -0700696 def CASE66(self, main):
697 main.log.report("Checking ONOS logs for exceptions")
698 count = 0
699 check1 = main.ONOS1.check_exceptions()
700 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
701 check2 = main.ONOS2.check_exceptions()
702 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
703 check3 = main.ONOS3.check_exceptions()
704 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
705 check4 = main.ONOS4.check_exceptions()
706 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
707 result = main.TRUE
708 if (check1 or check2 or check3 or check4):
709 result = main.FALSE
710 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
711 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
712 main.Mininet2.stop_tcpdump()
713
714
715 def CASE8(self,main) :
716 main.log.report("Testing Removal of Zookeeper")
717 main.Zookeeper2.stop()
718 main.Zookeeper3.stop()
719 main.Zookeeper4.stop()
720 strtTime = time.time()
721 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
722 for i in range(10):
723 if result == main.FALSE:
724 time.sleep(5)
725 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
726 else:
727 break
728
729 count = 1
730 i = 6
731 while i < 16 :
732 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
733 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
734 if ping == main.FALSE and count < 6:
735 count = count + 1
736 i = 6
737 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
738 time.sleep(2)
739 elif ping == main.FALSE and count ==6:
740 main.log.error("Ping test failed")
741 i = 17
742 result = main.FALSE
743 elif ping == main.TRUE:
744 i = i + 1
745 result = main.TRUE
746 endTime = time.time()
747 if result == main.TRUE:
748 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
749 else:
750 main.log.report("\tPING TEST FAIL")
751 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
752 time.sleep(10)
753 main.Zookeeper2.start()
754 main.Zookeeper3.start()
755 main.Zookeeper4.start()
756 time.sleep(10)
757
758
759 def CASE67(self, main) :
760 main.case("Flapping link s1-s2")
761 main.log.report("Toggling of link s1-s2 multiple times")
762 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
763 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
764 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
765 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
766 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
767 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
768 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
769 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
770 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
771 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
772 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
773 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
774 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
775 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
776 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
777 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
778 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
779 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
780 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
781 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
782 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
783 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
784 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
785 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
786 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
787 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
788 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
789 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
790 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
791 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
792 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
793 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
794 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
795 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
796 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
797 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
798 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
799 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
800 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
801 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
802 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
803 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
804 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
805 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
806 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
807 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
808 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
809 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
810 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
811 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
812 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
813 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
814 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
815 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
816 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
817 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
818 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
819 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
820 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
821 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
822 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
823 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
824 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
825
826 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
827 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
828 for i in range(10):
829 if result == main.FALSE:
830 time.sleep(15)
831 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
832 else:
833 break
834
835 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
836 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])))
837 for i in range(10):
838 if result == main.FALSE:
839 time.sleep(15)
840 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])))
841 else:
842 break
843 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
844 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
845 for i in range(10):
846 if result == main.FALSE:
847 time.sleep(15)
848 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
849 else:
850 break
851
admin803f05d2014-07-18 10:44:38 -0700852#*****************************************************************************************
853#*****************************************************************************************
854# CASE101:
855# This case is designed to test the intents framework
856# It will cover Installation, Deletion, Rerouting, and Calling of Intents
857#*****************************************************************************************
858#*****************************************************************************************
admin8a30f342014-06-24 15:54:26 -0700859
860
861 def CASE101(self,main) :
862 import time
863 import json
864 import re
865 main.case("Testing the Intent Framework of ONOS")
866
867#*****************************************************************************************
868#*****************************************************************************************
869# The first part of CASE 101 will be assigning the master controllers to the switches
870# and to check that each one is assigned correctly.
871#*****************************************************************************************
872#*****************************************************************************************
873 main.step("Assigning Master Controllers to the Switches and check")
874 for i in range(25):
875 if i<3:
876 j=i+1
877 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
878 elif i>=3 and i<5:
879 j=i+1
880 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1'])
881 elif i>=5 and i<15:
882 j=j+1
883 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1'])
884 else:
885 j=i+16
886 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1'])
887 result = main.TRUE
888 for i in range(25):
889 if i<3:
890 j=i+1
891 response=main.Mininet1.get_sw_controller("s"+str(j))
892 print("Response is " + str(response))
893 if re.search("tcp:"+main.params['CTRL']['ip1'],response) :
894 result = result and main.TRUE
895 else:
896 result = main.FALSE
897 elif i>=3 and i<5:
898 j=i+1
899 response=main.Mininet1.get_sw_controller("s"+str(j))
900 if re.search("tcp:"+main.params['CTRL']['ip2'],response) :
901 result = result and main.TRUE
902 else:
903 result = main.FALSE
904 elif i>=5 and i<15:
905 j=j+1
906 response=main.Mininet1.get_sw_controller("s"+str(j))
907 if re.search("tcp:"+main.params['CTRL']['ip3'],response) :
908 result = result and main.TRUE
909 else:
910 result = main.FALSE
911 else:
912 j=i+16
913 response=main.Mininet1.get_sw_controller("s"+str(j))
914 if re.search("tcp:"+main.params['CTRL']['ip4'],response) :
915 result = result and main.TRUE
916 else:
917 result = main.FALSE
918 print(result)
919 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Master Controllers assigned Properly",onfail="FAILED TO ASSIGN MASTER CONTROLLERS!")
920
921#*****************************************************************************************
922#*****************************************************************************************
923# Assign all controllers to the switches as backups. Run a get-controller on each
924# switch to ensure that all controllers have been assigned properly to its switches
925#*****************************************************************************************
926#*****************************************************************************************
927 main.step("Assigning all Controllers as Backups to Switches and Check")
928 for i in range(25):
929 if i<15:
930 j=i+1
931 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'])
932 else:
933 j=i+16
934 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'])
935 result = main.TRUE
936 time.sleep(5)
937 for i in range(25):
938 if i<15:
939 j=i+1
940 response=main.Mininet1.get_sw_controller("s"+str(j))
941 if re.search("tcp:"+main.params['CTRL']['ip1'],response) and re.search("tcp:"+main.params['CTRL']['ip2'],response) and re.search("tcp:"+main.params['CTRL']['ip3'],response) and re.search("tcp:"+main.params['CTRL']['ip4'],response):
942 result = result and main.TRUE
943 else:
944 result = main.FALSE
945 else:
946 j=i+16
947 response=main.Mininet1.get_sw_controller("s"+str(j))
948 if re.search("tcp:"+main.params['CTRL']['ip1'],response) and re.search("tcp:"+main.params['CTRL']['ip2'],response) and re.search("tcp:"+main.params['CTRL']['ip3'],response) and re.search("tcp:"+main.params['CTRL']['ip4'],response):
949 result = result and main.TRUE
950 else:
951 result = main.FALSE
952 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Controllers assigned properly to all switches",onfail="FAILED TO ASSIGN CONTROLLERS PROPERLY!")
953
954
955
956#*****************************************************************************************
957#*****************************************************************************************
958# Installation of Intents. This part will run run a forloop and add an intent from
959# h6 to h31, h7 to h32, etc and the other way as well, h31 to h6, h32 to h7, etc.
960# then Check by dumping the flows on SW2 and check for flows going bidirectionally.
961#*****************************************************************************************
962#*****************************************************************************************
963 main.step("Install intents and Check for Installation of Flows")
964 intentIP = main.params['INTENTREST']['intentIP']
965 intentPort=main.params['INTENTREST']['intentPort']
966 intentURL=main.params['INTENTREST']['intentURL']
967 count = 1
968 for i in range(6,16):
969 time.sleep(1)
970 srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2)
971 dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:])
972 #srcDPID=str(i)
973 #dstDPID=str(i+10)
974 srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2)
975 dstDPID= '00:00:00:00:00:00:20:' +str(i+25)
976 main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
977 count +=1
978 dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2)
979 srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:])
980 #srcDPID=str(i)
981 #dstDPID=str(i+10)
982 dstDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2)
983 srcDPID= '00:00:00:00:00:00:20:' +str(i+25)
984 main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
985 count+=1
admin803f05d2014-07-18 10:44:38 -0700986 main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
admin8a30f342014-06-24 15:54:26 -0700987 result = main.TRUE
988 response = main.Mininet1.check_flows(sw="s1")
989 print(response)
990 for i in range(6,16):
991 if re.search("dl_src=00:00:00:00:00:"+''.join('%02x'%i),response) and re.search("dl_src=00:00:00:00:00:"+''.join('%02x'%(i+10)),response) and re.search("dl_dst=00:00:00:00:00:"+''.join('%02x'%i),response) and re.search("dl_dst=00:00:00:00:00:"+''.join('%02x'%(i+10)),response):
992 result = result and main.TRUE
993 else:
994 result = main.FALSE
995 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added Properly",onfail="Flows were not added properly")
996
997#*****************************************************************************************
998#*****************************************************************************************
999# This step will run a ping test from h6 to h31, h7 to h32, etc as an End to End test
1000# All of these pings should run through.
1001#*****************************************************************************************
1002#*****************************************************************************************
1003 main.step("Ping Test as End to End Test that the Intents were Correctly Installed")
1004 main.log.report("Performing Ping Test")
1005 count = 1
1006 i = 6
1007 while i < 16 :
1008 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
1009 strtTime = time.time()
1010 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
1011 if ping == main.FALSE and count < 6:
1012 count = count + 1
1013 i = 6
1014 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
1015 time.sleep(2)
1016 elif ping == main.FALSE and count ==6:
1017 main.log.error("Ping test failed")
1018 i = 17
1019 result = main.FALSE
1020 elif ping == main.TRUE:
1021 i = i + 1
1022 result = main.TRUE
1023 endTime = time.time()
1024 if result == main.TRUE:
1025 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
1026 else:
1027 main.log.report("\tPING TEST FAIL")
1028 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
1029
1030#*****************************************************************************************
1031#*****************************************************************************************
1032# Removing a single intent. Then check to ensure that intent was found by calling
1033# show_intent. Then check that flows are removed by pinging.
1034#*****************************************************************************************
1035#*****************************************************************************************
1036 main.step("Delete a single intent and ensure that flows are deleted")
1037 main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id="intent_id=10")
1038 time.sleep(2)
1039 response = main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id=10)
1040 if re.search("INTENT_NOT_FOUND",response):
1041 main.log.report("Intent Removed Properly!")
1042 else:
1043 main.log.report("ERROR REMOVING INTENT")
1044 main.log.report("Performing Ping Test")
1045 count = 1
1046 for count in range(4):
1047 ping = main.Mininet1.pingHost(src="h10",target="h35")
1048 if ping==main.FALSE and count == 3:
1049 main.log.info("Ping failed as expected. Intent Deleted")
1050 result = main.TRUE
1051 elif ping == main.TRUE:
1052 main.log.error("Intent was not deleted correctly")
1053 result = main.FALSE
1054 else:
admin803f05d2014-07-18 10:44:38 -07001055 main.log.info("So far so good, attempting "+str(2-count) + " more times")
admin8a30f342014-06-24 15:54:26 -07001056 if result == main.TRUE:
1057 main.log.report("\tIntent Deleted!")
1058 else:
1059 main.log.report("\tINTENT FAILED TO BE DELETED")
1060 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Intent Deleted Properly - Step Passed",onfail="INTENT NOT DELETED - STEP FAILED")
admin089a0782014-07-22 15:48:19 -07001061 #main.ONOS1.del_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
1062 main.ONOS1.add_intent(intent_id=str(10),src_dpid="00:00:00:00:00:00:10:67",dst_dpid="00:00:00:00:00:32:21:10",src_mac="00:00:00:01:11:11",dst_mac="00:12:12:12:12:12",intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
1063
1064
1065
1066#*****************************************************************************************
1067#*****************************************************************************************
1068# Delete all intents, and ensure that all flows were deleted
1069# Will delete, then call for intents.
1070# Lastly try a ping test to check that all flows are deleted.
1071#*****************************************************************************************
1072#*****************************************************************************************
1073 main.step("Deleting all flows and check that they are all gone")
admin8a30f342014-06-24 15:54:26 -07001074
1075
1076#*****************************************************************************************
1077#*****************************************************************************************
1078# Install a bad intent. Then, ensure that we are able to get rid of it
1079# Installing an intent as ID=200, from a random dpid/mac to random dpid/mac. Then,
1080# check to make sure the intent is there, then delete it and ensure that it is gone
1081#*****************************************************************************************
1082#*****************************************************************************************
1083
1084
1085 main.step("Installing incorrect intent and checking for deletion")
1086 main.ONOS1.add_intent(intent_id=str(200),src_dpid="00:00:00:00:00:00:45:67",dst_dpid="00:00:00:00:00:32:21:10",src_mac="00:00:00:01:11:11",dst_mac="00:12:12:12:12:12",intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
admin803f05d2014-07-18 10:44:38 -07001087 main.ONOS1.show_intent(intent_id=str(200),intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
admin089a0782014-07-22 15:48:19 -07001088 main.ONOS1.del_intent(intent_id="intent_id=200",intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
admin803f05d2014-07-18 10:44:38 -07001089 time.sleep(2)
1090 response = main.ONOS1.show_intent(intentIP=intentIP,intentPort=intentPort,intentURL=intentURL,intent_id=200)
1091 if re.search("INTENT_NOT_FOUND",response):
1092 main.log.report("Intent Removed Properly!")
1093 else:
1094 main.log.report("ERROR REMOVING INTENT")
admin8a30f342014-06-24 15:54:26 -07001095
1096
1097
1098 def CASE10(self, main) :
1099 import time
1100 time.sleep(600)