blob: 1276d33afcc28685484e7bd79b9cd9961813c564 [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
9import time
10import json
11
12time.sleep(1)
13class MultiProd13:
14 def __init__(self):
15 self.default = ''
16
17 def CASE1(self, main):
18 '''
19 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080020 cell <name>
21 onos-verify-cell
22 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080023 git pull
24 mvn clean install
25 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080026 onos-install -f
27 onos-wait-for-start
28 '''
29
30 cell_name = main.params['ENV']['cellName']
31 ONOS1_ip = main.params['CTRL']['ip1']
32 ONOS2_ip = main.params['CTRL']['ip2']
33 ONOS3_ip = main.params['CTRL']['ip3']
34 ONOS1_port = main.params['CTRL']['port1']
35 ONOS2_port = main.params['CTRL']['port2']
shahshreyae6c7cf42014-11-26 16:39:01 -080036 ONOS3_port = main.params['CTRL']['port3']
37
shahshreya4e13a062014-11-11 16:46:18 -080038 main.case("Setting up test environment")
39 main.log.report("This testcase is testing setting up test environment")
40 main.log.report("__________________________________")
shahshreyae6c7cf42014-11-26 16:39:01 -080041
42 main.step("Applying cell variable to environment")
43 cell_result1 = main.ONOSbench.set_cell(cell_name)
44 #cell_result2 = main.ONOScli1.set_cell(cell_name)
45 #cell_result3 = main.ONOScli2.set_cell(cell_name)
46 #cell_result4 = main.ONOScli3.set_cell(cell_name)
47 verify_result = main.ONOSbench.verify_cell()
48 cell_result = cell_result1
49
50 main.step("Removing raft logs before a clen installation of ONOS")
51 remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
52
shahshreya4e13a062014-11-11 16:46:18 -080053 main.step("Git checkout and pull master and get version")
54 main.ONOSbench.git_checkout("master")
55 git_pull_result = main.ONOSbench.git_pull()
56 print "git_pull_result = ", git_pull_result
57 version_result = main.ONOSbench.get_version(report=True)
58
59 if git_pull_result == 1:
60 main.step("Using mvn clean & install")
61 clean_install_result = main.ONOSbench.clean_install()
62 #clean_install_result = main.TRUE
63
shahshreya4e13a062014-11-11 16:46:18 -080064 main.step("Creating ONOS package")
65 package_result = main.ONOSbench.onos_package()
66
67 #main.step("Creating a cell")
68 #cell_create_result = main.ONOSbench.create_cell_file(**************)
69
70 main.step("Installing ONOS package")
71 onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
72 onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip)
73 onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip)
74 onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
75 if onos_install_result == main.TRUE:
76 main.log.report("Installing ONOS package successful")
77 else:
78 main.log.report("Installing ONOS package failed")
79
80 onos1_isup = main.ONOSbench.isup(ONOS1_ip)
81 onos2_isup = main.ONOSbench.isup(ONOS2_ip)
82 onos3_isup = main.ONOSbench.isup(ONOS3_ip)
83 onos_isup = onos1_isup and onos2_isup and onos3_isup
84 if onos_isup == main.TRUE:
85 main.log.report("ONOS instances are up and ready")
86 else:
87 main.log.report("ONOS instances may not be up")
88
89 main.step("Starting ONOS service")
90 start_result = main.TRUE
91 #start_result = main.ONOSbench.onos_start(ONOS1_ip)
92 startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip)
93 startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip)
94 startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip)
95 print startcli1
96 print startcli2
97 print startcli3
98
99 case1_result = (package_result and\
100 cell_result and verify_result and onos_install_result and\
101 onos_isup and start_result )
102 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
103 onpass="Test startup successful",
104 onfail="Test startup NOT successful")
105
106 def CASE11(self, main):
107 '''
108 Cleanup sequence:
109 onos-service <node_ip> stop
110 onos-uninstall
111
112 TODO: Define rest of cleanup
113
114 '''
115
116 ONOS1_ip = main.params['CTRL']['ip1']
117 ONOS2_ip = main.params['CTRL']['ip2']
118 ONOS3_ip = main.params['CTRL']['ip3']
119
120 main.case("Cleaning up test environment")
121
122 main.step("Testing ONOS kill function")
123 kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip)
124 kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip)
125 kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip)
126
127 main.step("Stopping ONOS service")
128 stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip)
129 stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip)
130 stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip)
131
132 main.step("Uninstalling ONOS service")
133 uninstall_result = main.ONOSbench.onos_uninstall()
134
135 def CASE3(self, main):
136 '''
137 Test 'onos' command and its functionality in driver
138 '''
139
140 ONOS1_ip = main.params['CTRL']['ip1']
141 ONOS2_ip = main.params['CTRL']['ip2']
142 ONOS3_ip = main.params['CTRL']['ip3']
143
144 main.case("Testing 'onos' command")
145
146 main.step("Sending command 'onos -w <onos-ip> system:name'")
147 cmdstr1 = "system:name"
148 cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1)
149 main.log.info("onos command returned: "+cmd_result1)
150 cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1)
151 main.log.info("onos command returned: "+cmd_result2)
152 cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1)
153 main.log.info("onos command returned: "+cmd_result3)
154
155 main.step("Sending command 'onos -w <onos-ip> onos:topology'")
156 cmdstr2 = "onos:topology"
157 cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2)
158 main.log.info("onos command returned: "+cmd_result4)
159 cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2)
160 main.log.info("onos command returned: "+cmd_result5)
161 cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2)
162 main.log.info("onos command returned: "+cmd_result6)
163
164
165 def CASE4(self, main):
166 import re
167 import time
168 ONOS1_ip = main.params['CTRL']['ip1']
169 ONOS2_ip = main.params['CTRL']['ip2']
170 ONOS3_ip = main.params['CTRL']['ip3']
171 ONOS1_port = main.params['CTRL']['port1']
172 ONOS2_port = main.params['CTRL']['port2']
173 ONOS3_port = main.params['CTRL']['port3']
174
175 main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode")
176 main.log.report("__________________________________")
177 main.case("Pingall Test(No intents are added)")
178 main.step("Assigning switches to controllers")
179 for i in range(1,29): #1 to (num of switches +1)
180 main.Mininet1.assign_sw_controller(sw=str(i),count=3,
181 ip1=ONOS1_ip, port1=ONOS1_port,
182 ip2=ONOS2_ip, port2=ONOS2_port,
183 ip3=ONOS3_ip, port3=ONOS3_port)
184
185 switch_mastership = main.TRUE
186 for i in range (1,29):
187 response = main.Mininet1.get_sw_controller("s"+str(i))
188 print("Response is " + str(response))
189 if re.search("tcp:"+ONOS1_ip,response):
190 switch_mastership = switch_mastership and main.TRUE
191 else:
192 switch_mastership = main.FALSE
193
194 if switch_mastership == main.TRUE:
195 main.log.report("Controller assignment successfull")
196 else:
197 main.log.report("Controller assignment failed")
198 #REACTIVE FWD test
199 main.step("Pingall")
200 ping_result = main.FALSE
201 time1 = time.time()
202 ping_result = main.Mininet1.pingall()
203 time2 = time.time()
204 print "Time for pingall: %2f seconds" % (time2 - time1)
205
206 case4_result = switch_mastership and ping_result
207 if ping_result == main.TRUE:
208 main.log.report("Pingall Test in reactive mode to discover the hosts successful")
209 else:
210 main.log.report("Pingall Test in reactive mode to discover the hosts failed")
211
212 utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
213
214
215
216 def CASE5(self,main) :
217 import json
218 from subprocess import Popen, PIPE
219 from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
220 ONOS1_ip = main.params['CTRL']['ip1']
221 ONOS2_ip = main.params['CTRL']['ip2']
222 ONOS3_ip = main.params['CTRL']['ip3']
223
224 main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes")
225 main.log.report("__________________________________")
226 main.case ("Testing Mininet topology with the topology of multi instances ONOS")
227 main.step("Collecting topology information from ONOS")
228 devices1 = main.ONOScli1.devices()
229 devices2 = main.ONOScli2.devices()
230 devices3 = main.ONOScli3.devices()
shahshreyaeac353b2014-11-18 17:19:20 -0800231 #print "devices1 = ", devices1
232 #print "devices2 = ", devices2
233 #print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800234 hosts1 = main.ONOScli1.hosts()
235 hosts2 = main.ONOScli2.hosts()
236 hosts3 = main.ONOScli3.hosts()
237 #print "hosts1 = ", hosts1
238 #print "hosts2 = ", hosts2
239 #print "hosts3 = ", hosts3
240 ports1 = main.ONOScli1.ports()
241 ports2 = main.ONOScli2.ports()
242 ports3 = main.ONOScli3.ports()
243 #print "ports1 = ", ports1
244 #print "ports2 = ", ports2
245 #print "ports3 = ", ports3
246 links1 = main.ONOScli1.links()
247 links2 = main.ONOScli2.links()
248 links3 = main.ONOScli3.links()
249 #print "links1 = ", links1
250 #print "links2 = ", links2
251 #print "links3 = ", links3
252
253 print "**************"
254
255 main.step("Start continuous pings")
256 main.Mininet2.pingLong(src=main.params['PING']['source1'],
257 target=main.params['PING']['target1'],pingTime=500)
258 main.Mininet2.pingLong(src=main.params['PING']['source2'],
259 target=main.params['PING']['target2'],pingTime=500)
260 main.Mininet2.pingLong(src=main.params['PING']['source3'],
261 target=main.params['PING']['target3'],pingTime=500)
262 main.Mininet2.pingLong(src=main.params['PING']['source4'],
263 target=main.params['PING']['target4'],pingTime=500)
264 main.Mininet2.pingLong(src=main.params['PING']['source5'],
265 target=main.params['PING']['target5'],pingTime=500)
266 main.Mininet2.pingLong(src=main.params['PING']['source6'],
267 target=main.params['PING']['target6'],pingTime=500)
268 main.Mininet2.pingLong(src=main.params['PING']['source7'],
269 target=main.params['PING']['target7'],pingTime=500)
270 main.Mininet2.pingLong(src=main.params['PING']['source8'],
271 target=main.params['PING']['target8'],pingTime=500)
272 main.Mininet2.pingLong(src=main.params['PING']['source9'],
273 target=main.params['PING']['target9'],pingTime=500)
274 main.Mininet2.pingLong(src=main.params['PING']['source10'],
275 target=main.params['PING']['target10'],pingTime=500)
276
277 main.step("Create TestONTopology object")
278 global ctrls
279 ctrls = []
280 count = 1
281 while True:
282 temp = ()
283 if ('ip' + str(count)) in main.params['CTRL']:
284 temp = temp + (getattr(main,('ONOS' + str(count))),)
285 temp = temp + ("ONOS"+str(count),)
286 temp = temp + (main.params['CTRL']['ip'+str(count)],)
287 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
288 ctrls.append(temp)
289 count = count + 1
290 else:
291 break
292 global MNTopo
293 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
294 MNTopo = Topo
295
296 Topology_Check = main.TRUE
297 main.step("Compare ONOS Topology to MN Topology")
298
299 switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
300 print "switches_Result1 = ", switches_results1
301 utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
302 onpass="ONOS1 Switches view is correct",
303 onfail="ONOS1 Switches view is incorrect")
304
305 switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
306 utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
307 onpass="ONOS2 Switches view is correct",
308 onfail="ONOS2 Switches view is incorrect")
309
310 switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
311 utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
312 onpass="ONOS3 Switches view is correct",
313 onfail="ONOS3 Switches view is incorrect")
314
315 '''
316 ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
317 utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
318 onpass="ONOS1 Ports view is correct",
319 onfail="ONOS1 Ports view is incorrect")
320
321 ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
322 utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
323 onpass="ONOS2 Ports view is correct",
324 onfail="ONOS2 Ports view is incorrect")
325
326 ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
327 utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
328 onpass="ONOS3 Ports view is correct",
329 onfail="ONOS3 Ports view is incorrect")
330 '''
331
332 links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
333 utilities.assert_equals(expect=main.TRUE, actual=links_results1,
334 onpass="ONOS1 Links view is correct",
335 onfail="ONOS1 Links view is incorrect")
336
337 links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
338 utilities.assert_equals(expect=main.TRUE, actual=links_results2,
339 onpass="ONOS2 Links view is correct",
340 onfail="ONOS2 Links view is incorrect")
341
342 links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
343 utilities.assert_equals(expect=main.TRUE, actual=links_results3,
344 onpass="ONOS2 Links view is correct",
345 onfail="ONOS2 Links view is incorrect")
346
347 #topo_result = switches_results1 and switches_results2 and switches_results3\
348 #and ports_results1 and ports_results2 and ports_results3\
349 #and links_results1 and links_results2 and links_results3
350
351 topo_result = switches_results1 and switches_results2 and switches_results3\
352 and links_results1 and links_results2 and links_results3
353
354 if topo_result == main.TRUE:
355 main.log.report("Topology Check Test with mininet and ONOS instances successful")
356 else:
357 main.log.report("Topology Check Test with mininet and ONOS instances failed")
358
359 utilities.assert_equals(expect=main.TRUE, actual=topo_result,
360 onpass="Topology Check Test successful",
361 onfail="Topology Check Test NOT successful")
362
shahshreyaa9d79f22014-11-18 15:41:29 -0800363
364
365
366 def CASE10(self):
367 main.log.report("This testcase uninstalls the reactive forwarding app")
368 main.log.report("__________________________________")
369 main.case("Uninstalling reactive forwarding app")
370 #Unistall onos-app-fwd app to disable reactive forwarding
shahshreyaeac353b2014-11-18 17:19:20 -0800371 appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
372 appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
373 appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
shahshreyaa9d79f22014-11-18 15:41:29 -0800374 main.log.info("onos-app-fwd uninstalled")
375
376 #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
377 #So sleep for 15s
378 time.sleep(15)
shahshreyae6c7cf42014-11-26 16:39:01 -0800379
380 hosts = main.ONOScli1.hosts()
381 main.log.info(hosts)
382
shahshreyaeac353b2014-11-18 17:19:20 -0800383 case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
shahshreyaa9d79f22014-11-18 15:41:29 -0800384 utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
385
386
shahshreya4e13a062014-11-11 16:46:18 -0800387 def CASE6(self):
388 main.log.report("This testcase is testing the addition of host intents and then doing pingall")
389 main.log.report("__________________________________")
shahshreyaa9d79f22014-11-18 15:41:29 -0800390 main.case("Obtaining hostsfor adding host intents")
shahshreya4e13a062014-11-11 16:46:18 -0800391 main.step("Get hosts")
shahshreyaeac353b2014-11-18 17:19:20 -0800392 hosts = main.ONOScli1.hosts()
shahshreya4e13a062014-11-11 16:46:18 -0800393 main.log.info(hosts)
394
395 main.step("Get all devices id")
396 devices_id_list = main.ONOScli1.get_all_devices_id()
397 main.log.info(devices_id_list)
398
399 #ONOS displays the hosts in hex format unlike mininet which does in decimal format
400 #So take care while adding intents
shahshreyaa9d79f22014-11-18 15:41:29 -0800401
402 '''
shahshreya4e13a062014-11-11 16:46:18 -0800403 main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
404 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
405 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
406 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1")
407 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1")
408 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1")
409 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1")
410 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1")
411 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
412 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
413 hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
shahshreyaa9d79f22014-11-18 15:41:29 -0800414 '''
shahshreya4e13a062014-11-11 16:46:18 -0800415
shahshreyaa9d79f22014-11-18 15:41:29 -0800416 for i in range(8,18):
417 main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
418 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
419 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
420 #NOTE: get host can return None
421 #TODO: handle this
422 host1_id = main.ONOScli1.get_host(host1)['id']
423 host2_id = main.ONOScli1.get_host(host2)['id']
424 tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800425
426 flowHandle = main.ONOScli1.flows()
427 #print "flowHandle = ", flowHandle
428 main.log.info("flows:" +flowHandle)
429
430 count = 1
431 i = 8
432 Ping_Result = main.TRUE
433 while i <18 :
434 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
435 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
436 if ping == main.FALSE and count <5:
437 count+=1
438 #i = 8
439 Ping_Result = main.FALSE
440 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
441 time.sleep(2)
442 elif ping==main.FALSE:
443 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
444 i=19
445 Ping_Result = main.FALSE
446 elif ping==main.TRUE:
447 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
448 i+=1
449 Ping_Result = main.TRUE
450 else:
451 main.log.info("Unknown error")
452 Ping_Result = main.ERROR
453 if Ping_Result==main.FALSE:
454 main.log.report("Host intents have not ben installed correctly. Cleaning up")
455 #main.cleanup()
456 #main.exit()
457 if Ping_Result==main.TRUE:
458 main.log.report("Host intents have been installed correctly")
459
460 case6_result = Ping_Result
461 utilities.assert_equals(expect=main.TRUE, actual=case6_result,
462 onpass="Host intent addition and Pingall Test successful",
463 onfail="Host intent addition and Pingall Test NOT successful")
464
465
466 def CASE7 (self,main):
467
468 ONOS1_ip = main.params['CTRL']['ip1']
469
470 link_sleep = int(main.params['timers']['LinkDiscovery'])
471
472 main.log.report("This testscase is killing a link to ensure that link discovery is consistent")
473 main.log.report("__________________________________")
474 main.case("Killing a link to Ensure that Link Discovery is Working Properly")
475 main.step("Start continuous pings")
476
477 main.Mininet2.pingLong(src=main.params['PING']['source1'],
478 target=main.params['PING']['target1'],pingTime=500)
479 main.Mininet2.pingLong(src=main.params['PING']['source2'],
480 target=main.params['PING']['target2'],pingTime=500)
481 main.Mininet2.pingLong(src=main.params['PING']['source3'],
482 target=main.params['PING']['target3'],pingTime=500)
483 main.Mininet2.pingLong(src=main.params['PING']['source4'],
484 target=main.params['PING']['target4'],pingTime=500)
485 main.Mininet2.pingLong(src=main.params['PING']['source5'],
486 target=main.params['PING']['target5'],pingTime=500)
487 main.Mininet2.pingLong(src=main.params['PING']['source6'],
488 target=main.params['PING']['target6'],pingTime=500)
489 main.Mininet2.pingLong(src=main.params['PING']['source7'],
490 target=main.params['PING']['target7'],pingTime=500)
491 main.Mininet2.pingLong(src=main.params['PING']['source8'],
492 target=main.params['PING']['target8'],pingTime=500)
493 main.Mininet2.pingLong(src=main.params['PING']['source9'],
494 target=main.params['PING']['target9'],pingTime=500)
495 main.Mininet2.pingLong(src=main.params['PING']['source10'],
496 target=main.params['PING']['target10'],pingTime=500)
497
498
499 main.step("Determine the current number of switches and links")
500 topology_output = main.ONOScli1.topology()
501 topology_result = main.ONOSbench.get_topology(topology_output)
502 activeSwitches = topology_result['devices']
503 links = topology_result['links']
504 print "activeSwitches = ", type(activeSwitches)
505 print "links = ", type(links)
506 main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links)))
507
508 main.step("Kill Link between s3 and s28")
509 main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
510 time.sleep(link_sleep)
511 topology_output = main.ONOScli2.topology()
512 Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2))
513 if Link_Down == main.TRUE:
514 main.log.report("Link Down discovered properly")
515 utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
516 onpass="Link Down discovered properly",
517 onfail="Link down was not discovered in "+ str(link_sleep) + " seconds")
518
519 main.step("Bring link between s3 and s28 back up")
520 Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
521 time.sleep(link_sleep)
522 topology_output = main.ONOScli2.topology()
523 Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links))
524 if Link_Up == main.TRUE:
525 main.log.report("Link up discovered properly")
526 utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
527 onpass="Link up discovered properly",
528 onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
529
530 main.step("Compare ONOS Topology to MN Topology")
531 main.case ("Testing Mininet topology with the topology of multi instances ONOS")
532 main.step("Collecting topology information from ONOS")
533 devices1 = main.ONOScli1.devices()
534 devices2 = main.ONOScli2.devices()
535 devices3 = main.ONOScli3.devices()
536 print "devices1 = ", devices1
537 print "devices2 = ", devices2
538 print "devices3 = ", devices3
539 hosts1 = main.ONOScli1.hosts()
540 hosts2 = main.ONOScli2.hosts()
541 hosts3 = main.ONOScli3.hosts()
542 #print "hosts1 = ", hosts1
543 #print "hosts2 = ", hosts2
544 #print "hosts3 = ", hosts3
545 ports1 = main.ONOScli1.ports()
546 ports2 = main.ONOScli2.ports()
547 ports3 = main.ONOScli3.ports()
548 #print "ports1 = ", ports1
549 #print "ports2 = ", ports2
550 #print "ports3 = ", ports3
551 links1 = main.ONOScli1.links()
552 links2 = main.ONOScli2.links()
553 links3 = main.ONOScli3.links()
554 #print "links1 = ", links1
555 #print "links2 = ", links2
556 #print "links3 = ", links3
557
558 print "**************"
559
560 main.step("Start continuous pings")
561 main.Mininet2.pingLong(src=main.params['PING']['source1'],
562 target=main.params['PING']['target1'],pingTime=500)
563 main.Mininet2.pingLong(src=main.params['PING']['source2'],
564 target=main.params['PING']['target2'],pingTime=500)
565 main.Mininet2.pingLong(src=main.params['PING']['source3'],
566 target=main.params['PING']['target3'],pingTime=500)
567 main.Mininet2.pingLong(src=main.params['PING']['source4'],
568 target=main.params['PING']['target4'],pingTime=500)
569 main.Mininet2.pingLong(src=main.params['PING']['source5'],
570 target=main.params['PING']['target5'],pingTime=500)
571 main.Mininet2.pingLong(src=main.params['PING']['source6'],
572 target=main.params['PING']['target6'],pingTime=500)
573 main.Mininet2.pingLong(src=main.params['PING']['source7'],
574 target=main.params['PING']['target7'],pingTime=500)
575 main.Mininet2.pingLong(src=main.params['PING']['source8'],
576 target=main.params['PING']['target8'],pingTime=500)
577 main.Mininet2.pingLong(src=main.params['PING']['source9'],
578 target=main.params['PING']['target9'],pingTime=500)
579 main.Mininet2.pingLong(src=main.params['PING']['source10'],
580 target=main.params['PING']['target10'],pingTime=500)
581
582 main.step("Create TestONTopology object")
583 global ctrls
584 ctrls = []
585 count = 1
586 while True:
587 temp = ()
588 if ('ip' + str(count)) in main.params['CTRL']:
589 temp = temp + (getattr(main,('ONOS' + str(count))),)
590 temp = temp + ("ONOS"+str(count),)
591 temp = temp + (main.params['CTRL']['ip'+str(count)],)
592 temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
593 ctrls.append(temp)
594 count = count + 1
595 else:
596 break
597 global MNTopo
598 Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
599 MNTopo = Topo
600
601 Topology_Check = main.TRUE
602 main.step("Compare ONOS Topology to MN Topology")
603
604 switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1))
605 print "switches_Result1 = ", switches_results1
606 utilities.assert_equals(expect=main.TRUE, actual=switches_results1,
607 onpass="ONOS1 Switches view is correct",
608 onfail="ONOS1 Switches view is incorrect")
609
610 switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2))
611 utilities.assert_equals(expect=main.TRUE, actual=switches_results2,
612 onpass="ONOS2 Switches view is correct",
613 onfail="ONOS2 Switches view is incorrect")
614
615 switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3))
616 utilities.assert_equals(expect=main.TRUE, actual=switches_results3,
617 onpass="ONOS3 Switches view is correct",
618 onfail="ONOS3 Switches view is incorrect")
619
620 '''
621 ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1))
622 utilities.assert_equals(expect=main.TRUE, actual=ports_results1,
623 onpass="ONOS1 Ports view is correct",
624 onfail="ONOS1 Ports view is incorrect")
625
626 ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2))
627 utilities.assert_equals(expect=main.TRUE, actual=ports_results2,
628 onpass="ONOS2 Ports view is correct",
629 onfail="ONOS2 Ports view is incorrect")
630
631 ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3))
632 utilities.assert_equals(expect=main.TRUE, actual=ports_results3,
633 onpass="ONOS3 Ports view is correct",
634 onfail="ONOS3 Ports view is incorrect")
635 '''
636
637 links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1))
638 utilities.assert_equals(expect=main.TRUE, actual=links_results1,
639 onpass="ONOS1 Links view is correct",
640 onfail="ONOS1 Links view is incorrect")
641
642 links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2))
643 utilities.assert_equals(expect=main.TRUE, actual=links_results2,
644 onpass="ONOS2 Links view is correct",
645 onfail="ONOS2 Links view is incorrect")
646
647 links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3))
648 utilities.assert_equals(expect=main.TRUE, actual=links_results3,
649 onpass="ONOS2 Links view is correct",
650 onfail="ONOS2 Links view is incorrect")
651
652 #topo_result = switches_results1 and switches_results2 and switches_results3\
653 #and ports_results1 and ports_results2 and ports_results3\
654 #and links_results1 and links_results2 and links_results3
655
656 topo_result = switches_results1 and switches_results2 and switches_results3\
657 and links_results1 and links_results2 and links_results3
658
659 utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down,
660 onpass="Topology Check Test successful",
661 onfail="Topology Check Test NOT successful")
662
663
664 def CASE8(self):
665 '''
shahshreyaeac353b2014-11-18 17:19:20 -0800666 Intent removal
shahshreya4e13a062014-11-11 16:46:18 -0800667 '''
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800668 main.log.report("This testcase removes host any previously added intents")
shahshreya4e13a062014-11-11 16:46:18 -0800669 main.log.report("__________________________________")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800670 main.log.info("Removing any previously installed intents")
671 main.case("Removing intents")
shahshreya4e13a062014-11-11 16:46:18 -0800672 main.step("Obtain the intent id's")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800673 intent_result = main.ONOScli1.intents(json_format = False)
shahshreyaa9d79f22014-11-18 15:41:29 -0800674
shahshreya4e13a062014-11-11 16:46:18 -0800675 intent_linewise = intent_result.split("\n")
shahshreyaa9d79f22014-11-18 15:41:29 -0800676 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800677 for line in intent_linewise:
shahshreyaa9d79f22014-11-18 15:41:29 -0800678 if line.startswith("id="):
679 intentList.append(line)
680
681 intentids = []
682 for line in intentList:
shahshreya4e13a062014-11-11 16:46:18 -0800683 intentids.append(line.split(",")[0].split("=")[1])
684 for id in intentids:
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800685 main.log.info("id = " +id)
shahshreyaa9d79f22014-11-18 15:41:29 -0800686
shahshreya4e13a062014-11-11 16:46:18 -0800687 main.step("Iterate through the intentids list and remove each intent")
688 for id in intentids:
689 main.ONOScli1.remove_intent(intent_id = id)
shahshreyaa9d79f22014-11-18 15:41:29 -0800690
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800691 intent_result = main.ONOScli1.intents(json_format = False)
692 main.log.info("intent_result = " +intent_result)
shahshreya4e13a062014-11-11 16:46:18 -0800693 case8_result = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800694
shahshreyaeac353b2014-11-18 17:19:20 -0800695 i = 8
696 Ping_Result = main.TRUE
697 while i <18 :
698 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
699 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
700 if ping==main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800701 i = 19
shahshreyaeac353b2014-11-18 17:19:20 -0800702 Ping_Result = main.TRUE
703 elif ping==main.FALSE:
704 i+=1
705 Ping_Result = main.FALSE
706 else:
707 main.log.info("Unknown error")
708 Ping_Result = main.ERROR
709
710 #Note: If the ping result failed, that means the intents have been withdrawn correctly.
711 if Ping_Result==main.TRUE:
712 main.log.report("Host intents have not been withdrawn correctly")
713 #main.cleanup()
714 #main.exit()
715 if Ping_Result==main.FALSE:
716 main.log.report("Host intents have been withdrawn correctly")
717
718 case8_result = case8_result and Ping_Result
719
720 if case8_result == main.FALSE:
shahshreya4e13a062014-11-11 16:46:18 -0800721 main.log.report("Intent removal successful")
722 else:
723 main.log.report("Intent removal failed")
724
shahshreyaeac353b2014-11-18 17:19:20 -0800725 utilities.assert_equals(expect=main.FALSE, actual=case8_result,
shahshreyae6c7cf42014-11-26 16:39:01 -0800726 onpass="Intent removal test failed",
727 onfail="Intent removal test successful")
shahshreya4e13a062014-11-11 16:46:18 -0800728
729
730 def CASE9(self):
731 '''
732 This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
733 Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
734 '''
735 main.log.report("This testcase adds point intents and then does pingall")
736 main.log.report("__________________________________")
737 main.log.info("Adding point intents")
738 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)")
739 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 -0800740 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
shahshreya4e13a062014-11-11 16:46:18 -0800741 if ptp_intent_result == main.TRUE:
742 get_intent_result = main.ONOScli1.intents()
743 main.log.info("Point to point intent install successful")
744 #main.log.info(get_intent_result)
745
shahshreyae6c7cf42014-11-26 16:39:01 -0800746 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
shahshreya4e13a062014-11-11 16:46:18 -0800747 if ptp_intent_result == main.TRUE:
748 get_intent_result = main.ONOScli1.intents()
749 main.log.info("Point to point intent install successful")
750 #main.log.info(get_intent_result)
751
752 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 -0800753 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
shahshreya4e13a062014-11-11 16:46:18 -0800754 if ptp_intent_result == main.TRUE:
755 get_intent_result = main.ONOScli1.intents()
756 main.log.info("Point to point intent install successful")
757 #main.log.info(get_intent_result)
758
shahshreyae6c7cf42014-11-26 16:39:01 -0800759 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
shahshreya4e13a062014-11-11 16:46:18 -0800760 if ptp_intent_result == main.TRUE:
761 get_intent_result = main.ONOScli1.intents()
762 main.log.info("Point to point intent install successful")
763 #main.log.info(get_intent_result)
764
765 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 -0800766 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
shahshreya4e13a062014-11-11 16:46:18 -0800767 if ptp_intent_result == main.TRUE:
768 get_intent_result = main.ONOScli1.intents()
769 main.log.info("Point to point intent install successful")
770 #main.log.info(get_intent_result)
771
shahshreyae6c7cf42014-11-26 16:39:01 -0800772 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
shahshreya4e13a062014-11-11 16:46:18 -0800773 if ptp_intent_result == main.TRUE:
774 get_intent_result = main.ONOScli1.intents()
775 main.log.info("Point to point intent install successful")
776 #main.log.info(get_intent_result)
777
778 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 -0800779 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
shahshreya4e13a062014-11-11 16:46:18 -0800780 if ptp_intent_result == main.TRUE:
781 get_intent_result = main.ONOScli1.intents()
782 main.log.info("Point to point intent install successful")
783 #main.log.info(get_intent_result)
784
shahshreyae6c7cf42014-11-26 16:39:01 -0800785 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
shahshreya4e13a062014-11-11 16:46:18 -0800786 if ptp_intent_result == main.TRUE:
787 get_intent_result = main.ONOScli1.intents()
788 main.log.info("Point to point intent install successful")
789 #main.log.info(get_intent_result)
790
791 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 -0800792 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
shahshreya4e13a062014-11-11 16:46:18 -0800793 if ptp_intent_result == main.TRUE:
794 get_intent_result = main.ONOScli1.intents()
795 main.log.info("Point to point intent install successful")
796 #main.log.info(get_intent_result)
797
shahshreyae6c7cf42014-11-26 16:39:01 -0800798 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
shahshreya4e13a062014-11-11 16:46:18 -0800799 if ptp_intent_result == main.TRUE:
800 get_intent_result = main.ONOScli1.intents()
801 main.log.info("Point to point intent install successful")
802 #main.log.info(get_intent_result)
803
804 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 -0800805 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
shahshreya4e13a062014-11-11 16:46:18 -0800806 if ptp_intent_result == main.TRUE:
807 get_intent_result = main.ONOScli1.intents()
808 main.log.info("Point to point intent install successful")
809 #main.log.info(get_intent_result)
810
shahshreyae6c7cf42014-11-26 16:39:01 -0800811 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
shahshreya4e13a062014-11-11 16:46:18 -0800812 if ptp_intent_result == main.TRUE:
813 get_intent_result = main.ONOScli1.intents()
814 main.log.info("Point to point intent install successful")
815 #main.log.info(get_intent_result)
816
817 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 -0800818 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
shahshreya4e13a062014-11-11 16:46:18 -0800819 if ptp_intent_result == main.TRUE:
820 get_intent_result = main.ONOScli1.intents()
821 main.log.info("Point to point intent install successful")
822 #main.log.info(get_intent_result)
823
shahshreyae6c7cf42014-11-26 16:39:01 -0800824 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
shahshreya4e13a062014-11-11 16:46:18 -0800825 if ptp_intent_result == main.TRUE:
826 get_intent_result = main.ONOScli1.intents()
827 main.log.info("Point to point intent install successful")
828 #main.log.info(get_intent_result)
829
830 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 -0800831 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
shahshreya4e13a062014-11-11 16:46:18 -0800832 if ptp_intent_result == main.TRUE:
833 get_intent_result = main.ONOScli1.intents()
834 main.log.info("Point to point intent install successful")
835 #main.log.info(get_intent_result)
836
shahshreyae6c7cf42014-11-26 16:39:01 -0800837 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
shahshreya4e13a062014-11-11 16:46:18 -0800838 if ptp_intent_result == main.TRUE:
839 get_intent_result = main.ONOScli1.intents()
840 main.log.info("Point to point intent install successful")
841 #main.log.info(get_intent_result)
842
843 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 -0800844 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
shahshreya4e13a062014-11-11 16:46:18 -0800845 if ptp_intent_result == main.TRUE:
846 get_intent_result = main.ONOScli1.intents()
847 main.log.info("Point to point intent install successful")
848 #main.log.info(get_intent_result)
849
shahshreyae6c7cf42014-11-26 16:39:01 -0800850 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
shahshreya4e13a062014-11-11 16:46:18 -0800851 if ptp_intent_result == main.TRUE:
852 get_intent_result = main.ONOScli1.intents()
853 main.log.info("Point to point intent install successful")
854 #main.log.info(get_intent_result)
855
856
857 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 -0800858 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
shahshreya4e13a062014-11-11 16:46:18 -0800859 if ptp_intent_result == main.TRUE:
860 get_intent_result = main.ONOScli1.intents()
861 main.log.info("Point to point intent install successful")
862 #main.log.info(get_intent_result)
863
shahshreyae6c7cf42014-11-26 16:39:01 -0800864 ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
shahshreya4e13a062014-11-11 16:46:18 -0800865 if ptp_intent_result == main.TRUE:
866 get_intent_result = main.ONOScli1.intents()
867 main.log.info("Point to point intent install successful")
868 #main.log.info(get_intent_result)
869
870 print("_______________________________________________________________________________________")
871
872 flowHandle = main.ONOScli1.flows()
873 #print "flowHandle = ", flowHandle
874 main.log.info("flows :" + flowHandle)
875
876 count = 1
877 i = 8
878 Ping_Result = main.TRUE
879 while i <18 :
880 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
881 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
882 if ping == main.FALSE and count <5:
883 count+=1
884 #i = 8
885 Ping_Result = main.FALSE
886 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
887 time.sleep(2)
888 elif ping==main.FALSE:
889 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
890 i=19
891 Ping_Result = main.FALSE
892 elif ping==main.TRUE:
893 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
894 i+=1
895 Ping_Result = main.TRUE
896 else:
897 main.log.info("Unknown error")
898 Ping_Result = main.ERROR
899 if Ping_Result==main.FALSE:
900 main.log.report("Ping all test after Point intents addition failed. Cleaning up")
901 #main.cleanup()
902 #main.exit()
903 if Ping_Result==main.TRUE:
904 main.log.report("Ping all test after Point intents addition successful")
905
906 case8_result = Ping_Result
907 utilities.assert_equals(expect=main.TRUE, actual=case8_result,
908 onpass="Ping all test after Point intents addition successful",
909 onfail="Ping all test after Point intents addition failed")
910
shahshreyaa9d79f22014-11-18 15:41:29 -0800911 def CASE31(self):
912 '''
913 This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
914 '''
915 import json
916
917 main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
shahshreyae6c7cf42014-11-26 16:39:01 -0800918 main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
shahshreyaa9d79f22014-11-18 15:41:29 -0800919 main.step("Adding bidirectional point intent")
920 #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
921
922 hosts_json = json.loads(main.ONOScli1.hosts())
923 for i in range(8,11):
924 main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
925 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
926 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
927 host1_id = main.ONOScli1.get_host(host1)['id']
928 host2_id = main.ONOScli1.get_host(host2)['id']
929 for host in hosts_json:
930 if host['id'] == host1_id:
shahshreyae6c7cf42014-11-26 16:39:01 -0800931 ip1 = host['ips'][0]
932 ip1 = str(ip1+"/32")
shahshreyae6c7cf42014-11-26 16:39:01 -0800933 device1 = host['location']['device']
934 device1 = str(device1+"/1")
shahshreyaa9d79f22014-11-18 15:41:29 -0800935 elif host['id'] == host2_id:
shahshreyae6c7cf42014-11-26 16:39:01 -0800936 ip2 = str(host['ips'][0])+"/32"
shahshreyae6c7cf42014-11-26 16:39:01 -0800937 device2 = host['location']["device"]
938 device2 = str(device2+"/1")
shahshreyae6c7cf42014-11-26 16:39:01 -0800939
940 p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
941 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
942
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800943 get_intent_result = main.ONOScli1.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800944 main.log.info(get_intent_result)
945
946 p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
947 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
948
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800949 get_intent_result = main.ONOScli1.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800950 main.log.info(get_intent_result)
951 if (p_intent_result1 and p_intent_result2) == main.TRUE:
952 #get_intent_result = main.ONOScli1.intents()
953 #main.log.info(get_intent_result)
954 main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
955
956 time.sleep(15)
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800957 get_intent_result = main.ONOScli1.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -0800958 main.log.info("intents = "+ get_intent_result)
959 get_flows_result = main.ONOScli1.flows()
960 main.log.info("flows = " + get_flows_result)
961
962 count = 1
963 i = 8
964 Ping_Result = main.TRUE
965 while i <11 :
966 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
967 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
968 if ping == main.FALSE and count <3:
969 count+=1
970 #i = 8
971 Ping_Result = main.FALSE
972 main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
973 time.sleep(2)
974 elif ping==main.FALSE:
975 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
976 i=19
977 Ping_Result = main.FALSE
978 elif ping==main.TRUE:
979 main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
980 i+=1
981 Ping_Result = main.TRUE
982 else:
983 main.log.info("Unknown error")
984 Ping_Result = main.ERROR
985 if Ping_Result==main.FALSE:
986 main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
987 #main.cleanup()
988 #main.exit()
989 if Ping_Result==main.TRUE:
990 main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
991
992 case31_result = Ping_Result and p_intent_result1 and p_intent_result2
993 utilities.assert_equals(expect=main.TRUE, actual=case31_result,
994 onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
995 onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
996
997 def CASE32(self):
998 '''
999 This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
1000 Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
1001 '''
1002 import json
1003
1004 main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
1005 main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
1006 main.step("Adding bidirectional point intent")
1007 """
1008 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
1009
1010 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
1011
1012 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
1013
1014 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
1015
1016 """
1017
1018 hosts_json = json.loads(main.ONOScli1.hosts())
1019 for i in range(8,9):
1020 main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
1021 host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
1022 host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
1023 host1_id = main.ONOScli1.get_host(host1)['id']
1024 host2_id = main.ONOScli1.get_host(host2)['id']
1025 for host in hosts_json:
1026 if host['id'] == host1_id:
1027 ip1 = host['ips'][0]
1028 ip1 = str(ip1+"/32")
shahshreyae6c7cf42014-11-26 16:39:01 -08001029 device1 = host['location']['device']
1030 device1 = str(device1+"/1")
shahshreyae6c7cf42014-11-26 16:39:01 -08001031 elif host['id'] == host2_id:
1032 ip2 = str(host['ips'][0])+"/32"
shahshreyae6c7cf42014-11-26 16:39:01 -08001033 device2 = host['location']["device"]
1034 device2 = str(device2+"/1")
shahshreyae6c7cf42014-11-26 16:39:01 -08001035
1036 p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
1037 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
1038 p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
1039 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
1040
1041 p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
1042 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
1043 p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
1044 ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
1045
1046 p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
1047 if p_intent_result ==main.TRUE:
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001048 get_intent_result = main.ONOScli1.intents(json_format = False)
shahshreyae6c7cf42014-11-26 16:39:01 -08001049 main.log.info(get_intent_result)
1050 main.log.info("Point intent related to SDN-IP matching on TCP install successful")
1051
1052 iperf_result = main.Mininet1.iperf('h8', 'h18')
1053 if iperf_result == main.TRUE:
1054 main.log.report("iperf test successful")
1055 else:
1056 main.log.report("iperf test failed")
1057
1058
1059 case32_result = p_intent_result and iperf_result
1060 utilities.assert_equals(expect=main.TRUE, actual=case32_result,
1061 onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001062 onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
1063
1064
1065 def CASE33(self):
1066 '''
1067 This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
1068 Here the mac address to be rewritten is the mac address of the egress device
1069 '''
1070 import json
1071 import time
1072
1073 main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action")
1074 main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip")
1075 main.step("Adding bidirectional multipoint to singlepoint intent")
1076 """
1077 add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
1078
1079 add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
1080 """
1081
1082 main.case("Installing multipoint to single point intent with rewrite mac address")
1083 main.step("Uninstalling proxy arp app")
1084 #Unistall onos-app-proxyarp app to disable reactive forwarding
1085 appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp")
1086 appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp")
1087 appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp")
1088 main.log.info("onos-app-proxyarp uninstalled")
1089
1090 main.step("Changing ipaddress of hosts h8,h9 and h18")
1091 main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0')
1092 main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0')
1093 main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0')
1094
1095 main.step("Changing default gateway of hosts h8,h9 and h18")
1096 main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254')
1097 main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254')
1098 main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254')
1099
1100 main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled")
1101 main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11')
1102 main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22')
1103 main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33')
1104
1105 main.step("Verify static gateway and MAC address assignment")
1106 main.Mininet1.verifyStaticGWandMAC(host='h8')
1107 main.Mininet1.verifyStaticGWandMAC(host='h9')
1108 main.Mininet1.verifyStaticGWandMAC(host='h10')
1109
1110 main.step("Adding multipoint to singlepoint intent")
1111 p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
1112 egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1'])
1113
1114 p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'],
1115 egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2'])
1116
1117
1118 get_intent_result = main.ONOScli1.intents(json_format = False)
1119 main.log.info("intents = "+ get_intent_result)
1120
1121 time.sleep(10)
1122 get_flows_result = main.ONOScli1.flows(json_format = False)
1123 main.log.info("flows = " + get_flows_result)
1124
1125 count = 1
1126 i = 8
1127 Ping_Result = main.TRUE
1128
1129 main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2))
1130 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2))
1131 if ping == main.FALSE and count <3:
1132 count+=1
1133 Ping_Result = main.FALSE
1134 main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds")
1135 time.sleep(2)
1136 elif ping==main.FALSE:
1137 main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
1138 Ping_Result = main.FALSE
1139 elif ping==main.TRUE:
1140 main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!")
1141 Ping_Result = main.TRUE
1142 else:
1143 main.log.info("Unknown error")
1144 Ping_Result = main.ERROR
1145
1146 if Ping_Result==main.FALSE:
1147 main.log.report("Ping test failed.")
1148 #main.cleanup()
1149 #main.exit()
1150 if Ping_Result==main.TRUE:
1151 main.log.report("Ping all successful")
1152
1153
1154 p_intent_result = p_intent_result1 and p_intent_result2
1155 if p_intent_result ==main.TRUE:
1156 main.log.info("Multi point intent with rewrite mac address installation successful")
1157 else:
1158 main.log.info("Multi point intent with rewrite mac address installation failed")
1159
1160 case33_result = p_intent_result and Ping_Result
1161 utilities.assert_equals(expect=main.TRUE, actual=case33_result,
1162 onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
1163 onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed")