blob: d177f8b1a4109c636a836113b17b3ee4c2a2cf11 [file] [log] [blame]
admin733ae0a2014-04-09 15:01:12 -07001
2class RCOnosSanity4nodesJ :
3
adminf689a272014-06-17 14:08:57 -07004
5
admin733ae0a2014-04-09 15:01:12 -07006 def __init__(self) :
7 self.default = ''
8
adminf689a272014-06-17 14:08:57 -07009# def print_hello_world(self,main):
10# print("hello world")
admin733ae0a2014-04-09 15:01:12 -070011#*****************************************************************************************************************************************************************************************
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
adminf689a272014-06-17 14:08:57 -070015 main.case("Initial setup")
16 main.step("Stop ONOS")
admin733ae0a2014-04-09 15:01:12 -070017 import time
admine8c47d02014-06-03 11:59:16 -070018 main.ONOS1.stop_all()
19 main.ONOS2.stop_all()
20 main.ONOS3.stop_all()
adminf689a272014-06-17 14:08:57 -070021# main.print_hello_world()
admine8c47d02014-06-03 11:59:16 -070022 main.ONOS4.stop_all()
23 main.ONOS2.stop_rest()
Jon Halle80ef8c2014-04-29 15:29:13 -070024 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")
admine8c47d02014-06-03 11:59:16 -070027 main.ONOS4.handle.sendline("cp ~/onos.properties.proactive ~/ONOS/conf/onos.properties")
adminf689a272014-06-17 14:08:57 -070028 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")
Jon Hall0955bc92014-04-16 17:00:19 -070031 main.Zookeeper1.start()
Jon Halle80ef8c2014-04-29 15:29:13 -070032 main.Zookeeper2.start()
33 main.Zookeeper3.start()
34 main.Zookeeper4.start()
admine8c47d02014-06-03 11:59:16 -070035 time.sleep(1)
admin6c96b8e2014-05-15 11:11:58 -070036 main.RamCloud1.del_db()
37 main.RamCloud2.del_db()
38 main.RamCloud3.del_db()
39 main.RamCloud4.del_db()
admin733ae0a2014-04-09 15:01:12 -070040 main.log.report("Pulling latest code from github to all nodes")
admin21211792014-04-15 15:42:39 -070041 for i in range(2):
42 uptodate = main.ONOS1.git_pull()
43 main.ONOS2.git_pull()
44 main.ONOS3.git_pull()
45 main.ONOS4.git_pull()
46 ver1 = main.ONOS1.get_version()
47 ver2 = main.ONOS4.get_version()
48 if ver1==ver2:
49 break
50 elif i==1:
51 main.ONOS2.git_pull("ONOS1 master")
52 main.ONOS3.git_pull("ONOS1 master")
53 main.ONOS4.git_pull("ONOS1 master")
admine8c47d02014-06-03 11:59:16 -070054 if uptodate==0:
55 # if 1:
admin21211792014-04-15 15:42:39 -070056 main.ONOS1.git_compile()
57 main.ONOS2.git_compile()
58 main.ONOS3.git_compile()
59 main.ONOS4.git_compile()
Jon Hall364f37a2014-04-17 10:29:35 -070060 main.ONOS1.print_version()
admin733ae0a2014-04-09 15:01:12 -070061 # main.RamCloud1.git_pull()
62 # main.RamCloud2.git_pull()
63 # main.RamCloud3.git_pull()
64 # main.RamCloud4.git_pull()
65 # main.ONOS1.get_version()
66 # main.ONOS2.get_version()
67 # main.ONOS3.get_version()
68 # main.ONOS4.get_version()
admine8c47d02014-06-03 11:59:16 -070069 main.ONOS1.start_all()
70 main.ONOS2.start_all()
71 main.ONOS3.start_all()
72 main.ONOS4.start_all()
73 main.ONOS2.start_rest()
74 test= main.ONOS2.rest_status()
admin733ae0a2014-04-09 15:01:12 -070075 if test == main.FALSE:
76 main.ONOS1.start_rest()
77 main.ONOS1.get_version()
78 main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections")
admin733ae0a2014-04-09 15:01:12 -070079 main.step("Testing startup Zookeeper")
80 data = main.Zookeeper1.isup()
81 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
82 main.step("Testing startup RamCloud")
Jon Hall5a8aac62014-06-03 09:30:21 -070083 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
admin733ae0a2014-04-09 15:01:12 -070084 if data == main.FALSE:
85 main.RamCloud1.stop_coor()
86 main.RamCloud1.stop_serv()
87 main.RamCloud2.stop_serv()
88 main.RamCloud3.stop_serv()
89 main.RamCloud4.stop_serv()
90
91 time.sleep(5)
92 main.RamCloud1.start_coor()
93 main.RamCloud1.start_serv()
94 main.RamCloud2.start_serv()
95 main.RamCloud3.start_serv()
96 main.RamCloud4.start_serv()
Jon Hall5a8aac62014-06-03 09:30:21 -070097 time.sleep(5)
98 data = main.RamCloud1.status_serv() and main.RamCloud2.status_serv() and main.RamCloud3.status_serv() and main.RamCloud4.status_serv()
99
100
admin733ae0a2014-04-09 15:01:12 -0700101 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...")
102 main.step("Testing startup ONOS")
Jon Hall5a8aac62014-06-03 09:30:21 -0700103 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
adminaef00552014-05-08 09:18:36 -0700104 for i in range(3):
105 if data == main.FALSE:
106 #main.log.report("Something is funny... restarting ONOS")
107 #main.ONOS1.stop()
108 time.sleep(3)
109 #main.ONOS1.start()
110 #time.sleep(5)
Jon Hall5a8aac62014-06-03 09:30:21 -0700111 data = main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup()
adminaef00552014-05-08 09:18:36 -0700112 else:
113 break
admin733ae0a2014-04-09 15:01:12 -0700114 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
adminaef00552014-05-08 09:18:36 -0700115 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700116
117#**********************************************************************************************************************************************************************************************
118#Assign Controllers
119#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>).
120#Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers.
121#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
122# the controllers already assigned to the switch are not specified.
123
124 def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches
125 import time
126 main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4")
127 main.case("Checking if one MN host exists")
128 main.step("Host IP Checking using checkIP")
129 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
130 main.step("Verifying the result")
131 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
132 main.step("assigning ONOS controllers to switches")
133 for i in range(25):
134 if i < 3:
135 j=i+1
136 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
137 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700138 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'])
admin733ae0a2014-04-09 15:01:12 -0700139 elif i >= 3 and i < 5:
140 j=i+1
141 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
142 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700143 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'])
admin733ae0a2014-04-09 15:01:12 -0700144 elif i >= 5 and i < 15:
145 j=i+1
146 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
147 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700148 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'])
admin733ae0a2014-04-09 15:01:12 -0700149 else:
150 j=i+16
151 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
adminf689a272014-06-17 14:08:57 -0700152 time.sleep(2)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700153 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'])
admin733ae0a2014-04-09 15:01:12 -0700154 main.Mininet1.get_sw_controller("s1")
adminf689a272014-06-17 14:08:57 -0700155 time.sleep(30)
admin2580a0e2014-07-29 11:24:34 -0700156
157 main.Zookeeper1.findMaster(switchDPID="00:00:00:00:00:00:10:00")
admin733ae0a2014-04-09 15:01:12 -0700158
159# **********************************************************************************************************************************************************************************************
160#Add Flows
161#Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test
162#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
163
164 def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update
165 main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update")
166 import time
167 main.case("Taking care of these flows!")
168 main.step("Cleaning out any leftover flows...")
adminc6cfc1c2014-04-21 13:55:21 -0700169 #main.ONOS1.delete_flow("all")
admin733ae0a2014-04-09 15:01:12 -0700170 strtTime = time.time()
adminf689a272014-06-17 14:08:57 -0700171 main.ONOS1.rm_intents()
adminc6cfc1c2014-04-21 13:55:21 -0700172 print("world")
adminf689a272014-06-17 14:08:57 -0700173 main.ONOS1.add_intents()
Jon Halle80ef8c2014-04-29 15:29:13 -0700174 time.sleep(2)
adminf689a272014-06-17 14:08:57 -0700175 main.ONOS1.add_intents()
Jon Halle80ef8c2014-04-29 15:29:13 -0700176 print("hello")
adminc6cfc1c2014-04-21 13:55:21 -0700177 # main.ONOS1.add_flow(main.params['FLOWDEF']['testONip'],main.params['FLOWDEF']['user'],main.params['FLOWDEF']['password'],main.params['FLOWDEF']['flowDef'])
admin733ae0a2014-04-09 15:01:12 -0700178 main.case("Checking flows")
adminc6cfc1c2014-04-21 13:55:21 -0700179
admin733ae0a2014-04-09 15:01:12 -0700180 count = 1
181 i = 6
182 while i < 16 :
183 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
184 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
185 if ping == main.FALSE and count < 9:
186 count = count + 1
187 i = 6
188 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
189 time.sleep(2)
190 elif ping == main.FALSE and count ==9:
191 main.log.error("Ping test failed")
192 i = 17
193 result = main.FALSE
194 elif ping == main.TRUE:
195 i = i + 1
196 result = main.TRUE
197 endTime = time.time()
198 if result == main.TRUE:
199 main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds")
200 else:
201 main.log.report("\tFlows failed check")
202
203 result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
204 main.step("Verifying the result")
205 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL")
206
207#**********************************************************************************************************************************************************************************************
208#This test case removes Controllers 2,3, and 4 then performs a ping test.
209#The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned.
210#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.
211#If the ping test fails 6 times, then the test case will return false
212 def CASE41(self,main) :
213 main.log.report("Testing Removal")
adminf689a272014-06-17 14:08:57 -0700214 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700215 main.ONOS2.stop()
adminf689a272014-06-17 14:08:57 -0700216 time.sleep(30)
admin733ae0a2014-04-09 15:01:12 -0700217 main.ONOS3.stop()
adminf689a272014-06-17 14:08:57 -0700218 time.sleep(30)
admin733ae0a2014-04-09 15:01:12 -0700219 main.ONOS4.stop()
adminf689a272014-06-17 14:08:57 -0700220 time.sleep(45)
admin733ae0a2014-04-09 15:01:12 -0700221 strtTime = time.time()
222 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
223 for i in range(10):
224 if result == main.FALSE:
225 time.sleep(5)
226 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
227 else:
228 break
229
230 count = 1
231 i = 6
232 while i < 16 :
233 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
234 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
235 if ping == main.FALSE and count < 6:
236 count = count + 1
237 i = 6
238 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
239 time.sleep(2)
240 elif ping == main.FALSE and count ==6:
241 main.log.error("Ping test failed")
242 i = 17
243 result = main.FALSE
244 elif ping == main.TRUE:
245 i = i + 1
246 result = main.TRUE
247 endTime = time.time()
248 if result == main.TRUE:
249 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
250 else:
251 main.log.report("\tPING TEST FAIL")
252 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
253 time.sleep(10)
254 main.ONOS2.start()
255 main.ONOS3.start()
256 main.ONOS4.start()
adminf689a272014-06-17 14:08:57 -0700257 time.sleep(20)
admin733ae0a2014-04-09 15:01:12 -0700258
259
260 def CASE4(self,main) :
261 main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
262 import time
263 for i in range(25):
264 if i < 15:
265 j=i+1
266 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
267 else:
268 j=i+16
269 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
270
271 strtTime = time.time()
272 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
273 for i in range(10):
274 if result == main.FALSE:
275 time.sleep(5)
276 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
277 else:
278 break
279
280 count = 1
281 i = 6
282 while i < 16 :
283 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
284 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
285 if ping == main.FALSE and count < 6:
286 count = count + 1
287 i = 6
288 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
289 time.sleep(2)
290 elif ping == main.FALSE and count ==6:
291 main.log.error("Ping test failed")
292 i = 17
293 result = main.FALSE
294 elif ping == main.TRUE:
295 i = i + 1
296 result = main.TRUE
297 endTime = time.time()
298 if result == main.TRUE:
299 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
300 else:
301 main.log.report("\tPING TEST FAIL")
302 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
303 time.sleep(10)
304
305# **********************************************************************************************************************************************************************************************
306#This test case restores the controllers removed by Case 4 then performs a ping test.
307
308 def CASE5(self,main) :
309 main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts")
310 import time
adminf689a272014-06-17 14:08:57 -0700311 for i in range(25):
312 if i < 3:
admin733ae0a2014-04-09 15:01:12 -0700313 j=i+1
adminf689a272014-06-17 14:08:57 -0700314 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
315 time.sleep(1)
316 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'])
317 elif i >= 3 and i < 5:
318 j=i+1
319 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2'])
320 time.sleep(1)
321 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'])
322 elif i >= 5 and i < 15:
323 j=i+1
324 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3'])
325 time.sleep(1)
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700326 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'])
admin733ae0a2014-04-09 15:01:12 -0700327 else:
328 j=i+16
adminf689a272014-06-17 14:08:57 -0700329 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4'])
Jon Hall3f6ce3c2014-04-11 18:17:10 -0700330 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'])
adminf689a272014-06-17 14:08:57 -0700331 time.sleep(1)
admin733ae0a2014-04-09 15:01:12 -0700332 strtTime = time.time()
333 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
adminaef00552014-05-08 09:18:36 -0700334 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700335 if result == main.FALSE:
336 time.sleep(5)
337 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
338 else:
339 break
340
341 count = 1
342 i = 6
343 while i < 16 :
344 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
345 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
346 if ping == main.FALSE and count < 6:
347 count = count + 1
348 i = 6
349 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
350 time.sleep(2)
351 elif ping == main.FALSE and count ==6:
352 main.log.error("Ping test failed")
353 i = 17
354 result = main.FALSE
355 elif ping == main.TRUE:
356 i = i + 1
357 result = main.TRUE
358 endTime = time.time()
359 if result == main.TRUE:
360 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
361 else:
362 main.log.report("\tPING TEST FAILED")
363 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
364
365# **********************************************************************************************************************************************************************************************
366#Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time
367
368 def CASE6(self,main) :
369 main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts")
370 import time
371 main.case("Bringing Link down... ")
372 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
373 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
admin2580a0e2014-07-29 11:24:34 -0700374 time.sleep(30)
admin733ae0a2014-04-09 15:01:12 -0700375 strtTime = time.time()
376 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
adminaef00552014-05-08 09:18:36 -0700377 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700378 if result == main.FALSE:
379 time.sleep(5)
380 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
381 else:
382 break
383
384 count = 1
385 i = 6
386 while i < 16 :
387 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
388 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
389 if ping == main.FALSE and count < 10:
390 count = count + 1
391 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
392 i = 6
393 time.sleep(2)
394 elif ping == main.FALSE and count == 10:
395 main.log.error("Ping test failed")
396 i = 17
397 result = main.FALSE
398 elif ping == main.TRUE:
399 i = i + 1
400 result = main.TRUE
401 endTime = time.time()
402 if result == main.TRUE:
403 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
404 else:
405 main.log.report("\tPING TEST FAILED")
406 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
407
408# **********************************************************************************************************************************************************************************************
409#Brings the link that Case 6 took down back up, then runs a ping test to view reroute time
410
411 def CASE7(self,main) :
412 main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts")
413 import time
414 main.case("Bringing Link up... ")
Jon Hall5a8aac62014-06-03 09:30:21 -0700415 result = main.Mininet1.link(END1='s1',END2='s3',OPTION="down")
admin733ae0a2014-04-09 15:01:12 -0700416 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
417 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...")
admin2580a0e2014-07-29 11:24:34 -0700418 time.sleep(30)
admin733ae0a2014-04-09 15:01:12 -0700419 strtTime = time.time()
Jon Hall5a8aac62014-06-03 09:30:21 -0700420 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
421 for i in range(10):
admin733ae0a2014-04-09 15:01:12 -0700422 if result == main.FALSE:
Jon Hall5a8aac62014-06-03 09:30:21 -0700423 time.sleep(15)
adminf689a272014-06-17 14:08:57 -0700424 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
admin733ae0a2014-04-09 15:01:12 -0700425 else:
426 break
427
428 strtTime = time.time()
429 count = 1
430 i = 6
431 while i < 16 :
432 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
433 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
434 if ping == main.FALSE and count < 10:
435 count = count + 1
436 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
437 i = 6
438 time.sleep(2)
439 elif ping == main.FALSE and count ==10:
440 main.log.error("Ping test failed")
441 i = 17
442 result = main.FALSE
443 elif ping == main.TRUE:
444 i = i + 1
445 result = main.TRUE
446 endTime = time.time()
447 if result == main.TRUE:
448 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
449 else:
450 main.log.report("\tPING TESTS FAILED")
adminf689a272014-06-17 14:08:57 -0700451 data = main.Mininet1.link(END1='s1',END2='s3',OPTION="up")
admin733ae0a2014-04-09 15:01:12 -0700452 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
453
454
455# ******************************************************************************************************************************************************************
456# Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch
457
458 def CASE21(self,main) :
459 import json
admin733ae0a2014-04-09 15:01:12 -0700460 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.")
461 main.log.report("Check initially hostMAC/IP exist on the mininet...")
462 host = main.params['YANK']['hostname']
463 mac = main.params['YANK']['hostmac']
admin733ae0a2014-04-09 15:01:12 -0700464 RestIP1 = main.params['RESTCALL']['restIP1']
465 RestPort = main.params['RESTCALL']['restPort']
466 url = main.params['RESTCALL']['restURL']
467
adminf689a272014-06-17 14:08:57 -0700468 t_topowait = 5
469 t_restwait = 5
admin733ae0a2014-04-09 15:01:12 -0700470 main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
471 main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
472 #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort)
473 time.sleep(t_topowait)
Jon Hall208b3a22014-04-16 11:30:24 -0700474 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" )
admin733ae0a2014-04-09 15:01:12 -0700475 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
476 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700477 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
478 main.log.report("Number of host with MAC address = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700479 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700480 main.log.report("\t PASSED - Found host mac = " + mac + "; attached to switchDPID = " +"".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700481 result1 = main.TRUE
482 elif Reststatus > 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700483 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated mac addresses. FAILED")
admin733ae0a2014-04-09 15:01:12 -0700484 main.log.report("switches are: " + "; ".join(Switch))
485 main.log.report("Ports are: " + "; ".join(Port))
admin733ae0a2014-04-09 15:01:12 -0700486 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700487 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700488 main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
489 result1 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700490 else:# check if rest server is working
491 main.log.error("Issue with find host")
492 result1 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700493
494
495 ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 #####
496
497 main.log.report("Yank out s1-eth1")
498 main.case("Yankout s6-eth1 (link to h1) from s1")
499 result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
500 time.sleep(t_topowait)
501 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
502
Jon Hall208b3a22014-04-16 11:30:24 -0700503 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" )
admin733ae0a2014-04-09 15:01:12 -0700504 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
505 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700506 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700507
Jon Hall1c4d2742014-05-22 10:57:05 -0700508 main.log.report("Number of host with MAC = " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700509 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700510 main.log.report("\tFAILED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port))
admin733ae0a2014-04-09 15:01:12 -0700511 result2 = main.FALSE
512 elif Reststatus > 1:
513 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
514 main.log.report("switches are: " + "; ".join(Switch))
515 main.log.report("Ports are: " + "; ".join(Port))
516 main.log.report("MACs are: " + "; ".join(MAC))
517 result2 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700518 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700519 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.")
520 result2 = main.TRUE
Jon Hall208b3a22014-04-16 11:30:24 -0700521 else:# check if rest server is working
522 main.log.error("Issue with find host")
523 result2 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700524
525 ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ######
526 main.log.report("Plug s1-eth1 into s6")
527 main.case("Plug s1-eth1 to s6")
528 result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
529 time.sleep(t_topowait)
530 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700531 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" )
admin733ae0a2014-04-09 15:01:12 -0700532
533 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
534 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700535 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700536
Jon Hall1c4d2742014-05-22 10:57:05 -0700537 main.log.report("Number of host with MAC " + mac + " found by ONOS is: " + str(Reststatus))
admin733ae0a2014-04-09 15:01:12 -0700538 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700539 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700540 result3 = main.TRUE
541 elif Reststatus > 1:
542 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
543 main.log.report("switches are: " + "; ".join(Switch))
544 main.log.report("Ports are: " + "; ".join(Port))
545 main.log.report("MACs are: " + "; ".join(MAC))
546 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700547 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700548 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
549 result3 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700550 else:# check if rest server is working
551 main.log.error("Issue with find host")
552 result3 = main.FALSE
admin733ae0a2014-04-09 15:01:12 -0700553
554 ###### Step to put interface "s1-eth1" back to s1"#####
555 main.log.report("Move s1-eth1 back on to s1")
556 main.case("Move s1-eth1 back to s1")
557 result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
558 time.sleep(t_topowait)
559 result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
560 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
Jon Hall208b3a22014-04-16 11:30:24 -0700561 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" )
admin733ae0a2014-04-09 15:01:12 -0700562
563 ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
564 time.sleep(t_restwait)
Jon Hall1c4d2742014-05-22 10:57:05 -0700565 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url, mac)
admin733ae0a2014-04-09 15:01:12 -0700566
567 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
568 if Reststatus == 1:
Jon Hall1c4d2742014-05-22 10:57:05 -0700569 main.log.report("\tPASSED - Found host MAC = " + mac + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + str(Port[0]))
admin733ae0a2014-04-09 15:01:12 -0700570 result4 = main.TRUE
571 elif Reststatus > 1:
572 main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
573 main.log.report("switches are: " + "; ".join(Switch))
574 main.log.report("Ports are: " + "; ".join(Port))
575 main.log.report("MACs are: " + "; ".join(MAC))
576 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700577 elif Reststatus == 0 and Switch == []:
admin733ae0a2014-04-09 15:01:12 -0700578 main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
579 result4 = main.FALSE
Jon Hall208b3a22014-04-16 11:30:24 -0700580 else:# check if rest server is working
581 main.log.error("Issue with find host")
582 result4 = main.FALSE
Jon Hall5a8aac62014-06-03 09:30:21 -0700583 time.sleep(20)
Jon Hall1c4d2742014-05-22 10:57:05 -0700584 Reststatus, Switch, Port = main.ONOS1.find_host(RestIP1,RestPort,url,mac)
585 main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
586 if Reststatus ==1:
587 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout")
588 elif Reststatus>1:
589 main.log.report("\t FAILED - Host " + host + "with MAC:" + str(mac) + "was still found after expected timeout(multiple found)")
590 elif Reststatus==0:
591 main.log.report("\t PASSED - Device cleared after timeout")
admin733ae0a2014-04-09 15:01:12 -0700592
593 result = result1 and result2 and result3 and result4
594 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
595
596# Run a pure ping test.
597
598 def CASE31(self, main):
599 main.log.report("Performing Ping Test")
600 count = 1
601 i = 6
602 while i < 16 :
603 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
604 strtTime = time.time()
605 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
606 if ping == main.FALSE and count < 6:
607 count = count + 1
608 i = 6
609 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
610 time.sleep(2)
611 elif ping == main.FALSE and count ==6:
612 main.log.error("Ping test failed")
613 i = 17
614 result = main.FALSE
615 elif ping == main.TRUE:
616 i = i + 1
617 result = main.TRUE
618 endTime = time.time()
619 if result == main.TRUE:
620 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
621 else:
622 main.log.report("\tPING TEST FAIL")
623 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
624
admin1723f1c2014-05-19 16:08:39 -0700625
SeanCorcoran29b70542014-05-14 14:53:42 -0700626 def CASE66(self, main):
627 main.log.report("Checking ONOS logs for exceptions")
admin1723f1c2014-05-19 16:08:39 -0700628 count = 0
629 check1 = main.ONOS1.check_exceptions()
630 main.log.report("Exceptions in ONOS1 logs: \n" + check1)
631 check2 = main.ONOS2.check_exceptions()
632 main.log.report("Exceptions in ONOS2 logs: \n" + check2)
633 check3 = main.ONOS3.check_exceptions()
634 main.log.report("Exceptions in ONOS3 logs: \n" + check3)
635 check4 = main.ONOS4.check_exceptions()
636 main.log.report("Exceptions in ONOS4 logs: \n" + check4)
Jon Hall1c4d2742014-05-22 10:57:05 -0700637 result = main.TRUE
admin1723f1c2014-05-19 16:08:39 -0700638 if (check1 or check2 or check3 or check4):
Jon Hall1c4d2742014-05-22 10:57:05 -0700639 result = main.FALSE
admin1723f1c2014-05-19 16:08:39 -0700640 count = len(check1.splitlines()) + len(check2.splitlines()) + len(check3.splitlines()) + len(check4.splitlines())
Jon Hall1c4d2742014-05-22 10:57:05 -0700641 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No Exceptions found in the logs",onfail=str(count) + " Exceptions were found in the logs")
adminf689a272014-06-17 14:08:57 -0700642 main.Mininet1.stop_tcpdump()
admin1723f1c2014-05-19 16:08:39 -0700643
SeanCorcoran29b70542014-05-14 14:53:42 -0700644
adminf689a272014-06-17 14:08:57 -0700645 def CASE8(self,main) :
646 main.log.report("Testing Removal of Zookeeper")
647 main.Zookeeper2.stop()
648 main.Zookeeper3.stop()
649 main.Zookeeper4.stop()
650 strtTime = time.time()
651 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
652 for i in range(10):
653 if result == main.FALSE:
654 time.sleep(5)
655 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
656 else:
657 break
658
659 count = 1
660 i = 6
661 while i < 16 :
662 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
663 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
664 if ping == main.FALSE and count < 6:
665 count = count + 1
666 i = 6
667 main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
668 time.sleep(2)
669 elif ping == main.FALSE and count ==6:
670 main.log.error("Ping test failed")
671 i = 17
672 result = main.FALSE
673 elif ping == main.TRUE:
674 i = i + 1
675 result = main.TRUE
676 endTime = time.time()
677 if result == main.TRUE:
678 main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
679 else:
680 main.log.report("\tPING TEST FAIL")
681 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
682 time.sleep(10)
683 main.Zookeeper2.start()
684 main.Zookeeper3.start()
685 main.Zookeeper4.start()
686 time.sleep(10)
687
688
689 def CASE67(self, main) :
690 main.case("Flapping link s1-s2")
691 main.log.report("Toggling of link s1-s2 multiple times")
692 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
693 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
694 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
695 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
696 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
697 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
698 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
699 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
700 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
701 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
702 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
703 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
704 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
705 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
706 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
707 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
708 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
709 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
710 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
711 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
712 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
713 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
714 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
715 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
716 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
717 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
718 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
719 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
720 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
721 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
722 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
723 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
724 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
725 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
726 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
727 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
728 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
729 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
730 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
731 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
732 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
733 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
734 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
735 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
736 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
737 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
738 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
739 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
740 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
741 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
742 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
743 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
744 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
745 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
746 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
747 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
748 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
749 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
750 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
751 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
752 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
753 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
754 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
755
756 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
757 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
758 for i in range(10):
759 if result == main.FALSE:
760 time.sleep(15)
761 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
762 else:
763 break
764
765 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up")
766 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])))
767 for i in range(10):
768 if result == main.FALSE:
769 time.sleep(15)
770 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])))
771 else:
772 break
773 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
774 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
775 for i in range(10):
776 if result == main.FALSE:
777 time.sleep(15)
778 result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2))
779 else:
780 break
781
782
783
784 def CASE101(self,main) :
785 import time
786 import json
787 import re
788 main.case("Testing the Intent Framework of ONOS")
789
790 main.step("Assigning Master Controllers to the Switches and check")
791 for i in range(25):
792 if i<3:
793 j=i+1
794 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
795 elif i>=3 and i<5:
796 j=i+1
797 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port1'])
798 elif i>=5 and i<15:
799 j=j+1
800 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port1'])
801 else:
802 j=i+16
803 main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port1'])
804 result = main.TRUE
805 for i in range(25):
806 if i<3:
807 j=i+1
808 response=main.Mininet1.get_sw_controller("s"+str(j))
809 print(response)
810 if re.search("tcp:"+main.params['CTRL']['ip1'],response) :
811 result = result and main.TRUE
812 else:
813 result = main.FALSE
814 elif i>=3 and i<5:
815 j=i+1
816 response=main.Mininet1.get_sw_controller("s"+str(j))
817 if re.search("tcp:"+main.params['CTRL']['ip2'],response) :
818 result = result and main.TRUE
819 else:
820 result = main.FALSE
821 elif i>=5 and i<15:
822 j=j+1
823 response=main.Mininet1.get_sw_controller("s"+str(j))
824 if re.search("tcp:"+main.params['CTRL']['ip3'],response) :
825 result = result and main.TRUE
826 else:
827 result = main.FALSE
828 else:
829 j=i+16
830 response=main.Mininet1.get_sw_controller("s"+str(j))
831 if re.search("tcp:"+main.params['CTRL']['ip4'],response) :
832 result = result and main.TRUE
833 else:
834 result = main.FALSE
835 print(result)
836 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Master Controllers assigned Properly",onfail="FAILED TO ASSIGN MASTER CONTROLLERS!")
837
838 main.step("Assigning all Controllers as Backups to Switches and Check")
839 for i in range(25):
840 if i<15:
841 j=i+1
842 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'])
843 else:
844 j=i+16
845 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'])
846 result = main.TRUE
847 for i in range(25):
848 if i<15:
849 j=i+1
850 response=main.Mininet1.get_sw_controller("s"+str(j))
851 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):
852 result = result and main.TRUE
853 else:
854 result = main.FALSE
855 else:
856 j=i+16
857 response=main.Mininet1.get_sw_controller("s"+str(j))
858 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):
859 result = result and main.TRUE
860 else:
861 result = main.FALSE
862 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Controllers assigned properly to all switches",onfail="FAILED TO ASSIGN CONTROLLERS PROPERLY!")
863
864 main.step("Install intents and Check for Installation of Flows")
865 intentIP = main.params['INTENTREST']['intentIP']
866 intentPort=main.params['INTENTREST']['intentPort']
867 intentURL=main.params['INTENTREST']['intentURL']
868 for i in range(6,16):
869 srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2)
870 dstMac = '00:00:00:00:00:'+str(hex(i+25)[2:])
871 # srcDPID=str(i)
872 # dstDPID=str(i+10)
873 srcDPID = '00:00:00:00:00:00:10:'+str(i).zfill(2)
874 dstDPID= '00:00:00:00:00:00:20:' +str(i+25)
875 main.ONOS1.add_intent(intent_id=str(i),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL)
876 result = main.TRUE
877 response = main.Mininet1.check_flows(sw="s1")
878 for i in range(6,16):
879 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):
880 result = result and main.TRUE
881 else:
882 result = main.FALSE
883 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added Properly",onfail="Flows were not added properly")
884
885
886
887 def CASE10(self, main) :
888 import time
889 time.sleep(600)