blob: 205bfb80db28d624f79412823d0cfd9759451864 [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 ProdFunc13:
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")
38 cell_result1 = main.ONOSbench.set_cell(cell_name)
39 verify_result = main.ONOSbench.verify_cell()
40 cell_result2 = main.ONOS2.set_cell(cell_name)
41 verify_result = main.ONOS2.verify_cell()
42 cell_result = cell_result1 and cell_result2
43
44 main.step("Removing raft logs before a clen installation of ONOS")
45 main.ONOSbench.onos_remove_raft_logs()
46
shahshreya4e13a062014-11-11 16:46:18 -080047 main.step("Git checkout and pull master and get version")
48 main.ONOSbench.git_checkout("master")
49 git_pull_result = main.ONOSbench.git_pull()
50 print "git_pull_result = ", git_pull_result
51 version_result = main.ONOSbench.get_version(report=True)
52
53 if git_pull_result == 1:
54 main.step("Using mvn clean & install")
55 clean_install_result = main.ONOSbench.clean_install()
56 #clean_install_result = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -080057
shahshreya4e13a062014-11-11 16:46:18 -080058 main.step("Creating ONOS package")
59 package_result = main.ONOSbench.onos_package()
60
shahshreya4e13a062014-11-11 16:46:18 -080061
62 main.step("Installing ONOS package")
63 onos_install_result = main.ONOSbench.onos_install()
64 if onos_install_result == main.TRUE:
65 main.log.report("Installing ONOS package successful")
66 else:
67 main.log.report("Installing ONOS package failed")
68
69 onos1_isup = main.ONOSbench.isup()
70 if onos1_isup == main.TRUE:
71 main.log.report("ONOS instance is up and ready")
72 else:
73 main.log.report("ONOS instance may not be up")
74
75 main.step("Starting ONOS service")
76 start_result = main.ONOSbench.onos_start(ONOS1_ip)
shahshreyae6c7cf42014-11-26 16:39:01 -080077
78 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
shahshreya4e13a062014-11-11 16:46:18 -080079
80 case1_result = (package_result and\
81 cell_result and verify_result and onos_install_result and\
82 onos1_isup and start_result )
83 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
84 onpass="Test startup successful",
85 onfail="Test startup NOT successful")
86
87 def CASE11(self, main):
88 '''
89 Cleanup sequence:
90 onos-service <node_ip> stop
91 onos-uninstall
92
93 TODO: Define rest of cleanup
94
95 '''
96
97 ONOS1_ip = main.params['CTRL']['ip1']
98
99 main.case("Cleaning up test environment")
100
101 main.step("Testing ONOS kill function")
102 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
103
104 main.step("Stopping ONOS service")
105 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
106
107 main.step("Uninstalling ONOS service")
108 uninstall_result = main.ONOSbench.onos_uninstall()
109
110 def CASE3(self, main):
111 '''
112 Test 'onos' command and its functionality in driver
113 '''
114
115 ONOS1_ip = main.params['CTRL']['ip1']
116
117 main.case("Testing 'onos' command")
118
119 main.step("Sending command 'onos -w <onos-ip> system:name'")
120 cmdstr1 = "system:name"
121 cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
122 main.log.info("onos command returned: "+cmd_result1)
123
124 main.step("Sending command 'onos -w <onos-ip> onos:topology'")
125 cmdstr2 = "onos:topology"
126 cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
127 main.log.info("onos command returned: "+cmd_result2)
128
129
shahshreyae6c7cf42014-11-26 16:39:01 -0800130 def CASE20(self):
131 '''
132 Exit from mininet cli
133 reinstall ONOS
134 '''
135 main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
136 main.log.report("_____________________________________________")
137 main.step("Disconnecting mininet and restarting ONOS")
138 main.step("Disconnecting mininet and restarting ONOS")
139 mininet_disconnect = main.Mininet1.disconnect()
140
141 main.step("Applying cell variable to environment")
142 cell_result1 = main.ONOSbench.set_cell(cell_name)
143 verify_result = main.ONOSbench.verify_cell()
144 cell_result2 = main.ONOS2.set_cell(cell_name)
145 verify_result = main.ONOS2.verify_cell()
146 cell_result = cell_result1 and cell_result2
147
148 onos_install_result = main.ONOSbench.onos_install()
149 if onos_install_result == main.TRUE:
150 main.log.report("Installing ONOS package successful")
151 else:
152 main.log.report("Installing ONOS package failed")
153
154 onos1_isup = main.ONOSbench.isup()
155 if onos1_isup == main.TRUE:
156 main.log.report("ONOS instance is up and ready")
157 else:
158 main.log.report("ONOS instance may not be up")
159
160 main.step("Starting ONOS service")
161 start_result = main.ONOSbench.onos_start(ONOS1_ip)
162
163 print "mininet_disconnect =", mininet_disconnect
164 print "onos_install_result =", onos_install_result
165 print "onos1_isup =", onos1_isup
166 print "start_result =", start_result
167
168 case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
169 utilities.assert_equals(expect=main.TRUE, actual=case20_result,
170 onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
171 onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
172
173 def CASE21(self, main):
174 import time
175 '''
176 On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
177 which starts the rest and copies the links json file to the onos instance
178 Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
179 from the json config file
180 '''
181 main.log.report("This testcase starts the packet layer topology and REST")
182 main.log.report("_____________________________________________")
183 main.case("Starting LINC-OE and other components")
184 main.step("Starting LINC-OE and other components")
185 start_console_result = main.LincOE1.start_console()
186 optical_mn_script = main.LincOE2.run_optical_mn_script()
187 onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
188
189 print "start_console_result =",start_console_result
190 print "optical_mn_script = ",optical_mn_script
191 print "onos_topo_cfg_result =",onos_topo_cfg_result
192
193 case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
194 utilities.assert_equals(expect=main.TRUE, actual=case21_result,
195 onpass="Packet optical topology spawned successsfully",
196 onfail="Packet optical topology spawning failed")
197
198
199 def CASE22(self, main):
200 '''
201 Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
202 Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
203 and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
204 '''
205
206 main.log.report("This testcase compares the optical+packet topology against what is expected")
207 main.case("Topology comparision")
208 main.step("Topology comparision")
209 main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
210 devices_result = main.ONOS3.devices(json_format = False)
211
212 print "devices_result = ", devices_result
213 devices_linewise = devices_result.split("\n")
214 devices_linewise = devices_linewise[1:-1]
215 roadmCount = 0
216 packetLayerSWCount = 0
217 for line in devices_linewise:
218 components = line.split(",")
219 availability = components[1].split("=")[1]
220 type = components[3].split("=")[1]
221 if availability == 'true' and type == 'ROADM':
222 roadmCount += 1
223 elif availability == 'true' and type =='SWITCH':
224 packetLayerSWCount += 1
225 if roadmCount == 4:
226 print "Number of Optical Switches = %d and is correctly detected" %roadmCount
227 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
228 opticalSW_result = main.TRUE
229 else:
230 print "Number of Optical Switches = %d and is wrong" %roadCount
231 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
232 opticalSW_result = main.FALSE
233
234 if packetLayerSWCount == 2:
235 print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
236 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
237 packetSW_result = main.TRUE
238 else:
239 print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
240 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
241 packetSW_result = main.FALSE
242 print "_________________________________"
243
244 links_result = main.ONOS3.links(json_format = False)
245 print "links_result = ", links_result
246 print "_________________________________"
247
248
249
250 #Discover hosts using pingall
251 pingall_result = main.LincOE2.pingall()
252
253 hosts_result = main.ONOS3.hosts(json_format = False)
254 main.log.info("hosts_result = "+hosts_result)
255 main.log.info("_________________________________")
256 hosts_linewise = hosts_result.split("\n")
257 hosts_linewise = hosts_linewise[1:-1]
258 hostCount = 0
259 for line in hosts_linewise:
260 hostid = line.split(",")[0].split("=")[1]
261 hostCount +=1
262 if hostCount ==2:
263 print "Number of hosts = %d and is correctly detected" %hostCount
264 main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
265 hostDiscovery = main.TRUE
266 else:
267 print "Number of hosts = %d and is wrong" %hostCount
268 main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
269 hostDiscovery = main.FALSE
270
271 case22_result = opticalSW_result and packetSW_result and hostDiscovery
272 utilities.assert_equals(expect=main.TRUE, actual=case22_result,
273 onpass="Packet optical topology discovery successful",
274 onfail="Packet optical topology discovery failed")
275
276 def CASE23(self, main):
277 import time
278 '''
279 Add bidirectional point intents between 2 packet layer(mininet) devices and
280 ping mininet hosts
281 '''
282 main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
283 main.case("Topology comparision")
284 main.step("Adding point intents")
285 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
286 if ptp_intent_result == main.TRUE:
287 get_intent_result = main.ONOS3.intents()
288 main.log.info("Point to point intent install successful")
289 main.log.info(get_intent_result)
290
291 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
292 if ptp_intent_result == main.TRUE:
293 get_intent_result = main.ONOS3.intents()
294 main.log.info("Point to point intent install successful")
295 main.log.info(get_intent_result)
296
297 time.sleep(10)
298 flowHandle = main.ONOS3.flows()
299 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
340 def CASE24(self, main):
341 import time
342 '''
343 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
344 and do a ping test. If rerouting is successful, ping should pass. also check the flows
345 '''
346 main.log.report("This testcase tests rerouting and pings mininet hosts")
347 main.step("Test rerouting and pings mininet hosts")
348 main.case("Bring a port down and verify the link state")
349 main.LincOE1.port_down(sw_id=1, pt_id=22)
350 links_result = main.ONOS3.links()
351 links_state_result = main.FALSE
352 for item in links_result:
353 if item('src') == "of:0000ffffffffff01/22" and item('dst') == "of:0000ffffffffff04/30":
354 links_state = item('state')
355 if links_state == "INACTIVE":
356 main.log.info("Links state is inactive as expected due to one of the ports being down")
357 main.log.report("Links state is inactive as expected due to one of the ports being down")
358 links_state_result = main.TRUE
359 break
360 else:
361 main.log.info("Links state is not inactive as expected")
362 main.log.report("Links state is not inactive as expected")
363 links_state_result = main.FALSE
364
365 main.case("Verify Rerouting by a ping test")
366 Ping_Result = main.TRUE
367 count = 1
368 main.log.info("\n\nh1 is Pinging h2")
369 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
370 #ping = main.LincOE2.pinghost()
371 if ping == main.FALSE and count<5:
372 count+=1
373 Ping_Result = main.FALSE
374 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
375 time.sleep(2)
376 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
377 #ping = main.LincOE2.pinghost()
378 elif ping==main.FALSE:
379 main.log.info("All ping attempts between h1 and h2 have failed")
380 Ping_Result = main.FALSE
381 elif ping==main.TRUE:
382 main.log.info("Ping test between h1 and h2 passed!")
383 Ping_Result = main.TRUE
384 else:
385 main.log.info("Unknown error")
386 Ping_Result = main.ERROR
387
388 if Ping_Result==main.FALSE:
389 main.log.report("Ping test successful ")
390 if Ping_Result==main.TRUE:
391 main.log.report("Ping test failed")
392
393 case24_result = Ping_Result and links_state_result
394 utilities.assert_equals(expect=main.TRUE, actual=case24_result,
395 onpass="Packet optical rerouting successful",
396 onfail="Packet optical rerouting failed")
shahshreya4e13a062014-11-11 16:46:18 -0800397
398 def CASE4(self, main):
399 import re
400 import time
401 main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
402 main.log.report("__________________________________")
403 main.case("Pingall Test")
404 main.step("Assigning switches to controllers")
405 for i in range(1,29):
406 if i ==1:
407 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
408 elif i>=2 and i<5:
409 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
410 elif i>=5 and i<8:
411 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
412 elif i>=8 and i<18:
413 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
414 elif i>=18 and i<28:
415 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
416 else:
417 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
418 Switch_Mastership = main.TRUE
419 for i in range (1,29):
420 if i==1:
421 response = main.Mininet1.get_sw_controller("s"+str(i))
422 print("Response is " + str(response))
423 if re.search("tcp:"+ONOS1_ip,response):
424 Switch_Mastership = Switch_Mastership and main.TRUE
425 else:
426 Switch_Mastership = main.FALSE
427 elif i>=2 and i<5:
428 response = main.Mininet1.get_sw_controller("s"+str(i))
429 print("Response is " + str(response))
430 if re.search("tcp:"+ONOS1_ip,response):
431 Switch_Mastership = Switch_Mastership and main.TRUE
432 else:
433 Switch_Mastership = main.FALSE
434 elif i>=5 and i<8:
435 response = main.Mininet1.get_sw_controller("s"+str(i))
436 print("Response is " + str(response))
437 if re.search("tcp:"+ONOS1_ip,response):
438 Switch_Mastership = Switch_Mastership and main.TRUE
439 else:
440 Switch_Mastership = main.FALSE
441 elif i>=8 and i<18:
442 response = main.Mininet1.get_sw_controller("s"+str(i))
443 print("Response is " + str(response))
444 if re.search("tcp:"+ONOS1_ip,response):
445 Switch_Mastership = Switch_Mastership and main.TRUE
446 else:
447 Switch_Mastership = main.FALSE
448 elif i>=18 and i<28:
449 response = main.Mininet1.get_sw_controller("s"+str(i))
450 print("Response is " + str(response))
451 if re.search("tcp:"+ONOS1_ip,response):
452 Switch_Mastership = Switch_Mastership and main.TRUE
453 else:
454 Switch_Mastership = main.FALSE
455 else:
456 response = main.Mininet1.get_sw_controller("s"+str(i))
457 print("Response is" + str(response))
458 if re.search("tcp:" +ONOS1_ip,response):
459 Switch_Mastership = Switch_Mastership and main.TRUE
460 else:
461 Switch_Mastership = main.FALSE
462
463 if Switch_Mastership == main.TRUE:
464 main.log.report("Controller assignmnet successful")
465 else:
466 main.log.report("Controller assignmnet failed")
467 utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
468 onpass="MasterControllers assigned correctly")
469 '''
470 for i in range (1,29):
471 main.Mininet1.assign_sw_controller(sw=str(i),count=5,
472 ip1=ONOS1_ip,port1=ONOS1_port,
473 ip2=ONOS2_ip,port2=ONOS2_port,
474 ip3=ONOS3_ip,port3=ONOS3_port,
475 ip4=ONOS4_ip,port4=ONOS4_port,
476 ip5=ONOS5_ip,port5=ONOS5_port)
477 '''
478 #REACTIVE FWD test
479
480 main.step("Get list of hosts from Mininet")
481 host_list = main.Mininet1.get_hosts()
482 main.log.info(host_list)
483
484 main.step("Get host list in ONOS format")
485 host_onos_list = main.ONOS2.get_hosts_id(host_list)
486 main.log.info(host_onos_list)
487 #time.sleep(5)
488
489 main.step("Pingall")
490 ping_result = main.FALSE
491 while ping_result == main.FALSE:
492 time1 = time.time()
493 ping_result = main.Mininet1.pingall()
494 time2 = time.time()
495 print "Time for pingall: %2f seconds" % (time2 - time1)
496
497 #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
498 #if there was no activity
499 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
500
501 case4_result = Switch_Mastership and ping_result
502 if ping_result == main.TRUE:
503 main.log.report("Pingall Test in reactive mode to discover the hosts successful")
504 else:
505 main.log.report("Pingall Test in reactive mode to discover the hosts failed")
506
shahshreyae6c7cf42014-11-26 16:39:01 -0800507 utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
508
509 def CASE10(self):
510 main.log.report("This testcase uninstalls the reactive forwarding app")
511 main.log.report("__________________________________")
512 main.case("Uninstalling reactive forwarding app")
513 #Unistall onos-app-fwd app to disable reactive forwarding
514 appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
515 main.log.info("onos-app-fwd uninstalled")
516
517 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
518 #So sleep for 15s
519 time.sleep(15)
520
521 flows = main.ONOS2.flows()
522 main.log.info(flows)
523
524 case10_result = appUninstall_result
525 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 -0800526
527
528 def CASE6(self):
shahshreyae6c7cf42014-11-26 16:39:01 -0800529 main.log.report("This testcase is testing the addition of host intents and then does pingall")
shahshreya4e13a062014-11-11 16:46:18 -0800530 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -0800531 main.case("Obtaining host id's")
shahshreya4e13a062014-11-11 16:46:18 -0800532 main.step("Get hosts")
shahshreyae6c7cf42014-11-26 16:39:01 -0800533 hosts = main.ONOS2.hosts()
shahshreya4e13a062014-11-11 16:46:18 -0800534 main.log.info(hosts)
535
536 main.step("Get all devices id")
537 devices_id_list = main.ONOS2.get_all_devices_id()
538 main.log.info(devices_id_list)
539
540 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
541 #So take care while adding intents
shahshreyae6c7cf42014-11-26 16:39:01 -0800542 '''
shahshreya4e13a062014-11-11 16:46:18 -0800543 main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
544 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
545 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
546 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
547 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
548 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
549 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
550 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
551 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
552 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
553 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 -0800554 print "_____________________________________________________________________________________"
shahshreyae6c7cf42014-11-26 16:39:01 -0800555 '''
shahshreya4e13a062014-11-11 16:46:18 -0800556
shahshreyae6c7cf42014-11-26 16:39:01 -0800557 for i in range(8,18):
558 main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
559 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
560 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
561 #NOTE: get host can return None
562 #TODO: handle this
563 host1_id = main.ONOS2.get_host(host1)['id']
564 host2_id = main.ONOS2.get_host(host2)['id']
565 tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800566
shahshreyae6c7cf42014-11-26 16:39:01 -0800567 time.sleep(10)
568 h_intents = main.ONOS2.intents()
569 main.log.info("intents:" +h_intents)
shahshreya4e13a062014-11-11 16:46:18 -0800570 flowHandle = main.ONOS2.flows()
shahshreyae6c7cf42014-11-26 16:39:01 -0800571 #main.log.info("flow:" +flowHandle)
shahshreya4e13a062014-11-11 16:46:18 -0800572
573 count = 1
574 i = 8
575 Ping_Result = main.TRUE
576 #while i<10:
577 while i <18 :
578 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
579 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
580 if ping == main.FALSE and count <5:
581 count+=1
582 #i = 8
583 Ping_Result = main.FALSE
584 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
585 time.sleep(2)
586 elif ping==main.FALSE:
587 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
588 i=19
589 Ping_Result = main.FALSE
590 elif ping==main.TRUE:
591 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
592 i+=1
593 Ping_Result = main.TRUE
594 else:
595 main.log.info("Unknown error")
596 Ping_Result = main.ERROR
597 if Ping_Result==main.FALSE:
598 main.log.report("Ping all test after Host intent addition failed. Cleaning up")
599 #main.cleanup()
600 #main.exit()
601 if Ping_Result==main.TRUE:
602 main.log.report("Ping all test after Host intent addition successful")
603
604 case6_result = Ping_Result
shahshreyae6c7cf42014-11-26 16:39:01 -0800605 utilities.assert_equals(expect=main.TRUE, actual=case6_result,
shahshreya4e13a062014-11-11 16:46:18 -0800606 onpass="Pingall Test after Host intents addition successful",
607 onfail="Pingall Test after Host intents addition failed")
608
609
610 def CASE5(self,main) :
611 import json
612 from subprocess import Popen, PIPE
613 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
614 #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
615 deviceResult = main.ONOS2.devices()
616 linksResult = main.ONOS2.links()
617 #portsResult = main.ONOS2.ports()
618 print "**************"
619
620 main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
621 main.log.report("__________________________________")
622 main.case("Comparing Mininet topology with the topology of ONOS")
623 main.step("Start continuous pings")
624 main.Mininet2.pingLong(src=main.params['PING']['source1'],
625 target=main.params['PING']['target1'],pingTime=500)
626 main.Mininet2.pingLong(src=main.params['PING']['source2'],
627 target=main.params['PING']['target2'],pingTime=500)
628 main.Mininet2.pingLong(src=main.params['PING']['source3'],
629 target=main.params['PING']['target3'],pingTime=500)
630 main.Mininet2.pingLong(src=main.params['PING']['source4'],
631 target=main.params['PING']['target4'],pingTime=500)
632 main.Mininet2.pingLong(src=main.params['PING']['source5'],
633 target=main.params['PING']['target5'],pingTime=500)
634 main.Mininet2.pingLong(src=main.params['PING']['source6'],
635 target=main.params['PING']['target6'],pingTime=500)
636 main.Mininet2.pingLong(src=main.params['PING']['source7'],
637 target=main.params['PING']['target7'],pingTime=500)
638 main.Mininet2.pingLong(src=main.params['PING']['source8'],
639 target=main.params['PING']['target8'],pingTime=500)
640 main.Mininet2.pingLong(src=main.params['PING']['source9'],
641 target=main.params['PING']['target9'],pingTime=500)
642 main.Mininet2.pingLong(src=main.params['PING']['source10'],
643 target=main.params['PING']['target10'],pingTime=500)
644
645 main.step("Create TestONTopology object")
646 global ctrls
647 ctrls = []
648 count = 1
649 while True:
650 temp = ()
651 if ('ip' + str(count)) in main.params['CTRL']:
652 temp = temp + (getattr(main,('ONOS' + str(count))),)
653 temp = temp + ("ONOS"+str(count),)
654 temp = temp + (main.params['CTRL']['ip'+str(count)],)
655 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
656 ctrls.append(temp)
657 count = count + 1
658 else:
659 break
660 global MNTopo
661 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
662 MNTopo = Topo
663
664 Topology_Check = main.TRUE
665 main.step("Compare ONOS Topology to MN Topology")
666 devices_json = main.ONOS2.devices()
667 links_json = main.ONOS2.links()
668 #ports_json = main.ONOS2.ports()
669 print "devices_json= ", devices_json
670
671 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
672 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
673 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
674
675 #result = result1 and result2 and result3
676 result = result1 and result2
677
678 print "***********************"
679 if result == main.TRUE:
680 main.log.report("ONOS"+ " Topology matches MN Topology")
681 else:
682 main.log.report("ONOS"+ " Topology does not match MN Topology")
683
684 utilities.assert_equals(expect=main.TRUE,actual=result,
685 onpass="ONOS" + " Topology matches MN Topology",
686 onfail="ONOS" + " Topology does not match MN Topology")
687
688 Topology_Check = Topology_Check and result
689 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
690 onpass="Topology checks passed", onfail="Topology checks failed")
691
692
693 def CASE7 (self,main):
694
695 ONOS1_ip = main.params['CTRL']['ip1']
696
697 link_sleep = int(main.params['timers']['LinkDiscovery'])
698
699 main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
700 main.log.report("__________________________________")
701 main.log.report("Killing a link to ensure that link discovery is consistent")
702 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
shahshreyae6c7cf42014-11-26 16:39:01 -0800703 '''
shahshreya4e13a062014-11-11 16:46:18 -0800704 main.step("Start continuous pings")
705
706 main.Mininet2.pingLong(src=main.params['PING']['source1'],
707 target=main.params['PING']['target1'],pingTime=500)
708 main.Mininet2.pingLong(src=main.params['PING']['source2'],
709 target=main.params['PING']['target2'],pingTime=500)
710 main.Mininet2.pingLong(src=main.params['PING']['source3'],
711 target=main.params['PING']['target3'],pingTime=500)
712 main.Mininet2.pingLong(src=main.params['PING']['source4'],
713 target=main.params['PING']['target4'],pingTime=500)
714 main.Mininet2.pingLong(src=main.params['PING']['source5'],
715 target=main.params['PING']['target5'],pingTime=500)
716 main.Mininet2.pingLong(src=main.params['PING']['source6'],
717 target=main.params['PING']['target6'],pingTime=500)
718 main.Mininet2.pingLong(src=main.params['PING']['source7'],
719 target=main.params['PING']['target7'],pingTime=500)
720 main.Mininet2.pingLong(src=main.params['PING']['source8'],
721 target=main.params['PING']['target8'],pingTime=500)
722 main.Mininet2.pingLong(src=main.params['PING']['source9'],
723 target=main.params['PING']['target9'],pingTime=500)
724 main.Mininet2.pingLong(src=main.params['PING']['source10'],
725 target=main.params['PING']['target10'],pingTime=500)
shahshreyae6c7cf42014-11-26 16:39:01 -0800726 '''
shahshreya4e13a062014-11-11 16:46:18 -0800727
728 main.step("Determine the current number of switches and links")
729 topology_output = main.ONOS2.topology()
730 topology_result = main.ONOS1.get_topology(topology_output)
731 activeSwitches = topology_result['devices']
732 links = topology_result['links']
733 print "activeSwitches = ", type(activeSwitches)
734 print "links = ", type(links)
735 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
736
737 main.step("Kill Link between s3 and s28")
738 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
739 time.sleep(link_sleep)
740 topology_output = main.ONOS2.topology()
741 Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
742 if Link_Down == main.TRUE:
743 main.log.report("Link Down discovered properly")
744 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
745 onpass="Link Down discovered properly",
746 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
747
748 #Check ping result here..add code for it
749
750 main.step("Bring link between s3 and s28 back up")
751 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
752 time.sleep(link_sleep)
753 topology_output = main.ONOS2.topology()
754 Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
755 if Link_Up == main.TRUE:
756 main.log.report("Link up discovered properly")
757 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
758 onpass="Link up discovered properly",
759 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
760
shahshreyae6c7cf42014-11-26 16:39:01 -0800761 #NOTE Check ping result here..add code for it
762
763
shahshreya4e13a062014-11-11 16:46:18 -0800764 main.step("Compare ONOS Topology to MN Topology")
765 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
766 MNTopo = Topo
767 Topology_Check = main.TRUE
768
769 devices_json = main.ONOS2.devices()
770 links_json = main.ONOS2.links()
771 ports_json = main.ONOS2.ports()
772 print "devices_json= ", devices_json
773
774 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
775 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
776 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
777
778 #result = result1 and result2 and result3
779 result = result1 and result2
780 print "***********************"
781
782 if result == main.TRUE:
783 main.log.report("ONOS"+ " Topology matches MN Topology")
784 utilities.assert_equals(expect=main.TRUE,actual=result,
785 onpass="ONOS" + " Topology matches MN Topology",
786 onfail="ONOS" + " Topology does not match MN Topology")
787
788 Topology_Check = Topology_Check and result
789 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
790 onpass="Topology checks passed", onfail="Topology checks failed")
791
792 result = Link_Down and Link_Up and Topology_Check
793 utilities.assert_equals(expect=main.TRUE,actual=result,
794 onpass="Link failure is discovered correctly",
795 onfail="Link Discovery failed")
796
797
798 def CASE8(self):
799 '''
800 Host intents removal
801 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800802 main.log.report("This testcase removes host intents before adding the same intents or point intents")
shahshreya4e13a062014-11-11 16:46:18 -0800803 main.log.report("__________________________________")
804 main.log.info("Host intents removal")
805 main.case("Removing host intents")
806 main.step("Obtain the intent id's")
807 intent_result = main.ONOS2.intents()
808 #print "intent_result = ",intent_result
shahshreyae6c7cf42014-11-26 16:39:01 -0800809
shahshreya4e13a062014-11-11 16:46:18 -0800810 intent_linewise = intent_result.split("\n")
shahshreyae6c7cf42014-11-26 16:39:01 -0800811 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800812 for line in intent_linewise:
shahshreyae6c7cf42014-11-26 16:39:01 -0800813 if line.startswith("id="):
814 intentList.append(line)
815
816 intentids = []
817 for line in intentList:
shahshreya4e13a062014-11-11 16:46:18 -0800818 intentids.append(line.split(",")[0].split("=")[1])
819 for id in intentids:
820 print "id = ", id
821
822 main.step("Iterate through the intentids list and remove each intent")
823 for id in intentids:
824 main.ONOS2.remove_intent(intent_id = id)
825
826 intent_result = main.ONOS2.intents()
827 intent_linewise = intent_result.split("\n")
shahshreyae6c7cf42014-11-26 16:39:01 -0800828 list_afterRemoval = []
829 for line in intent_linewise:
830 if line.startswith("id="):
831 list_afterRemoval.append(line)
832
shahshreya4e13a062014-11-11 16:46:18 -0800833 intentState = {}
shahshreyae6c7cf42014-11-26 16:39:01 -0800834 for id, line in zip(intentids, list_afterRemoval):
shahshreya4e13a062014-11-11 16:46:18 -0800835 #print "line after removing intent = ", line
836 x = line.split(",")
837 state = x[1].split("=")[1]
838 intentState[id] = state
839
840 case8_result = main.TRUE
841 for key,value in intentState.iteritems():
842 print "key,value = ", key, value
843 if value == "WITHDRAWN":
844 case8_result = case8_result and main.TRUE
845 else:
846 case8_result = case8_result and main.FALSE
847
848 if case8_result == main.TRUE:
849 main.log.report("Intent removal successful")
850 else:
851 main.log.report("Intent removal failed")
shahshreyae6c7cf42014-11-26 16:39:01 -0800852
853 Ping_Result = main.TRUE
854 if case8_result == main.TRUE:
855 i = 8
856 while i <18 :
857 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
858 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
859 if ping==main.TRUE:
860 i = 19
861 Ping_Result = Ping_Result and main.TRUE
862 elif ping==main.FALSE:
863 i+=1
864 Ping_Result = Ping_Result and main.FALSE
865 else:
866 main.log.info("Unknown error")
867 Ping_Result = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -0800868
shahshreyae6c7cf42014-11-26 16:39:01 -0800869 #Note: If the ping result failed, that means the intents have been withdrawn correctly.
870 if Ping_Result==main.TRUE:
871 main.log.report("Host intents have not been withdrawn correctly")
872 #main.cleanup()
873 #main.exit()
874 if Ping_Result==main.FALSE:
875 main.log.report("Host intents have been withdrawn correctly")
shahshreya4e13a062014-11-11 16:46:18 -0800876
shahshreyae6c7cf42014-11-26 16:39:01 -0800877 case8_result = case8_result and Ping_Result
878
879 if case8_result == main.FALSE:
880 main.log.report("Intent removal successful")
881 else:
882 main.log.report("Intent removal failed")
883
884 utilities.assert_equals(expect=main.FALSE, actual=case8_result,
885 onpass="Intent removal test failed",
886 onfail="Intent removal test passed")
shahshreya4e13a062014-11-11 16:46:18 -0800887
888
889 def CASE9(self):
890 main.log.report("This testcase adds point intents and then does pingall")
891 main.log.report("__________________________________")
892 main.log.info("Adding point intents")
893 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)")
894 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 -0800895 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/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:0000000000006018/1", "of:0000000000003008/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 h9 and h19 or ONOS hosts h9 and h13")
shahshreyae6c7cf42014-11-26 16:39:01 -0800908 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/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:0000000000006019/1", "of:0000000000003009/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 h10 and h20 or ONOS hosts hA and h14")
shahshreyae6c7cf42014-11-26 16:39:01 -0800921 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/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:0000000000006020/1", "of:0000000000003010/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 h11 and h21 or ONOS hosts hB and h15")
shahshreyae6c7cf42014-11-26 16:39:01 -0800934 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/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:0000000000006021/1", "of:0000000000003011/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 h12 and h22 or ONOS hosts hC and h16")
shahshreyae6c7cf42014-11-26 16:39:01 -0800947 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/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:0000000000006022/1", "of:0000000000003012/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 h13 and h23 or ONOS hosts hD and h17")
shahshreyae6c7cf42014-11-26 16:39:01 -0800960 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/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:0000000000006023/1", "of:0000000000003013/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 h14 and h24 or ONOS hosts hE and h18")
shahshreyae6c7cf42014-11-26 16:39:01 -0800973 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/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:0000000000006024/1", "of:0000000000003014/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 h15 and h25 or ONOS hosts hF and h19")
shahshreyae6c7cf42014-11-26 16:39:01 -0800986 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/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:0000000000006025/1", "of:0000000000003015/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 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 -0800999 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
shahshreya4e13a062014-11-11 16:46:18 -08001000 if ptp_intent_result == main.TRUE:
1001 get_intent_result = main.ONOS2.intents()
1002 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001003 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001004
shahshreyae6c7cf42014-11-26 16:39:01 -08001005 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
shahshreya4e13a062014-11-11 16:46:18 -08001006 if ptp_intent_result == main.TRUE:
1007 get_intent_result = main.ONOS2.intents()
1008 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001009 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001010
1011
1012 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 -08001013 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
shahshreya4e13a062014-11-11 16:46:18 -08001014 if ptp_intent_result == main.TRUE:
1015 get_intent_result = main.ONOS2.intents()
1016 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001017 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001018
shahshreyae6c7cf42014-11-26 16:39:01 -08001019 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
shahshreya4e13a062014-11-11 16:46:18 -08001020 if ptp_intent_result == main.TRUE:
1021 get_intent_result = main.ONOS2.intents()
1022 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001023 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001024
1025 print("_______________________________________________________________________________________")
1026
1027 flowHandle = main.ONOS2.flows()
1028 #print "flowHandle = ", flowHandle
1029 main.log.info("flows :" + flowHandle)
1030
1031 count = 1
1032 i = 8
1033 Ping_Result = main.TRUE
1034 while i <18 :
1035 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
1036 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
1037 if ping == main.FALSE and count <5:
1038 count+=1
1039 #i = 8
1040 Ping_Result = main.FALSE
1041 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
1042 time.sleep(2)
1043 elif ping==main.FALSE:
1044 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
1045 i=19
1046 Ping_Result = main.FALSE
1047 elif ping==main.TRUE:
1048 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
1049 i+=1
1050 Ping_Result = main.TRUE
1051 else:
1052 main.log.info("Unknown error")
1053 Ping_Result = main.ERROR
1054
1055 if Ping_Result==main.FALSE:
1056 main.log.report("Point intents have not ben installed correctly. Cleaning up")
1057 #main.cleanup()
1058 #main.exit()
1059 if Ping_Result==main.TRUE:
1060 main.log.report("Point Intents have been installed correctly")
1061
1062 case9_result = Ping_Result
1063 utilities.assert_equals(expect=main.TRUE, actual=case9_result,
1064 onpass="Point intents addition and Pingall Test successful",
1065 onfail="Point intents addition and Pingall Test NOT successful")
1066
1067