blob: e6fdec53dda728e45fbb0e8a2ea18b11a0973001 [file] [log] [blame]
Shreya Shah7a6a1872014-10-27 15:25:13 -04001
2#Testing the basic functionality of ONOS Next
3#For sanity and driver functionality excercises only.
4
5import time
6import sys
7import os
8import re
9import time
10import json
11
12time.sleep(1)
13class FuncNext:
14 def __init__(self):
15 self.default = ''
16
17 def CASE1(self, main):
18 '''
19 Startup sequence:
20 git pull
21 mvn clean install
22 onos-package
23 cell <name>
24 onos-verify-cell
25 onos-install -f
26 onos-wait-for-start
27 '''
28
29 cell_name = main.params['ENV']['cellName']
30 ONOS1_ip = main.params['CTRL']['ip1']
31 ONOS1_port = main.params['CTRL']['port1']
32
33 main.case("Setting up test environment")
34
35 main.step("Git checkout and pull master and get version")
36 main.ONOSbench.git_checkout("master")
37 git_pull_result = main.ONOSbench.git_pull()
38 print "git_pull_result = ", git_pull_result
39 version_result = main.ONOSbench.get_version()
40
41 main.step("Using mvn clean & install")
42 #clean_install_result = main.ONOSbench.clean_install()
43 #clean_install_result = main.TRUE
44
45 main.step("Applying cell variable to environment")
46 cell_result1 = main.ONOSbench.set_cell(cell_name)
47 verify_result = main.ONOSbench.verify_cell()
48 cell_result2 = main.ONOS2.set_cell(cell_name)
49 #verify_result = main.ONOS2.verify_cell()
50 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
51
52 cell_result = cell_result1 and cell_result2
53
54 main.step("Creating ONOS package")
55 package_result = main.ONOSbench.onos_package()
56
57 #main.step("Creating a cell")
58 #cell_create_result = main.ONOSbench.create_cell_file(**************)
59
60 main.step("Installing ONOS package")
61 onos_install_result = main.ONOSbench.onos_install()
62 onos1_isup = main.ONOSbench.isup()
63
64 main.step("Starting ONOS service")
65 start_result = main.ONOSbench.onos_start(ONOS1_ip)
66
67 case1_result = (package_result and\
68 cell_result and verify_result and onos_install_result and\
69 onos1_isup and start_result )
70 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
71 onpass="Test startup successful",
72 onfail="Test startup NOT successful")
73
74 def CASE11(self, main):
75 '''
76 Cleanup sequence:
77 onos-service <node_ip> stop
78 onos-uninstall
79
80 TODO: Define rest of cleanup
81
82 '''
83
84 ONOS1_ip = main.params['CTRL']['ip1']
85
86 main.case("Cleaning up test environment")
87
88 main.step("Testing ONOS kill function")
89 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
90
91 main.step("Stopping ONOS service")
92 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
93
94 main.step("Uninstalling ONOS service")
95 uninstall_result = main.ONOSbench.onos_uninstall()
96
97 def CASE3(self, main):
98 '''
99 Test 'onos' command and its functionality in driver
100 '''
101
102 ONOS1_ip = main.params['CTRL']['ip1']
103
104 main.case("Testing 'onos' command")
105
106 main.step("Sending command 'onos -w <onos-ip> system:name'")
107 cmdstr1 = "system:name"
108 cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
109 main.log.info("onos command returned: "+cmd_result1)
110
111 main.step("Sending command 'onos -w <onos-ip> onos:topology'")
112 cmdstr2 = "onos:topology"
113 cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
114 main.log.info("onos command returned: "+cmd_result2)
115
116
117
118 def CASE4(self, main):
119 import re
120 import time
121 main.case("Pingall Test")
122 main.step("Assigning switches to controllers")
123 for i in range(1,29):
124 if i ==1:
125 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
126 elif i>=2 and i<5:
127 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
128 elif i>=5 and i<8:
129 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
130 elif i>=8 and i<18:
131 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
132 elif i>=18 and i<28:
133 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
134 else:
135 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
136 Switch_Mastership = main.TRUE
137 for i in range (1,29):
138 if i==1:
139 response = main.Mininet1.get_sw_controller("s"+str(i))
140 print("Response is " + str(response))
141 if re.search("tcp:"+ONOS1_ip,response):
142 Switch_Mastership = Switch_Mastership and main.TRUE
143 else:
144 Switch_Mastership = main.FALSE
145 elif i>=2 and i<5:
146 response = main.Mininet1.get_sw_controller("s"+str(i))
147 print("Response is " + str(response))
148 if re.search("tcp:"+ONOS1_ip,response):
149 Switch_Mastership = Switch_Mastership and main.TRUE
150 else:
151 Switch_Mastership = main.FALSE
152 elif i>=5 and i<8:
153 response = main.Mininet1.get_sw_controller("s"+str(i))
154 print("Response is " + str(response))
155 if re.search("tcp:"+ONOS1_ip,response):
156 Switch_Mastership = Switch_Mastership and main.TRUE
157 else:
158 Switch_Mastership = main.FALSE
159 elif i>=8 and i<18:
160 response = main.Mininet1.get_sw_controller("s"+str(i))
161 print("Response is " + str(response))
162 if re.search("tcp:"+ONOS1_ip,response):
163 Switch_Mastership = Switch_Mastership and main.TRUE
164 else:
165 Switch_Mastership = main.FALSE
166 elif i>=18 and i<28:
167 response = main.Mininet1.get_sw_controller("s"+str(i))
168 print("Response is " + str(response))
169 if re.search("tcp:"+ONOS1_ip,response):
170 Switch_Mastership = Switch_Mastership and main.TRUE
171 else:
172 Switch_Mastership = main.FALSE
173 else:
174 response = main.Mininet1.get_sw_controller("s"+str(i))
175 print("Response is" + str(response))
176 if re.search("tcp:" +ONOS1_ip,response):
177 Switch_Mastership = Switch_Mastership and main.TRUE
178 else:
179 Switch_Mastership = main.FALSE
180
181 if Switch_Mastership == main.TRUE:
182 main.log.report("MasterControllers assigned correctly")
183 utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
184 onpass="MasterControllers assigned correctly")
185 '''
186 for i in range (1,29):
187 main.Mininet1.assign_sw_controller(sw=str(i),count=5,
188 ip1=ONOS1_ip,port1=ONOS1_port,
189 ip2=ONOS2_ip,port2=ONOS2_port,
190 ip3=ONOS3_ip,port3=ONOS3_port,
191 ip4=ONOS4_ip,port4=ONOS4_port,
192 ip5=ONOS5_ip,port5=ONOS5_port)
193 '''
194 #REACTIVE FWD test
195
196 main.step("Get list of hosts from Mininet")
197 host_list = main.Mininet1.get_hosts()
198 main.log.info(host_list)
199
200 main.step("Get host list in ONOS format")
201 host_onos_list = main.ONOS2.get_hosts_id(host_list)
202 main.log.info(host_onos_list)
203 #time.sleep(5)
204
205 #We must use ping from hosts we want to add intents from
206 #to make the hosts talk
207 #main.Mininet2.handle.sendline("\r")
208 #main.Mininet2.handle.sendline("h4 ping 10.1.1.1 -c 1 -W 1")
209 #time.sleep(3)
210 #main.Mininet2.handle.sendline("h5 ping 10.1.1.1 -c 1 -W 1")
211 #time.sleep(5)
212
213 main.step("Pingall")
214 ping_result = main.FALSE
215 while ping_result == main.FALSE:
216 time1 = time.time()
217 ping_result = main.Mininet1.pingall()
218 time2 = time.time()
219 print "Time for pingall: %2f seconds" % (time2 - time1)
220
221 #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
222 #if there was no activity
223 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
224
225 main.step("Get hosts")
226 main.ONOS2.handle.sendline("hosts")
227 main.ONOS2.handle.expect("onos>")
228 hosts = main.ONOS2.handle.before
229 main.log.info(hosts)
230
231 main.step("Get all devices id")
232 devices_id_list = main.ONOS2.get_all_devices_id()
233 main.log.info(devices_id_list)
234
235 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
236 #So take care while adding intents
237
238 main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
239 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
240 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
241 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
242 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
243 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
244 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
245 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
246 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
247 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
248 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
249
250
251
252 print "_____________________________________________________________________________________"
253 '''
254 main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
255 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
256 if ptp_intent_result == main.TRUE:
257 get_intent_result = main.ONOS2.intents()
258 main.log.info("Point to point intent install successful")
259 main.log.info(get_intent_result)
260
261 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
262 if ptp_intent_result == main.TRUE:
263 get_intent_result = main.ONOS2.intents()
264 main.log.info("Point to point intent install successful")
265 main.log.info(get_intent_result)
266
267 main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
268 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
269 if ptp_intent_result == main.TRUE:
270 get_intent_result = main.ONOS2.intents()
271 main.log.info("Point to point intent install successful")
272 main.log.info(get_intent_result)
273
274 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
275 if ptp_intent_result == main.TRUE:
276 get_intent_result = main.ONOS2.intents()
277 main.log.info("Point to point intent install successful")
278 main.log.info(get_intent_result)
279
280 main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
281 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
282 if ptp_intent_result == main.TRUE:
283 get_intent_result = main.ONOS2.intents()
284 main.log.info("Point to point intent install successful")
285 main.log.info(get_intent_result)
286
287 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
288 if ptp_intent_result == main.TRUE:
289 get_intent_result = main.ONOS2.intents()
290 main.log.info("Point to point intent install successful")
291 main.log.info(get_intent_result)
292
293 main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
294 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
295 if ptp_intent_result == main.TRUE:
296 get_intent_result = main.ONOS2.intents()
297 main.log.info("Point to point intent install successful")
298 main.log.info(get_intent_result)
299
300 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
301 if ptp_intent_result == main.TRUE:
302 get_intent_result = main.ONOS2.intents()
303 main.log.info("Point to point intent install successful")
304 main.log.info(get_intent_result)
305
306 main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
307 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
308 if ptp_intent_result == main.TRUE:
309 get_intent_result = main.ONOS2.intents()
310 main.log.info("Point to point intent install successful")
311 main.log.info(get_intent_result)
312
313 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
314 if ptp_intent_result == main.TRUE:
315 get_intent_result = main.ONOS2.intents()
316 main.log.info("Point to point intent install successful")
317 main.log.info(get_intent_result)
318
319 main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
320 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
321 if ptp_intent_result == main.TRUE:
322 get_intent_result = main.ONOS2.intents()
323 main.log.info("Point to point intent install successful")
324 main.log.info(get_intent_result)
325
326 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
327 if ptp_intent_result == main.TRUE:
328 get_intent_result = main.ONOS2.intents()
329 main.log.info("Point to point intent install successful")
330 main.log.info(get_intent_result)
331
332 main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
333 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
334 if ptp_intent_result == main.TRUE:
335 get_intent_result = main.ONOS2.intents()
336 main.log.info("Point to point intent install successful")
337 main.log.info(get_intent_result)
338
339 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
340 if ptp_intent_result == main.TRUE:
341 get_intent_result = main.ONOS2.intents()
342 main.log.info("Point to point intent install successful")
343 main.log.info(get_intent_result)
344
345 main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
346 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
347 if ptp_intent_result == main.TRUE:
348 get_intent_result = main.ONOS2.intents()
349 main.log.info("Point to point intent install successful")
350 main.log.info(get_intent_result)
351
352 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
353 if ptp_intent_result == main.TRUE:
354 get_intent_result = main.ONOS2.intents()
355 main.log.info("Point to point intent install successful")
356 main.log.info(get_intent_result)
357
358 main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
359 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
360 if ptp_intent_result == main.TRUE:
361 get_intent_result = main.ONOS2.intents()
362 main.log.info("Point to point intent install successful")
363 main.log.info(get_intent_result)
364
365 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
366 if ptp_intent_result == main.TRUE:
367 get_intent_result = main.ONOS2.intents()
368 main.log.info("Point to point intent install successful")
369 main.log.info(get_intent_result)
370
371 main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
372 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
373 if ptp_intent_result == main.TRUE:
374 get_intent_result = main.ONOS2.intents()
375 main.log.info("Point to point intent install successful")
376 main.log.info(get_intent_result)
377
378 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
379 if ptp_intent_result == main.TRUE:
380 get_intent_result = main.ONOS2.intents()
381 main.log.info("Point to point intent install successful")
382 main.log.info(get_intent_result)
383
384 print("_______________________________________________________________________________________")
385 '''
386 #Unistall onos-app-fwd app to disable reactive forwarding
387 appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
388 main.log.info("onos-app-fwd uninstalled")
389
390 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
391 #So sleep for 15s
392 time.sleep(15)
393
394 flowHandle = main.ONOS2.flows()
395 print "flowHandle = ", flowHandle
396
397 count = 1
398 i = 8
399 Ping_Result = main.TRUE
400 #while i<10:
401 while i <18 :
402 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
403 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
404 if ping == main.FALSE and count <5:
405 count+=1
406 i = 8
407 Ping_Result = main.FALSE
408 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
409 time.sleep(2)
410 elif ping==main.FALSE:
411 main.log.report("All ping attempts have failed")
412 i=19
413 Ping_Result = main.FALSE
414 elif ping==main.TRUE:
415 main.log.info("Ping test passed!")
416 i+=1
417 Ping_Result = main.TRUE
418 else:
419 main.log.info("Unknown error")
420 Ping_Result = main.ERROR
421 if Ping_Result==main.FALSE:
422 main.log.report("Intents have not ben installed correctly. Cleaning up")
423 main.cleanup()
424 main.exit()
425 if Ping_Result==main.TRUE:
426 main.log.report("Intents have been installed correctly")
427
428 case4_result = Switch_Mastership and Ping_Result
429 utilities.assert_equals(expect=main.TRUE, actual=case4_result,
430 onpass="Pingall Test successful",
431 onfail="Pingall Test NOT successful")
432
433 def CASE5(self,main) :
434 import json
435 from subprocess import Popen, PIPE
436 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
437 #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
438 deviceResult = main.ONOS2.devices()
439 linksResult = main.ONOS2.links()
440 portsResult = main.ONOS2.ports()
441 print "**************"
442 main.step("Start continuous pings")
443 main.Mininet2.pingLong(src=main.params['PING']['source1'],
444 target=main.params['PING']['target1'],pingTime=500)
445 main.Mininet2.pingLong(src=main.params['PING']['source2'],
446 target=main.params['PING']['target2'],pingTime=500)
447 main.Mininet2.pingLong(src=main.params['PING']['source3'],
448 target=main.params['PING']['target3'],pingTime=500)
449 main.Mininet2.pingLong(src=main.params['PING']['source4'],
450 target=main.params['PING']['target4'],pingTime=500)
451 main.Mininet2.pingLong(src=main.params['PING']['source5'],
452 target=main.params['PING']['target5'],pingTime=500)
453 main.Mininet2.pingLong(src=main.params['PING']['source6'],
454 target=main.params['PING']['target6'],pingTime=500)
455 main.Mininet2.pingLong(src=main.params['PING']['source7'],
456 target=main.params['PING']['target7'],pingTime=500)
457 main.Mininet2.pingLong(src=main.params['PING']['source8'],
458 target=main.params['PING']['target8'],pingTime=500)
459 main.Mininet2.pingLong(src=main.params['PING']['source9'],
460 target=main.params['PING']['target9'],pingTime=500)
461 main.Mininet2.pingLong(src=main.params['PING']['source10'],
462 target=main.params['PING']['target10'],pingTime=500)
463
464 main.step("Create TestONTopology object")
465 global ctrls
466 ctrls = []
467 count = 1
468 while True:
469 temp = ()
470 if ('ip' + str(count)) in main.params['CTRL']:
471 temp = temp + (getattr(main,('ONOS' + str(count))),)
472 temp = temp + ("ONOS"+str(count),)
473 temp = temp + (main.params['CTRL']['ip'+str(count)],)
474 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
475 ctrls.append(temp)
476 count = count + 1
477 else:
478 break
479 global MNTopo
480 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
481 MNTopo = Topo
482
483 Topology_Check = main.TRUE
484 main.step("Compare ONOS Topology to MN Topology")
485 devices_json = main.ONOS2.devices()
486 links_json = main.ONOS2.links()
487 ports_json = main.ONOS2.ports()
488 print "devices_json= ", devices_json
489
490 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
491 print "***********************"
492 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
493 print "***********************"
494 result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
495
496 result = result1 and result2 and result3
497 print "***********************"
498 if result == main.TRUE:
499 main.log.report("ONOS"+ " Topology matches MN Topology")
500 utilities.assert_equals(expect=main.TRUE,actual=result,
501 onpass="ONOS" + " Topology matches MN Topology",
502 onfail="ONOS" + " Topology does not match MN Topology")
503 Topology_Check = Topology_Check and result
504 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
505 onpass="Topology checks passed", onfail="Topology checks failed")
506
507
508 def CASE7 (self,main):
509
510 ONOS1_ip = main.params['CTRL']['ip1']
511
512 link_sleep = int(main.params['timers']['LinkDiscovery'])
513
514 main.log.report("Killing a link to ensure that link discovery is consistent")
515 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
516 main.step("Start continuous pings")
517
518 main.Mininet2.pingLong(src=main.params['PING']['source1'],
519 target=main.params['PING']['target1'],pingTime=500)
520 main.Mininet2.pingLong(src=main.params['PING']['source2'],
521 target=main.params['PING']['target2'],pingTime=500)
522 main.Mininet2.pingLong(src=main.params['PING']['source3'],
523 target=main.params['PING']['target3'],pingTime=500)
524 main.Mininet2.pingLong(src=main.params['PING']['source4'],
525 target=main.params['PING']['target4'],pingTime=500)
526 main.Mininet2.pingLong(src=main.params['PING']['source5'],
527 target=main.params['PING']['target5'],pingTime=500)
528 main.Mininet2.pingLong(src=main.params['PING']['source6'],
529 target=main.params['PING']['target6'],pingTime=500)
530 main.Mininet2.pingLong(src=main.params['PING']['source7'],
531 target=main.params['PING']['target7'],pingTime=500)
532 main.Mininet2.pingLong(src=main.params['PING']['source8'],
533 target=main.params['PING']['target8'],pingTime=500)
534 main.Mininet2.pingLong(src=main.params['PING']['source9'],
535 target=main.params['PING']['target9'],pingTime=500)
536 main.Mininet2.pingLong(src=main.params['PING']['source10'],
537 target=main.params['PING']['target10'],pingTime=500)
538
539
540 main.step("Determine the current number of switches and links")
541 topology_output = main.ONOS2.topology()
542 topology_result = main.ONOS1.get_topology(topology_output)
543 activeSwitches = topology_result['devices']
544 links = topology_result['links']
545 print "activeSwitches = ", type(activeSwitches)
546 print "links = ", type(links)
547 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
548
549 main.step("Kill Link between s3 and s28")
550 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
551 time.sleep(link_sleep)
552 topology_output = main.ONOS2.topology()
553 Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
554 if Link_Down == main.TRUE:
555 main.log.report("Link Down discovered properly")
556 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
557 onpass="Link Down discovered properly",
558 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
559
560 main.step("Bring link between s3 and s28 back up")
561 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
562 time.sleep(link_sleep)
563 topology_output = main.ONOS2.topology()
564 Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
565 if Link_Up == main.TRUE:
566 main.log.report("Link up discovered properly")
567 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
568 onpass="Link up discovered properly",
569 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
570
571
572
573
574 main.step("Compare ONOS Topology to MN Topology")
575 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
576 MNTopo = Topo
577 Topology_Check = main.TRUE
578 devices_json = main.ONOS2.devices()
579 links_json = main.ONOS2.links()
580 ports_json = main.ONOS2.ports()
581 print "devices_json= ", devices_json
582
583 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
584 print "***********************"
585 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
586 print "***********************"
587 result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
588
589 result = result1 and result2 and result3
590 print "***********************"
591 if result == main.TRUE:
592 main.log.report("ONOS"+ " Topology matches MN Topology")
593 utilities.assert_equals(expect=main.TRUE,actual=result,
594 onpass="ONOS" + " Topology matches MN Topology",
595 onfail="ONOS" + " Topology does not match MN Topology")
596 Topology_Check = Topology_Check and result
597 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
598 onpass="Topology checks passed", onfail="Topology checks failed")
599
600 result = Link_Down and Link_Up and Topology_Check
601 utilities.assert_equals(expect=main.TRUE,actual=result,
602 onpass="Link failure is discovered correctly",
603 onfail="Link Discovery failed")
604
605
606