blob: babf853c04186b4c1cbe14b9faab9bef353a0a51 [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()
shahshreyaa22f8f82014-12-08 16:59:21 -080047 main.log.info("git_pull_result = " +git_pull_result)
shahshreya4e13a062014-11-11 16:46:18 -080048 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
shahshreyaa22f8f82014-12-08 16:59:21 -080054 elif git_pull_result == 0:
55 main.log.report("Git Pull Failed, look into logs for detailed reason")
56 main.cleanup()
57 main.exit()
shahshreyae6c7cf42014-11-26 16:39:01 -080058
shahshreya4e13a062014-11-11 16:46:18 -080059 main.step("Creating ONOS package")
60 package_result = main.ONOSbench.onos_package()
61
shahshreya4e13a062014-11-11 16:46:18 -080062
63 main.step("Installing ONOS package")
64 onos_install_result = main.ONOSbench.onos_install()
65 if onos_install_result == main.TRUE:
66 main.log.report("Installing ONOS package successful")
67 else:
68 main.log.report("Installing ONOS package failed")
69
70 onos1_isup = main.ONOSbench.isup()
71 if onos1_isup == main.TRUE:
72 main.log.report("ONOS instance is up and ready")
73 else:
74 main.log.report("ONOS instance may not be up")
75
76 main.step("Starting ONOS service")
77 start_result = main.ONOSbench.onos_start(ONOS1_ip)
shahshreyae6c7cf42014-11-26 16:39:01 -080078
79 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
shahshreya4e13a062014-11-11 16:46:18 -080080
81 case1_result = (package_result and\
82 cell_result and verify_result and onos_install_result and\
83 onos1_isup and start_result )
84 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
85 onpass="Test startup successful",
86 onfail="Test startup NOT successful")
87
shahshreyaa22f8f82014-12-08 16:59:21 -080088 def CASE2(self, main) :
89 '''
90 Switch Down
91 '''
92 #NOTE: You should probably run a topology check after this
93 import time
94 import json
95
96 main.case("Switch down discovery")
97 main.log.report("This testcase is testing a switch down discovery")
98 main.log.report("__________________________________")
99
100 switch_sleep = int(main.params['timers']['SwitchDiscovery'])
101
102 description = "Killing a switch to ensure it is discovered correctly"
103 main.log.report(description)
104 main.case(description)
105
106 #TODO: Make this switch parameterizable
107 main.step("Kill s28 ")
108 main.log.report("Deleting s28")
109 #FIXME: use new dynamic topo functions
110 main.Mininet1.del_switch("s28")
111 main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
112 time.sleep(switch_sleep)
113 #Peek at the deleted switch
114 device = main.ONOS2.get_device(dpid="0028")
115 print "device = ", device
116 if device[u'available'] == 'False':
117 case2_result = main.FALSE
118 else:
119 case2_result = main.TRUE
120 utilities.assert_equals(expect=main.TRUE, actual=case2_result,
121 onpass="Switch down discovery successful",
122 onfail="Switch down discovery failed")
123
shahshreya4e13a062014-11-11 16:46:18 -0800124 def CASE11(self, main):
125 '''
126 Cleanup sequence:
127 onos-service <node_ip> stop
128 onos-uninstall
129
130 TODO: Define rest of cleanup
131
132 '''
133
134 ONOS1_ip = main.params['CTRL']['ip1']
135
136 main.case("Cleaning up test environment")
137
138 main.step("Testing ONOS kill function")
139 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
140
141 main.step("Stopping ONOS service")
142 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
143
144 main.step("Uninstalling ONOS service")
145 uninstall_result = main.ONOSbench.onos_uninstall()
146
147 def CASE3(self, main):
148 '''
149 Test 'onos' command and its functionality in driver
150 '''
151
152 ONOS1_ip = main.params['CTRL']['ip1']
153
154 main.case("Testing 'onos' command")
155
156 main.step("Sending command 'onos -w <onos-ip> system:name'")
157 cmdstr1 = "system:name"
158 cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
159 main.log.info("onos command returned: "+cmd_result1)
160
161 main.step("Sending command 'onos -w <onos-ip> onos:topology'")
162 cmdstr2 = "onos:topology"
163 cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
164 main.log.info("onos command returned: "+cmd_result2)
165
166
shahshreyae6c7cf42014-11-26 16:39:01 -0800167 def CASE20(self):
168 '''
169 Exit from mininet cli
170 reinstall ONOS
171 '''
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800172 cell_name = main.params['ENV']['cellName']
173 ONOS1_ip = main.params['CTRL']['ip1']
174 ONOS1_port = main.params['CTRL']['port1']
175
shahshreyae6c7cf42014-11-26 16:39:01 -0800176 main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
177 main.log.report("_____________________________________________")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800178 main.case("Disconnecting mininet and restarting ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800179 main.step("Disconnecting mininet and restarting ONOS")
180 mininet_disconnect = main.Mininet1.disconnect()
181
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800182 main.step("Removing raft logs before a clen installation of ONOS")
183 main.ONOSbench.onos_remove_raft_logs()
184
shahshreyae6c7cf42014-11-26 16:39:01 -0800185 main.step("Applying cell variable to environment")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800186 cell_result = main.ONOSbench.set_cell(cell_name)
shahshreyae6c7cf42014-11-26 16:39:01 -0800187 verify_result = main.ONOSbench.verify_cell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800188
189 onos_install_result = main.ONOSbench.onos_install()
190 if onos_install_result == main.TRUE:
191 main.log.report("Installing ONOS package successful")
192 else:
193 main.log.report("Installing ONOS package failed")
194
195 onos1_isup = main.ONOSbench.isup()
196 if onos1_isup == main.TRUE:
197 main.log.report("ONOS instance is up and ready")
198 else:
199 main.log.report("ONOS instance may not be up")
200
201 main.step("Starting ONOS service")
202 start_result = main.ONOSbench.onos_start(ONOS1_ip)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800203
204 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
shahshreyae6c7cf42014-11-26 16:39:01 -0800205 print "mininet_disconnect =", mininet_disconnect
206 print "onos_install_result =", onos_install_result
207 print "onos1_isup =", onos1_isup
208 print "start_result =", start_result
209
210 case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
211 utilities.assert_equals(expect=main.TRUE, actual=case20_result,
212 onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
213 onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
214
215 def CASE21(self, main):
216 import time
217 '''
218 On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
219 which starts the rest and copies the links json file to the onos instance
220 Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
221 from the json config file
222 '''
223 main.log.report("This testcase starts the packet layer topology and REST")
224 main.log.report("_____________________________________________")
225 main.case("Starting LINC-OE and other components")
226 main.step("Starting LINC-OE and other components")
227 start_console_result = main.LincOE1.start_console()
228 optical_mn_script = main.LincOE2.run_optical_mn_script()
229 onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
230
231 print "start_console_result =",start_console_result
232 print "optical_mn_script = ",optical_mn_script
233 print "onos_topo_cfg_result =",onos_topo_cfg_result
234
235 case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
236 utilities.assert_equals(expect=main.TRUE, actual=case21_result,
237 onpass="Packet optical topology spawned successsfully",
238 onfail="Packet optical topology spawning failed")
239
240
241 def CASE22(self, main):
242 '''
243 Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
244 Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
245 and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
246 '''
247
248 main.log.report("This testcase compares the optical+packet topology against what is expected")
249 main.case("Topology comparision")
250 main.step("Topology comparision")
251 main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
252 devices_result = main.ONOS3.devices(json_format = False)
253
254 print "devices_result = ", devices_result
255 devices_linewise = devices_result.split("\n")
256 devices_linewise = devices_linewise[1:-1]
257 roadmCount = 0
258 packetLayerSWCount = 0
259 for line in devices_linewise:
260 components = line.split(",")
261 availability = components[1].split("=")[1]
262 type = components[3].split("=")[1]
263 if availability == 'true' and type == 'ROADM':
264 roadmCount += 1
265 elif availability == 'true' and type =='SWITCH':
266 packetLayerSWCount += 1
267 if roadmCount == 4:
268 print "Number of Optical Switches = %d and is correctly detected" %roadmCount
269 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
270 opticalSW_result = main.TRUE
271 else:
272 print "Number of Optical Switches = %d and is wrong" %roadCount
273 main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
274 opticalSW_result = main.FALSE
275
276 if packetLayerSWCount == 2:
277 print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
278 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
279 packetSW_result = main.TRUE
280 else:
281 print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
282 main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
283 packetSW_result = main.FALSE
284 print "_________________________________"
285
286 links_result = main.ONOS3.links(json_format = False)
287 print "links_result = ", links_result
288 print "_________________________________"
289
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800290 #NOTE:Since only point intents are added, there is no requirement to discover the hosts
291 #Therfore, the below portion of the code is commented.
292 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800293 #Discover hosts using pingall
294 pingall_result = main.LincOE2.pingall()
295
296 hosts_result = main.ONOS3.hosts(json_format = False)
297 main.log.info("hosts_result = "+hosts_result)
298 main.log.info("_________________________________")
299 hosts_linewise = hosts_result.split("\n")
300 hosts_linewise = hosts_linewise[1:-1]
301 hostCount = 0
302 for line in hosts_linewise:
303 hostid = line.split(",")[0].split("=")[1]
304 hostCount +=1
305 if hostCount ==2:
306 print "Number of hosts = %d and is correctly detected" %hostCount
307 main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
308 hostDiscovery = main.TRUE
309 else:
310 print "Number of hosts = %d and is wrong" %hostCount
311 main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
312 hostDiscovery = main.FALSE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800313 '''
314
315 case22_result = opticalSW_result and packetSW_result
shahshreyae6c7cf42014-11-26 16:39:01 -0800316 utilities.assert_equals(expect=main.TRUE, actual=case22_result,
317 onpass="Packet optical topology discovery successful",
318 onfail="Packet optical topology discovery failed")
319
320 def CASE23(self, main):
321 import time
322 '''
323 Add bidirectional point intents between 2 packet layer(mininet) devices and
324 ping mininet hosts
325 '''
326 main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
327 main.case("Topology comparision")
328 main.step("Adding point intents")
329 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
330 if ptp_intent_result == main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800331 get_intent_result = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800332 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800333
334 ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
335 if ptp_intent_result == main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800336 get_intent_result = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800337 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800338
339 time.sleep(10)
340 flowHandle = main.ONOS3.flows()
341 main.log.info("flows :" + flowHandle)
342
343 # Sleep for 30 seconds to provide time for the intent state to change
344 time.sleep(30)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800345 intentHandle = main.ONOS3.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800346 main.log.info("intents :" + intentHandle)
347
348 Ping_Result = main.TRUE
349 count = 1
350 main.log.info("\n\nh1 is Pinging h2")
351 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
352 #ping = main.LincOE2.pinghost()
353 if ping == main.FALSE and count<5:
354 count+=1
355 Ping_Result = main.FALSE
356 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
357 time.sleep(2)
shahshreyae6c7cf42014-11-26 16:39:01 -0800358 elif ping==main.FALSE:
359 main.log.info("All ping attempts between h1 and h2 have failed")
360 Ping_Result = main.FALSE
361 elif ping==main.TRUE:
362 main.log.info("Ping test between h1 and h2 passed!")
363 Ping_Result = main.TRUE
364 else:
365 main.log.info("Unknown error")
366 Ping_Result = main.ERROR
367
368 if Ping_Result==main.FALSE:
369 main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
370 if Ping_Result==main.TRUE:
371 main.log.report("Point Intents for packet optical have been installed correctly")
372
373 case23_result = Ping_Result
374 utilities.assert_equals(expect=main.TRUE, actual=case23_result,
375 onpass="Point intents addition for packet optical and Pingall Test successful",
376 onfail="Point intents addition for packet optical and Pingall Test NOT successful")
377
378
379
380 def CASE24(self, main):
381 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800382 import json
shahshreyae6c7cf42014-11-26 16:39:01 -0800383 '''
384 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
385 and do a ping test. If rerouting is successful, ping should pass. also check the flows
386 '''
387 main.log.report("This testcase tests rerouting and pings mininet hosts")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800388 main.case("Test rerouting and pings mininet hosts")
389 main.step("Bring a port down and verify the link state")
390 main.LincOE1.port_down(sw_id="1", pt_id="22")
391 links_nonjson = main.ONOS3.links(json_format = False)
392 main.log.info("links = " +links_nonjson)
393
394 links = main.ONOS3.links()
395 main.log.info("links = " +links)
396
397 links_result = json.loads(links)
shahshreyae6c7cf42014-11-26 16:39:01 -0800398 links_state_result = main.FALSE
399 for item in links_result:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800400 if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22":
401 if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30":
402 links_state = item['state']
403 if links_state == "INACTIVE":
404 main.log.info("Links state is inactive as expected due to one of the ports being down")
405 main.log.report("Links state is inactive as expected due to one of the ports being down")
406 links_state_result = main.TRUE
407 break
408 else:
409 main.log.info("Links state is not inactive as expected")
410 main.log.report("Links state is not inactive as expected")
411 links_state_result = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800412
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800413 print "links_state_result = ", links_state_result
414 time.sleep(10)
415 flowHandle = main.ONOS3.flows()
416 main.log.info("flows :" + flowHandle)
417
418 main.step("Verify Rerouting by a ping test")
shahshreyae6c7cf42014-11-26 16:39:01 -0800419 Ping_Result = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800420 count = 1
shahshreyae6c7cf42014-11-26 16:39:01 -0800421 main.log.info("\n\nh1 is Pinging h2")
422 ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
423 #ping = main.LincOE2.pinghost()
424 if ping == main.FALSE and count<5:
425 count+=1
426 Ping_Result = main.FALSE
427 main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
428 time.sleep(2)
shahshreyae6c7cf42014-11-26 16:39:01 -0800429 elif ping==main.FALSE:
430 main.log.info("All ping attempts between h1 and h2 have failed")
431 Ping_Result = main.FALSE
432 elif ping==main.TRUE:
433 main.log.info("Ping test between h1 and h2 passed!")
434 Ping_Result = main.TRUE
435 else:
436 main.log.info("Unknown error")
437 Ping_Result = main.ERROR
438
shahshreyae6c7cf42014-11-26 16:39:01 -0800439 if Ping_Result==main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800440 main.log.report("Ping test successful ")
441 if Ping_Result==main.FALSE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800442 main.log.report("Ping test failed")
443
444 case24_result = Ping_Result and links_state_result
445 utilities.assert_equals(expect=main.TRUE, actual=case24_result,
446 onpass="Packet optical rerouting successful",
447 onfail="Packet optical rerouting failed")
shahshreya4e13a062014-11-11 16:46:18 -0800448
449 def CASE4(self, main):
450 import re
451 import time
452 main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode")
453 main.log.report("__________________________________")
454 main.case("Pingall Test")
455 main.step("Assigning switches to controllers")
456 for i in range(1,29):
457 if i ==1:
458 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
459 elif i>=2 and i<5:
460 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
461 elif i>=5 and i<8:
462 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
463 elif i>=8 and i<18:
464 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
465 elif i>=18 and i<28:
466 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
467 else:
468 main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port)
469 Switch_Mastership = main.TRUE
470 for i in range (1,29):
471 if i==1:
472 response = main.Mininet1.get_sw_controller("s"+str(i))
473 print("Response is " + str(response))
474 if re.search("tcp:"+ONOS1_ip,response):
475 Switch_Mastership = Switch_Mastership and main.TRUE
476 else:
477 Switch_Mastership = main.FALSE
478 elif i>=2 and i<5:
479 response = main.Mininet1.get_sw_controller("s"+str(i))
480 print("Response is " + str(response))
481 if re.search("tcp:"+ONOS1_ip,response):
482 Switch_Mastership = Switch_Mastership and main.TRUE
483 else:
484 Switch_Mastership = main.FALSE
485 elif i>=5 and i<8:
486 response = main.Mininet1.get_sw_controller("s"+str(i))
487 print("Response is " + str(response))
488 if re.search("tcp:"+ONOS1_ip,response):
489 Switch_Mastership = Switch_Mastership and main.TRUE
490 else:
491 Switch_Mastership = main.FALSE
492 elif i>=8 and i<18:
493 response = main.Mininet1.get_sw_controller("s"+str(i))
494 print("Response is " + str(response))
495 if re.search("tcp:"+ONOS1_ip,response):
496 Switch_Mastership = Switch_Mastership and main.TRUE
497 else:
498 Switch_Mastership = main.FALSE
499 elif i>=18 and i<28:
500 response = main.Mininet1.get_sw_controller("s"+str(i))
501 print("Response is " + str(response))
502 if re.search("tcp:"+ONOS1_ip,response):
503 Switch_Mastership = Switch_Mastership and main.TRUE
504 else:
505 Switch_Mastership = main.FALSE
506 else:
507 response = main.Mininet1.get_sw_controller("s"+str(i))
508 print("Response is" + str(response))
509 if re.search("tcp:" +ONOS1_ip,response):
510 Switch_Mastership = Switch_Mastership and main.TRUE
511 else:
512 Switch_Mastership = main.FALSE
513
514 if Switch_Mastership == main.TRUE:
515 main.log.report("Controller assignmnet successful")
516 else:
517 main.log.report("Controller assignmnet failed")
518 utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership,
519 onpass="MasterControllers assigned correctly")
520 '''
521 for i in range (1,29):
522 main.Mininet1.assign_sw_controller(sw=str(i),count=5,
523 ip1=ONOS1_ip,port1=ONOS1_port,
524 ip2=ONOS2_ip,port2=ONOS2_port,
525 ip3=ONOS3_ip,port3=ONOS3_port,
526 ip4=ONOS4_ip,port4=ONOS4_port,
527 ip5=ONOS5_ip,port5=ONOS5_port)
528 '''
529 #REACTIVE FWD test
530
531 main.step("Get list of hosts from Mininet")
532 host_list = main.Mininet1.get_hosts()
533 main.log.info(host_list)
534
535 main.step("Get host list in ONOS format")
536 host_onos_list = main.ONOS2.get_hosts_id(host_list)
537 main.log.info(host_onos_list)
538 #time.sleep(5)
539
540 main.step("Pingall")
541 ping_result = main.FALSE
542 while ping_result == main.FALSE:
543 time1 = time.time()
544 ping_result = main.Mininet1.pingall()
545 time2 = time.time()
546 print "Time for pingall: %2f seconds" % (time2 - time1)
547
548 #Start onos cli again because u might have dropped out of onos prompt to the shell prompt
549 #if there was no activity
550 main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
551
552 case4_result = Switch_Mastership and ping_result
553 if ping_result == main.TRUE:
554 main.log.report("Pingall Test in reactive mode to discover the hosts successful")
555 else:
556 main.log.report("Pingall Test in reactive mode to discover the hosts failed")
557
shahshreyae6c7cf42014-11-26 16:39:01 -0800558 utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
559
560 def CASE10(self):
561 main.log.report("This testcase uninstalls the reactive forwarding app")
562 main.log.report("__________________________________")
563 main.case("Uninstalling reactive forwarding app")
564 #Unistall onos-app-fwd app to disable reactive forwarding
565 appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
566 main.log.info("onos-app-fwd uninstalled")
567
568 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
569 #So sleep for 15s
570 time.sleep(15)
571
572 flows = main.ONOS2.flows()
573 main.log.info(flows)
574
575 case10_result = appUninstall_result
576 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 -0800577
578
579 def CASE6(self):
shahshreyae6c7cf42014-11-26 16:39:01 -0800580 main.log.report("This testcase is testing the addition of host intents and then does pingall")
shahshreya4e13a062014-11-11 16:46:18 -0800581 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -0800582 main.case("Obtaining host id's")
shahshreya4e13a062014-11-11 16:46:18 -0800583 main.step("Get hosts")
shahshreyae6c7cf42014-11-26 16:39:01 -0800584 hosts = main.ONOS2.hosts()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800585 #main.log.info(hosts)
shahshreya4e13a062014-11-11 16:46:18 -0800586
587 main.step("Get all devices id")
588 devices_id_list = main.ONOS2.get_all_devices_id()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800589 #main.log.info(devices_id_list)
shahshreya4e13a062014-11-11 16:46:18 -0800590
591 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
592 #So take care while adding intents
shahshreyae6c7cf42014-11-26 16:39:01 -0800593 '''
shahshreya4e13a062014-11-11 16:46:18 -0800594 main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
595 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
596 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
597 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
598 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
599 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
600 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
601 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
602 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
603 hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
604 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 -0800605 print "_____________________________________________________________________________________"
shahshreyae6c7cf42014-11-26 16:39:01 -0800606 '''
shahshreya4e13a062014-11-11 16:46:18 -0800607
shahshreyae6c7cf42014-11-26 16:39:01 -0800608 for i in range(8,18):
609 main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
610 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
611 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
612 #NOTE: get host can return None
613 #TODO: handle this
614 host1_id = main.ONOS2.get_host(host1)['id']
615 host2_id = main.ONOS2.get_host(host2)['id']
616 tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800617
shahshreyae6c7cf42014-11-26 16:39:01 -0800618 time.sleep(10)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800619 h_intents = main.ONOS2.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800620 main.log.info("intents:" +h_intents)
shahshreya4e13a062014-11-11 16:46:18 -0800621 flowHandle = main.ONOS2.flows()
shahshreyae6c7cf42014-11-26 16:39:01 -0800622 #main.log.info("flow:" +flowHandle)
shahshreya4e13a062014-11-11 16:46:18 -0800623
624 count = 1
625 i = 8
626 Ping_Result = main.TRUE
627 #while i<10:
628 while i <18 :
629 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
630 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
631 if ping == main.FALSE and count <5:
632 count+=1
633 #i = 8
634 Ping_Result = main.FALSE
635 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
636 time.sleep(2)
637 elif ping==main.FALSE:
638 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
639 i=19
640 Ping_Result = main.FALSE
641 elif ping==main.TRUE:
642 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
643 i+=1
644 Ping_Result = main.TRUE
645 else:
646 main.log.info("Unknown error")
647 Ping_Result = main.ERROR
648 if Ping_Result==main.FALSE:
649 main.log.report("Ping all test after Host intent addition failed. Cleaning up")
650 #main.cleanup()
651 #main.exit()
652 if Ping_Result==main.TRUE:
653 main.log.report("Ping all test after Host intent addition successful")
654
655 case6_result = Ping_Result
shahshreyae6c7cf42014-11-26 16:39:01 -0800656 utilities.assert_equals(expect=main.TRUE, actual=case6_result,
shahshreya4e13a062014-11-11 16:46:18 -0800657 onpass="Pingall Test after Host intents addition successful",
658 onfail="Pingall Test after Host intents addition failed")
659
660
661 def CASE5(self,main) :
662 import json
663 from subprocess import Popen, PIPE
664 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
665 #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
666 deviceResult = main.ONOS2.devices()
667 linksResult = main.ONOS2.links()
668 #portsResult = main.ONOS2.ports()
669 print "**************"
670
671 main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet")
672 main.log.report("__________________________________")
673 main.case("Comparing Mininet topology with the topology of ONOS")
674 main.step("Start continuous pings")
675 main.Mininet2.pingLong(src=main.params['PING']['source1'],
676 target=main.params['PING']['target1'],pingTime=500)
677 main.Mininet2.pingLong(src=main.params['PING']['source2'],
678 target=main.params['PING']['target2'],pingTime=500)
679 main.Mininet2.pingLong(src=main.params['PING']['source3'],
680 target=main.params['PING']['target3'],pingTime=500)
681 main.Mininet2.pingLong(src=main.params['PING']['source4'],
682 target=main.params['PING']['target4'],pingTime=500)
683 main.Mininet2.pingLong(src=main.params['PING']['source5'],
684 target=main.params['PING']['target5'],pingTime=500)
685 main.Mininet2.pingLong(src=main.params['PING']['source6'],
686 target=main.params['PING']['target6'],pingTime=500)
687 main.Mininet2.pingLong(src=main.params['PING']['source7'],
688 target=main.params['PING']['target7'],pingTime=500)
689 main.Mininet2.pingLong(src=main.params['PING']['source8'],
690 target=main.params['PING']['target8'],pingTime=500)
691 main.Mininet2.pingLong(src=main.params['PING']['source9'],
692 target=main.params['PING']['target9'],pingTime=500)
693 main.Mininet2.pingLong(src=main.params['PING']['source10'],
694 target=main.params['PING']['target10'],pingTime=500)
695
696 main.step("Create TestONTopology object")
697 global ctrls
698 ctrls = []
699 count = 1
700 while True:
701 temp = ()
702 if ('ip' + str(count)) in main.params['CTRL']:
703 temp = temp + (getattr(main,('ONOS' + str(count))),)
704 temp = temp + ("ONOS"+str(count),)
705 temp = temp + (main.params['CTRL']['ip'+str(count)],)
706 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
707 ctrls.append(temp)
708 count = count + 1
709 else:
710 break
711 global MNTopo
712 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
713 MNTopo = Topo
714
715 Topology_Check = main.TRUE
716 main.step("Compare ONOS Topology to MN Topology")
717 devices_json = main.ONOS2.devices()
718 links_json = main.ONOS2.links()
719 #ports_json = main.ONOS2.ports()
720 print "devices_json= ", devices_json
721
722 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
723 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
724 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
725
726 #result = result1 and result2 and result3
727 result = result1 and result2
728
729 print "***********************"
730 if result == main.TRUE:
731 main.log.report("ONOS"+ " Topology matches MN Topology")
732 else:
733 main.log.report("ONOS"+ " Topology does not match MN Topology")
734
735 utilities.assert_equals(expect=main.TRUE,actual=result,
736 onpass="ONOS" + " Topology matches MN Topology",
737 onfail="ONOS" + " Topology does not match MN Topology")
738
739 Topology_Check = Topology_Check and result
740 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
741 onpass="Topology checks passed", onfail="Topology checks failed")
742
743
744 def CASE7 (self,main):
745
746 ONOS1_ip = main.params['CTRL']['ip1']
747
748 link_sleep = int(main.params['timers']['LinkDiscovery'])
749
750 main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
751 main.log.report("__________________________________")
752 main.log.report("Killing a link to ensure that link discovery is consistent")
753 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
shahshreyae6c7cf42014-11-26 16:39:01 -0800754 '''
shahshreya4e13a062014-11-11 16:46:18 -0800755 main.step("Start continuous pings")
756
757 main.Mininet2.pingLong(src=main.params['PING']['source1'],
758 target=main.params['PING']['target1'],pingTime=500)
759 main.Mininet2.pingLong(src=main.params['PING']['source2'],
760 target=main.params['PING']['target2'],pingTime=500)
761 main.Mininet2.pingLong(src=main.params['PING']['source3'],
762 target=main.params['PING']['target3'],pingTime=500)
763 main.Mininet2.pingLong(src=main.params['PING']['source4'],
764 target=main.params['PING']['target4'],pingTime=500)
765 main.Mininet2.pingLong(src=main.params['PING']['source5'],
766 target=main.params['PING']['target5'],pingTime=500)
767 main.Mininet2.pingLong(src=main.params['PING']['source6'],
768 target=main.params['PING']['target6'],pingTime=500)
769 main.Mininet2.pingLong(src=main.params['PING']['source7'],
770 target=main.params['PING']['target7'],pingTime=500)
771 main.Mininet2.pingLong(src=main.params['PING']['source8'],
772 target=main.params['PING']['target8'],pingTime=500)
773 main.Mininet2.pingLong(src=main.params['PING']['source9'],
774 target=main.params['PING']['target9'],pingTime=500)
775 main.Mininet2.pingLong(src=main.params['PING']['source10'],
776 target=main.params['PING']['target10'],pingTime=500)
shahshreyae6c7cf42014-11-26 16:39:01 -0800777 '''
shahshreya4e13a062014-11-11 16:46:18 -0800778
779 main.step("Determine the current number of switches and links")
780 topology_output = main.ONOS2.topology()
781 topology_result = main.ONOS1.get_topology(topology_output)
782 activeSwitches = topology_result['devices']
783 links = topology_result['links']
784 print "activeSwitches = ", type(activeSwitches)
785 print "links = ", type(links)
786 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
787
788 main.step("Kill Link between s3 and s28")
789 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
790 time.sleep(link_sleep)
791 topology_output = main.ONOS2.topology()
792 Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2))
793 if Link_Down == main.TRUE:
794 main.log.report("Link Down discovered properly")
795 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
796 onpass="Link Down discovered properly",
797 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
798
799 #Check ping result here..add code for it
800
801 main.step("Bring link between s3 and s28 back up")
802 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
803 time.sleep(link_sleep)
804 topology_output = main.ONOS2.topology()
805 Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links))
806 if Link_Up == main.TRUE:
807 main.log.report("Link up discovered properly")
808 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
809 onpass="Link up discovered properly",
810 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
811
shahshreyae6c7cf42014-11-26 16:39:01 -0800812 #NOTE Check ping result here..add code for it
813
814
shahshreya4e13a062014-11-11 16:46:18 -0800815 main.step("Compare ONOS Topology to MN Topology")
816 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
817 MNTopo = Topo
818 Topology_Check = main.TRUE
819
820 devices_json = main.ONOS2.devices()
821 links_json = main.ONOS2.links()
822 ports_json = main.ONOS2.ports()
823 print "devices_json= ", devices_json
824
825 result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json))
826 result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json))
827 #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json))
828
829 #result = result1 and result2 and result3
830 result = result1 and result2
831 print "***********************"
832
833 if result == main.TRUE:
834 main.log.report("ONOS"+ " Topology matches MN Topology")
835 utilities.assert_equals(expect=main.TRUE,actual=result,
836 onpass="ONOS" + " Topology matches MN Topology",
837 onfail="ONOS" + " Topology does not match MN Topology")
838
839 Topology_Check = Topology_Check and result
840 utilities.assert_equals(expect=main.TRUE,actual=Topology_Check,
841 onpass="Topology checks passed", onfail="Topology checks failed")
842
843 result = Link_Down and Link_Up and Topology_Check
844 utilities.assert_equals(expect=main.TRUE,actual=result,
845 onpass="Link failure is discovered correctly",
846 onfail="Link Discovery failed")
847
848
849 def CASE8(self):
850 '''
851 Host intents removal
852 '''
shahshreyae6c7cf42014-11-26 16:39:01 -0800853 main.log.report("This testcase removes host intents before adding the same intents or point intents")
shahshreya4e13a062014-11-11 16:46:18 -0800854 main.log.report("__________________________________")
855 main.log.info("Host intents removal")
856 main.case("Removing host intents")
857 main.step("Obtain the intent id's")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800858 intent_result = main.ONOS2.intents(json_format = False)
859 main.log.info("intent_result = " +intent_result)
860
shahshreya4e13a062014-11-11 16:46:18 -0800861 intent_linewise = intent_result.split("\n")
shahshreyae6c7cf42014-11-26 16:39:01 -0800862 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800863 for line in intent_linewise:
shahshreyae6c7cf42014-11-26 16:39:01 -0800864 if line.startswith("id="):
865 intentList.append(line)
866
867 intentids = []
868 for line in intentList:
shahshreya4e13a062014-11-11 16:46:18 -0800869 intentids.append(line.split(",")[0].split("=")[1])
870 for id in intentids:
871 print "id = ", id
872
873 main.step("Iterate through the intentids list and remove each intent")
874 for id in intentids:
875 main.ONOS2.remove_intent(intent_id = id)
876
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800877 intent_result = main.ONOS2.intents(json_format = False)
878 main.log.info("intent_result = " +intent_result)
shahshreyae6c7cf42014-11-26 16:39:01 -0800879
shahshreya4e13a062014-11-11 16:46:18 -0800880 case8_result = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800881 if case8_result == main.TRUE:
882 main.log.report("Intent removal successful")
883 else:
884 main.log.report("Intent removal failed")
shahshreyae6c7cf42014-11-26 16:39:01 -0800885
886 Ping_Result = main.TRUE
887 if case8_result == main.TRUE:
888 i = 8
889 while i <18 :
890 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
891 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
892 if ping==main.TRUE:
893 i = 19
894 Ping_Result = Ping_Result and main.TRUE
895 elif ping==main.FALSE:
896 i+=1
897 Ping_Result = Ping_Result and main.FALSE
898 else:
899 main.log.info("Unknown error")
900 Ping_Result = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -0800901
shahshreyae6c7cf42014-11-26 16:39:01 -0800902 #Note: If the ping result failed, that means the intents have been withdrawn correctly.
903 if Ping_Result==main.TRUE:
904 main.log.report("Host intents have not been withdrawn correctly")
905 #main.cleanup()
906 #main.exit()
907 if Ping_Result==main.FALSE:
908 main.log.report("Host intents have been withdrawn correctly")
shahshreya4e13a062014-11-11 16:46:18 -0800909
shahshreyae6c7cf42014-11-26 16:39:01 -0800910 case8_result = case8_result and Ping_Result
911
912 if case8_result == main.FALSE:
913 main.log.report("Intent removal successful")
914 else:
915 main.log.report("Intent removal failed")
916
917 utilities.assert_equals(expect=main.FALSE, actual=case8_result,
918 onpass="Intent removal test failed",
919 onfail="Intent removal test passed")
shahshreya4e13a062014-11-11 16:46:18 -0800920
921
922 def CASE9(self):
923 main.log.report("This testcase adds point intents and then does pingall")
924 main.log.report("__________________________________")
925 main.log.info("Adding point intents")
926 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)")
927 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 -0800928 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
shahshreya4e13a062014-11-11 16:46:18 -0800929 if ptp_intent_result == main.TRUE:
930 get_intent_result = main.ONOS2.intents()
931 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800932 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800933
shahshreyae6c7cf42014-11-26 16:39:01 -0800934 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/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
940 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 -0800941 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
shahshreya4e13a062014-11-11 16:46:18 -0800942 if ptp_intent_result == main.TRUE:
943 get_intent_result = main.ONOS2.intents()
944 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800945 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800946
shahshreyae6c7cf42014-11-26 16:39:01 -0800947 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/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
953 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 -0800954 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
shahshreya4e13a062014-11-11 16:46:18 -0800955 if ptp_intent_result == main.TRUE:
956 get_intent_result = main.ONOS2.intents()
957 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800958 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800959
shahshreyae6c7cf42014-11-26 16:39:01 -0800960 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/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
966 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 -0800967 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
shahshreya4e13a062014-11-11 16:46:18 -0800968 if ptp_intent_result == main.TRUE:
969 get_intent_result = main.ONOS2.intents()
970 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800971 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800972
shahshreyae6c7cf42014-11-26 16:39:01 -0800973 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/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
979 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 -0800980 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
shahshreya4e13a062014-11-11 16:46:18 -0800981 if ptp_intent_result == main.TRUE:
982 get_intent_result = main.ONOS2.intents()
983 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800984 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800985
shahshreyae6c7cf42014-11-26 16:39:01 -0800986 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/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
992 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 -0800993 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
shahshreya4e13a062014-11-11 16:46:18 -0800994 if ptp_intent_result == main.TRUE:
995 get_intent_result = main.ONOS2.intents()
996 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -0800997 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800998
shahshreyae6c7cf42014-11-26 16:39:01 -0800999 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/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
1005 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 -08001006 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
shahshreya4e13a062014-11-11 16:46:18 -08001007 if ptp_intent_result == main.TRUE:
1008 get_intent_result = main.ONOS2.intents()
1009 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001010 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001011
shahshreyae6c7cf42014-11-26 16:39:01 -08001012 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
shahshreya4e13a062014-11-11 16:46:18 -08001013 if ptp_intent_result == main.TRUE:
1014 get_intent_result = main.ONOS2.intents()
1015 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001016 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001017
1018 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 -08001019 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/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
shahshreyae6c7cf42014-11-26 16:39:01 -08001025 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
shahshreya4e13a062014-11-11 16:46:18 -08001026 if ptp_intent_result == main.TRUE:
1027 get_intent_result = main.ONOS2.intents()
1028 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001029 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001030
1031 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 -08001032 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
shahshreya4e13a062014-11-11 16:46:18 -08001033 if ptp_intent_result == main.TRUE:
1034 get_intent_result = main.ONOS2.intents()
1035 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001036 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001037
shahshreyae6c7cf42014-11-26 16:39:01 -08001038 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
shahshreya4e13a062014-11-11 16:46:18 -08001039 if ptp_intent_result == main.TRUE:
1040 get_intent_result = main.ONOS2.intents()
1041 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001042 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001043
1044
1045 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 -08001046 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
shahshreya4e13a062014-11-11 16:46:18 -08001047 if ptp_intent_result == main.TRUE:
1048 get_intent_result = main.ONOS2.intents()
1049 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001050 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001051
shahshreyae6c7cf42014-11-26 16:39:01 -08001052 ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
shahshreya4e13a062014-11-11 16:46:18 -08001053 if ptp_intent_result == main.TRUE:
1054 get_intent_result = main.ONOS2.intents()
1055 main.log.info("Point to point intent install successful")
shahshreyae6c7cf42014-11-26 16:39:01 -08001056 #main.log.info(get_intent_result)
shahshreya4e13a062014-11-11 16:46:18 -08001057
1058 print("_______________________________________________________________________________________")
1059
1060 flowHandle = main.ONOS2.flows()
1061 #print "flowHandle = ", flowHandle
1062 main.log.info("flows :" + flowHandle)
1063
1064 count = 1
1065 i = 8
1066 Ping_Result = main.TRUE
1067 while i <18 :
1068 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
1069 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
1070 if ping == main.FALSE and count <5:
1071 count+=1
1072 #i = 8
1073 Ping_Result = main.FALSE
1074 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
1075 time.sleep(2)
1076 elif ping==main.FALSE:
1077 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
1078 i=19
1079 Ping_Result = main.FALSE
1080 elif ping==main.TRUE:
1081 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
1082 i+=1
1083 Ping_Result = main.TRUE
1084 else:
1085 main.log.info("Unknown error")
1086 Ping_Result = main.ERROR
1087
1088 if Ping_Result==main.FALSE:
1089 main.log.report("Point intents have not ben installed correctly. Cleaning up")
1090 #main.cleanup()
1091 #main.exit()
1092 if Ping_Result==main.TRUE:
1093 main.log.report("Point Intents have been installed correctly")
1094
1095 case9_result = Ping_Result
1096 utilities.assert_equals(expect=main.TRUE, actual=case9_result,
1097 onpass="Point intents addition and Pingall Test successful",
1098 onfail="Point intents addition and Pingall Test NOT successful")
1099
1100