blob: e0e772aa352714c25dd7d2863c2c01c3f35a04b8 [file] [log] [blame]
shahshreyab512cd02015-01-27 17:01:47 -08001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
8time.sleep( 1 )
9
10
11class MultiProd:
12
13 def __init__( self ):
14 self.default = ''
15
16 def CASE1( self, main ):
17 """
18 Startup sequence:
19 cell <name>
20 onos-verify-cell
21 onos-remove-raft-logs
22 git pull
23 mvn clean install
24 onos-package
25 onos-install -f
26 onos-wait-for-start
27 """
28 cell_name = main.params[ 'ENV' ][ 'cellName' ]
29 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
30 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
31 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
32
33 main.case( "Setting up test environment" )
34 main.log.report(
35 "This testcase is testing setting up test environment" )
36 main.log.report( "__________________________________" )
37
38 main.step( "Applying cell variable to environment" )
39 cell_result1 = main.ONOSbench.set_cell( cell_name )
40 # cell_result2 = main.ONOScli1.set_cell( cell_name )
41 # cell_result3 = main.ONOScli2.set_cell( cell_name )
42 # cell_result4 = main.ONOScli3.set_cell( cell_name )
43 verify_result = main.ONOSbench.verify_cell()
44 cell_result = cell_result1
45
46 main.step( "Removing raft logs before a clen installation of ONOS" )
47 main.ONOSbench.onos_remove_raft_logs()
48
49 main.step( "Git checkout and pull master and get version" )
50 main.ONOSbench.git_checkout( "master" )
51 git_pull_result = main.ONOSbench.git_pull()
52 print "git_pull_result = ", git_pull_result
53 main.ONOSbench.get_version( report=True )
54
55 if git_pull_result == 1:
56 main.step( "Using mvn clean & install" )
57 main.ONOSbench.clean_install()
58
59 main.step( "Creating ONOS package" )
60 package_result = main.ONOSbench.onos_package()
61
62 # main.step( "Creating a cell" )
63 # cell_create_result = main.ONOSbench.create_cell_file( **************
64 # )
65
66 main.step( "Installing ONOS package" )
67 onos1_install_result = main.ONOSbench.onos_install(
68 options="-f",
69 node=ONOS1_ip )
70 onos2_install_result = main.ONOSbench.onos_install(
71 options="-f",
72 node=ONOS2_ip )
73 onos3_install_result = main.ONOSbench.onos_install(
74 options="-f",
75 node=ONOS3_ip )
76 onos_install_result = onos1_install_result and onos2_install_result \
77 and onos3_install_result
78 if onos_install_result == main.TRUE:
79 main.log.report( "Installing ONOS package successful" )
80 else:
81 main.log.report( "Installing ONOS package failed" )
82
83 onos1_isup = main.ONOSbench.isup( ONOS1_ip )
84 onos2_isup = main.ONOSbench.isup( ONOS2_ip )
85 onos3_isup = main.ONOSbench.isup( ONOS3_ip )
86 onos_isup = onos1_isup and onos2_isup and onos3_isup
87 if onos_isup == main.TRUE:
88 main.log.report( "ONOS instances are up and ready" )
89 else:
90 main.log.report( "ONOS instances may not be up" )
91
92 main.step( "Starting ONOS service" )
93 start_result = main.TRUE
94 # start_result = main.ONOSbench.onos_start( ONOS1_ip )
95 startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
96 startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
97 startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
98 print startcli1
99 print startcli2
100 print startcli3
101
102 case1_result = ( package_result and cell_result and
103 verify_result and onos_install_result
104 and onos_isup and start_result )
105 utilities.assert_equals( expect=main.TRUE, actual=case1_result,
106 onpass="Test startup successful",
107 onfail="Test startup NOT successful" )
108
109 def CASE11( self, main ):
110 """
111 Cleanup sequence:
112 onos-service <node_ip> stop
113 onos-uninstall
114
115 TODO: Define rest of cleanup
116
117 """
118 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
119 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
120 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
121
122 main.case( "Cleaning up test environment" )
123
124 main.step( "Testing ONOS kill function" )
125 kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
126 kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
127 kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
128 kill_result = kill_result1 and kill_result2 and kill_result3
129
130 main.step( "Stopping ONOS service" )
131 stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
132 stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
133 stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
134 stop_result = stop_result1 and stop_result2 and stop_result3
135
136 main.step( "Uninstalling ONOS service" )
137 uninstall_result = main.ONOSbench.onos_uninstall()
138
139 case11_result = kill_result and stop_result and uninstall_result
140 utilities.assert_equals( expect=main.TRUE, actual=case11_result,
141 onpass="Cleanup successful",
142 onfail="Cleanup failed" )
143
144 def CASE3( self, main ):
145 """
146 Test 'onos' command and its functionality in driver
147 """
148 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
149 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
150 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
151
152 main.case( "Testing 'onos' command" )
153
154 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
155 cmdstr1 = "system:name"
156 cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
157 main.log.info( "onos command returned: " + cmd_result1 )
158 cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
159 main.log.info( "onos command returned: " + cmd_result2 )
160 cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
161 main.log.info( "onos command returned: " + cmd_result3 )
162
163 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
164 cmdstr2 = "onos:topology"
165 cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
166 main.log.info( "onos command returned: " + cmd_result4 )
167 cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
168 main.log.info( "onos command returned: " + cmd_result5 )
169 cmd_result6 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr2 )
170 main.log.info( "onos command returned: " + cmd_result6 )
171
172 def CASE4( self, main ):
173 import re
174 import time
175 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
176 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
177 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
178 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
179 ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
180 ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
181
182 main.log.report(
183 "This testcase is testing the assignment of all the switches to \
184 all controllers and discovering the hosts in reactive mode" )
185 main.log.report( "__________________________________" )
186 main.case( "Pingall Test(No intents are added)" )
187 main.step( "Assigning switches to controllers" )
188 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
189 main.Mininet1.assign_sw_controller(
190 sw=str( i ),
191 count=3,
192 ip1=ONOS1_ip,
193 port1=ONOS1_port,
194 ip2=ONOS2_ip,
195 port2=ONOS2_port,
196 ip3=ONOS3_ip,
197 port3=ONOS3_port )
198
199 switch_mastership = main.TRUE
200 for i in range( 1, 29 ):
201 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
202 print( "Response is " + str( response ) )
203 if re.search( "tcp:" + ONOS1_ip, response ):
204 switch_mastership = switch_mastership and main.TRUE
205 else:
206 switch_mastership = main.FALSE
207
208 if switch_mastership == main.TRUE:
209 main.log.report( "Controller assignment successfull" )
210 else:
211 main.log.report( "Controller assignment failed" )
212 # REACTIVE FWD test
213 main.step( "Pingall" )
214 ping_result = main.FALSE
215 time1 = time.time()
216 ping_result = main.Mininet1.pingall()
217 time2 = time.time()
218 print "Time for pingall: %2f seconds" % ( time2 - time1 )
219
220 case4_result = switch_mastership and ping_result
221 if ping_result == main.TRUE:
222 main.log.report( "Pingall Test in reactive mode to discover \
223 the hosts successful" )
224 else:
225 main.log.report( "Pingall Test in reactive mode to discover \
226 the hosts failed" )
227
228 utilities.assert_equals(
229 expect=main.TRUE,
230 actual=case4_result,
231 onpass="Controller assignment and Pingall Test successful",
232 onfail="Controller assignment and Pingall Test NOT successful" )
233
234 def CASE5( self, main ):
235 import json
236 from subprocess import Popen, PIPE
237 # assumes that sts is already in you PYTHONPATH
238 from sts.topology.teston_topology import TestONTopology
239
240 main.log.report( "This testcase is testing if all ONOS nodes are in \
241 topology sync with mininet and its peer ONOS nodes" )
242 main.log.report( "__________________________________" )
243 main.case(
244 "Testing Mininet topology with the topology \
245 of multi instances ONOS" )
246 main.step( "Collecting topology information from ONOS" )
247 devices1 = main.ONOScli1.devices()
248 devices2 = main.ONOScli2.devices()
249 devices3 = main.ONOScli3.devices()
250 hosts1 = main.ONOScli1.hosts()
251 hosts2 = main.ONOScli2.hosts()
252 hosts3 = main.ONOScli3.hosts()
253 ports1 = main.ONOScli1.ports()
254 ports2 = main.ONOScli2.ports()
255 ports3 = main.ONOScli3.ports()
256 links1 = main.ONOScli1.links()
257 links2 = main.ONOScli2.links()
258 links3 = main.ONOScli3.links()
259
260 main.step( "Start continuous pings" )
261 main.Mininet2.pingLong(
262 src=main.params[ 'PING' ][ 'source1' ],
263 target=main.params[ 'PING' ][ 'target1' ],
264 pingTime=500 )
265 main.Mininet2.pingLong(
266 src=main.params[ 'PING' ][ 'source2' ],
267 target=main.params[ 'PING' ][ 'target2' ],
268 pingTime=500 )
269 main.Mininet2.pingLong(
270 src=main.params[ 'PING' ][ 'source3' ],
271 target=main.params[ 'PING' ][ 'target3' ],
272 pingTime=500 )
273 main.Mininet2.pingLong(
274 src=main.params[ 'PING' ][ 'source4' ],
275 target=main.params[ 'PING' ][ 'target4' ],
276 pingTime=500 )
277 main.Mininet2.pingLong(
278 src=main.params[ 'PING' ][ 'source5' ],
279 target=main.params[ 'PING' ][ 'target5' ],
280 pingTime=500 )
281 main.Mininet2.pingLong(
282 src=main.params[ 'PING' ][ 'source6' ],
283 target=main.params[ 'PING' ][ 'target6' ],
284 pingTime=500 )
285 main.Mininet2.pingLong(
286 src=main.params[ 'PING' ][ 'source7' ],
287 target=main.params[ 'PING' ][ 'target7' ],
288 pingTime=500 )
289 main.Mininet2.pingLong(
290 src=main.params[ 'PING' ][ 'source8' ],
291 target=main.params[ 'PING' ][ 'target8' ],
292 pingTime=500 )
293 main.Mininet2.pingLong(
294 src=main.params[ 'PING' ][ 'source9' ],
295 target=main.params[ 'PING' ][ 'target9' ],
296 pingTime=500 )
297 main.Mininet2.pingLong(
298 src=main.params[ 'PING' ][ 'source10' ],
299 target=main.params[ 'PING' ][ 'target10' ],
300 pingTime=500 )
301
302 main.step( "Create TestONTopology object" )
303 global ctrls
304 ctrls = []
305 count = 1
306 while True:
307 temp = ()
308 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
309 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
310 temp = temp + ( "ONOS" + str( count ), )
311 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
312 temp = temp + \
313 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
314 ctrls.append( temp )
315 count = count + 1
316 else:
317 break
318 global MNTopo
319 Topo = TestONTopology(
320 main.Mininet1,
321 ctrls ) # can also add Intent API info for intent operations
322 MNTopo = Topo
323
324 Topology_Check = main.TRUE
325 main.step( "Compare ONOS Topology to MN Topology" )
326
327 switches_results1 = main.Mininet1.compare_switches(
328 MNTopo,
329 json.loads( devices1 ) )
330 print "switches_Result1 = ", switches_results1
331 utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
332 onpass="ONOS1 Switches view is correct",
333 onfail="ONOS1 Switches view is incorrect" )
334
335 switches_results2 = main.Mininet1.compare_switches(
336 MNTopo,
337 json.loads( devices2 ) )
338 utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
339 onpass="ONOS2 Switches view is correct",
340 onfail="ONOS2 Switches view is incorrect" )
341
342 switches_results3 = main.Mininet1.compare_switches(
343 MNTopo,
344 json.loads( devices3 ) )
345 utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
346 onpass="ONOS3 Switches view is correct",
347 onfail="ONOS3 Switches view is incorrect" )
348
349 ports_results1 = main.Mininet1.compare_ports(
350 MNTopo, json.loads( ports1 ) )
351 utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
352 onpass="ONOS1 Ports view is correct",
353 onfail="ONOS1 Ports view is incorrect" )
354
355 ports_results2 = main.Mininet1.compare_ports(
356 MNTopo, json.loads( ports2 ) )
357 utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
358 onpass="ONOS2 Ports view is correct",
359 onfail="ONOS2 Ports view is incorrect" )
360
361 ports_results3 = main.Mininet1.compare_ports(
362 MNTopo, json.loads( ports3 ) )
363 utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
364 onpass="ONOS3 Ports view is correct",
365 onfail="ONOS3 Ports view is incorrect" )
366
367 links_results1 = main.Mininet1.compare_links(
368 MNTopo,
369 json.loads( links1 ) )
370 utilities.assert_equals( expect=main.TRUE, actual=links_results1,
371 onpass="ONOS1 Links view is correct",
372 onfail="ONOS1 Links view is incorrect" )
373
374 links_results2 = main.Mininet1.compare_links(
375 MNTopo,
376 json.loads( links2 ) )
377 utilities.assert_equals( expect=main.TRUE, actual=links_results2,
378 onpass="ONOS2 Links view is correct",
379 onfail="ONOS2 Links view is incorrect" )
380
381 links_results3 = main.Mininet1.compare_links(
382 MNTopo,
383 json.loads( links3 ) )
384 utilities.assert_equals( expect=main.TRUE, actual=links_results3,
385 onpass="ONOS2 Links view is correct",
386 onfail="ONOS2 Links view is incorrect" )
387
388 topo_result = switches_results1 and switches_results2 and \
389 switches_results3\
390 and ports_results1 and ports_results2 and ports_results3\
391 and links_results1 and links_results2 and links_results3
392
393 '''
394 topo_result = switches_results1 and switches_results2 and \
395 switches_results3 and links_results1 and \
396 links_results2 and links_results3
397 '''
398
399 if topo_result == main.TRUE:
400 main.log.report(
401 "Topology Check Test with mininet and \
402 ONOS instances successful" )
403 else:
404 main.log.report(
405 "Topology Check Test with mininet and \
406 ONOS instances failed" )
407
408 utilities.assert_equals( expect=main.TRUE, actual=topo_result,
409 onpass="Topology Check Test successful",
410 onfail="Topology Check Test NOT successful" )
411
412 def CASE10( self ):
413 main.log.report(
414 "This testcase uninstalls the reactive forwarding app" )
415 main.log.report( "__________________________________" )
416 main.case( "Uninstalling reactive forwarding app" )
417 # Unistall onos-app-fwd app to disable reactive forwarding
418 appUninstall_result1 = main.ONOScli1.feature_uninstall(
419 "onos-app-fwd" )
420 appUninstall_result2 = main.ONOScli2.feature_uninstall(
421 "onos-app-fwd" )
422 appUninstall_result3 = main.ONOScli3.feature_uninstall(
423 "onos-app-fwd" )
424 main.log.info( "onos-app-fwd uninstalled" )
425
426 # After reactive forwarding is disabled,
427 # the reactive flows on switches timeout in 10-15s
428 # So sleep for 15s
429 time.sleep( 15 )
430
431 hosts = main.ONOScli1.hosts()
432 main.log.info( hosts )
433
434 case10_result = appUninstall_result1 and appUninstall_result2 and \
435 appUninstall_result3
436 utilities.assert_equals(
437 expect=main.TRUE,
438 actual=case10_result,
439 onpass="Reactive forwarding app uninstallation successful",
440 onfail="Reactive forwarding app uninstallation failed" )
441
442 def CASE6( self ):
443 main.log.report(
444 "This testcase is testing the addition of host intents and \
445 then doing pingall" )
446 main.log.report( "__________________________________" )
447 main.case( "Obtaining hostsfor adding host intents" )
448 main.step( "Get hosts" )
449 hosts = main.ONOScli1.hosts()
450 main.log.info( hosts )
451
452 main.step( "Get all devices id" )
453 devices_id_list = main.ONOScli1.get_all_devices_id()
454 main.log.info( devices_id_list )
455
456 # ONOS displays the hosts in hex format unlike mininet
457 # which does in decimal format
458 # So take care while adding intents
459
460 """
461 main.step(
462 "Add host intents for mn hosts
463 (h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,
464 h15-h25,h16-h26,h17-h27)" )
465 hth_intent_result = main.ONOScli1.add_host_intent(
466 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
467 hth_intent_result = main.ONOScli1.add_host_intent(
468 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
469 hth_intent_result = main.ONOScli1.add_host_intent(
470 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
471 hth_intent_result = main.ONOScli1.add_host_intent(
472 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
473 hth_intent_result = main.ONOScli1.add_host_intent(
474 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
475 hth_intent_result = main.ONOScli1.add_host_intent(
476 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
477 hth_intent_result = main.ONOScli1.add_host_intent(
478 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
479 hth_intent_result = main.ONOScli1.add_host_intent(
480 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
481 hth_intent_result = main.ONOScli1.add_host_intent(
482 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
483 hth_intent_result = main.ONOScli1.add_host_intent(
484 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
485 """
486 for i in range( 8, 18 ):
487 main.log.info(
488 "Adding host intent between h" + str( i ) +
489 " and h" + str( i + 10 ) )
490 host1 = "00:00:00:00:00:" + \
491 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
492 host2 = "00:00:00:00:00:" + \
493 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
494 # NOTE: get host can return None
495 # TODO: handle this
496 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
497 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
498 tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
499
500 flowHandle = main.ONOScli1.flows()
501 main.log.info( "flows:" + flowHandle )
502
503 count = 1
504 i = 8
505 Ping_Result = main.TRUE
506 while i < 18:
507 main.log.info(
508 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
509 ping = main.Mininet1.pingHost(
510 src="h" + str( i ), target="h" + str( i + 10 ) )
511 if ping == main.FALSE and count < 5:
512 count += 1
513 # i = 8
514 Ping_Result = main.FALSE
515 main.log.report( "Ping between h" +
516 str( i ) +
517 " and h" +
518 str( i +
519 10 ) +
520 " failed. Making attempt number " +
521 str( count ) +
522 " in 2 seconds" )
523 time.sleep( 2 )
524 elif ping == main.FALSE:
525 main.log.report( "All ping attempts between h" +
526 str( i ) +
527 " and h" +
528 str( i +
529 10 ) +
530 "have failed" )
531 i = 19
532 Ping_Result = main.FALSE
533 elif ping == main.TRUE:
534 main.log.info( "Ping test between h" +
535 str( i ) +
536 " and h" +
537 str( i +
538 10 ) +
539 "passed!" )
540 i += 1
541 Ping_Result = main.TRUE
542 else:
543 main.log.info( "Unknown error" )
544 Ping_Result = main.ERROR
545 if Ping_Result == main.FALSE:
546 main.log.report(
547 "Host intents have not ben installed correctly. Cleaning up" )
548 # main.cleanup()
549 # main.exit()
550 if Ping_Result == main.TRUE:
551 main.log.report( "Host intents have been installed correctly" )
552
553 case6_result = Ping_Result
554 utilities.assert_equals(
555 expect=main.TRUE,
556 actual=case6_result,
557 onpass="Host intent addition and Pingall Test successful",
558 onfail="Host intent addition and Pingall Test NOT successful" )
559
560 def CASE7( self, main ):
561
562 from sts.topology.teston_topology import TestONTopology
563 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
564
565 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
566
567 main.log.report(
568 "This testscase is killing a link to ensure that \
569 link discovery is consistent" )
570 main.log.report( "__________________________________" )
571 main.case(
572 "Killing a link to ensure that \
573 Link Discovery is Working Properly" )
574 main.step( "Start continuous pings" )
575
576 main.Mininet2.pingLong(
577 src=main.params[ 'PING' ][ 'source1' ],
578 target=main.params[ 'PING' ][ 'target1' ],
579 pingTime=500 )
580 main.Mininet2.pingLong(
581 src=main.params[ 'PING' ][ 'source2' ],
582 target=main.params[ 'PING' ][ 'target2' ],
583 pingTime=500 )
584 main.Mininet2.pingLong(
585 src=main.params[ 'PING' ][ 'source3' ],
586 target=main.params[ 'PING' ][ 'target3' ],
587 pingTime=500 )
588 main.Mininet2.pingLong(
589 src=main.params[ 'PING' ][ 'source4' ],
590 target=main.params[ 'PING' ][ 'target4' ],
591 pingTime=500 )
592 main.Mininet2.pingLong(
593 src=main.params[ 'PING' ][ 'source5' ],
594 target=main.params[ 'PING' ][ 'target5' ],
595 pingTime=500 )
596 main.Mininet2.pingLong(
597 src=main.params[ 'PING' ][ 'source6' ],
598 target=main.params[ 'PING' ][ 'target6' ],
599 pingTime=500 )
600 main.Mininet2.pingLong(
601 src=main.params[ 'PING' ][ 'source7' ],
602 target=main.params[ 'PING' ][ 'target7' ],
603 pingTime=500 )
604 main.Mininet2.pingLong(
605 src=main.params[ 'PING' ][ 'source8' ],
606 target=main.params[ 'PING' ][ 'target8' ],
607 pingTime=500 )
608 main.Mininet2.pingLong(
609 src=main.params[ 'PING' ][ 'source9' ],
610 target=main.params[ 'PING' ][ 'target9' ],
611 pingTime=500 )
612 main.Mininet2.pingLong(
613 src=main.params[ 'PING' ][ 'source10' ],
614 target=main.params[ 'PING' ][ 'target10' ],
615 pingTime=500 )
616
617 main.step( "Determine the current number of switches and links" )
618 topology_output = main.ONOScli1.topology()
619 topology_result = main.ONOSbench.get_topology( topology_output )
620 activeSwitches = topology_result[ 'devices' ]
621 links = topology_result[ 'links' ]
622 main.log.info(
623 "Currently there are %s switches and %s links" %
624 ( str( activeSwitches ), str( links ) ) )
625
626 main.step( "Kill Link between s3 and s28" )
627 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
628 time.sleep( link_sleep )
629 topology_output = main.ONOScli2.topology()
630 Link_Down = main.ONOSbench.check_status(
631 topology_output, activeSwitches, str(
632 int( links ) - 2 ) )
633 if Link_Down == main.TRUE:
634 main.log.report( "Link Down discovered properly" )
635 utilities.assert_equals(
636 expect=main.TRUE,
637 actual=Link_Down,
638 onpass="Link Down discovered properly",
639 onfail="Link down was not discovered in " +
640 str( link_sleep ) +
641 " seconds" )
642
643 main.step( "Bring link between s3 and s28 back up" )
644 Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
645 time.sleep( link_sleep )
646 topology_output = main.ONOScli2.topology()
647 Link_Up = main.ONOSbench.check_status(
648 topology_output,
649 activeSwitches,
650 str( links ) )
651 if Link_Up == main.TRUE:
652 main.log.report( "Link up discovered properly" )
653 utilities.assert_equals(
654 expect=main.TRUE,
655 actual=Link_Up,
656 onpass="Link up discovered properly",
657 onfail="Link up was not discovered in " +
658 str( link_sleep ) +
659 " seconds" )
660
661 main.step( "Compare ONOS Topology to MN Topology" )
662 main.case(
663 "Testing Mininet topology with the topology of \
664 multi instances ONOS" )
665 main.step( "Collecting topology information from ONOS" )
666 devices1 = main.ONOScli1.devices()
667 devices2 = main.ONOScli2.devices()
668 devices3 = main.ONOScli3.devices()
669 hosts1 = main.ONOScli1.hosts()
670 hosts2 = main.ONOScli2.hosts()
671 hosts3 = main.ONOScli3.hosts()
672 ports1 = main.ONOScli1.ports()
673 ports2 = main.ONOScli2.ports()
674 ports3 = main.ONOScli3.ports()
675 links1 = main.ONOScli1.links()
676 links2 = main.ONOScli2.links()
677 links3 = main.ONOScli3.links()
678
679 main.step( "Start continuous pings" )
680 main.Mininet2.pingLong(
681 src=main.params[ 'PING' ][ 'source1' ],
682 target=main.params[ 'PING' ][ 'target1' ],
683 pingTime=500 )
684 main.Mininet2.pingLong(
685 src=main.params[ 'PING' ][ 'source2' ],
686 target=main.params[ 'PING' ][ 'target2' ],
687 pingTime=500 )
688 main.Mininet2.pingLong(
689 src=main.params[ 'PING' ][ 'source3' ],
690 target=main.params[ 'PING' ][ 'target3' ],
691 pingTime=500 )
692 main.Mininet2.pingLong(
693 src=main.params[ 'PING' ][ 'source4' ],
694 target=main.params[ 'PING' ][ 'target4' ],
695 pingTime=500 )
696 main.Mininet2.pingLong(
697 src=main.params[ 'PING' ][ 'source5' ],
698 target=main.params[ 'PING' ][ 'target5' ],
699 pingTime=500 )
700 main.Mininet2.pingLong(
701 src=main.params[ 'PING' ][ 'source6' ],
702 target=main.params[ 'PING' ][ 'target6' ],
703 pingTime=500 )
704 main.Mininet2.pingLong(
705 src=main.params[ 'PING' ][ 'source7' ],
706 target=main.params[ 'PING' ][ 'target7' ],
707 pingTime=500 )
708 main.Mininet2.pingLong(
709 src=main.params[ 'PING' ][ 'source8' ],
710 target=main.params[ 'PING' ][ 'target8' ],
711 pingTime=500 )
712 main.Mininet2.pingLong(
713 src=main.params[ 'PING' ][ 'source9' ],
714 target=main.params[ 'PING' ][ 'target9' ],
715 pingTime=500 )
716 main.Mininet2.pingLong(
717 src=main.params[ 'PING' ][ 'source10' ],
718 target=main.params[ 'PING' ][ 'target10' ],
719 pingTime=500 )
720
721 main.step( "Create TestONTopology object" )
722 global ctrls
723 ctrls = []
724 count = 1
725 while True:
726 temp = ()
727 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
728 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
729 temp = temp + ( "ONOS" + str( count ), )
730 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
731 temp = temp + \
732 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
733 ctrls.append( temp )
734 count = count + 1
735 else:
736 break
737 global MNTopo
738 Topo = TestONTopology(
739 main.Mininet1,
740 ctrls ) # can also add Intent API info for intent operations
741 MNTopo = Topo
742
743 Topology_Check = main.TRUE
744 main.step( "Compare ONOS Topology to MN Topology" )
745
746 switches_results1 = main.Mininet1.compare_switches(
747 MNTopo,
748 json.loads( devices1 ) )
749 print "switches_Result1 = ", switches_results1
750 utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
751 onpass="ONOS1 Switches view is correct",
752 onfail="ONOS1 Switches view is incorrect" )
753
754 switches_results2 = main.Mininet1.compare_switches(
755 MNTopo,
756 json.loads( devices2 ) )
757 utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
758 onpass="ONOS2 Switches view is correct",
759 onfail="ONOS2 Switches view is incorrect" )
760
761 switches_results3 = main.Mininet1.compare_switches(
762 MNTopo,
763 json.loads( devices3 ) )
764 utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
765 onpass="ONOS3 Switches view is correct",
766 onfail="ONOS3 Switches view is incorrect" )
767
768 """
769 ports_results1 = main.Mininet1.compare_ports(
770 MNTopo, json.loads( ports1 ) )
771 utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
772 onpass="ONOS1 Ports view is correct",
773 onfail="ONOS1 Ports view is incorrect" )
774
775 ports_results2 = main.Mininet1.compare_ports(
776 MNTopo, json.loads( ports2 ) )
777 utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
778 onpass="ONOS2 Ports view is correct",
779 onfail="ONOS2 Ports view is incorrect" )
780
781 ports_results3 = main.Mininet1.compare_ports(
782 MNTopo, json.loads( ports3 ) )
783 utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
784 onpass="ONOS3 Ports view is correct",
785 onfail="ONOS3 Ports view is incorrect" )
786 """
787 links_results1 = main.Mininet1.compare_links(
788 MNTopo,
789 json.loads( links1 ) )
790 utilities.assert_equals( expect=main.TRUE, actual=links_results1,
791 onpass="ONOS1 Links view is correct",
792 onfail="ONOS1 Links view is incorrect" )
793
794 links_results2 = main.Mininet1.compare_links(
795 MNTopo,
796 json.loads( links2 ) )
797 utilities.assert_equals( expect=main.TRUE, actual=links_results2,
798 onpass="ONOS2 Links view is correct",
799 onfail="ONOS2 Links view is incorrect" )
800
801 links_results3 = main.Mininet1.compare_links(
802 MNTopo,
803 json.loads( links3 ) )
804 utilities.assert_equals( expect=main.TRUE, actual=links_results3,
805 onpass="ONOS2 Links view is correct",
806 onfail="ONOS2 Links view is incorrect" )
807
808 # topo_result = switches_results1 and switches_results2 and \
809 # switches_results3 and ports_results1 and ports_results2 and \
810 # ports_results3 and links_results1 and links_results2 and \
811 # links_results3
812
813 topo_result = switches_results1 and switches_results2 \
814 and switches_results3 and links_results1 and \
815 links_results2 and links_results3
816
817 utilities.assert_equals(
818 expect=main.TRUE,
819 actual=topo_result and Link_Up and Link_Down,
820 onpass="Topology Check Test successful",
821 onfail="Topology Check Test NOT successful" )
822
823 def CASE8( self ):
824 """
825 Intent removal
826 """
827 main.log.report(
828 "This testcase removes host any previously added intents" )
829 main.log.report( "__________________________________" )
830 main.log.info( "Removing any previously installed intents" )
831 main.case( "Removing intents" )
832 main.step( "Obtain the intent id's" )
833 intent_result = main.ONOScli1.intents( json_format=False )
834
835 intent_linewise = intent_result.split( "\n" )
836 intentList = []
837 for line in intent_linewise:
838 if line.startswith( "id=" ):
839 intentList.append( line )
840
841 intentids = []
842 for line in intentList:
843 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
844 for id in intentids:
845 main.log.info( "id = " + id )
846
847 main.step(
848 "Iterate through the intentids list and remove each intent" )
849 for id in intentids:
850 main.ONOScli1.remove_intent( intent_id=id )
851
852 intent_result = main.ONOScli1.intents( json_format=False )
853 main.log.info( "intent_result = " + intent_result )
854 case8_result = main.TRUE
855
856 i = 8
857 Ping_Result = main.TRUE
858 while i < 18:
859 main.log.info(
860 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
861 ping = main.Mininet1.pingHost(
862 src="h" + str( i ), target="h" + str( i + 10 ) )
863 if ping == main.TRUE:
864 i = 19
865 Ping_Result = main.TRUE
866 elif ping == main.FALSE:
867 i += 1
868 Ping_Result = main.FALSE
869 else:
870 main.log.info( "Unknown error" )
871 Ping_Result = main.ERROR
872
873 # Note: If the ping result failed, that means the intents have been
874 # withdrawn correctly.
875 if Ping_Result == main.TRUE:
876 main.log.report( "Host intents have not been withdrawn correctly" )
877 # main.cleanup()
878 # main.exit()
879 if Ping_Result == main.FALSE:
880 main.log.report( "Host intents have been withdrawn correctly" )
881
882 case8_result = case8_result and Ping_Result
883
884 if case8_result == main.FALSE:
885 main.log.report( "Intent removal successful" )
886 else:
887 main.log.report( "Intent removal failed" )
888
889 utilities.assert_equals( expect=main.FALSE, actual=case8_result,
890 onpass="Intent removal test failed",
891 onfail="Intent removal test successful" )
892
893 def CASE9( self ):
894 """
895 This test case adds point intents. Make sure you run test case 8
896 which is host intent removal before executing this test case.
897 Else the host intents flows will persist on switches and the ping
898 would work even if there is some issue with the point intent's flows
899 """
900 main.log.report(
901 "This testcase adds point intents and then does pingall" )
902 main.log.report( "__________________________________" )
903 main.log.info( "Adding point intents" )
904 main.case(
905 "Adding bidirectional point for mn hosts \
906 h8-h18 h9-h19 h10-h20 h11-h21 h12-h22 h13-h23 \
907 h14-h24 h15-h25 h16-h26 h17-h27" )
908
909 main.step( "Add point-to-point intents for mininet hosts \
910 h8 and h18 or ONOS hosts h8 and h12" )
911 ptp_intent_result = main.ONOScli1.add_point_intent(
912 "of:0000000000003008/1",
913 "of:0000000000006018/1" )
914 if ptp_intent_result == main.TRUE:
915 get_intent_result = main.ONOScli1.intents()
916 main.log.info( "Point to point intent install successful" )
917 # main.log.info( get_intent_result )
918
919 ptp_intent_result = main.ONOScli1.add_point_intent(
920 "of:0000000000006018/1",
921 "of:0000000000003008/1" )
922 if ptp_intent_result == main.TRUE:
923 get_intent_result = main.ONOScli1.intents()
924 main.log.info( "Point to point intent install successful" )
925 # main.log.info( get_intent_result )
926
927 main.step( "Add point-to-point intents for mininet hosts \
928 h9 and h19 or ONOS hosts h9 and h13" )
929 ptp_intent_result = main.ONOScli1.add_point_intent(
930 "of:0000000000003009/1",
931 "of:0000000000006019/1" )
932 if ptp_intent_result == main.TRUE:
933 get_intent_result = main.ONOScli1.intents()
934 main.log.info( "Point to point intent install successful" )
935 # main.log.info( get_intent_result )
936
937 ptp_intent_result = main.ONOScli1.add_point_intent(
938 "of:0000000000006019/1",
939 "of:0000000000003009/1" )
940 if ptp_intent_result == main.TRUE:
941 get_intent_result = main.ONOScli1.intents()
942 main.log.info( "Point to point intent install successful" )
943 # main.log.info( get_intent_result )
944
945 main.step( "Add point-to-point intents for mininet hosts \
946 h10 and h20 or ONOS hosts hA and h14" )
947 ptp_intent_result = main.ONOScli1.add_point_intent(
948 "of:0000000000003010/1",
949 "of:0000000000006020/1" )
950 if ptp_intent_result == main.TRUE:
951 get_intent_result = main.ONOScli1.intents()
952 main.log.info( "Point to point intent install successful" )
953 # main.log.info( get_intent_result )
954
955 ptp_intent_result = main.ONOScli1.add_point_intent(
956 "of:0000000000006020/1",
957 "of:0000000000003010/1" )
958 if ptp_intent_result == main.TRUE:
959 get_intent_result = main.ONOScli1.intents()
960 main.log.info( "Point to point intent install successful" )
961 # main.log.info( get_intent_result )
962
963 main.step( "Add point-to-point intents for mininet hosts \
964 h11 and h21 or ONOS hosts hB and h15" )
965 ptp_intent_result = main.ONOScli1.add_point_intent(
966 "of:0000000000003011/1",
967 "of:0000000000006021/1" )
968 if ptp_intent_result == main.TRUE:
969 get_intent_result = main.ONOScli1.intents()
970 main.log.info( "Point to point intent install successful" )
971 # main.log.info( get_intent_result )
972
973 ptp_intent_result = main.ONOScli1.add_point_intent(
974 "of:0000000000006021/1",
975 "of:0000000000003011/1" )
976 if ptp_intent_result == main.TRUE:
977 get_intent_result = main.ONOScli1.intents()
978 main.log.info( "Point to point intent install successful" )
979 # main.log.info( get_intent_result )
980
981 main.step( "Add point-to-point intents for mininet hosts \
982 h12 and h22 or ONOS hosts hC and h16" )
983 ptp_intent_result = main.ONOScli1.add_point_intent(
984 "of:0000000000003012/1",
985 "of:0000000000006022/1" )
986 if ptp_intent_result == main.TRUE:
987 get_intent_result = main.ONOScli1.intents()
988 main.log.info( "Point to point intent install successful" )
989 # main.log.info( get_intent_result )
990
991 ptp_intent_result = main.ONOScli1.add_point_intent(
992 "of:0000000000006022/1",
993 "of:0000000000003012/1" )
994 if ptp_intent_result == main.TRUE:
995 get_intent_result = main.ONOScli1.intents()
996 main.log.info( "Point to point intent install successful" )
997 # main.log.info( get_intent_result )
998
999 main.step( "Add point-to-point intents for mininet hosts \
1000 h13 and h23 or ONOS hosts hD and h17" )
1001 ptp_intent_result = main.ONOScli1.add_point_intent(
1002 "of:0000000000003013/1",
1003 "of:0000000000006023/1" )
1004 if ptp_intent_result == main.TRUE:
1005 get_intent_result = main.ONOScli1.intents()
1006 main.log.info( "Point to point intent install successful" )
1007 # main.log.info( get_intent_result )
1008
1009 ptp_intent_result = main.ONOScli1.add_point_intent(
1010 "of:0000000000006023/1",
1011 "of:0000000000003013/1" )
1012 if ptp_intent_result == main.TRUE:
1013 get_intent_result = main.ONOScli1.intents()
1014 main.log.info( "Point to point intent install successful" )
1015 # main.log.info( get_intent_result )
1016
1017 main.step( "Add point-to-point intents for mininet hosts \
1018 h14 and h24 or ONOS hosts hE and h18" )
1019 ptp_intent_result = main.ONOScli1.add_point_intent(
1020 "of:0000000000003014/1",
1021 "of:0000000000006024/1" )
1022 if ptp_intent_result == main.TRUE:
1023 get_intent_result = main.ONOScli1.intents()
1024 main.log.info( "Point to point intent install successful" )
1025 # main.log.info( get_intent_result )
1026
1027 ptp_intent_result = main.ONOScli1.add_point_intent(
1028 "of:0000000000006024/1",
1029 "of:0000000000003014/1" )
1030 if ptp_intent_result == main.TRUE:
1031 get_intent_result = main.ONOScli1.intents()
1032 main.log.info( "Point to point intent install successful" )
1033 # main.log.info( get_intent_result )
1034
1035 main.step( "Add point-to-point intents for mininet hosts \
1036 h15 and h25 or ONOS hosts hF and h19" )
1037 ptp_intent_result = main.ONOScli1.add_point_intent(
1038 "of:0000000000003015/1",
1039 "of:0000000000006025/1" )
1040 if ptp_intent_result == main.TRUE:
1041 get_intent_result = main.ONOScli1.intents()
1042 main.log.info( "Point to point intent install successful" )
1043 # main.log.info( get_intent_result )
1044
1045 ptp_intent_result = main.ONOScli1.add_point_intent(
1046 "of:0000000000006025/1",
1047 "of:0000000000003015/1" )
1048 if ptp_intent_result == main.TRUE:
1049 get_intent_result = main.ONOScli1.intents()
1050 main.log.info( "Point to point intent install successful" )
1051 # main.log.info( get_intent_result )
1052
1053 main.step( "Add point-to-point intents for mininet hosts \
1054 h16 and h26 or ONOS hosts h10 and h1A" )
1055 ptp_intent_result = main.ONOScli1.add_point_intent(
1056 "of:0000000000003016/1",
1057 "of:0000000000006026/1" )
1058 if ptp_intent_result == main.TRUE:
1059 get_intent_result = main.ONOScli1.intents()
1060 main.log.info( "Point to point intent install successful" )
1061 # main.log.info( get_intent_result )
1062
1063 ptp_intent_result = main.ONOScli1.add_point_intent(
1064 "of:0000000000006026/1",
1065 "of:0000000000003016/1" )
1066 if ptp_intent_result == main.TRUE:
1067 get_intent_result = main.ONOScli1.intents()
1068 main.log.info( "Point to point intent install successful" )
1069 # main.log.info( get_intent_result )
1070
1071 main.step( "Add point-to-point intents for mininet hosts \
1072 h17 and h27 or ONOS hosts h11 and h1B" )
1073 ptp_intent_result = main.ONOScli1.add_point_intent(
1074 "of:0000000000003017/1",
1075 "of:0000000000006027/1" )
1076 if ptp_intent_result == main.TRUE:
1077 get_intent_result = main.ONOScli1.intents()
1078 main.log.info( "Point to point intent install successful" )
1079 # main.log.info( get_intent_result )
1080
1081 ptp_intent_result = main.ONOScli1.add_point_intent(
1082 "of:0000000000006027/1",
1083 "of:0000000000003017/1" )
1084 if ptp_intent_result == main.TRUE:
1085 get_intent_result = main.ONOScli1.intents()
1086 main.log.info( "Point to point intent install successful" )
1087 # main.log.info( get_intent_result )
1088
1089 print("___________________________________________________________" )
1090
1091 flowHandle = main.ONOScli1.flows()
1092 main.log.info( "flows :" + flowHandle )
1093
1094 count = 1
1095 i = 8
1096 Ping_Result = main.TRUE
1097 while i < 18:
1098 main.log.info(
1099 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1100 ping = main.Mininet1.pingHost(
1101 src="h" + str( i ), target="h" + str( i + 10 ) )
1102 if ping == main.FALSE and count < 5:
1103 count += 1
1104 # i = 8
1105 Ping_Result = main.FALSE
1106 main.log.report( "Ping between h" +
1107 str( i ) +
1108 " and h" +
1109 str( i +
1110 10 ) +
1111 " failed. Making attempt number " +
1112 str( count ) +
1113 " in 2 seconds" )
1114 time.sleep( 2 )
1115 elif ping == main.FALSE:
1116 main.log.report( "All ping attempts between h" +
1117 str( i ) +
1118 " and h" +
1119 str( i +
1120 10 ) +
1121 "have failed" )
1122 i = 19
1123 Ping_Result = main.FALSE
1124 elif ping == main.TRUE:
1125 main.log.info( "Ping test between h" +
1126 str( i ) +
1127 " and h" +
1128 str( i +
1129 10 ) +
1130 "passed!" )
1131 i += 1
1132 Ping_Result = main.TRUE
1133 else:
1134 main.log.info( "Unknown error" )
1135 Ping_Result = main.ERROR
1136
1137 if Ping_Result == main.FALSE:
1138 main.log.report(
1139 "Ping all test after Point intents addition failed. \
1140 Cleaning up" )
1141 # main.cleanup()
1142 # main.exit()
1143 if Ping_Result == main.TRUE:
1144 main.log.report(
1145 "Ping all test after Point intents addition successful" )
1146
1147 case8_result = Ping_Result
1148 utilities.assert_equals(
1149 expect=main.TRUE,
1150 actual=case8_result,
1151 onpass="Ping all test after Point intents addition successful",
1152 onfail="Ping all test after Point intents addition failed" )
1153
1154 def CASE31( self ):
1155 """
1156 This test case adds point intent related to SDN-IP
1157 matching on ICMP ( ethertype=IPV4, ipProto=1 )
1158 """
1159 import json
1160
1161 main.log.report(
1162 '''This test case adds point intent related to SDN-IP
1163 matching on ICMP''' )
1164 main.case(
1165 '''Adding bidirectional point intent related to SDN-IP
1166 matching on ICMP''' )
1167 main.step( "Adding bidirectional point intent" )
1168 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1169 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1170 # of:0000000000006018/1
1171
1172 hosts_json = json.loads( main.ONOScli1.hosts() )
1173 for i in range( 8, 11 ):
1174 main.log.info(
1175 "Adding point intent between h" + str( i ) +
1176 " and h" + str( i + 10 ) )
1177 host1 = "00:00:00:00:00:" + \
1178 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1179 host2 = "00:00:00:00:00:" + \
1180 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1181 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
1182 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
1183 for host in hosts_json:
1184 if host[ 'id' ] == host1_id:
1185 ip1 = host[ 'ips' ][ 0 ]
1186 ip1 = str( ip1 + "/32" )
1187 device1 = host[ 'location' ][ 'device' ]
1188 device1 = str( device1 + "/1" )
1189 elif host[ 'id' ] == host2_id:
1190 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1191 device2 = host[ 'location' ][ "device" ]
1192 device2 = str( device2 + "/1" )
1193
1194 p_intent_result1 = main.ONOScli1.add_point_intent(
1195 ingress_device=device1,
1196 egress_device=device2,
1197 ipSrc=ip1,
1198 ipDst=ip2,
1199 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1200 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1201
1202 get_intent_result = main.ONOScli1.intents( json_format=False )
1203 main.log.info( get_intent_result )
1204
1205 p_intent_result2 = main.ONOScli1.add_point_intent(
1206 ingress_device=device2,
1207 egress_device=device1,
1208 ipSrc=ip2,
1209 ipDst=ip1,
1210 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1211 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1212
1213 get_intent_result = main.ONOScli1.intents( json_format=False )
1214 main.log.info( get_intent_result )
1215 if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
1216 # get_intent_result = main.ONOScli1.intents()
1217 # main.log.info( get_intent_result )
1218 main.log.info(
1219 '''Point intent related to SDN-IP matching on ICMP install
1220 successful''' )
1221
1222 time.sleep( 15 )
1223 get_intent_result = main.ONOScli1.intents( json_format=False )
1224 main.log.info( "intents = " + get_intent_result )
1225 get_flows_result = main.ONOScli1.flows()
1226 main.log.info( "flows = " + get_flows_result )
1227
1228 count = 1
1229 i = 8
1230 Ping_Result = main.TRUE
1231 while i < 11:
1232 main.log.info(
1233 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1234 ping = main.Mininet1.pingHost(
1235 src="h" + str( i ), target="h" + str( i + 10 ) )
1236 if ping == main.FALSE and count < 3:
1237 count += 1
1238 # i = 8
1239 Ping_Result = main.FALSE
1240 main.log.report( "Ping between h" +
1241 str( i ) +
1242 " and h" +
1243 str( i +
1244 10 ) +
1245 " failed. Making attempt number " +
1246 str( count ) +
1247 " in 2 seconds" )
1248 time.sleep( 2 )
1249 elif ping == main.FALSE:
1250 main.log.report( "All ping attempts between h" +
1251 str( i ) +
1252 " and h" +
1253 str( i +
1254 10 ) +
1255 "have failed" )
1256 i = 19
1257 Ping_Result = main.FALSE
1258 elif ping == main.TRUE:
1259 main.log.info( "Ping test between h" +
1260 str( i ) +
1261 " and h" +
1262 str( i +
1263 10 ) +
1264 "passed!" )
1265 i += 1
1266 Ping_Result = main.TRUE
1267 else:
1268 main.log.info( "Unknown error" )
1269 Ping_Result = main.ERROR
1270 if Ping_Result == main.FALSE:
1271 main.log.report(
1272 "Ping test after Point intents related to SDN-IP \
1273 matching on ICMP failed." )
1274 # main.cleanup()
1275 # main.exit()
1276 if Ping_Result == main.TRUE:
1277 main.log.report(
1278 "Ping all test after Point intents related to SDN-IP \
1279 matching on ICMP successful" )
1280
1281 case31_result = Ping_Result and p_intent_result1 and p_intent_result2
1282 utilities.assert_equals(
1283 expect=main.TRUE,
1284 actual=case31_result,
1285 onpass="Point intent related to SDN-IP matching on ICMP and \
1286 ping test successful",
1287 onfail="Point intent related to SDN-IP matching on ICMP and \
1288 ping test failed" )
1289
1290 def CASE32( self ):
1291 '''
1292 This test case adds point intent related to SDN-IP matching on TCP
1293 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1294 Note: Although BGP port is 179, we are using 5001 because iperf is
1295 used for verifying and iperf's default port is 5001
1296 '''
1297 import json
1298
1299 main.log.report( '''This test case adds point intent related
1300 to SDN-IP matching on TCP''' )
1301 main.case( '''Adding bidirectional point intent related to SDN-IP
1302 matching on TCP''' )
1303 main.step( "Adding bidirectional point intent" )
1304
1305 """
1306 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1307 --ethType=IPV4 --ipProto=6 --tcpDst=5001
1308 of:0000000000003008/1 of:0000000000006018/1
1309
1310 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1311 --ethType=IPV4 --ipProto=6 --tcpDst=5001
1312 of:0000000000006018/1 of:0000000000003008/1
1313
1314 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1315 --ethType=IPV4 --ipProto=6 --tcpSrc=5001
1316 of:0000000000003008/1 of:0000000000006018/1
1317
1318 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1319 --ethType=IPV4 --ipProto=6 --tcpSrc=5001
1320 of:0000000000006018/1 of:0000000000003008/1
1321
1322 """
1323 hosts_json = json.loads( main.ONOScli1.hosts() )
1324 for i in range( 8, 9 ):
1325 main.log.info(
1326 "Adding point intent between h" + str( i ) +
1327 " and h" + str( i + 10 ) )
1328 host1 = "00:00:00:00:00:" + \
1329 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1330 host2 = "00:00:00:00:00:" + \
1331 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1332 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
1333 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
1334 for host in hosts_json:
1335 if host[ 'id' ] == host1_id:
1336 ip1 = host[ 'ips' ][ 0 ]
1337 ip1 = str( ip1 + "/32" )
1338 device1 = host[ 'location' ][ 'device' ]
1339 device1 = str( device1 + "/1" )
1340 elif host[ 'id' ] == host2_id:
1341 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1342 device2 = host[ 'location' ][ "device" ]
1343 device2 = str( device2 + "/1" )
1344
1345 p_intent_result1 = main.ONOScli1.add_point_intent(
1346 ingress_device=device1,
1347 egress_device=device2,
1348 ipSrc=ip1,
1349 ipDst=ip2,
1350 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1351 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1352 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1353 p_intent_result2 = main.ONOScli1.add_point_intent(
1354 ingress_device=device2,
1355 egress_device=device1,
1356 ipSrc=ip2,
1357 ipDst=ip1,
1358 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1359 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1360 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1361
1362 p_intent_result3 = main.ONOScli1.add_point_intent(
1363 ingress_device=device1,
1364 egress_device=device2,
1365 ipSrc=ip1,
1366 ipDst=ip2,
1367 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1368 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1369 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
1370 p_intent_result4 = main.ONOScli1.add_point_intent(
1371 ingress_device=device2,
1372 egress_device=device1,
1373 ipSrc=ip2,
1374 ipDst=ip1,
1375 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1376 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1377 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
1378
1379 p_intent_result = p_intent_result1 and p_intent_result2 and \
1380 p_intent_result3 and p_intent_result4
1381 if p_intent_result == main.TRUE:
1382 get_intent_result = main.ONOScli1.intents( json_format=False )
1383 main.log.info( get_intent_result )
1384 main.log.info( '''Point intent related to SDN-IP matching
1385 on TCP install successful''' )
1386
1387 iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
1388 if iperf_result == main.TRUE:
1389 main.log.report( "iperf test successful" )
1390 else:
1391 main.log.report( "iperf test failed" )
1392
1393 case32_result = p_intent_result and iperf_result
1394 utilities.assert_equals(
1395 expect=main.TRUE,
1396 actual=case32_result,
1397 onpass="Ping all test after Point intents addition related to \
1398 SDN-IP on TCP match successful",
1399 onfail="Ping all test after Point intents addition related to \
1400 SDN-IP on TCP match failed" )
1401
1402 def CASE33( self ):
1403 """
1404 This test case adds multipoint to singlepoint intent related
1405 to SDN-IP matching on destination ip and the action is to
1406 rewrite the mac address.
1407 Here the mac address to be rewritten is the mac address
1408 of the egress device
1409 """
1410 import json
1411 import time
1412
1413 main.log.report( "This test case adds multipoint to singlepoint intent\
1414 related to SDN-IP matching on destination ip and\
1415 rewrite mac address action" )
1416 main.case( "Adding multipoint to singlepoint intent related to SDN-IP\
1417 matching on destination ip" )
1418 main.step( "Adding bidirectional multipoint to singlepoint intent" )
1419 """
1420 add-multi-to-single-intent --ipDst=10.0.3.0/24
1421 --setEthDst=00:00:00:00:00:12
1422 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
1423
1424 add-multi-to-single-intent --ipDst=10.0.1.0/24
1425 --setEthDst=00:00:00:00:00:08
1426 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
1427 """
1428 main.case( "Installing multipoint to single point intent with\
1429 rewrite mac address" )
1430 main.step( "Uninstalling proxy arp app" )
1431 # Unistall onos-app-proxyarp app to disable reactive forwarding
1432 appUninstall_result1 = main.ONOScli1.feature_uninstall(
1433 "onos-app-proxyarp" )
1434 appUninstall_result2 = main.ONOScli2.feature_uninstall(
1435 "onos-app-proxyarp" )
1436 appUninstall_result3 = main.ONOScli3.feature_uninstall(
1437 "onos-app-proxyarp" )
1438 main.log.info( "onos-app-proxyarp uninstalled" )
1439
1440 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1441 main.Mininet1.changeIP(
1442 host='h8',
1443 intf='h8-eth0',
1444 newIP='10.0.1.1',
1445 newNetmask='255.255.255.0' )
1446 main.Mininet1.changeIP(
1447 host='h9',
1448 intf='h9-eth0',
1449 newIP='10.0.2.1',
1450 newNetmask='255.255.255.0' )
1451 main.Mininet1.changeIP(
1452 host='h10',
1453 intf='h10-eth0',
1454 newIP='10.0.3.1',
1455 newNetmask='255.255.255.0' )
1456
1457 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1458 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1459 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1460 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
1461
1462 main.step( "Assigning random mac address to the default gateways\
1463 since proxyarp app is uninstalled" )
1464 main.Mininet1.addStaticMACAddress(
1465 host='h8',
1466 GW='10.0.1.254',
1467 macaddr='00:00:00:00:11:11' )
1468 main.Mininet1.addStaticMACAddress(
1469 host='h9',
1470 GW='10.0.2.254',
1471 macaddr='00:00:00:00:22:22' )
1472 main.Mininet1.addStaticMACAddress(
1473 host='h10',
1474 GW='10.0.3.254',
1475 macaddr='00:00:00:00:33:33' )
1476
1477 main.step( "Verify static gateway and MAC address assignment" )
1478 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1479 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1480 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1481
1482 main.step( "Adding multipoint to singlepoint intent" )
1483 p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
1484 ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1485 ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1486 egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1487 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1488 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1489
1490 p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
1491 ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1492 ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1493 egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1494 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1495 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1496
1497 get_intent_result = main.ONOScli1.intents( json_format=False )
1498 main.log.info( "intents = " + get_intent_result )
1499
1500 time.sleep( 10 )
1501 get_flows_result = main.ONOScli1.flows( json_format=False )
1502 main.log.info( "flows = " + get_flows_result )
1503
1504 count = 1
1505 i = 8
1506 Ping_Result = main.TRUE
1507
1508 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1509 ping = main.Mininet1.pingHost(
1510 src="h" + str( i ), target="h" + str( i + 2 ) )
1511 if ping == main.FALSE and count < 3:
1512 count += 1
1513 Ping_Result = main.FALSE
1514 main.log.report( "Ping between h" +
1515 str( i ) +
1516 " and h" +
1517 str( i +
1518 2 ) +
1519 " failed. Making attempt number " +
1520 str( count ) +
1521 " in 2 seconds" )
1522 time.sleep( 2 )
1523 elif ping == main.FALSE:
1524 main.log.report( "All ping attempts between h" +
1525 str( i ) +
1526 " and h" +
1527 str( i +
1528 10 ) +
1529 "have failed" )
1530 Ping_Result = main.FALSE
1531 elif ping == main.TRUE:
1532 main.log.info( "Ping test between h" +
1533 str( i ) +
1534 " and h" +
1535 str( i +
1536 2 ) +
1537 "passed!" )
1538 Ping_Result = main.TRUE
1539 else:
1540 main.log.info( "Unknown error" )
1541 Ping_Result = main.ERROR
1542
1543 if Ping_Result == main.FALSE:
1544 main.log.report( "Ping test failed." )
1545 # main.cleanup()
1546 # main.exit()
1547 if Ping_Result == main.TRUE:
1548 main.log.report( "Ping all successful" )
1549
1550 p_intent_result = p_intent_result1 and p_intent_result2
1551 if p_intent_result == main.TRUE:
1552 main.log.info( "Multi point intent with rewrite mac address\
1553 installation successful" )
1554 else:
1555 main.log.info( "Multi point intent with rewrite mac address\
1556 installation failed" )
1557
1558 case33_result = p_intent_result and Ping_Result
1559 utilities.assert_equals(
1560 expect=main.TRUE,
1561 actual=case33_result,
1562 onpass="Ping all test after multipoint to single point intent \
1563 addition with rewrite mac address successful",
1564 onfail="Ping all test after multipoint to single point intent \
1565 addition with rewrite mac address failed" )
1566