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