blob: 05c420ebe2975f69aaae867c04be07a751899950 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -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
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
11time.sleep(1)
12class ProdFunc:
13 def __init__(self):
14 self.default = ''
15
16 def CASE1(self, main):
17 '''
18 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080019 cell <name>
20 onos-verify-cell
21 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080022 git pull
23 mvn clean install
24 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080025 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 main.log.report("This testcase is testing setting up test environment")
35 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -080036
37 main.step("Applying cell variable to environment")
shahshreyaf1b1b9f2014-12-04 16:59:20 -080038 cell_result = main.ONOSbench.set_cell(cell_name)
shahshreyae6c7cf42014-11-26 16:39:01 -080039 verify_result = main.ONOSbench.verify_cell()
shahshreyae6c7cf42014-11-26 16:39:01 -080040
41 main.step("Removing raft logs before a clen installation of ONOS")
42 main.ONOSbench.onos_remove_raft_logs()
43
shahshreya4e13a062014-11-11 16:46:18 -080044 main.step("Git checkout and pull master and get version")
45 main.ONOSbench.git_checkout("master")
46 git_pull_result = main.ONOSbench.git_pull()
47 print "git_pull_result = ", git_pull_result
48 version_result = main.ONOSbench.get_version(report=True)
49
50 if git_pull_result == 1:
51 main.step("Using mvn clean & install")
52 clean_install_result = main.ONOSbench.clean_install()
53 #clean_install_result = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -080054
shahshreya4e13a062014-11-11 16:46:18 -080055 main.step("Creating ONOS package")
56 package_result = main.ONOSbench.onos_package()
57
shahshreya4e13a062014-11-11 16:46:18 -080058
59 main.step("Installing ONOS package")
60 onos_install_result = main.ONOSbench.onos_install()
61 if onos_install_result == main.TRUE:
62 main.log.report("Installing ONOS package successful")
63 else:
64 main.log.report("Installing ONOS package failed")
65
66 onos1_isup = main.ONOSbench.isup()
67 if onos1_isup == main.TRUE:
68 main.log.report("ONOS instance is up and ready")
69 else:
70 main.log.report("ONOS instance may not be up")
71
72 main.step("Starting ONOS service")
73 start_result = main.ONOSbench.onos_start(ONOS1_ip)
shahshreyae6c7cf42014-11-26 16:39:01 -080074
75 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
shahshreya4e13a062014-11-11 16:46:18 -080076
77 case1_result = (package_result and\
78 cell_result and verify_result and onos_install_result and\
79 onos1_isup and start_result )
80 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
81 onpass="Test startup successful",
82 onfail="Test startup NOT successful")
83
84 def CASE11(self, main):
85 '''
86 Cleanup sequence:
87 onos-service <node_ip> stop
88 onos-uninstall
89
90 TODO: Define rest of cleanup
91
92 '''
93
94 ONOS1_ip = main.params['CTRL']['ip1']
95
96 main.case("Cleaning up test environment")
97
98 main.step("Testing ONOS kill function")
99 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
100
101 main.step("Stopping ONOS service")
102 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
103
104 main.step("Uninstalling ONOS service")
105 uninstall_result = main.ONOSbench.onos_uninstall()
106
107 def CASE3(self, main):
108 '''
109 Test 'onos' command and its functionality in driver
110 '''
111
112 ONOS1_ip = main.params['CTRL']['ip1']
113
114 main.case("Testing 'onos' command")
115
116 main.step("Sending command 'onos -w <onos-ip> system:name'")
117 cmdstr1 = "system:name"
118 cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
119 main.log.info("onos command returned: "+cmd_result1)
120
121 main.step("Sending command 'onos -w <onos-ip> onos:topology'")
122 cmdstr2 = "onos:topology"
123 cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
124 main.log.info("onos command returned: "+cmd_result2)
125
126
shahshreyae6c7cf42014-11-26 16:39:01 -0800127 def CASE20(self):
128 '''
129 Exit from mininet cli
130 reinstall ONOS
131 '''
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800132 cell_name = main.params['ENV']['cellName']
133 ONOS1_ip = main.params['CTRL']['ip1']
134 ONOS1_port = main.params['CTRL']['port1']
135
shahshreyae6c7cf42014-11-26 16:39:01 -0800136 main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
137 main.log.report("_____________________________________________")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800138 main.case("Disconnecting mininet and restarting ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800139 main.step("Disconnecting mininet and restarting ONOS")
140 mininet_disconnect = main.Mininet1.disconnect()
141
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800142 main.step("Removing raft logs before a clen installation of ONOS")
143 main.ONOSbench.onos_remove_raft_logs()
144
shahshreyae6c7cf42014-11-26 16:39:01 -0800145 main.step("Applying cell variable to environment")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800146 cell_result = main.ONOSbench.set_cell(cell_name)
shahshreyae6c7cf42014-11-26 16:39:01 -0800147 verify_result = main.ONOSbench.verify_cell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800148
149 onos_install_result = main.ONOSbench.onos_install()
150 if onos_install_result == main.TRUE:
151 main.log.report("Installing ONOS package successful")
152 else:
153 main.log.report("Installing ONOS package failed")
154
155 onos1_isup = main.ONOSbench.isup()
156 if onos1_isup == main.TRUE:
157 main.log.report("ONOS instance is up and ready")
158 else:
159 main.log.report("ONOS instance may not be up")
160
161 main.step("Starting ONOS service")
162 start_result = main.ONOSbench.onos_start(ONOS1_ip)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800163
164 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
shahshreyae6c7cf42014-11-26 16:39:01 -0800165 print "mininet_disconnect =", mininet_disconnect
166 print "onos_install_result =", onos_install_result
167 print "onos1_isup =", onos1_isup
168 print "start_result =", start_result
169
170 case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
171 utilities.assert_equals(expect=main.TRUE, actual=case20_result,
172 onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
173 onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
174
175 def CASE21(self, main):
176 import time
177 '''
178 On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
179 which starts the rest and copies the links json file to the onos instance
180 Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
181 from the json config file
182 '''
183 main.log.report("This testcase starts the packet layer topology and REST")
184 main.log.report("_____________________________________________")
185 main.case("Starting LINC-OE and other components")
186 main.step("Starting LINC-OE and other components")
187 start_console_result = main.LincOE1.start_console()
188 optical_mn_script = main.LincOE2.run_optical_mn_script()
189 onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
190
191 print "start_console_result =",start_console_result
192 print "optical_mn_script = ",optical_mn_script
193 print "onos_topo_cfg_result =",onos_topo_cfg_result
194
195 case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
196 utilities.assert_equals(expect=main.TRUE, actual=case21_result,
197 onpass="Packet optical topology spawned successsfully",
198 onfail="Packet optical topology spawning failed")
199
200
201 def CASE22(self, main):
202 '''
203 Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
204 Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
205 and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
206 '''
207
208 main.log.report("This testcase compares the optical+packet topology against what is expected")
209 main.case("Topology comparision")
210 main.step("Topology comparision")
211 main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
212 devices_result = main.ONOS3.devices(json_format = False)
213
214 print "devices_result = ", devices_result
215 devices_linewise = devices_result.split("\n")
216 devices_linewise = devices_linewise[1:-1]
217 roadmCount = 0
218 packetLayerSWCount = 0
219 for line in devices_linewise:
220 components = line.split(",")
221 availability = components[1].split("=")[1]
222 type = components[3].split("=")[1]
223 if availability == 'true' and type == 'ROADM':
224 roadmCount += 1
225 elif availability == 'true' and type =='SWITCH':
226 packetLayerSWCount += 1
227 if roadmCount == 4:
228 print "Number of Optical Switches = %d and is correctly detected" %roadmCount
229 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
230 opticalSW_result = main.TRUE
231 else:
232 print "Number of Optical Switches = %d and is wrong" %roadCount
233 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
234 opticalSW_result = main.FALSE
235
236 if packetLayerSWCount == 2:
237 print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
238 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
239 packetSW_result = main.TRUE
240 else:
241 print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
242 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
243 packetSW_result = main.FALSE
244 print "_________________________________"
245
246 links_result = main.ONOS3.links(json_format = False)
247 print "links_result = ", links_result
248 print "_________________________________"
249
250
251
252 #Discover hosts using pingall
253 pingall_result = main.LincOE2.pingall()
254
255 hosts_result = main.ONOS3.hosts(json_format = False)
256 main.log.info("hosts_result = "+hosts_result)
257 main.log.info("_________________________________")
258 hosts_linewise = hosts_result.split("\n")
259 hosts_linewise = hosts_linewise[1:-1]
260 hostCount = 0
261 for line in hosts_linewise:
262 hostid = line.split(",")[0].split("=")[1]
263 hostCount +=1
264 if hostCount ==2:
265 print "Number of hosts = %d and is correctly detected" %hostCount
266 main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
267 hostDiscovery = main.TRUE
268 else:
269 print "Number of hosts = %d and is wrong" %hostCount
270 main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
271 hostDiscovery = main.FALSE
272
273 case22_result = opticalSW_result and packetSW_result and hostDiscovery
274 utilities.assert_equals(expect=main.TRUE, actual=case22_result,
275 onpass="Packet optical topology discovery successful",
276 onfail="Packet optical topology discovery failed")
277
278 def CASE23(self, main):
279 import time
280 '''
281 Add bidirectional point intents between 2 packet layer(mininet) devices and
282 ping mininet hosts
283 '''
284 main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
285 main.case("Topology comparision")
286 main.step("Adding point intents")
287 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
288 if ptp_intent_result == main.TRUE:
289 get_intent_result = main.ONOS3.intents()
290 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800291
292 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
293 if ptp_intent_result == main.TRUE:
294 get_intent_result = main.ONOS3.intents()
295 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800296
297 time.sleep(10)
298 flowHandle = main.ONOS3.flows()
shahshreyae6c7cf42014-11-26 16:39:01 -0800299 main.log.info("flows :" + flowHandle)
300
301 # Sleep for 30 seconds to provide time for the intent state to change
302 time.sleep(30)
303 intentHandle = main.ONOS3.intents()
304 main.log.info("intents :" + intentHandle)
305
306 Ping_Result = main.TRUE
307 count = 1
308 main.log.info("\n\nh1 is Pinging h2")
309 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
310 #ping = main.LincOE2.pinghost()
311 if ping == main.FALSE and count<5:
312 count+=1
313 Ping_Result = main.FALSE
314 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
315 time.sleep(2)
316 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
317 #ping = main.LincOE2.pinghost()
318 elif ping==main.FALSE:
319 main.log.info("All ping attempts between h1 and h2 have failed")
320 Ping_Result = main.FALSE
321 elif ping==main.TRUE:
322 main.log.info("Ping test between h1 and h2 passed!")
323 Ping_Result = main.TRUE
324 else:
325 main.log.info("Unknown error")
326 Ping_Result = main.ERROR
327
328 if Ping_Result==main.FALSE:
329 main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
330 if Ping_Result==main.TRUE:
331 main.log.report("Point Intents for packet optical have been installed correctly")
332
333 case23_result = Ping_Result
334 utilities.assert_equals(expect=main.TRUE, actual=case23_result,
335 onpass="Point intents addition for packet optical and Pingall Test successful",
336 onfail="Point intents addition for packet optical and Pingall Test NOT successful")
337
338
339
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800340 def CASE24(self, main):
341 import time
342 import json
343 '''
344 Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
345 and do a ping test. If rerouting is successful, ping should pass. also check the flows
346 '''
347 main.log.report("This testcase tests rerouting and pings mininet hosts")
348 main.step("Test rerouting and pings mininet hosts")
349 main.case("Bring a port down and verify the link state")
350 main.LincOE1.port_down(sw_id="1", pt_id="22")
351 links = main.ONOS3.links()
352 main.log.info(main.ONOS3.links)
shahshreyae6c7cf42014-11-26 16:39:01 -0800353
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800354 links_result = json.loads(links)
355 links_state_result = main.FALSE
356 for item in links_result:
357 if item['src'] == "of:0000ffffffffff01/22" and item['dst'] == "of:0000ffffffffff04/30":
358 links_state = item['state']
359 if links_state == "INACTIVE":
360 main.log.info("Links state is inactive as expected due to one of the ports being down")
361 main.log.report("Links state is inactive as expected due to one of the ports being down")
362 links_state_result = main.TRUE
363 break
364 else:
365 main.log.info("Links state is not inactive as expected")
366 main.log.report("Links state is not inactive as expected")
367 links_state_result = main.FALSE
368
369 print "links_state_result = ", links_state_result
370 main.case("Verify Rerouting by a ping test")
371 Ping_Result = main.TRUE
372 count = 1
373 main.log.info("\n\nh1 is Pinging h2")
374 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
375 #ping = main.LincOE2.pinghost()
376 if ping == main.FALSE and count<5:
377 count+=1
378 Ping_Result = main.FALSE
379 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
380 time.sleep(2)
381 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
382 #ping = main.LincOE2.pinghost()
383 elif ping==main.FALSE:
384 main.log.info("All ping attempts between h1 and h2 have failed")
385 Ping_Result = main.FALSE
386 elif ping==main.TRUE:
387 main.log.info("Ping test between h1 and h2 passed!")
388 Ping_Result = main.TRUE
389 else:
390 main.log.info("Unknown error")
391 Ping_Result = main.ERROR
392
393 if Ping_Result==main.FALSE:
394 main.log.report("Ping test successful ")
395 if Ping_Result==main.TRUE:
396 main.log.report("Ping test failed")
397
398 case24_result = Ping_Result and links_state_result
399 utilities.assert_equals(expect=main.TRUE, actual=case24_result,
400 onpass="Packet optical rerouting successful",
401 onfail="Packet optical rerouting failed")
shahshreya4e13a062014-11-11 16:46:18 -0800402
403 def CASE4(self, main):
404 import re
405 import time
406 main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
407 main.log.report("__________________________________")
408 main.case("Pingall Test")
409 main.step("Assigning switches to controllers")
410 for i in range(1,29):
411 if i ==1:
412 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
413 elif i>=2 and i<5:
414 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
415 elif i>=5 and i<8:
416 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
417 elif i>=8 and i<18:
418 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
419 elif i>=18 and i<28:
420 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
421 else:
422 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
423 Switch_Mastership = main.TRUE
424 for i in range (1,29):
425 if i==1:
426 response = main.Mininet1.get_sw_controller("s"+str(i))
427 print("Response is " + str(response))
428 if re.search("tcp:"+ONOS1_ip,response):
429 Switch_Mastership = Switch_Mastership and main.TRUE
430 else:
431 Switch_Mastership = main.FALSE
432 elif i>=2 and i<5:
433 response = main.Mininet1.get_sw_controller("s"+str(i))
434 print("Response is " + str(response))
435 if re.search("tcp:"+ONOS1_ip,response):
436 Switch_Mastership = Switch_Mastership and main.TRUE
437 else:
438 Switch_Mastership = main.FALSE
439 elif i>=5 and i<8:
440 response = main.Mininet1.get_sw_controller("s"+str(i))
441 print("Response is " + str(response))
442 if re.search("tcp:"+ONOS1_ip,response):
443 Switch_Mastership = Switch_Mastership and main.TRUE
444 else:
445 Switch_Mastership = main.FALSE
446 elif i>=8 and i<18:
447 response = main.Mininet1.get_sw_controller("s"+str(i))
448 print("Response is " + str(response))
449 if re.search("tcp:"+ONOS1_ip,response):
450 Switch_Mastership = Switch_Mastership and main.TRUE
451 else:
452 Switch_Mastership = main.FALSE
453 elif i>=18 and i<28:
454 response = main.Mininet1.get_sw_controller("s"+str(i))
455 print("Response is " + str(response))
456 if re.search("tcp:"+ONOS1_ip,response):
457 Switch_Mastership = Switch_Mastership and main.TRUE
458 else:
459 Switch_Mastership = main.FALSE
460 else:
461 response = main.Mininet1.get_sw_controller("s"+str(i))
462 print("Response is" + str(response))
463 if re.search("tcp:" +ONOS1_ip,response):
464 Switch_Mastership = Switch_Mastership and main.TRUE
465 else:
466 Switch_Mastership = main.FALSE
467
468 if Switch_Mastership == main.TRUE:
469 main.log.report("Controller assignmnet successful")
470 else:
471 main.log.report("Controller assignmnet failed")
472 utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
473 onpass="MasterControllers assigned correctly")
474 '''
475 for i in range (1,29):
476 main.Mininet1.assign_sw_controller(sw=str(i),count=5,
477 ip1=ONOS1_ip,port1=ONOS1_port,
478 ip2=ONOS2_ip,port2=ONOS2_port,
479 ip3=ONOS3_ip,port3=ONOS3_port,
480 ip4=ONOS4_ip,port4=ONOS4_port,
481 ip5=ONOS5_ip,port5=ONOS5_port)
482 '''
483 #REACTIVE FWD test
484
485 main.step("Get list of hosts from Mininet")
486 host_list = main.Mininet1.get_hosts()
487 main.log.info(host_list)
488
489 main.step("Get host list in ONOS format")
490 host_onos_list = main.ONOS2.get_hosts_id(host_list)
491 main.log.info(host_onos_list)
492 #time.sleep(5)
493
494 main.step("Pingall")
495 ping_result = main.FALSE
496 while ping_result == main.FALSE:
497 time1 = time.time()
498 ping_result = main.Mininet1.pingall()
499 time2 = time.time()
500 print "Time for pingall: %2f seconds" % (time2 - time1)
501
502 #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
503 #if there was no activity
504 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
505
506 case4_result = Switch_Mastership and ping_result
507 if ping_result == main.TRUE:
508 main.log.report("Pingall Test in reactive mode to discover the hosts successful")
509 else:
510 main.log.report("Pingall Test in reactive mode to discover the hosts failed")
511
shahshreyae6c7cf42014-11-26 16:39:01 -0800512 utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
513
514 def CASE10(self):
515 main.log.report("This testcase uninstalls the reactive forwarding app")
516 main.log.report("__________________________________")
517 main.case("Uninstalling reactive forwarding app")
518 #Unistall onos-app-fwd app to disable reactive forwarding
519 appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
520 main.log.info("onos-app-fwd uninstalled")
521
522 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
523 #So sleep for 15s
524 time.sleep(15)
525
526 flows = main.ONOS2.flows()
527 main.log.info(flows)
528
529 case10_result = appUninstall_result
530 utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
shahshreya4e13a062014-11-11 16:46:18 -0800531
532
533 def CASE6(self):
shahshreyae6c7cf42014-11-26 16:39:01 -0800534 main.log.report("This testcase is testing the addition of host intents and then does pingall")
shahshreya4e13a062014-11-11 16:46:18 -0800535 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -0800536 main.case("Obtaining host id's")
shahshreya4e13a062014-11-11 16:46:18 -0800537 main.step("Get hosts")
shahshreyae6c7cf42014-11-26 16:39:01 -0800538 hosts = main.ONOS2.hosts()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800539 #main.log.info(hosts)
shahshreya4e13a062014-11-11 16:46:18 -0800540
541 main.step("Get all devices id")
542 devices_id_list = main.ONOS2.get_all_devices_id()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800543 #main.log.info(devices_id_list)
shahshreya4e13a062014-11-11 16:46:18 -0800544
545 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
546 #So take care while adding intents
shahshreyae6c7cf42014-11-26 16:39:01 -0800547 '''
shahshreya4e13a062014-11-11 16:46:18 -0800548 main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
549 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
550 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
551 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
552 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
553 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
554 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
555 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
556 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
557 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
558 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
shahshreya4e13a062014-11-11 16:46:18 -0800559 print "_____________________________________________________________________________________"
shahshreyae6c7cf42014-11-26 16:39:01 -0800560 '''
shahshreya4e13a062014-11-11 16:46:18 -0800561
shahshreyae6c7cf42014-11-26 16:39:01 -0800562 for i in range(8,18):
563 main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
564 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
565 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
566 #NOTE: get host can return None
567 #TODO: handle this
568 host1_id = main.ONOS2.get_host(host1)['id']
569 host2_id = main.ONOS2.get_host(host2)['id']
570 tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800571
shahshreyae6c7cf42014-11-26 16:39:01 -0800572 time.sleep(10)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800573 h_intents = main.ONOS2.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800574 main.log.info("intents:" +h_intents)
shahshreya4e13a062014-11-11 16:46:18 -0800575 flowHandle = main.ONOS2.flows()
shahshreyae6c7cf42014-11-26 16:39:01 -0800576 #main.log.info("flow:" +flowHandle)
shahshreya4e13a062014-11-11 16:46:18 -0800577
578 count = 1
579 i = 8
580 Ping_Result = main.TRUE
581 #while i<10:
582 while i <18 :
583 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
584 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
585 if ping == main.FALSE and count <5:
586 count+=1
587 #i = 8
588 Ping_Result = main.FALSE
589 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
590 time.sleep(2)
591 elif ping==main.FALSE:
592 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
593 i=19
594 Ping_Result = main.FALSE
595 elif ping==main.TRUE:
596 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
597 i+=1
598 Ping_Result = main.TRUE
599 else:
600 main.log.info("Unknown error")
601 Ping_Result = main.ERROR
602 if Ping_Result==main.FALSE:
603 main.log.report("Ping all test after Host intent addition failed. Cleaning up")
604 #main.cleanup()
605 #main.exit()
606 if Ping_Result==main.TRUE:
607 main.log.report("Ping all test after Host intent addition successful")
608
609 case6_result = Ping_Result
shahshreyae6c7cf42014-11-26 16:39:01 -0800610 utilities.assert_equals(expect=main.TRUE, actual=case6_result,
shahshreya4e13a062014-11-11 16:46:18 -0800611 onpass="Pingall Test after Host intents addition successful",
612 onfail="Pingall Test after Host intents addition failed")
613
614
615 def CASE5(self,main) :
616 import json
617 from subprocess import Popen, PIPE
618 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
619 #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
620 deviceResult = main.ONOS2.devices()
621 linksResult = main.ONOS2.links()
622 #portsResult = main.ONOS2.ports()
623 print "**************"
624
625 main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
626 main.log.report("__________________________________")
627 main.case("Comparing Mininet topology with the topology of ONOS")
628 main.step("Start continuous pings")
629 main.Mininet2.pingLong(src=main.params['PING']['source1'],
630 target=main.params['PING']['target1'],pingTime=500)
631 main.Mininet2.pingLong(src=main.params['PING']['source2'],
632 target=main.params['PING']['target2'],pingTime=500)
633 main.Mininet2.pingLong(src=main.params['PING']['source3'],
634 target=main.params['PING']['target3'],pingTime=500)
635 main.Mininet2.pingLong(src=main.params['PING']['source4'],
636 target=main.params['PING']['target4'],pingTime=500)
637 main.Mininet2.pingLong(src=main.params['PING']['source5'],
638 target=main.params['PING']['target5'],pingTime=500)
639 main.Mininet2.pingLong(src=main.params['PING']['source6'],
640 target=main.params['PING']['target6'],pingTime=500)
641 main.Mininet2.pingLong(src=main.params['PING']['source7'],
642 target=main.params['PING']['target7'],pingTime=500)
643 main.Mininet2.pingLong(src=main.params['PING']['source8'],
644 target=main.params['PING']['target8'],pingTime=500)
645 main.Mininet2.pingLong(src=main.params['PING']['source9'],
646 target=main.params['PING']['target9'],pingTime=500)
647 main.Mininet2.pingLong(src=main.params['PING']['source10'],
648 target=main.params['PING']['target10'],pingTime=500)
649
650 main.step("Create TestONTopology object")
651 global ctrls
652 ctrls = []
653 count = 1
654 while True:
655 temp = ()
656 if ('ip' + str(count)) in main.params['CTRL']:
657 temp = temp + (getattr(main,('ONOS' + str(count))),)
658 temp = temp + ("ONOS"+str(count),)
659 temp = temp + (main.params['CTRL']['ip'+str(count)],)
660 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
661 ctrls.append(temp)
662 count = count + 1
663 else:
664 break
665 global MNTopo
666 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
667 MNTopo = Topo
668
669 Topology_Check = main.TRUE
670 main.step("Compare ONOS Topology to MN Topology")
671 devices_json = main.ONOS2.devices()
672 links_json = main.ONOS2.links()
673 #ports_json = main.ONOS2.ports()
674 print "devices_json= ", devices_json
675
676 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
677 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
678 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
679
680 #result = result1 and result2 and result3
681 result = result1 and result2
682
683 print "***********************"
684 if result == main.TRUE:
685 main.log.report("ONOS"+ " Topology matches MN Topology")
686 else:
687 main.log.report("ONOS"+ " Topology does not match MN Topology")
688
689 utilities.assert_equals(expect=main.TRUE,actual=result,
690 onpass="ONOS" + " Topology matches MN Topology",
691 onfail="ONOS" + " Topology does not match MN Topology")
692
693 Topology_Check = Topology_Check and result
694 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
695 onpass="Topology checks passed", onfail="Topology checks failed")
696
697
698 def CASE7 (self,main):
699
700 ONOS1_ip = main.params['CTRL']['ip1']
701
702 link_sleep = int(main.params['timers']['LinkDiscovery'])
703
704 main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
705 main.log.report("__________________________________")
706 main.log.report("Killing a link to ensure that link discovery is consistent")
707 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
shahshreyae6c7cf42014-11-26 16:39:01 -0800708 '''
shahshreya4e13a062014-11-11 16:46:18 -0800709 main.step("Start continuous pings")
710
711 main.Mininet2.pingLong(src=main.params['PING']['source1'],
712 target=main.params['PING']['target1'],pingTime=500)
713 main.Mininet2.pingLong(src=main.params['PING']['source2'],
714 target=main.params['PING']['target2'],pingTime=500)
715 main.Mininet2.pingLong(src=main.params['PING']['source3'],
716 target=main.params['PING']['target3'],pingTime=500)
717 main.Mininet2.pingLong(src=main.params['PING']['source4'],
718 target=main.params['PING']['target4'],pingTime=500)
719 main.Mininet2.pingLong(src=main.params['PING']['source5'],
720 target=main.params['PING']['target5'],pingTime=500)
721 main.Mininet2.pingLong(src=main.params['PING']['source6'],
722 target=main.params['PING']['target6'],pingTime=500)
723 main.Mininet2.pingLong(src=main.params['PING']['source7'],
724 target=main.params['PING']['target7'],pingTime=500)
725 main.Mininet2.pingLong(src=main.params['PING']['source8'],
726 target=main.params['PING']['target8'],pingTime=500)
727 main.Mininet2.pingLong(src=main.params['PING']['source9'],
728 target=main.params['PING']['target9'],pingTime=500)
729 main.Mininet2.pingLong(src=main.params['PING']['source10'],
730 target=main.params['PING']['target10'],pingTime=500)
shahshreyae6c7cf42014-11-26 16:39:01 -0800731 '''
shahshreya4e13a062014-11-11 16:46:18 -0800732
733 main.step("Determine the current number of switches and links")
734 topology_output = main.ONOS2.topology()
735 topology_result = main.ONOS1.get_topology(topology_output)
736 activeSwitches = topology_result['devices']
737 links = topology_result['links']
738 print "activeSwitches = ", type(activeSwitches)
739 print "links = ", type(links)
740 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
741
742 main.step("Kill Link between s3 and s28")
743 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
744 time.sleep(link_sleep)
745 topology_output = main.ONOS2.topology()
746 Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
747 if Link_Down == main.TRUE:
748 main.log.report("Link Down discovered properly")
749 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
750 onpass="Link Down discovered properly",
751 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
752
753 #Check ping result here..add code for it
754
755 main.step("Bring link between s3 and s28 back up")
756 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
757 time.sleep(link_sleep)
758 topology_output = main.ONOS2.topology()
759 Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
760 if Link_Up == main.TRUE:
761 main.log.report("Link up discovered properly")
762 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
763 onpass="Link up discovered properly",
764 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
765
shahshreyae6c7cf42014-11-26 16:39:01 -0800766 #NOTE Check ping result here..add code for it
767
768
shahshreya4e13a062014-11-11 16:46:18 -0800769 main.step("Compare ONOS Topology to MN Topology")
770 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
771 MNTopo = Topo
772 Topology_Check = main.TRUE
773
774 devices_json = main.ONOS2.devices()
775 links_json = main.ONOS2.links()
776 ports_json = main.ONOS2.ports()
777 print "devices_json= ", devices_json
778
779 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
780 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
781 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
782
783 #result = result1 and result2 and result3
784 result = result1 and result2
785 print "***********************"
786
787 if result == main.TRUE:
788 main.log.report("ONOS"+ " Topology matches MN Topology")
789 utilities.assert_equals(expect=main.TRUE,actual=result,
790 onpass="ONOS" + " Topology matches MN Topology",
791 onfail="ONOS" + " Topology does not match MN Topology")
792
793 Topology_Check = Topology_Check and result
794 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
795 onpass="Topology checks passed", onfail="Topology checks failed")
796
797 result = Link_Down and Link_Up and Topology_Check
798 utilities.assert_equals(expect=main.TRUE,actual=result,
799 onpass="Link failure is discovered correctly",
800 onfail="Link Discovery failed")
801
802
803 def CASE8(self):
804 '''
805 Host intents removal
806 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800807 main.log.report("This testcase removes host intents before adding the same intents or point intents")
shahshreya4e13a062014-11-11 16:46:18 -0800808 main.log.report("__________________________________")
809 main.log.info("Host intents removal")
810 main.case("Removing host intents")
811 main.step("Obtain the intent id's")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800812 intent_result = main.ONOS2.intents(json_format = False)
813 main.log.info("intent_result = " +intent_result)
814
shahshreya4e13a062014-11-11 16:46:18 -0800815 intent_linewise = intent_result.split("\n")
shahshreyae6c7cf42014-11-26 16:39:01 -0800816 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800817 for line in intent_linewise:
shahshreyae6c7cf42014-11-26 16:39:01 -0800818 if line.startswith("id="):
819 intentList.append(line)
820
821 intentids = []
822 for line in intentList:
shahshreya4e13a062014-11-11 16:46:18 -0800823 intentids.append(line.split(",")[0].split("=")[1])
824 for id in intentids:
825 print "id = ", id
826
827 main.step("Iterate through the intentids list and remove each intent")
828 for id in intentids:
829 main.ONOS2.remove_intent(intent_id = id)
830
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800831 intent_result = main.ONOS2.intents(json_format = False)
832 main.log.info("intent_result = " +intent_result)
shahshreyae6c7cf42014-11-26 16:39:01 -0800833
shahshreya4e13a062014-11-11 16:46:18 -0800834 case8_result = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800835 if case8_result == main.TRUE:
836 main.log.report("Intent removal successful")
837 else:
838 main.log.report("Intent removal failed")
shahshreyae6c7cf42014-11-26 16:39:01 -0800839
840 Ping_Result = main.TRUE
841 if case8_result == main.TRUE:
842 i = 8
843 while i <18 :
844 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
845 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
846 if ping==main.TRUE:
847 i = 19
848 Ping_Result = Ping_Result and main.TRUE
849 elif ping==main.FALSE:
850 i+=1
851 Ping_Result = Ping_Result and main.FALSE
852 else:
853 main.log.info("Unknown error")
854 Ping_Result = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -0800855
shahshreyae6c7cf42014-11-26 16:39:01 -0800856 #Note: If the ping result failed, that means the intents have been withdrawn correctly.
857 if Ping_Result==main.TRUE:
858 main.log.report("Host intents have not been withdrawn correctly")
859 #main.cleanup()
860 #main.exit()
861 if Ping_Result==main.FALSE:
862 main.log.report("Host intents have been withdrawn correctly")
shahshreya4e13a062014-11-11 16:46:18 -0800863
shahshreyae6c7cf42014-11-26 16:39:01 -0800864 case8_result = case8_result and Ping_Result
865
866 if case8_result == main.FALSE:
867 main.log.report("Intent removal successful")
868 else:
869 main.log.report("Intent removal failed")
870
871 utilities.assert_equals(expect=main.FALSE, actual=case8_result,
872 onpass="Intent removal test failed",
873 onfail="Intent removal test passed")
shahshreya4e13a062014-11-11 16:46:18 -0800874
875
876 def CASE9(self):
877 main.log.report("This testcase adds point intents and then does pingall")
878 main.log.report("__________________________________")
879 main.log.info("Adding point intents")
880 main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
881 main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
shahshreyae6c7cf42014-11-26 16:39:01 -0800882 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
shahshreya4e13a062014-11-11 16:46:18 -0800883 if ptp_intent_result == main.TRUE:
884 get_intent_result = main.ONOS2.intents()
885 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800886 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800887
shahshreyae6c7cf42014-11-26 16:39:01 -0800888 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
shahshreya4e13a062014-11-11 16:46:18 -0800889 if ptp_intent_result == main.TRUE:
890 get_intent_result = main.ONOS2.intents()
891 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800892 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800893
894 main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
shahshreyae6c7cf42014-11-26 16:39:01 -0800895 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
shahshreya4e13a062014-11-11 16:46:18 -0800896 if ptp_intent_result == main.TRUE:
897 get_intent_result = main.ONOS2.intents()
898 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800899 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800900
shahshreyae6c7cf42014-11-26 16:39:01 -0800901 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
shahshreya4e13a062014-11-11 16:46:18 -0800902 if ptp_intent_result == main.TRUE:
903 get_intent_result = main.ONOS2.intents()
904 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800905 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800906
907 main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
shahshreyae6c7cf42014-11-26 16:39:01 -0800908 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
shahshreya4e13a062014-11-11 16:46:18 -0800909 if ptp_intent_result == main.TRUE:
910 get_intent_result = main.ONOS2.intents()
911 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800912 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800913
shahshreyae6c7cf42014-11-26 16:39:01 -0800914 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
shahshreya4e13a062014-11-11 16:46:18 -0800915 if ptp_intent_result == main.TRUE:
916 get_intent_result = main.ONOS2.intents()
917 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800918 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800919
920 main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
shahshreyae6c7cf42014-11-26 16:39:01 -0800921 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
shahshreya4e13a062014-11-11 16:46:18 -0800922 if ptp_intent_result == main.TRUE:
923 get_intent_result = main.ONOS2.intents()
924 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800925 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800926
shahshreyae6c7cf42014-11-26 16:39:01 -0800927 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
shahshreya4e13a062014-11-11 16:46:18 -0800928 if ptp_intent_result == main.TRUE:
929 get_intent_result = main.ONOS2.intents()
930 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800931 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800932
933 main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
shahshreyae6c7cf42014-11-26 16:39:01 -0800934 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
shahshreya4e13a062014-11-11 16:46:18 -0800935 if ptp_intent_result == main.TRUE:
936 get_intent_result = main.ONOS2.intents()
937 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800938 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800939
shahshreyae6c7cf42014-11-26 16:39:01 -0800940 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
shahshreya4e13a062014-11-11 16:46:18 -0800941 if ptp_intent_result == main.TRUE:
942 get_intent_result = main.ONOS2.intents()
943 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800944 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800945
946 main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
shahshreyae6c7cf42014-11-26 16:39:01 -0800947 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
shahshreya4e13a062014-11-11 16:46:18 -0800948 if ptp_intent_result == main.TRUE:
949 get_intent_result = main.ONOS2.intents()
950 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800951 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800952
shahshreyae6c7cf42014-11-26 16:39:01 -0800953 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
shahshreya4e13a062014-11-11 16:46:18 -0800954 if ptp_intent_result == main.TRUE:
955 get_intent_result = main.ONOS2.intents()
956 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800957 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800958
959 main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
shahshreyae6c7cf42014-11-26 16:39:01 -0800960 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
shahshreya4e13a062014-11-11 16:46:18 -0800961 if ptp_intent_result == main.TRUE:
962 get_intent_result = main.ONOS2.intents()
963 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800964 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800965
shahshreyae6c7cf42014-11-26 16:39:01 -0800966 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
shahshreya4e13a062014-11-11 16:46:18 -0800967 if ptp_intent_result == main.TRUE:
968 get_intent_result = main.ONOS2.intents()
969 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800970 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800971
972 main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
shahshreyae6c7cf42014-11-26 16:39:01 -0800973 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
shahshreya4e13a062014-11-11 16:46:18 -0800974 if ptp_intent_result == main.TRUE:
975 get_intent_result = main.ONOS2.intents()
976 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800977 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800978
shahshreyae6c7cf42014-11-26 16:39:01 -0800979 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
shahshreya4e13a062014-11-11 16:46:18 -0800980 if ptp_intent_result == main.TRUE:
981 get_intent_result = main.ONOS2.intents()
982 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800983 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800984
985 main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
shahshreyae6c7cf42014-11-26 16:39:01 -0800986 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
shahshreya4e13a062014-11-11 16:46:18 -0800987 if ptp_intent_result == main.TRUE:
988 get_intent_result = main.ONOS2.intents()
989 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800990 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800991
shahshreyae6c7cf42014-11-26 16:39:01 -0800992 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
shahshreya4e13a062014-11-11 16:46:18 -0800993 if ptp_intent_result == main.TRUE:
994 get_intent_result = main.ONOS2.intents()
995 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800996 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800997
998
999 main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
shahshreyae6c7cf42014-11-26 16:39:01 -08001000 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
shahshreya4e13a062014-11-11 16:46:18 -08001001 if ptp_intent_result == main.TRUE:
1002 get_intent_result = main.ONOS2.intents()
1003 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001004 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001005
shahshreyae6c7cf42014-11-26 16:39:01 -08001006 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
shahshreya4e13a062014-11-11 16:46:18 -08001007 if ptp_intent_result == main.TRUE:
1008 get_intent_result = main.ONOS2.intents()
1009 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001010 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001011
1012 print("_______________________________________________________________________________________")
1013
1014 flowHandle = main.ONOS2.flows()
1015 #print "flowHandle = ", flowHandle
1016 main.log.info("flows :" + flowHandle)
1017
1018 count = 1
1019 i = 8
1020 Ping_Result = main.TRUE
1021 while i <18 :
1022 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
1023 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
1024 if ping == main.FALSE and count <5:
1025 count+=1
1026 #i = 8
1027 Ping_Result = main.FALSE
1028 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
1029 time.sleep(2)
1030 elif ping==main.FALSE:
1031 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
1032 i=19
1033 Ping_Result = main.FALSE
1034 elif ping==main.TRUE:
1035 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
1036 i+=1
1037 Ping_Result = main.TRUE
1038 else:
1039 main.log.info("Unknown error")
1040 Ping_Result = main.ERROR
1041
1042 if Ping_Result==main.FALSE:
1043 main.log.report("Point intents have not ben installed correctly. Cleaning up")
1044 #main.cleanup()
1045 #main.exit()
1046 if Ping_Result==main.TRUE:
1047 main.log.report("Point Intents have been installed correctly")
1048
1049 case9_result = Ping_Result
1050 utilities.assert_equals(expect=main.TRUE, actual=case9_result,
1051 onpass="Point intents addition and Pingall Test successful",
1052 onfail="Point intents addition and Pingall Test NOT successful")
1053
1054