blob: fdc5f570ae7435b273ca5627f192c04e1e08363d [file] [log] [blame]
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001
2class RCOnosCHO4nodes :
3
4 def __init__(self) :
5 self.default = ''
6
7#**********************************************************************************************************************************************************************************************
8#Test startup
9#Tests the startup of Zookeeper1, RamCloud1, 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
Jon Hall81d3daa2014-09-03 14:15:10 -070012 main.ONOS1.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
13 main.ONOS2.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
14 main.ONOS3.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
15 main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
Jon Hall010f5412014-05-21 15:10:12 -070016
Jon Hallbb650fe2014-07-14 14:54:48 -070017 main.ONOS1.stop_all()
18 main.ONOS2.stop_all()
19 main.ONOS3.stop_all()
20 main.ONOS4.stop_all()
SeanCorcoranf4ee2582014-04-16 17:12:30 -070021 main.Zookeeper1.start()
SeanCorcoranf4ee2582014-04-16 17:12:30 -070022 main.Zookeeper2.start()
23 main.Zookeeper3.start()
24 main.Zookeeper4.start()
Jon Hall010f5412014-05-21 15:10:12 -070025 main.RamCloud1.stop_coor()
26 main.RamCloud1.stop_serv()
27 main.RamCloud2.stop_serv()
28 main.RamCloud3.stop_serv()
29 main.RamCloud4.stop_serv()
30 time.sleep(10)
31 main.RamCloud1.del_db()
32 main.RamCloud2.del_db()
33 main.RamCloud3.del_db()
34 main.RamCloud4.del_db()
35 time.sleep(10)
Jon Hall0e09e6a2014-04-25 13:42:15 -070036 main.log.report("Pulling latest code from github to all nodes")
37 for i in range(2):
38 uptodate = main.ONOS1.git_pull()
39 main.ONOS2.git_pull()
40 main.ONOS3.git_pull()
41 main.ONOS4.git_pull()
42 ver1 = main.ONOS1.get_version()
43 ver2 = main.ONOS4.get_version()
44 if ver1==ver2:
45 break
46 elif i==1:
47 main.ONOS2.git_pull("ONOS1 master")
48 main.ONOS3.git_pull("ONOS1 master")
49 main.ONOS4.git_pull("ONOS1 master")
Jon Hall010f5412014-05-21 15:10:12 -070050 #if uptodate==0
51 if 1:
Jon Hall0e09e6a2014-04-25 13:42:15 -070052 main.ONOS1.git_compile()
53 main.ONOS2.git_compile()
54 main.ONOS3.git_compile()
55 main.ONOS4.git_compile()
56 main.ONOS1.print_version()
Jon Hall010f5412014-05-21 15:10:12 -070057 # main.RamCloud1.git_pull()
58 # main.RamCloud2.git_pull()
59 # main.RamCloud3.git_pull()
60 # main.RamCloud4.git_pull()
61 # main.ONOS1.get_version()
62 # main.ONOS2.get_version()
63 # main.ONOS3.get_version()
64 # main.ONOS4.get_version()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070065 main.RamCloud1.start_coor()
Jon Hall010f5412014-05-21 15:10:12 -070066 time.sleep(1)
SeanCorcoranc3ed7432014-04-09 16:32:27 -070067 main.RamCloud1.start_serv()
68 main.RamCloud2.start_serv()
69 main.RamCloud3.start_serv()
Jon Hall010f5412014-05-21 15:10:12 -070070 main.RamCloud4.start_serv()
Jon Hallbb650fe2014-07-14 14:54:48 -070071 main.ONOS1.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
Jon Hall010f5412014-05-21 15:10:12 -070072 time.sleep(5)
Jon Hallbb650fe2014-07-14 14:54:48 -070073 main.ONOS2.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
74 main.ONOS3.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
75 main.ONOS4.start("env JVM_OPTS=\"-Xmx2g -Xms2g -Xmn800m\" ")
Jon Hall010f5412014-05-21 15:10:12 -070076 main.ONOS1.start_rest()
77 time.sleep(10)
78 test= main.ONOS1.rest_status()
79 if test == main.FALSE:
80 main.ONOS1.start_rest()
81 main.ONOS1.get_version()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070082 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
83 main.case("Checking if the startup was clean...")
Jon Hall010f5412014-05-21 15:10:12 -070084 main.step("Testing startup Zookeeper")
SeanCorcoranc3ed7432014-04-09 16:32:27 -070085 data = main.Zookeeper1.isup()
86 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
Jon Hall010f5412014-05-21 15:10:12 -070087 main.step("Testing startup RamCloud")
88 data = main.RamCloud1.status_serv()
SeanCorcoranc3ed7432014-04-09 16:32:27 -070089 if data == main.FALSE:
90 main.RamCloud1.stop_coor()
91 main.RamCloud1.stop_serv()
92 main.RamCloud2.stop_serv()
93 main.RamCloud3.stop_serv()
94 main.RamCloud4.stop_serv()
95
96 time.sleep(5)
SeanCorcoranc3ed7432014-04-09 16:32:27 -070097 main.RamCloud1.start_coor()
98 main.RamCloud1.start_serv()
99 main.RamCloud2.start_serv()
100 main.RamCloud3.start_serv()
Jon Hall010f5412014-05-21 15:10:12 -0700101 main.RamCloud4.start_serv()
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700102 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
Jon Hall010f5412014-05-21 15:10:12 -0700103 main.step("Testing startup ONOS")
104 data = main.ONOS1.isup()
105 for i in range(3):
106 if data == main.FALSE:
107 #main.log.report("Something is funny... restarting ONOS")
108 #main.ONOS1.stop()
109 time.sleep(3)
110 #main.ONOS1.start()
111 #time.sleep(5)
112 data = main.ONOS1.isup()
113 else:
114 break
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700115 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
Jon Hallbb650fe2014-07-14 14:54:48 -0700116 time.sleep(10)
Jon Hall010f5412014-05-21 15:10:12 -0700117
118
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700119#**********************************************************************************************************************************************************************************************
120#Assign Controllers
121#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>).
122#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
123#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
124# the controllers already assigned to the switch are not specified.
125
126 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
127 import time
128 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
129 main.case("Checking if one MN host exists")
130 main.step("Host IP Checking using checkIP")
131 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
132 main.step("Verifying the result")
133 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
134 main.step("assigning ONOS controllers to switches")
135 for i in range(25):
136 if i < 3:
137 j=i+1
138 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
139 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700141 elif i >= 3 and i < 5:
142 j=i+1
143 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
144 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700146 elif i >= 5 and i < 15:
147 j=i+1
148 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
149 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700150 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700151 else:
152 j=i+16
153 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
154 time.sleep(1)
Jon Hall0e09e6a2014-04-25 13:42:15 -0700155 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'])
Jon Hall670808c2014-06-23 16:07:22 -0700156 result = main.Mininet1.get_sw_controller("s1")
157 if result:
158 result = main.TRUE
159 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="S1 assigned to controller",onfail="S1 not assigned to controller")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700160
161 for i in range(9):
162 if result == main.FALSE:
163 time.sleep(3)
164 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
165 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700166 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
167 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
168 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700169 break
170
171# **********************************************************************************************************************************************************************************************
172#Add Flows
173#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
174#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
175
176 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
Jon Hall010f5412014-05-21 15:10:12 -0700177 main.log.report("Delete any flows from previous tests, then add flows using intents and wait for switch flow tables to update")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700178 import time
179
180 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
181 for counter in range(9):
182 if result == main.FALSE:
183 time.sleep(3)
184 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
185 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700186 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
187 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
188 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700189 break
190
Jon Hall81d3daa2014-09-03 14:15:10 -0700191 ####New Topo Check
192 ctrls = []
193 count = 1
194 while True:
195 temp = ()
196 if ('ip' + str(count)) in main.params['CTRL']:
197 temp = temp + (getattr(main,('ONOS' + str(count))),)
198 temp = temp + ("ONOS"+str(count),)
199 temp = temp + (main.params['CTRL']['ip'+str(count)],)
200 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
201 ctrls.append(temp)
202 count = count + 1
203 else:
204 break
205 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
206 global MNTopo
207 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
208
209
210 topo_result = main.TRUE
211 for n in range(1,5):
212 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
213 topo_result = topo_result and temp_result
214 print "Topoology check results: " + str(topo_result)
215 ###End New Topo Check
216 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
217
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700218 main.case("Taking care of these flows!")
219 main.step("Cleaning out any leftover flows...")
Jon Hall81d3daa2014-09-03 14:15:10 -0700220 intentIP = main.params['CTRL']['ip1']
221 intentPort=main.params['INTENTS']['intentPort']
222 intentURL=main.params['INTENTS']['intentURL']
Jon Hall0e09e6a2014-04-25 13:42:15 -0700223 #main.ONOS1.delete_flow("all")
Jon Hall81d3daa2014-09-03 14:15:10 -0700224 main.ONOS1.del_intent(intentIP=intentIP)
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700225 time.sleep(5)
226 strtTime = time.time()
Jon Hall81d3daa2014-09-03 14:15:10 -0700227 main.step("Adding Intents")
228 count=1
229 for i in range(6,16):
230 srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2)
231 dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:])
232 srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2)
233 dstDPID= '00:00:00:00:00:00:20:' +str(i+25)
234 main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,
235 src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,
236 intentURL=intentURL)
237 count=count +1
238 dstDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2)
239 srcDPID= '00:00:00:00:00:00:20:' +str(i+25)
240 dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2)
241 srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:])
242 main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,
243 src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,
244 intentURL=intentURL)
245 count=count +1
246 main.step("Checking flows with pings")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700247
248 pingAttempts = main.params['pingAttempts']
249 pingSleep = main.params['pingSleep']
250
Jon Hall81d3daa2014-09-03 14:15:10 -0700251
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700252 count = 1
253 i = 6
254 while i < 16 :
255 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
256 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
257 if ping == main.FALSE and count < int(pingAttempts):
258 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700259 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700260 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
261 time.sleep(int(pingSleep))
262 elif ping == main.FALSE and count == int(pingAttempts):
263 main.log.error("Ping test failed")
264 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700265 result2 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700266 elif ping == main.TRUE:
267 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700268 result2 = main.TRUE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700269 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700270 result = result and result2
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700271 if result == main.TRUE:
Jon Hall010f5412014-05-21 15:10:12 -0700272 main.log.report("\n\t\t\t\tTime from pushing intents to successful ping test: "+str(round(endTime-strtTime,2))+" seconds")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700273 else:
274 main.log.report("\tFlows failed check")
275
276 main.step("Verifying the result")
Jon Hall670808c2014-06-23 16:07:22 -0700277 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
278 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700279
280#**********************************************************************************************************************************************************************************************
281#This test case removes Controllers 2,3, and 4 then performs a ping test.
282#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
283#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.
284#If the ping test fails 6 times, then the test case will return false
285
286 def CASE4(self,main) :
Jon Hall670808c2014-06-23 16:07:22 -0700287 main.log.report("Assign all switches to just one ONOS instance then ping until all hosts are reachable or fail after 6 attempts")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700288 import time
289 import random
290
291 random.seed(None)
292
293 num = random.randint(1,4)
294 if num == 1:
295 ip = main.params['CTRL']['ip1']
296 port = main.params['CTRL']['port1']
297 elif num == 2:
298 ip = main.params['CTRL']['ip2']
299 port = main.params['CTRL']['port2']
300 elif num == 3:
301 ip = main.params['CTRL']['ip3']
302 port = main.params['CTRL']['port3']
303 else:
304 ip = main.params['CTRL']['ip4']
305 port = main.params['CTRL']['port4']
306
307 main.log.report("ONOS"+str(num)+" will be the sole controller")
308 for i in range(25):
309 if i < 15:
310 j=i+1
311 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers
312 else:
313 j=i+16
314 main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port)
315
316 strtTime = time.time()
317 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
318 for counter in range(9):
319 if result == main.FALSE:
320 time.sleep(3)
321 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
322 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700323 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
324 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
325 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700326 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700327 ####New Topo Check
328 ctrls = []
329 count = 1
330 while True:
331 temp = ()
332 if ('ip' + str(count)) in main.params['CTRL']:
333 temp = temp + (getattr(main,('ONOS' + str(count))),)
334 temp = temp + ("ONOS"+str(count),)
335 temp = temp + (main.params['CTRL']['ip'+str(count)],)
336 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
337 ctrls.append(temp)
338 count = count + 1
339 else:
340 break
341 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
342 global MNTopo
343 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
344
345
346 topo_result = main.TRUE
347 for n in range(1,5):
348 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
349 topo_result = topo_result and temp_result
350 print "Topoology check results: " + str(topo_result)
351 ###End New Topo Check
Jon Hall670808c2014-06-23 16:07:22 -0700352 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700353
354 pingAttempts = main.params['pingAttempts']
355 pingSleep = main.params['pingSleep']
356
357 count = 1
358 i = 6
359 while i < 16 :
360 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
361 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
362 if ping == main.FALSE and count < int(pingAttempts):
363 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700364 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700365 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
366 time.sleep(int(pingSleep))
367 elif ping == main.FALSE and count == int(pingAttempts):
368 main.log.error("Ping test failed")
369 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700370 result2 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700371 elif ping == main.TRUE:
372 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700373 result2 = main.TRUE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700374 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700375 result = result and result2
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700376 if result == main.TRUE:
377 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
378 else:
379 main.log.report("\tPING TEST FAIL")
Jon Hallbb650fe2014-07-14 14:54:48 -0700380 main.ONOS1.show_intent(main.params['RestIP'])
Jon Hall670808c2014-06-23 16:07:22 -0700381 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
382 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700383
384# **********************************************************************************************************************************************************************************************
385#This test case restores the controllers removed by Case 4 then performs a ping test.
386
387 def CASE5(self,main) :
Jon Hall670808c2014-06-23 16:07:22 -0700388 main.log.report("Restore switch assignments to all 4 ONOS instances then ping until all hosts are reachable or fail after 6 attempts")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700389 import time
Jon Hallbb650fe2014-07-14 14:54:48 -0700390
391 #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
392 time.sleep(10)
393
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700394 for i in range(25):
395 if i < 15:
396 j=i+1
Jon Hall670808c2014-06-23 16:07:22 -0700397 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700398 else:
399 j=i+16
Jon Hall670808c2014-06-23 16:07:22 -0700400 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'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700401
402 strtTime = time.time()
403 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
404 for counter in range(9):
405 if result == main.FALSE:
406 time.sleep(3)
407 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
408 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700409 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
410 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
411 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700412 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700413 ####New Topo Check
414 ctrls = []
415 count = 1
416 while True:
417 temp = ()
418 if ('ip' + str(count)) in main.params['CTRL']:
419 temp = temp + (getattr(main,('ONOS' + str(count))),)
420 temp = temp + ("ONOS"+str(count),)
421 temp = temp + (main.params['CTRL']['ip'+str(count)],)
422 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
423 ctrls.append(temp)
424 count = count + 1
425 else:
426 break
427 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
428 global MNTopo
429 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
430
431
432 topo_result = main.TRUE
433 for n in range(1,5):
434 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
435 topo_result = topo_result and temp_result
436 print "Topoology check results: " + str(topo_result)
437 ###End New Topo Check
Jon Hall670808c2014-06-23 16:07:22 -0700438 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700439
440 pingAttempts = main.params['pingAttempts']
441 pingSleep = main.params['pingSleep']
442
443 count = 1
444 i = 6
445 while i < 16 :
446 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
447 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
448 if ping == main.FALSE and count < int(pingAttempts):
449 count = count + 1
Jon Hall010f5412014-05-21 15:10:12 -0700450 # i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700451 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
452 time.sleep(int(pingSleep))
453 elif ping == main.FALSE and count == int(pingAttempts):
454 main.log.error("Ping test failed")
455 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700456 result2 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700457 elif ping == main.TRUE:
458 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700459 result2 = main.TRUE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700460 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700461 result = result and result2
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700462 if result == main.TRUE:
463 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
464 else:
465 main.log.report("\tPING TEST FAILED")
Jon Hallbb650fe2014-07-14 14:54:48 -0700466 main.ONOS1.show_intent(main.params['RestIP'])
Jon Hall670808c2014-06-23 16:07:22 -0700467 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
468 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700469
470# **********************************************************************************************************************************************************************************************
471#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
472
473 def CASE6(self,main) :
474 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
475 import time
Jon Hall670808c2014-06-23 16:07:22 -0700476
Jon Hallbb650fe2014-07-14 14:54:48 -0700477 #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
478 time.sleep(10)
Jon Hall670808c2014-06-23 16:07:22 -0700479
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700480 main.case("Bringing Link down... ")
481 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
482 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
483
484 strtTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700485 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700486 for counter in range(9):
Jon Hall670808c2014-06-23 16:07:22 -0700487 if result1 == main.FALSE:
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700488 time.sleep(3)
Jon Hall670808c2014-06-23 16:07:22 -0700489 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700490 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700491 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
492 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
493 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700494 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700495 ####New Topo Check
496 ctrls = []
497 count = 1
498 while True:
499 temp = ()
500 if ('ip' + str(count)) in main.params['CTRL']:
501 temp = temp + (getattr(main,('ONOS' + str(count))),)
502 temp = temp + ("ONOS"+str(count),)
503 temp = temp + (main.params['CTRL']['ip'+str(count)],)
504 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
505 ctrls.append(temp)
506 count = count + 1
507 else:
508 break
509 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
510 global MNTopo
511 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
512
513
514 topo_result = main.TRUE
515 for n in range(1,5):
516 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
517 topo_result = topo_result and temp_result
518 print "Topoology check results: " + str(topo_result)
519 ###End New Topo Check
Jon Hall670808c2014-06-23 16:07:22 -0700520 utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700521
522 pingAttempts = main.params['pingAttempts']
523 pingSleep = main.params['pingSleep']
524
525 count = 1
526 i = 6
527 while i < 16 :
528 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
529 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
530 if ping == main.FALSE and count < int(pingAttempts):
531 count = count + 1
532 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
Jon Hall0e09e6a2014-04-25 13:42:15 -0700533 #i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700534 time.sleep(int(pingSleep))
535 elif ping == main.FALSE and count == int(pingAttempts):
536 main.log.error("Ping test failed")
537 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700538 result2 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700539 elif ping == main.TRUE:
540 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700541 result2 = main.TRUE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700542 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700543 result = result and result2 and result1
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700544 if result == main.TRUE:
545 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
546 else:
547 main.log.report("\tPING TEST FAILED")
Jon Hallbb650fe2014-07-14 14:54:48 -0700548 main.ONOS1.show_intent(main.params['RestIP'])
Jon Hall670808c2014-06-23 16:07:22 -0700549 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
550 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700551
552# **********************************************************************************************************************************************************************************************
553#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
554
555 def CASE7(self,main) :
556 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
557 import time
558 main.case("Bringing Link up... ")
Jon Hall670808c2014-06-23 16:07:22 -0700559
Jon Hallbb650fe2014-07-14 14:54:48 -0700560 #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
561 time.sleep(10)
Jon Hall670808c2014-06-23 16:07:22 -0700562
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700563 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
564 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
565
566 strtTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700567 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700568 for counter in range(9):
Jon Hall670808c2014-06-23 16:07:22 -0700569 if result1 == main.FALSE:
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700570 time.sleep(3)
Jon Hall670808c2014-06-23 16:07:22 -0700571 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700572 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700573 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
574 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
575 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700576 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700577 ####New Topo Check
578 ctrls = []
579 count = 1
580 while True:
581 temp = ()
582 if ('ip' + str(count)) in main.params['CTRL']:
583 temp = temp + (getattr(main,('ONOS' + str(count))),)
584 temp = temp + ("ONOS"+str(count),)
585 temp = temp + (main.params['CTRL']['ip'+str(count)],)
586 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
587 ctrls.append(temp)
588 count = count + 1
589 else:
590 break
591 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
592 global MNTopo
593 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
594
595
596 topo_result = main.TRUE
597 for n in range(1,5):
598 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
599 topo_result = topo_result and temp_result
600 print "Topoology check results: " + str(topo_result)
601 ###End New Topo Check
Jon Hall670808c2014-06-23 16:07:22 -0700602 utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700603
604 pingAttempts = main.params['pingAttempts']
605 pingSleep = main.params['pingSleep']
606
607 strtTime = time.time()
608 count = 1
609 i = 6
610 while i < 16 :
611 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
612 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
613 if ping == main.FALSE and count < int(pingAttempts):
614 count = count + 1
615 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
Jon Hall010f5412014-05-21 15:10:12 -0700616 #i = 6
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700617 time.sleep(int(pingSleep))
618 elif ping == main.FALSE and count == int(pingAttempts):
619 main.log.error("Ping test failed")
620 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700621 result2 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700622 elif ping == main.TRUE:
623 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700624 result2 = main.TRUE
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700625 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700626 result = result and result2 and result1
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700627 if result == main.TRUE:
628 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
629 else:
630 main.log.report("\tPING TESTS FAILED")
Jon Hallbb650fe2014-07-14 14:54:48 -0700631 main.ONOS1.show_intent(main.params['RestIP'])
Jon Hall010f5412014-05-21 15:10:12 -0700632
Jon Hallbb650fe2014-07-14 14:54:48 -0700633 print main.ONOS1.check_exceptions()
634 print main.ONOS2.check_exceptions()
635 print main.ONOS3.check_exceptions()
636 print main.ONOS4.check_exceptions()
Jon Hall010f5412014-05-21 15:10:12 -0700637
Jon Hall670808c2014-06-23 16:07:22 -0700638 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
639 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
640
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700641
Jon Hallf7947982014-05-22 10:44:45 -0700642# **********************************************************************************************************************************************************************************************
643# Runs reactive ping test
644 def CASE8(self,main) :
645 main.log.report("Reactive flow ping test:ping until the routes are active or fail after 10 attempts")
646 import time
647
648 strtTime = time.time()
649 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
650 for counter in range(9):
651 if result == main.FALSE:
652 time.sleep(3)
653 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
654 else:
Jon Hallbb650fe2014-07-14 14:54:48 -0700655 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
656 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
657 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
Jon Hallf7947982014-05-22 10:44:45 -0700658 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700659 ####New Topo Check
660 ctrls = []
661 count = 1
662 while True:
663 temp = ()
664 if ('ip' + str(count)) in main.params['CTRL']:
665 temp = temp + (getattr(main,('ONOS' + str(count))),)
666 temp = temp + ("ONOS"+str(count),)
667 temp = temp + (main.params['CTRL']['ip'+str(count)],)
668 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
669 ctrls.append(temp)
670 count = count + 1
671 else:
672 break
673 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
674 global MNTopo
675 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
676
677
678 topo_result = main.TRUE
679 for n in range(1,5):
680 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
681 topo_result = topo_result and temp_result
682 print "Topoology check results: " + str(topo_result)
683 ###End New Topo Check
Jon Hall670808c2014-06-23 16:07:22 -0700684 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Topology check pass",onfail="Topology check FAIL")
Jon Hallf7947982014-05-22 10:44:45 -0700685
686 pingAttempts = main.params['pingAttempts']
687 pingSleep = main.params['pingSleep']
688
689 strtTime = time.time()
690 count = 1
691 i = 6
692 while i < 16 :
693 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
694 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
695 if ping == main.FALSE and count < int(pingAttempts):
696 count = count + 1
697 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
698 #i = 6
699 time.sleep(int(pingSleep))
700 elif ping == main.FALSE and count == int(pingAttempts):
701 main.log.error("Ping test failed")
702 i = 17
Jon Hall670808c2014-06-23 16:07:22 -0700703 result2 = main.FALSE
Jon Hallf7947982014-05-22 10:44:45 -0700704 elif ping == main.TRUE:
705 i = i + 1
Jon Hall670808c2014-06-23 16:07:22 -0700706 result2 = main.TRUE
Jon Hallf7947982014-05-22 10:44:45 -0700707 endTime = time.time()
Jon Hall670808c2014-06-23 16:07:22 -0700708 result = result and result2
Jon Hallf7947982014-05-22 10:44:45 -0700709 if result == main.TRUE:
710 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
711 else:
712 main.log.report("\tPING TESTS FAILED")
Jon Hallbb650fe2014-07-14 14:54:48 -0700713 main.ONOS1.show_intent(main.params['RestIP'])
Jon Hallf7947982014-05-22 10:44:45 -0700714
Jon Hallbb650fe2014-07-14 14:54:48 -0700715 print main.ONOS1.check_exceptions()
716 print main.ONOS2.check_exceptions()
717 print main.ONOS3.check_exceptions()
718 print main.ONOS4.check_exceptions()
719
720 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
721 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
722# **********************************************************************************************************************************************************************************************
723#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
724# This is the same as case 6, but specifically for the reactive tests
725
726 def CASE61(self,main) :
727 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
728 import time
729
730 #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
731 time.sleep(10)
732
733 main.case("Bringing Link down... ")
734 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
735 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
736
737 strtTime = time.time()
738 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
739 for counter in range(9):
740 if result1 == main.FALSE:
741 time.sleep(3)
742 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
743 else:
744 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
745 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
746 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
747 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700748 ####New Topo Check
749 ctrls = []
750 count = 1
751 while True:
752 temp = ()
753 if ('ip' + str(count)) in main.params['CTRL']:
754 temp = temp + (getattr(main,('ONOS' + str(count))),)
755 temp = temp + ("ONOS"+str(count),)
756 temp = temp + (main.params['CTRL']['ip'+str(count)],)
757 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
758 ctrls.append(temp)
759 count = count + 1
760 else:
761 break
762 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
763 global MNTopo
764 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
765
766
767 topo_result = main.TRUE
768 for n in range(1,5):
769 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
770 topo_result = topo_result and temp_result
771 print "Topoology check results: " + str(topo_result)
772 ###End New Topo Check
Jon Hallbb650fe2014-07-14 14:54:48 -0700773 utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
774
775 pingAttempts = main.params['pingAttempts']
776 pingSleep = main.params['pingSleep']
777
778 count = 1
779 i = 6
780 while i < 16 :
781 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
782 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
783 if ping == main.FALSE and count < int(pingAttempts):
784 count = count + 1
785 main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds")
786 #i = 6
787 time.sleep(int(pingSleep))
788 elif ping == main.FALSE and count == int(pingAttempts):
789 main.log.error("Ping test failed")
790 i = 17
791 result2 = main.FALSE
792 elif ping == main.TRUE:
793 i = i + 1
794 result2 = main.TRUE
795 endTime = time.time()
796 result = result and result2 and result1
797 if result == main.TRUE:
798 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
799 else:
800 main.log.report("\tPING TEST FAILED")
801 main.ONOS1.show_intent(main.params['RestIP'])
802 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
803 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
804
805
806# **********************************************************************************************************************************************************************************************
807#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
808# Specifically for the Reactive tests
809
810 def CASE71(self,main) :
811 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
812 import time
813 main.case("Bringing Link up... ")
814
815 #add a wait as a work around for a known bug where topology changes after a switch mastership change causes intents to not reroute
816 time.sleep(10)
817
818 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
819 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
820
821 strtTime = time.time()
822 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
823 for counter in range(9):
824 if result1 == main.FALSE:
825 time.sleep(3)
826 result1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
827 else:
828 main.ONOS2.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
829 main.ONOS3.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
830 main.ONOS4.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
831 break
Jon Hall81d3daa2014-09-03 14:15:10 -0700832 ####New Topo Check
833 ctrls = []
834 count = 1
835 while True:
836 temp = ()
837 if ('ip' + str(count)) in main.params['CTRL']:
838 temp = temp + (getattr(main,('ONOS' + str(count))),)
839 temp = temp + ("ONOS"+str(count),)
840 temp = temp + (main.params['CTRL']['ip'+str(count)],)
841 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
842 ctrls.append(temp)
843 count = count + 1
844 else:
845 break
846 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
847 global MNTopo
848 MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
849
850
851 topo_result = main.TRUE
852 for n in range(1,5):
853 temp_result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
854 topo_result = topo_result and temp_result
855 print "Topoology check results: " + str(topo_result)
856 ###End New Topo Check
Jon Hallbb650fe2014-07-14 14:54:48 -0700857 utilities.assert_equals(expect=main.TRUE,actual=result1,onpass="Topology check pass",onfail="Topology check FAIL")
858
859 pingAttempts = main.params['pingAttempts']
860 pingSleep = main.params['pingSleep']
861
862 strtTime = time.time()
863 count = 1
864 i = 6
865 while i < 16 :
866 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(46-i) )
867 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(46-i))
868 if ping == main.FALSE and count < int(pingAttempts):
869 count = count + 1
870 main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds")
871 #i = 6
872 time.sleep(int(pingSleep))
873 elif ping == main.FALSE and count == int(pingAttempts):
874 main.log.error("Ping test failed")
875 i = 17
876 result2 = main.FALSE
877 elif ping == main.TRUE:
878 i = i + 1
879 result2 = main.TRUE
880 endTime = time.time()
881 result = result and result2 and result1
882 if result == main.TRUE:
883 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
884 else:
885 main.log.report("\tPING TESTS FAILED")
886 main.ONOS1.show_intent(main.params['RestIP'])
887
888 print main.ONOS1.check_exceptions()
889 print main.ONOS2.check_exceptions()
890 print main.ONOS3.check_exceptions()
891 print main.ONOS4.check_exceptions()
Jon Hallf7947982014-05-22 10:44:45 -0700892
Jon Hall670808c2014-06-23 16:07:22 -0700893 utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
894 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Testcase passed",onfail="Testcase failed")
Jon Hallf7947982014-05-22 10:44:45 -0700895
896
Jon Hallbb650fe2014-07-14 14:54:48 -0700897
898
Jon Hall670808c2014-06-23 16:07:22 -0700899# ******************************************************************************************************************************************************************
Jon Hallbb650fe2014-07-14 14:54:48 -0700900# Check for ONOS Components health
Jon Hall670808c2014-06-23 16:07:22 -0700901
902 def CASE9(self,main) :
903 main.case("Checking component status")
904 result = main.TRUE
905
906 main.step("Checking Zookeeper status")
907 result1 = main.Zookeeper1.status()
908 if not result1:
909 main.log.report("Zookeeper1 encountered a tragic death!")
910 result2 = main.Zookeeper2.status()
911 if not result2:
912 main.log.report("Zookeeper2 encountered a tragic death!")
913 result3 = main.Zookeeper3.status()
914 if not result3:
915 main.log.report("Zookeeper3 encountered a tragic death!")
916 result4 = main.Zookeeper4.status()
917 if not result4:
918 main.log.report("Zookeeper4 encountered a tragic death!")
919 result = result and result1 and result2 and result3 and result4
920
921 main.step("Checking RamCloud status")
922 result5 = main.RamCloud1.status_coor()
923 if not result5:
924 main.log.report("RamCloud Coordinator1 encountered a tragic death!")
925 result6 = main.RamCloud1.status_serv()
926 if not result6:
927 main.log.report("RamCloud Server1 encountered a tragic death!")
928 result7 = main.RamCloud2.status_serv()
929 if not result7:
930 main.log.report("RamCloud Server2 encountered a tragic death!")
931 result8 = main.RamCloud3.status_serv()
932 if not result8:
933 main.log.report("RamCloud Server3 encountered a tragic death!")
934 result9 = main.RamCloud4.status_serv()
935 if not result9:
936 main.log.report("RamCloud Server4 encountered a tragic death!")
937 result = result and result5 and result6 and result7 and result8 and result9
938
939
940 main.step("Checking ONOS status")
941 result10 = main.ONOS1.status()
942 if not result10:
943 main.log.report("ONOS1 core encountered a tragic death!")
944 result11 = main.ONOS2.status()
945 if not result11:
946 main.log.report("ONOS2 core encountered a tragic death!")
947 result12 = main.ONOS3.status()
948 if not result12:
949 main.log.report("ONOS3 core encountered a tragic death!")
950 result13 = main.ONOS4.status()
951 if not result13:
952 main.log.report("ONOS4 core encountered a tragic death!")
953 result = result and result10 and result11 and result12 and result13
954
955
956
957 rest_result = main.ONOS1.rest_status()
958 if not rest_result:
959 main.log.report("Simple Rest GUI server is not running on ONOS1")
960
961
962 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="All Components are running",onfail="One or more components failed")
Jon Hallf7947982014-05-22 10:44:45 -0700963
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700964# ******************************************************************************************************************************************************************
965# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
966
967 def CASE21(self,main) :
968 import json
Jon Hallbb650fe2014-07-14 14:54:48 -0700969 main.log.report("Test device discovery function, by attach, detach, and move host h1 from s1->s6->s1. Per mininet naming, the name of the switch port the host attaches to will remain as 's1-eth1' throughout the test.")
970 main.log.report("Check initially hostMAC/IP exist on the mininet...")
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700971 host = main.params['YANK']['hostname']
972 mac = main.params['YANK']['hostmac']
973 RestIP1 = main.params['RESTCALL']['restIP1']
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700974 RestPort = main.params['RESTCALL']['restPort']
975 url = main.params['RESTCALL']['restURL']
Jon Hallbb650fe2014-07-14 14:54:48 -0700976
977 t_topowait = 5
Jon Hall81d3daa2014-09-03 14:15:10 -0700978 t_restwait = 5
Jon Hallbb650fe2014-07-14 14:54:48 -0700979 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
980 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700981 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
Jon Hallbb650fe2014-07-14 14:54:48 -0700982 time.sleep(t_topowait)
983 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" )
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700984 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallbb650fe2014-07-14 14:54:48 -0700985 time.sleep(t_restwait)
986 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
987 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
SeanCorcoranc3ed7432014-04-09 16:32:27 -0700988 if Reststatus == 1:
Jon Hallbb650fe2014-07-14 14:54:48 -0700989 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
990 result1 = main.TRUE
991 elif Reststatus > 1:
992 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
993 main.log.report("switches are: " + "; ".join(Switch))
994 main.log.report("Ports are: " + "; ".join(Port))
995 result1 = main.FALSE
996 elif Reststatus == 0 and Switch == []:
997 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
998 result1 = main.FALSE
999 else:# check if rest server is working
1000 main.log.error("Issue with find host")
1001 result1 = main.FALSE
1002
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001003
1004 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
1005
1006 main.log.report("Yank out s1-eth1")
1007 main.case("Yankout s6-eth1 (link to h1) from s1")
1008 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
Jon Hallbb650fe2014-07-14 14:54:48 -07001009 time.sleep(t_topowait)
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001010 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
Jon Hallbb650fe2014-07-14 14:54:48 -07001011
1012 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" )
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001013 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallbb650fe2014-07-14 14:54:48 -07001014 time.sleep(t_restwait)
1015 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
1016
1017 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
1018 if Reststatus == 1:
1019 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
1020 result2 = main.FALSE
1021 elif Reststatus > 1:
1022 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
1023 main.log.report("switches are: " + "; ".join(Switch))
1024 main.log.report("Ports are: " + "; ".join(Port))
1025 main.log.report("MACs are: " + "; ".join(MAC))
1026 result2 = main.FALSE
1027 elif Reststatus == 0 and Switch == []:
1028 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.")
1029 result2 = main.TRUE
1030 else:# check if rest server is working
1031 main.log.error("Issue with find host")
1032 result2 = main.FALSE
1033
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001034 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
1035 main.log.report("Plug s1-eth1 into s6")
1036 main.case("Plug s1-eth1 to s6")
1037 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
Jon Hallbb650fe2014-07-14 14:54:48 -07001038 time.sleep(t_topowait)
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001039 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
Jon Hallbb650fe2014-07-14 14:54:48 -07001040 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" )
1041
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001042 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallbb650fe2014-07-14 14:54:48 -07001043 time.sleep(t_restwait)
1044 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
1045
1046 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
1047 if Reststatus == 1:
1048 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
1049 result3 = main.TRUE
1050 elif Reststatus > 1:
1051 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
1052 main.log.report("switches are: " + "; ".join(Switch))
1053 main.log.report("Ports are: " + "; ".join(Port))
1054 main.log.report("MACs are: " + "; ".join(MAC))
1055 result3 = main.FALSE
1056 elif Reststatus == 0 and Switch == []:
1057 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
1058 result3 = main.FALSE
1059 else:# check if rest server is working
1060 main.log.error("Issue with find host")
1061 result3 = main.FALSE
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001062
1063 ###### Step to put interface "s1-eth1" back to s1"#####
1064 main.log.report("Move s1-eth1 back on to s1")
1065 main.case("Move s1-eth1 back to s1")
1066 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
Jon Hallbb650fe2014-07-14 14:54:48 -07001067 time.sleep(t_topowait)
1068 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001069 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
Jon Hallbb650fe2014-07-14 14:54:48 -07001070 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" )
1071
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001072 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
Jon Hallbb650fe2014-07-14 14:54:48 -07001073 time.sleep(t_restwait)
1074 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001075
Jon Hallbb650fe2014-07-14 14:54:48 -07001076 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
1077 if Reststatus == 1:
1078 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
1079 result4 = main.TRUE
1080 elif Reststatus > 1:
1081 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
1082 main.log.report("switches are: " + "; ".join(Switch))
1083 main.log.report("Ports are: " + "; ".join(Port))
1084 main.log.report("MACs are: " + "; ".join(MAC))
1085 result4 = main.FALSE
1086 elif Reststatus == 0 and Switch == []:
1087 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
1088 result4 = main.FALSE
1089 else:# check if rest server is working
1090 main.log.error("Issue with find host")
1091 result4 = main.FALSE
1092 time.sleep(20)
1093 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
1094 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
1095 if Reststatus ==1:
1096 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
1097 elif Reststatus>1:
1098 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
1099 elif Reststatus==0:
1100 main.log.report("\t PASSED - Device cleared after timeout")
1101
1102 result = result1 and result2 and result3 and result4
SeanCorcoranc3ed7432014-04-09 16:32:27 -07001103 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
1104