blob: abb99d2bbd4debd125c4e82501538ad1f9a81b2e [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")
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
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800250 #NOTE:Since only point intents are added, there is no requirement to discover the hosts
251 #Therfore, the below portion of the code is commented.
252 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800253 #Discover hosts using pingall
254 pingall_result = main.LincOE2.pingall()
255
256 hosts_result = main.ONOS3.hosts(json_format = False)
257 main.log.info("hosts_result = "+hosts_result)
258 main.log.info("_________________________________")
259 hosts_linewise = hosts_result.split("\n")
260 hosts_linewise = hosts_linewise[1:-1]
261 hostCount = 0
262 for line in hosts_linewise:
263 hostid = line.split(",")[0].split("=")[1]
264 hostCount +=1
265 if hostCount ==2:
266 print "Number of hosts = %d and is correctly detected" %hostCount
267 main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
268 hostDiscovery = main.TRUE
269 else:
270 print "Number of hosts = %d and is wrong" %hostCount
271 main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
272 hostDiscovery = main.FALSE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800273 '''
274
275 case22_result = opticalSW_result and packetSW_result
shahshreyae6c7cf42014-11-26 16:39:01 -0800276 utilities.assert_equals(expect=main.TRUE, actual=case22_result,
277 onpass="Packet optical topology discovery successful",
278 onfail="Packet optical topology discovery failed")
279
280 def CASE23(self, main):
281 import time
282 '''
283 Add bidirectional point intents between 2 packet layer(mininet) devices and
284 ping mininet hosts
285 '''
286 main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
287 main.case("Topology comparision")
288 main.step("Adding point intents")
289 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
290 if ptp_intent_result == main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800291 get_intent_result = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800292 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800293
294 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
295 if ptp_intent_result == main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800296 get_intent_result = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800297 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800298
299 time.sleep(10)
300 flowHandle = main.ONOS3.flows()
301 main.log.info("flows :" + flowHandle)
302
303 # Sleep for 30 seconds to provide time for the intent state to change
304 time.sleep(30)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800305 intentHandle = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800306 main.log.info("intents :" + intentHandle)
307
308 Ping_Result = main.TRUE
309 count = 1
310 main.log.info("\n\nh1 is Pinging h2")
311 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
312 #ping = main.LincOE2.pinghost()
313 if ping == main.FALSE and count<5:
314 count+=1
315 Ping_Result = main.FALSE
316 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
317 time.sleep(2)
318 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
319 #ping = main.LincOE2.pinghost()
320 elif ping==main.FALSE:
321 main.log.info("All ping attempts between h1 and h2 have failed")
322 Ping_Result = main.FALSE
323 elif ping==main.TRUE:
324 main.log.info("Ping test between h1 and h2 passed!")
325 Ping_Result = main.TRUE
326 else:
327 main.log.info("Unknown error")
328 Ping_Result = main.ERROR
329
330 if Ping_Result==main.FALSE:
331 main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
332 if Ping_Result==main.TRUE:
333 main.log.report("Point Intents for packet optical have been installed correctly")
334
335 case23_result = Ping_Result
336 utilities.assert_equals(expect=main.TRUE, actual=case23_result,
337 onpass="Point intents addition for packet optical and Pingall Test successful",
338 onfail="Point intents addition for packet optical and Pingall Test NOT successful")
339
340
341
342 def CASE24(self, main):
343 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800344 import json
shahshreyae6c7cf42014-11-26 16:39:01 -0800345 '''
346 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
347 and do a ping test. If rerouting is successful, ping should pass. also check the flows
348 '''
349 main.log.report("This testcase tests rerouting and pings mininet hosts")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800350 main.case("Test rerouting and pings mininet hosts")
351 main.step("Bring a port down and verify the link state")
352 main.LincOE1.port_down(sw_id="1", pt_id="22")
353 links_nonjson = main.ONOS3.links(json_format = False)
354 main.log.info("links = " +links_nonjson)
355
356 links = main.ONOS3.links()
357 main.log.info("links = " +links)
358
359 links_result = json.loads(links)
shahshreyae6c7cf42014-11-26 16:39:01 -0800360 links_state_result = main.FALSE
361 for item in links_result:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800362 if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22":
363 if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30":
364 links_state = item['state']
365 if links_state == "INACTIVE":
366 main.log.info("Links state is inactive as expected due to one of the ports being down")
367 main.log.report("Links state is inactive as expected due to one of the ports being down")
368 links_state_result = main.TRUE
369 break
370 else:
371 main.log.info("Links state is not inactive as expected")
372 main.log.report("Links state is not inactive as expected")
373 links_state_result = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800374
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800375 print "links_state_result = ", links_state_result
376 time.sleep(10)
377 flowHandle = main.ONOS3.flows()
378 main.log.info("flows :" + flowHandle)
379
380 main.step("Verify Rerouting by a ping test")
shahshreyae6c7cf42014-11-26 16:39:01 -0800381 Ping_Result = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800382 count = 1
shahshreyae6c7cf42014-11-26 16:39:01 -0800383 main.log.info("\n\nh1 is Pinging h2")
384 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
385 #ping = main.LincOE2.pinghost()
386 if ping == main.FALSE and count<5:
387 count+=1
388 Ping_Result = main.FALSE
389 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
390 time.sleep(2)
391 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
392 #ping = main.LincOE2.pinghost()
393 elif ping==main.FALSE:
394 main.log.info("All ping attempts between h1 and h2 have failed")
395 Ping_Result = main.FALSE
396 elif ping==main.TRUE:
397 main.log.info("Ping test between h1 and h2 passed!")
398 Ping_Result = main.TRUE
399 else:
400 main.log.info("Unknown error")
401 Ping_Result = main.ERROR
402
shahshreyae6c7cf42014-11-26 16:39:01 -0800403 if Ping_Result==main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800404 main.log.report("Ping test successful ")
405 if Ping_Result==main.FALSE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800406 main.log.report("Ping test failed")
407
408 case24_result = Ping_Result and links_state_result
409 utilities.assert_equals(expect=main.TRUE, actual=case24_result,
410 onpass="Packet optical rerouting successful",
411 onfail="Packet optical rerouting failed")
shahshreya4e13a062014-11-11 16:46:18 -0800412
413 def CASE4(self, main):
414 import re
415 import time
416 main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
417 main.log.report("__________________________________")
418 main.case("Pingall Test")
419 main.step("Assigning switches to controllers")
420 for i in range(1,29):
421 if i ==1:
422 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
423 elif i>=2 and i<5:
424 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
425 elif i>=5 and i<8:
426 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
427 elif i>=8 and i<18:
428 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
429 elif i>=18 and i<28:
430 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
431 else:
432 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
433 Switch_Mastership = main.TRUE
434 for i in range (1,29):
435 if i==1:
436 response = main.Mininet1.get_sw_controller("s"+str(i))
437 print("Response is " + str(response))
438 if re.search("tcp:"+ONOS1_ip,response):
439 Switch_Mastership = Switch_Mastership and main.TRUE
440 else:
441 Switch_Mastership = main.FALSE
442 elif i>=2 and i<5:
443 response = main.Mininet1.get_sw_controller("s"+str(i))
444 print("Response is " + str(response))
445 if re.search("tcp:"+ONOS1_ip,response):
446 Switch_Mastership = Switch_Mastership and main.TRUE
447 else:
448 Switch_Mastership = main.FALSE
449 elif i>=5 and i<8:
450 response = main.Mininet1.get_sw_controller("s"+str(i))
451 print("Response is " + str(response))
452 if re.search("tcp:"+ONOS1_ip,response):
453 Switch_Mastership = Switch_Mastership and main.TRUE
454 else:
455 Switch_Mastership = main.FALSE
456 elif i>=8 and i<18:
457 response = main.Mininet1.get_sw_controller("s"+str(i))
458 print("Response is " + str(response))
459 if re.search("tcp:"+ONOS1_ip,response):
460 Switch_Mastership = Switch_Mastership and main.TRUE
461 else:
462 Switch_Mastership = main.FALSE
463 elif i>=18 and i<28:
464 response = main.Mininet1.get_sw_controller("s"+str(i))
465 print("Response is " + str(response))
466 if re.search("tcp:"+ONOS1_ip,response):
467 Switch_Mastership = Switch_Mastership and main.TRUE
468 else:
469 Switch_Mastership = main.FALSE
470 else:
471 response = main.Mininet1.get_sw_controller("s"+str(i))
472 print("Response is" + str(response))
473 if re.search("tcp:" +ONOS1_ip,response):
474 Switch_Mastership = Switch_Mastership and main.TRUE
475 else:
476 Switch_Mastership = main.FALSE
477
478 if Switch_Mastership == main.TRUE:
479 main.log.report("Controller assignmnet successful")
480 else:
481 main.log.report("Controller assignmnet failed")
482 utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
483 onpass="MasterControllers assigned correctly")
484 '''
485 for i in range (1,29):
486 main.Mininet1.assign_sw_controller(sw=str(i),count=5,
487 ip1=ONOS1_ip,port1=ONOS1_port,
488 ip2=ONOS2_ip,port2=ONOS2_port,
489 ip3=ONOS3_ip,port3=ONOS3_port,
490 ip4=ONOS4_ip,port4=ONOS4_port,
491 ip5=ONOS5_ip,port5=ONOS5_port)
492 '''
493 #REACTIVE FWD test
494
495 main.step("Get list of hosts from Mininet")
496 host_list = main.Mininet1.get_hosts()
497 main.log.info(host_list)
498
499 main.step("Get host list in ONOS format")
500 host_onos_list = main.ONOS2.get_hosts_id(host_list)
501 main.log.info(host_onos_list)
502 #time.sleep(5)
503
504 main.step("Pingall")
505 ping_result = main.FALSE
506 while ping_result == main.FALSE:
507 time1 = time.time()
508 ping_result = main.Mininet1.pingall()
509 time2 = time.time()
510 print "Time for pingall: %2f seconds" % (time2 - time1)
511
512 #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
513 #if there was no activity
514 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
515
516 case4_result = Switch_Mastership and ping_result
517 if ping_result == main.TRUE:
518 main.log.report("Pingall Test in reactive mode to discover the hosts successful")
519 else:
520 main.log.report("Pingall Test in reactive mode to discover the hosts failed")
521
shahshreyae6c7cf42014-11-26 16:39:01 -0800522 utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
523
524 def CASE10(self):
525 main.log.report("This testcase uninstalls the reactive forwarding app")
526 main.log.report("__________________________________")
527 main.case("Uninstalling reactive forwarding app")
528 #Unistall onos-app-fwd app to disable reactive forwarding
529 appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
530 main.log.info("onos-app-fwd uninstalled")
531
532 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
533 #So sleep for 15s
534 time.sleep(15)
535
536 flows = main.ONOS2.flows()
537 main.log.info(flows)
538
539 case10_result = appUninstall_result
540 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 -0800541
542
543 def CASE6(self):
shahshreyae6c7cf42014-11-26 16:39:01 -0800544 main.log.report("This testcase is testing the addition of host intents and then does pingall")
shahshreya4e13a062014-11-11 16:46:18 -0800545 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -0800546 main.case("Obtaining host id's")
shahshreya4e13a062014-11-11 16:46:18 -0800547 main.step("Get hosts")
shahshreyae6c7cf42014-11-26 16:39:01 -0800548 hosts = main.ONOS2.hosts()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800549 #main.log.info(hosts)
shahshreya4e13a062014-11-11 16:46:18 -0800550
551 main.step("Get all devices id")
552 devices_id_list = main.ONOS2.get_all_devices_id()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800553 #main.log.info(devices_id_list)
shahshreya4e13a062014-11-11 16:46:18 -0800554
555 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
556 #So take care while adding intents
shahshreyae6c7cf42014-11-26 16:39:01 -0800557 '''
shahshreya4e13a062014-11-11 16:46:18 -0800558 main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
559 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
560 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
561 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
562 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
563 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
564 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
565 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
566 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
567 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
568 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 -0800569 print "_____________________________________________________________________________________"
shahshreyae6c7cf42014-11-26 16:39:01 -0800570 '''
shahshreya4e13a062014-11-11 16:46:18 -0800571
shahshreyae6c7cf42014-11-26 16:39:01 -0800572 for i in range(8,18):
573 main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
574 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
575 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
576 #NOTE: get host can return None
577 #TODO: handle this
578 host1_id = main.ONOS2.get_host(host1)['id']
579 host2_id = main.ONOS2.get_host(host2)['id']
580 tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800581
shahshreyae6c7cf42014-11-26 16:39:01 -0800582 time.sleep(10)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800583 h_intents = main.ONOS2.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800584 main.log.info("intents:" +h_intents)
shahshreya4e13a062014-11-11 16:46:18 -0800585 flowHandle = main.ONOS2.flows()
shahshreyae6c7cf42014-11-26 16:39:01 -0800586 #main.log.info("flow:" +flowHandle)
shahshreya4e13a062014-11-11 16:46:18 -0800587
588 count = 1
589 i = 8
590 Ping_Result = main.TRUE
591 #while i<10:
592 while i <18 :
593 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
594 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
595 if ping == main.FALSE and count <5:
596 count+=1
597 #i = 8
598 Ping_Result = main.FALSE
599 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
600 time.sleep(2)
601 elif ping==main.FALSE:
602 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
603 i=19
604 Ping_Result = main.FALSE
605 elif ping==main.TRUE:
606 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
607 i+=1
608 Ping_Result = main.TRUE
609 else:
610 main.log.info("Unknown error")
611 Ping_Result = main.ERROR
612 if Ping_Result==main.FALSE:
613 main.log.report("Ping all test after Host intent addition failed. Cleaning up")
614 #main.cleanup()
615 #main.exit()
616 if Ping_Result==main.TRUE:
617 main.log.report("Ping all test after Host intent addition successful")
618
619 case6_result = Ping_Result
shahshreyae6c7cf42014-11-26 16:39:01 -0800620 utilities.assert_equals(expect=main.TRUE, actual=case6_result,
shahshreya4e13a062014-11-11 16:46:18 -0800621 onpass="Pingall Test after Host intents addition successful",
622 onfail="Pingall Test after Host intents addition failed")
623
624
625 def CASE5(self,main) :
626 import json
627 from subprocess import Popen, PIPE
628 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
629 #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
630 deviceResult = main.ONOS2.devices()
631 linksResult = main.ONOS2.links()
632 #portsResult = main.ONOS2.ports()
633 print "**************"
634
635 main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
636 main.log.report("__________________________________")
637 main.case("Comparing Mininet topology with the topology of ONOS")
638 main.step("Start continuous pings")
639 main.Mininet2.pingLong(src=main.params['PING']['source1'],
640 target=main.params['PING']['target1'],pingTime=500)
641 main.Mininet2.pingLong(src=main.params['PING']['source2'],
642 target=main.params['PING']['target2'],pingTime=500)
643 main.Mininet2.pingLong(src=main.params['PING']['source3'],
644 target=main.params['PING']['target3'],pingTime=500)
645 main.Mininet2.pingLong(src=main.params['PING']['source4'],
646 target=main.params['PING']['target4'],pingTime=500)
647 main.Mininet2.pingLong(src=main.params['PING']['source5'],
648 target=main.params['PING']['target5'],pingTime=500)
649 main.Mininet2.pingLong(src=main.params['PING']['source6'],
650 target=main.params['PING']['target6'],pingTime=500)
651 main.Mininet2.pingLong(src=main.params['PING']['source7'],
652 target=main.params['PING']['target7'],pingTime=500)
653 main.Mininet2.pingLong(src=main.params['PING']['source8'],
654 target=main.params['PING']['target8'],pingTime=500)
655 main.Mininet2.pingLong(src=main.params['PING']['source9'],
656 target=main.params['PING']['target9'],pingTime=500)
657 main.Mininet2.pingLong(src=main.params['PING']['source10'],
658 target=main.params['PING']['target10'],pingTime=500)
659
660 main.step("Create TestONTopology object")
661 global ctrls
662 ctrls = []
663 count = 1
664 while True:
665 temp = ()
666 if ('ip' + str(count)) in main.params['CTRL']:
667 temp = temp + (getattr(main,('ONOS' + str(count))),)
668 temp = temp + ("ONOS"+str(count),)
669 temp = temp + (main.params['CTRL']['ip'+str(count)],)
670 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
671 ctrls.append(temp)
672 count = count + 1
673 else:
674 break
675 global MNTopo
676 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
677 MNTopo = Topo
678
679 Topology_Check = main.TRUE
680 main.step("Compare ONOS Topology to MN Topology")
681 devices_json = main.ONOS2.devices()
682 links_json = main.ONOS2.links()
683 #ports_json = main.ONOS2.ports()
684 print "devices_json= ", devices_json
685
686 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
687 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
688 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
689
690 #result = result1 and result2 and result3
691 result = result1 and result2
692
693 print "***********************"
694 if result == main.TRUE:
695 main.log.report("ONOS"+ " Topology matches MN Topology")
696 else:
697 main.log.report("ONOS"+ " Topology does not match MN Topology")
698
699 utilities.assert_equals(expect=main.TRUE,actual=result,
700 onpass="ONOS" + " Topology matches MN Topology",
701 onfail="ONOS" + " Topology does not match MN Topology")
702
703 Topology_Check = Topology_Check and result
704 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
705 onpass="Topology checks passed", onfail="Topology checks failed")
706
707
708 def CASE7 (self,main):
709
710 ONOS1_ip = main.params['CTRL']['ip1']
711
712 link_sleep = int(main.params['timers']['LinkDiscovery'])
713
714 main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
715 main.log.report("__________________________________")
716 main.log.report("Killing a link to ensure that link discovery is consistent")
717 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
shahshreyae6c7cf42014-11-26 16:39:01 -0800718 '''
shahshreya4e13a062014-11-11 16:46:18 -0800719 main.step("Start continuous pings")
720
721 main.Mininet2.pingLong(src=main.params['PING']['source1'],
722 target=main.params['PING']['target1'],pingTime=500)
723 main.Mininet2.pingLong(src=main.params['PING']['source2'],
724 target=main.params['PING']['target2'],pingTime=500)
725 main.Mininet2.pingLong(src=main.params['PING']['source3'],
726 target=main.params['PING']['target3'],pingTime=500)
727 main.Mininet2.pingLong(src=main.params['PING']['source4'],
728 target=main.params['PING']['target4'],pingTime=500)
729 main.Mininet2.pingLong(src=main.params['PING']['source5'],
730 target=main.params['PING']['target5'],pingTime=500)
731 main.Mininet2.pingLong(src=main.params['PING']['source6'],
732 target=main.params['PING']['target6'],pingTime=500)
733 main.Mininet2.pingLong(src=main.params['PING']['source7'],
734 target=main.params['PING']['target7'],pingTime=500)
735 main.Mininet2.pingLong(src=main.params['PING']['source8'],
736 target=main.params['PING']['target8'],pingTime=500)
737 main.Mininet2.pingLong(src=main.params['PING']['source9'],
738 target=main.params['PING']['target9'],pingTime=500)
739 main.Mininet2.pingLong(src=main.params['PING']['source10'],
740 target=main.params['PING']['target10'],pingTime=500)
shahshreyae6c7cf42014-11-26 16:39:01 -0800741 '''
shahshreya4e13a062014-11-11 16:46:18 -0800742
743 main.step("Determine the current number of switches and links")
744 topology_output = main.ONOS2.topology()
745 topology_result = main.ONOS1.get_topology(topology_output)
746 activeSwitches = topology_result['devices']
747 links = topology_result['links']
748 print "activeSwitches = ", type(activeSwitches)
749 print "links = ", type(links)
750 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
751
752 main.step("Kill Link between s3 and s28")
753 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
754 time.sleep(link_sleep)
755 topology_output = main.ONOS2.topology()
756 Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
757 if Link_Down == main.TRUE:
758 main.log.report("Link Down discovered properly")
759 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
760 onpass="Link Down discovered properly",
761 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
762
763 #Check ping result here..add code for it
764
765 main.step("Bring link between s3 and s28 back up")
766 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
767 time.sleep(link_sleep)
768 topology_output = main.ONOS2.topology()
769 Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
770 if Link_Up == main.TRUE:
771 main.log.report("Link up discovered properly")
772 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
773 onpass="Link up discovered properly",
774 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
775
shahshreyae6c7cf42014-11-26 16:39:01 -0800776 #NOTE Check ping result here..add code for it
777
778
shahshreya4e13a062014-11-11 16:46:18 -0800779 main.step("Compare ONOS Topology to MN Topology")
780 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
781 MNTopo = Topo
782 Topology_Check = main.TRUE
783
784 devices_json = main.ONOS2.devices()
785 links_json = main.ONOS2.links()
786 ports_json = main.ONOS2.ports()
787 print "devices_json= ", devices_json
788
789 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
790 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
791 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
792
793 #result = result1 and result2 and result3
794 result = result1 and result2
795 print "***********************"
796
797 if result == main.TRUE:
798 main.log.report("ONOS"+ " Topology matches MN Topology")
799 utilities.assert_equals(expect=main.TRUE,actual=result,
800 onpass="ONOS" + " Topology matches MN Topology",
801 onfail="ONOS" + " Topology does not match MN Topology")
802
803 Topology_Check = Topology_Check and result
804 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
805 onpass="Topology checks passed", onfail="Topology checks failed")
806
807 result = Link_Down and Link_Up and Topology_Check
808 utilities.assert_equals(expect=main.TRUE,actual=result,
809 onpass="Link failure is discovered correctly",
810 onfail="Link Discovery failed")
811
812
813 def CASE8(self):
814 '''
815 Host intents removal
816 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800817 main.log.report("This testcase removes host intents before adding the same intents or point intents")
shahshreya4e13a062014-11-11 16:46:18 -0800818 main.log.report("__________________________________")
819 main.log.info("Host intents removal")
820 main.case("Removing host intents")
821 main.step("Obtain the intent id's")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800822 intent_result = main.ONOS2.intents(json_format = False)
823 main.log.info("intent_result = " +intent_result)
824
shahshreya4e13a062014-11-11 16:46:18 -0800825 intent_linewise = intent_result.split("\n")
shahshreyae6c7cf42014-11-26 16:39:01 -0800826 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800827 for line in intent_linewise:
shahshreyae6c7cf42014-11-26 16:39:01 -0800828 if line.startswith("id="):
829 intentList.append(line)
830
831 intentids = []
832 for line in intentList:
shahshreya4e13a062014-11-11 16:46:18 -0800833 intentids.append(line.split(",")[0].split("=")[1])
834 for id in intentids:
835 print "id = ", id
836
837 main.step("Iterate through the intentids list and remove each intent")
838 for id in intentids:
839 main.ONOS2.remove_intent(intent_id = id)
840
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800841 intent_result = main.ONOS2.intents(json_format = False)
842 main.log.info("intent_result = " +intent_result)
shahshreyae6c7cf42014-11-26 16:39:01 -0800843
shahshreya4e13a062014-11-11 16:46:18 -0800844 case8_result = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800845 if case8_result == main.TRUE:
846 main.log.report("Intent removal successful")
847 else:
848 main.log.report("Intent removal failed")
shahshreyae6c7cf42014-11-26 16:39:01 -0800849
850 Ping_Result = main.TRUE
851 if case8_result == main.TRUE:
852 i = 8
853 while i <18 :
854 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
855 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
856 if ping==main.TRUE:
857 i = 19
858 Ping_Result = Ping_Result and main.TRUE
859 elif ping==main.FALSE:
860 i+=1
861 Ping_Result = Ping_Result and main.FALSE
862 else:
863 main.log.info("Unknown error")
864 Ping_Result = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -0800865
shahshreyae6c7cf42014-11-26 16:39:01 -0800866 #Note: If the ping result failed, that means the intents have been withdrawn correctly.
867 if Ping_Result==main.TRUE:
868 main.log.report("Host intents have not been withdrawn correctly")
869 #main.cleanup()
870 #main.exit()
871 if Ping_Result==main.FALSE:
872 main.log.report("Host intents have been withdrawn correctly")
shahshreya4e13a062014-11-11 16:46:18 -0800873
shahshreyae6c7cf42014-11-26 16:39:01 -0800874 case8_result = case8_result and Ping_Result
875
876 if case8_result == main.FALSE:
877 main.log.report("Intent removal successful")
878 else:
879 main.log.report("Intent removal failed")
880
881 utilities.assert_equals(expect=main.FALSE, actual=case8_result,
882 onpass="Intent removal test failed",
883 onfail="Intent removal test passed")
shahshreya4e13a062014-11-11 16:46:18 -0800884
885
886 def CASE9(self):
887 main.log.report("This testcase adds point intents and then does pingall")
888 main.log.report("__________________________________")
889 main.log.info("Adding point intents")
890 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)")
891 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 -0800892 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
shahshreya4e13a062014-11-11 16:46:18 -0800893 if ptp_intent_result == main.TRUE:
894 get_intent_result = main.ONOS2.intents()
895 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800896 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800897
shahshreyae6c7cf42014-11-26 16:39:01 -0800898 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
shahshreya4e13a062014-11-11 16:46:18 -0800899 if ptp_intent_result == main.TRUE:
900 get_intent_result = main.ONOS2.intents()
901 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800902 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800903
904 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 -0800905 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
shahshreya4e13a062014-11-11 16:46:18 -0800906 if ptp_intent_result == main.TRUE:
907 get_intent_result = main.ONOS2.intents()
908 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800909 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800910
shahshreyae6c7cf42014-11-26 16:39:01 -0800911 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
shahshreya4e13a062014-11-11 16:46:18 -0800912 if ptp_intent_result == main.TRUE:
913 get_intent_result = main.ONOS2.intents()
914 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800915 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800916
917 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 -0800918 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
shahshreya4e13a062014-11-11 16:46:18 -0800919 if ptp_intent_result == main.TRUE:
920 get_intent_result = main.ONOS2.intents()
921 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800922 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800923
shahshreyae6c7cf42014-11-26 16:39:01 -0800924 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
shahshreya4e13a062014-11-11 16:46:18 -0800925 if ptp_intent_result == main.TRUE:
926 get_intent_result = main.ONOS2.intents()
927 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800928 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800929
930 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 -0800931 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
shahshreya4e13a062014-11-11 16:46:18 -0800932 if ptp_intent_result == main.TRUE:
933 get_intent_result = main.ONOS2.intents()
934 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800935 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800936
shahshreyae6c7cf42014-11-26 16:39:01 -0800937 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
shahshreya4e13a062014-11-11 16:46:18 -0800938 if ptp_intent_result == main.TRUE:
939 get_intent_result = main.ONOS2.intents()
940 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800941 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800942
943 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 -0800944 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
shahshreya4e13a062014-11-11 16:46:18 -0800945 if ptp_intent_result == main.TRUE:
946 get_intent_result = main.ONOS2.intents()
947 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800948 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800949
shahshreyae6c7cf42014-11-26 16:39:01 -0800950 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
shahshreya4e13a062014-11-11 16:46:18 -0800951 if ptp_intent_result == main.TRUE:
952 get_intent_result = main.ONOS2.intents()
953 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800954 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800955
956 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 -0800957 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
shahshreya4e13a062014-11-11 16:46:18 -0800958 if ptp_intent_result == main.TRUE:
959 get_intent_result = main.ONOS2.intents()
960 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800961 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800962
shahshreyae6c7cf42014-11-26 16:39:01 -0800963 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
shahshreya4e13a062014-11-11 16:46:18 -0800964 if ptp_intent_result == main.TRUE:
965 get_intent_result = main.ONOS2.intents()
966 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800967 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800968
969 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 -0800970 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
shahshreya4e13a062014-11-11 16:46:18 -0800971 if ptp_intent_result == main.TRUE:
972 get_intent_result = main.ONOS2.intents()
973 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800974 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800975
shahshreyae6c7cf42014-11-26 16:39:01 -0800976 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
shahshreya4e13a062014-11-11 16:46:18 -0800977 if ptp_intent_result == main.TRUE:
978 get_intent_result = main.ONOS2.intents()
979 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800980 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800981
982 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 -0800983 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
shahshreya4e13a062014-11-11 16:46:18 -0800984 if ptp_intent_result == main.TRUE:
985 get_intent_result = main.ONOS2.intents()
986 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800987 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800988
shahshreyae6c7cf42014-11-26 16:39:01 -0800989 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
shahshreya4e13a062014-11-11 16:46:18 -0800990 if ptp_intent_result == main.TRUE:
991 get_intent_result = main.ONOS2.intents()
992 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800993 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800994
995 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 -0800996 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
shahshreya4e13a062014-11-11 16:46:18 -0800997 if ptp_intent_result == main.TRUE:
998 get_intent_result = main.ONOS2.intents()
999 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001000 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001001
shahshreyae6c7cf42014-11-26 16:39:01 -08001002 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
shahshreya4e13a062014-11-11 16:46:18 -08001003 if ptp_intent_result == main.TRUE:
1004 get_intent_result = main.ONOS2.intents()
1005 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001006 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001007
1008
1009 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 -08001010 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
shahshreya4e13a062014-11-11 16:46:18 -08001011 if ptp_intent_result == main.TRUE:
1012 get_intent_result = main.ONOS2.intents()
1013 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001014 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001015
shahshreyae6c7cf42014-11-26 16:39:01 -08001016 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
shahshreya4e13a062014-11-11 16:46:18 -08001017 if ptp_intent_result == main.TRUE:
1018 get_intent_result = main.ONOS2.intents()
1019 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001020 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001021
1022 print("_______________________________________________________________________________________")
1023
1024 flowHandle = main.ONOS2.flows()
1025 #print "flowHandle = ", flowHandle
1026 main.log.info("flows :" + flowHandle)
1027
1028 count = 1
1029 i = 8
1030 Ping_Result = main.TRUE
1031 while i <18 :
1032 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
1033 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
1034 if ping == main.FALSE and count <5:
1035 count+=1
1036 #i = 8
1037 Ping_Result = main.FALSE
1038 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
1039 time.sleep(2)
1040 elif ping==main.FALSE:
1041 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
1042 i=19
1043 Ping_Result = main.FALSE
1044 elif ping==main.TRUE:
1045 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
1046 i+=1
1047 Ping_Result = main.TRUE
1048 else:
1049 main.log.info("Unknown error")
1050 Ping_Result = main.ERROR
1051
1052 if Ping_Result==main.FALSE:
1053 main.log.report("Point intents have not ben installed correctly. Cleaning up")
1054 #main.cleanup()
1055 #main.exit()
1056 if Ping_Result==main.TRUE:
1057 main.log.report("Point Intents have been installed correctly")
1058
1059 case9_result = Ping_Result
1060 utilities.assert_equals(expect=main.TRUE, actual=case9_result,
1061 onpass="Point intents addition and Pingall Test successful",
1062 onfail="Point intents addition and Pingall Test NOT successful")
1063
1064