blob: 6f4b72b5f49fa6478ab63fb9fc130535cd5ab1d1 [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
6# import sys
7# import os
8# import re
9import json
10
11time.sleep( 1 )
12
13
14class ProdFunc:
15
16 def __init__( self ):
17 self.default = ''
18
19 def CASE1( self, main ):
20 """
21 Startup sequence:
22 cell <name>
23 onos-verify-cell
24 onos-remove-raft-log
25 git pull
26 mvn clean install
27 onos-package
28 onos-install -f
29 onos-wait-for-start
30 """
31 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
33
34 main.case( "Setting up test environment" )
35 main.log.report(
36 "This testcase is testing setting up test environment" )
37 main.log.report( "__________________________________" )
38
39 main.step( "Applying cell variable to environment" )
40 cellResult = main.ONOSbench.setCell( cellName )
41 verifyResult = main.ONOSbench.verifyCell()
42
43 main.step( "Removing raft logs before a clen installation of ONOS" )
44 main.ONOSbench.onosRemoveRaftLogs()
45
46 main.step( "Git checkout and pull master and get version" )
47 main.ONOSbench.gitCheckout( "master" )
48 gitPullResult = main.ONOSbench.gitPull()
49 main.log.info( "git_pull_result = " + gitPullResult )
50 main.ONOSbench.getVersion( report=True )
51
52 if gitPullResult == 1:
53 main.step( "Using mvn clean & install" )
54 main.ONOSbench.cleanInstall()
55 elif gitPullResult == 0:
56 main.log.report(
57 "Git Pull Failed, look into logs for detailed reason" )
58 main.cleanup()
59 main.exit()
60
61 main.step( "Creating ONOS package" )
62 packageResult = main.ONOSbench.onosPackage()
63
64 main.step( "Installing ONOS package" )
65 onosInstallResult = main.ONOSbench.onosInstall()
66 if onosInstallResult == main.TRUE:
67 main.log.report( "Installing ONOS package successful" )
68 else:
69 main.log.report( "Installing ONOS package failed" )
70
71 onos1Isup = main.ONOSbench.isup()
72 if onos1Isup == main.TRUE:
73 main.log.report( "ONOS instance is up and ready" )
74 else:
75 main.log.report( "ONOS instance may not be up" )
76
77 main.step( "Starting ONOS service" )
78 startResult = main.ONOSbench.onosStart( ONOS1Ip )
79
80 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
81
82 case1Result = ( packageResult and
83 cellResult and verifyResult
84 and onosInstallResult and
85 onos1Isup and startResult )
86 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
87 onpass="Test startup successful",
88 onfail="Test startup NOT successful" )
89
90 def CASE2( self, main ):
91 """
92 Switch Down
93 """
94 # NOTE: You should probably run a topology check after this
95 import time
96
97 main.case( "Switch down discovery" )
98 main.log.report( "This testcase is testing a switch down discovery" )
99 main.log.report( "__________________________________" )
100
101 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
102
103 description = "Killing a switch to ensure it is discovered correctly"
104 main.log.report( description )
105 main.case( description )
106
107 # TODO: Make this switch parameterizable
108 main.step( "Kill s28 " )
109 main.log.report( "Deleting s28" )
110 # FIXME: use new dynamic topo functions
111 main.Mininet1.delSwitch( "s28" )
112 main.log.info(
113 "Waiting " +
114 str( switchSleep ) +
115 " seconds for switch down to be discovered" )
116 time.sleep( switchSleep )
117 # Peek at the deleted switch
118 device = main.ONOS2.getDevice( dpid="0028" )
119 print "device = ", device
120 if device[ u'available' ] == 'False':
121 case2Result = main.FALSE
122 else:
123 case2Result = main.TRUE
124 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
125 onpass="Switch down discovery successful",
126 onfail="Switch down discovery failed" )
127
128 def CASE11( self, main ):
129 """
130 Cleanup sequence:
131 onos-service <nodeIp> stop
132 onos-uninstall
133
134 TODO: Define rest of cleanup
135
136 """
137 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
138
139 main.case( "Cleaning up test environment" )
140
141 main.step( "Testing ONOS kill function" )
142 killResult = main.ONOSbench.onosKill( ONOS1Ip )
143
144 main.step( "Stopping ONOS service" )
145 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
146
147 main.step( "Uninstalling ONOS service" )
148 uninstallResult = main.ONOSbench.onosUninstall()
149
150 case11Result = killResult and stopResult and uninstallResult
151 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
152 onpass="Cleanup successful",
153 onfail="Cleanup failed" )
154
155 def CASE3( self, main ):
156 """
157 Test 'onos' command and its functionality in driver
158 """
159 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
160
161 main.case( "Testing 'onos' command" )
162
163 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
164 cmdstr1 = "system:name"
165 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
166 main.log.info( "onos command returned: " + cmdResult1 )
167
168 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
169 cmdstr2 = "onos:topology"
170 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
171 main.log.info( "onos command returned: " + cmdResult2 )
172
173 def CASE20( self ):
174 """
175 Exit from mininet cli
176 reinstall ONOS
177 """
178 cellName = main.params[ 'ENV' ][ 'cellName' ]
179 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
180
181 main.log.report( "This testcase exits the mininet cli and reinstalls\
182 ONOS to switch over to Packet Optical topology" )
183 main.log.report( "_____________________________________________" )
184 main.case( "Disconnecting mininet and restarting ONOS" )
185 main.step( "Disconnecting mininet and restarting ONOS" )
186 mininetDisconnect = main.Mininet1.disconnect()
187
188 main.step( "Removing raft logs before a clen installation of ONOS" )
189 main.ONOSbench.onosRemoveRaftLogs()
190
191 main.step( "Applying cell variable to environment" )
192 cellResult = main.ONOSbench.setCell( cellName )
193 verifyResult = main.ONOSbench.verifyCell()
194
195 onosInstallResult = main.ONOSbench.onosInstall()
196 if onosInstallResult == main.TRUE:
197 main.log.report( "Installing ONOS package successful" )
198 else:
199 main.log.report( "Installing ONOS package failed" )
200
201 onos1Isup = main.ONOSbench.isup()
202 if onos1Isup == main.TRUE:
203 main.log.report( "ONOS instance is up and ready" )
204 else:
205 main.log.report( "ONOS instance may not be up" )
206
207 main.step( "Starting ONOS service" )
208 startResult = main.ONOSbench.onosStart( ONOS1Ip )
209
210 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
211 case20Result = mininetDisconnect and cellResult and verifyResult \
212 and onosInstallResult and onos1Isup and \
213 startResult
214 utilities.assert_equals(
215 expect=main.TRUE,
216 actual=case20Result,
217 onpass="Exiting functionality mininet topology and reinstalling \
218 ONOS successful",
219 onfail="Exiting functionality mininet topology and reinstalling \
220 ONOS failed" )
221
222 def CASE21( self, main ):
223 """
224 On ONOS bench, run this command:
225 ./~/ONOS/tools/test/bin/onos-topo-cfg
226 which starts the rest and copies the links
227 json file to the onos instance.
228 Note that in case of Packet Optical, the links are not learnt
229 from the topology, instead the links are learnt
230 from the json config file
231 """
232 main.log.report(
233 "This testcase starts the packet layer topology and REST" )
234 main.log.report( "_____________________________________________" )
235 main.case( "Starting LINC-OE and other components" )
236 main.step( "Starting LINC-OE and other components" )
237 startConsoleResult = main.LincOE1.startConsole()
238 opticalMnScript = main.LincOE2.runOpticalMnScript()
239 onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
240 instanceName=main.params[ 'CTRL' ][ 'ip1' ],
241 jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
242
243 print "start_console_result =", startConsoleResult
244 print "optical_mn_script = ", opticalMnScript
245 print "onos_topo_cfg_result =", onosTopoCfgResult
246
247 case21Result = startConsoleResult and opticalMnScript and \
248 onosTopoCfgResult
249 utilities.assert_equals(
250 expect=main.TRUE,
251 actual=case21Result,
252 onpass="Packet optical topology spawned successsfully",
253 onfail="Packet optical topology spawning failed" )
254
255 def CASE22( self, main ):
256 """
257 Curretly we use, 4 linear switch optical topology and
258 2 packet layer mininet switches each with one host.
259 Therefore, the roadmCount variable = 4,
260 packetLayerSWCount variable = 2 and hostCount = 2
261 and this is hardcoded in the testcase. If the topology changes,
262 these hardcoded values need to be changed
263 """
264 main.log.report(
265 "This testcase compares the optical+packet topology against what\
266 is expected" )
267 main.case( "Topology comparision" )
268 main.step( "Topology comparision" )
269 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
270 devicesResult = main.ONOS3.devices( jsonFormat=False )
271
272 print "devices_result = ", devicesResult
273 devicesLinewise = devicesResult.split( "\n" )
274 devicesLinewise = devicesLinewise[ 1:-1 ]
275 roadmCount = 0
276 packetLayerSWCount = 0
277 for line in devicesLinewise:
278 components = line.split( "," )
279 availability = components[ 1 ].split( "=" )[ 1 ]
280 type = components[ 3 ].split( "=" )[ 1 ]
281 if availability == 'true' and type == 'ROADM':
282 roadmCount += 1
283 elif availability == 'true' and type == 'SWITCH':
284 packetLayerSWCount += 1
285 if roadmCount == 4:
286 print "Number of Optical Switches = %d and is \
287 correctly detected" % roadmCount
288 main.log.info(
289 "Number of Optical Switches = " +
290 str( roadmCount ) +
291 " and is correctly detected" )
292 opticalSWResult = main.TRUE
293 else:
294 print "Number of Optical Switches = %d and is wrong" % roadmCount
295 main.log.info(
296 "Number of Optical Switches = " +
297 str( roadmCount ) +
298 " and is wrong" )
299 opticalSWResult = main.FALSE
300
301 if packetLayerSWCount == 2:
302 print "Number of Packet layer or mininet Switches = %d and \
303 is correctly detected" % packetLayerSWCount
304 main.log.info(
305 "Number of Packet layer or mininet Switches = " +
306 str( packetLayerSWCount ) +
307 " and is correctly detected" )
308 packetSWResult = main.TRUE
309 else:
310 print "Number of Packet layer or mininet Switches = %d and \
311 is wrong" % packetLayerSWCount
312 main.log.info(
313 "Number of Packet layer or mininet Switches = " +
314 str( packetLayerSWCount ) +
315 " and is wrong" )
316 packetSWResult = main.FALSE
317 print "_________________________________"
318
319 linksResult = main.ONOS3.links( jsonFormat=False )
320 print "links_result = ", linksResult
321 print "_________________________________"
322
323 # NOTE:Since only point intents are added, there is no
324 # requirement to discover the hosts
325 # Therfore, the below portion of the code is commented.
326 """
327 #Discover hosts using pingall
328 pingallResult = main.LincOE2.pingall()
329
330 hostsResult = main.ONOS3.hosts( jsonFormat=False )
331 main.log.info( "hosts_result = "+hostsResult )
332 main.log.info( "_________________________________" )
333 hostsLinewise = hostsResult.split( "\n" )
334 hostsLinewise = hostsLinewise[ 1:-1 ]
335 hostCount = 0
336 for line in hostsLinewise:
337 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
338 hostCount +=1
339 if hostCount ==2:
340 print "Number of hosts = %d and is correctly detected" %hostCount
341 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
342 is correctly detected" )
343 hostDiscovery = main.TRUE
344 else:
345 print "Number of hosts = %d and is wrong" %hostCount
346 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
347 is wrong" )
348 hostDiscovery = main.FALSE
349 """
350 case22Result = opticalSWResult and packetSWResult
351 utilities.assert_equals(
352 expect=main.TRUE,
353 actual=case22Result,
354 onpass="Packet optical topology discovery successful",
355 onfail="Packet optical topology discovery failed" )
356
357 def CASE23( self, main ):
358 import time
359 """
360 Add bidirectional point intents between 2 packet layer( mininet )
361 devices and
362 ping mininet hosts
363 """
364 main.log.report(
365 "This testcase adds bidirectional point intents between 2 \
366 packet layer( mininet ) devices and ping mininet hosts" )
367 main.case( "Topology comparision" )
368 main.step( "Adding point intents" )
369 ptpIntentResult = main.ONOS3.addPointIntent(
370 "of:0000ffffffff0001/1",
371 "of:0000ffffffff0002/1" )
372 if ptpIntentResult == main.TRUE:
373 main.ONOS3.intents( jsonFormat=False )
374 main.log.info( "Point to point intent install successful" )
375
376 ptpIntentResult = main.ONOS3.addPointIntent(
377 "of:0000ffffffff0002/1",
378 "of:0000ffffffff0001/1" )
379 if ptpIntentResult == main.TRUE:
380 main.ONOS3.intents( jsonFormat=False )
381 main.log.info( "Point to point intent install successful" )
382
383 time.sleep( 10 )
384 flowHandle = main.ONOS3.flows()
385 main.log.info( "flows :" + flowHandle )
386
387 # Sleep for 30 seconds to provide time for the intent state to change
388 time.sleep( 30 )
389 intentHandle = main.ONOS3.intents( jsonFormat=False )
390 main.log.info( "intents :" + intentHandle )
391
392 PingResult = main.TRUE
393 count = 1
394 main.log.info( "\n\nh1 is Pinging h2" )
395 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
396 # ping = main.LincOE2.pinghost()
397 if ping == main.FALSE and count < 5:
398 count += 1
399 PingResult = main.FALSE
400 main.log.info(
401 "Ping between h1 and h2 failed. Making attempt number " +
402 str( count ) +
403 " in 2 seconds" )
404 time.sleep( 2 )
405 elif ping == main.FALSE:
406 main.log.info( "All ping attempts between h1 and h2 have failed" )
407 PingResult = main.FALSE
408 elif ping == main.TRUE:
409 main.log.info( "Ping test between h1 and h2 passed!" )
410 PingResult = main.TRUE
411 else:
412 main.log.info( "Unknown error" )
413 PingResult = main.ERROR
414
415 if PingResult == main.FALSE:
416 main.log.report(
417 "Point intents for packet optical have not ben installed\
418 correctly. Cleaning up" )
419 if PingResult == main.TRUE:
420 main.log.report(
421 "Point Intents for packet optical have been\
422 installed correctly" )
423
424 case23Result = PingResult
425 utilities.assert_equals(
426 expect=main.TRUE,
427 actual=case23Result,
428 onpass="Point intents addition for packet optical and\
429 Pingall Test successful",
430 onfail="Point intents addition for packet optical and\
431 Pingall Test NOT successful" )
432
433 def CASE24( self, main ):
434 import time
435 import json
436 """
437 Test Rerouting of Packet Optical by bringing a port down
438 ( port 22 ) of a switch( switchID=1 ), so that link
439 ( between switch1 port22 - switch4-port30 ) is inactive
440 and do a ping test. If rerouting is successful,
441 ping should pass. also check the flows
442 """
443 main.log.report(
444 "This testcase tests rerouting and pings mininet hosts" )
445 main.case( "Test rerouting and pings mininet hosts" )
446 main.step( "Bring a port down and verify the link state" )
447 main.LincOE1.portDown( swId="1", ptId="22" )
448 linksNonjson = main.ONOS3.links( jsonFormat=False )
449 main.log.info( "links = " + linksNonjson )
450
451 links = main.ONOS3.links()
452 main.log.info( "links = " + links )
453
454 linksResult = json.loads( links )
455 linksStateResult = main.FALSE
456 for item in linksResult:
457 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
458 'src' ][ 'port' ] == "22":
459 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
460 'dst' ][ 'port' ] == "30":
461 linksState = item[ 'state' ]
462 if linksState == "INACTIVE":
463 main.log.info(
464 "Links state is inactive as expected due to one \
465 of the ports being down" )
466 main.log.report(
467 "Links state is inactive as expected due to one \
468 of the ports being down" )
469 linksStateResult = main.TRUE
470 break
471 else:
472 main.log.info(
473 "Links state is not inactive as expected" )
474 main.log.report(
475 "Links state is not inactive as expected" )
476 linksStateResult = main.FALSE
477
478 print "links_state_result = ", linksStateResult
479 time.sleep( 10 )
480 flowHandle = main.ONOS3.flows()
481 main.log.info( "flows :" + flowHandle )
482
483 main.step( "Verify Rerouting by a ping test" )
484 PingResult = main.TRUE
485 count = 1
486 main.log.info( "\n\nh1 is Pinging h2" )
487 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
488 # ping = main.LincOE2.pinghost()
489 if ping == main.FALSE and count < 5:
490 count += 1
491 PingResult = main.FALSE
492 main.log.info(
493 "Ping between h1 and h2 failed. Making attempt number " +
494 str( count ) +
495 " in 2 seconds" )
496 time.sleep( 2 )
497 elif ping == main.FALSE:
498 main.log.info( "All ping attempts between h1 and h2 have failed" )
499 PingResult = main.FALSE
500 elif ping == main.TRUE:
501 main.log.info( "Ping test between h1 and h2 passed!" )
502 PingResult = main.TRUE
503 else:
504 main.log.info( "Unknown error" )
505 PingResult = main.ERROR
506
507 if PingResult == main.TRUE:
508 main.log.report( "Ping test successful " )
509 if PingResult == main.FALSE:
510 main.log.report( "Ping test failed" )
511
512 case24Result = PingResult and linksStateResult
513 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
514 onpass="Packet optical rerouting successful",
515 onfail="Packet optical rerouting failed" )
516
517 def CASE4( self, main ):
518 import re
519 import time
520 main.log.report( "This testcase is testing the assignment of \
521 all the switches to all the controllers and \
522 discovering the hists in reactive mode" )
523 main.log.report( "__________________________________" )
524 main.case( "Pingall Test" )
525 main.step( "Assigning switches to controllers" )
526 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
527 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
528 for i in range( 1, 29 ):
529 if i == 1:
530 main.Mininet1.assignSwController(
531 sw=str( i ),
532 ip1=ONOS1Ip,
533 port1=ONOS1Port )
534 elif i >= 2 and i < 5:
535 main.Mininet1.assignSwController(
536 sw=str( i ),
537 ip1=ONOS1Ip,
538 port1=ONOS1Port )
539 elif i >= 5 and i < 8:
540 main.Mininet1.assignSwController(
541 sw=str( i ),
542 ip1=ONOS1Ip,
543 port1=ONOS1Port )
544 elif i >= 8 and i < 18:
545 main.Mininet1.assignSwController(
546 sw=str( i ),
547 ip1=ONOS1Ip,
548 port1=ONOS1Port )
549 elif i >= 18 and i < 28:
550 main.Mininet1.assignSwController(
551 sw=str( i ),
552 ip1=ONOS1Ip,
553 port1=ONOS1Port )
554 else:
555 main.Mininet1.assignSwController(
556 sw=str( i ),
557 ip1=ONOS1Ip,
558 port1=ONOS1Port )
559 SwitchMastership = main.TRUE
560 for i in range( 1, 29 ):
561 if i == 1:
562 response = main.Mininet1.getSwController( "s" + str( i ) )
563 print( "Response is " + str( response ) )
564 if re.search( "tcp:" + ONOS1Ip, response ):
565 SwitchMastership = SwitchMastership and main.TRUE
566 else:
567 SwitchMastership = main.FALSE
568 elif i >= 2 and i < 5:
569 response = main.Mininet1.getSwController( "s" + str( i ) )
570 print( "Response is " + str( response ) )
571 if re.search( "tcp:" + ONOS1Ip, response ):
572 SwitchMastership = SwitchMastership and main.TRUE
573 else:
574 SwitchMastership = main.FALSE
575 elif i >= 5 and i < 8:
576 response = main.Mininet1.getSwController( "s" + str( i ) )
577 print( "Response is " + str( response ) )
578 if re.search( "tcp:" + ONOS1Ip, response ):
579 SwitchMastership = SwitchMastership and main.TRUE
580 else:
581 SwitchMastership = main.FALSE
582 elif i >= 8 and i < 18:
583 response = main.Mininet1.getSwController( "s" + str( i ) )
584 print( "Response is " + str( response ) )
585 if re.search( "tcp:" + ONOS1Ip, response ):
586 SwitchMastership = SwitchMastership and main.TRUE
587 else:
588 SwitchMastership = main.FALSE
589 elif i >= 18 and i < 28:
590 response = main.Mininet1.getSwController( "s" + str( i ) )
591 print( "Response is " + str( response ) )
592 if re.search( "tcp:" + ONOS1Ip, response ):
593 SwitchMastership = SwitchMastership and main.TRUE
594 else:
595 SwitchMastership = main.FALSE
596 else:
597 response = main.Mininet1.getSwController( "s" + str( i ) )
598 print( "Response is" + str( response ) )
599 if re.search( "tcp:" + ONOS1Ip, response ):
600 SwitchMastership = SwitchMastership and main.TRUE
601 else:
602 SwitchMastership = main.FALSE
603
604 if SwitchMastership == main.TRUE:
605 main.log.report( "Controller assignmnet successful" )
606 else:
607 main.log.report( "Controller assignmnet failed" )
608 utilities.assert_equals(
609 expect=main.TRUE,
610 actual=SwitchMastership,
611 onpass="MasterControllers assigned correctly" )
612 """
613 for i in range ( 1,29 ):
614 main.Mininet1.assignSwController( sw=str( i ),count=5,
615 ip1=ONOS1Ip,port1=ONOS1Port,
616 ip2=ONOS2Ip,port2=ONOS2Port,
617 ip3=ONOS3Ip,port3=ONOS3Port,
618 ip4=ONOS4Ip,port4=ONOS4Port,
619 ip5=ONOS5Ip,port5=ONOS5Port )
620 """
621 # REACTIVE FWD test
622
623 main.step( "Get list of hosts from Mininet" )
624 hostList = main.Mininet1.getHosts()
625 main.log.info( hostList )
626
627 main.step( "Get host list in ONOS format" )
628 hostOnosList = main.ONOS2.getHostsId( hostList )
629 main.log.info( hostOnosList )
630 # time.sleep( 5 )
631
632 main.step( "Pingall" )
633 pingResult = main.FALSE
634 while pingResult == main.FALSE:
635 time1 = time.time()
636 pingResult = main.Mininet1.pingall()
637 time2 = time.time()
638 print "Time for pingall: %2f seconds" % ( time2 - time1 )
639
640 # Start onos cli again because u might have dropped out of
641 # onos prompt to the shell prompt
642 # if there was no activity
643 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
644
645 case4Result = SwitchMastership and pingResult
646 if pingResult == main.TRUE:
647 main.log.report( "Pingall Test in reactive mode to \
648 discover the hosts successful" )
649 else:
650 main.log.report( "Pingall Test in reactive mode to \
651 discover the hosts failed" )
652
653 utilities.assert_equals(
654 expect=main.TRUE,
655 actual=case4Result,
656 onpass="Controller assignment and Pingall Test successful",
657 onfail="Controller assignment and Pingall Test NOT successful" )
658
659 def CASE10( self ):
660 main.log.report(
661 "This testcase uninstalls the reactive forwarding app" )
662 main.log.report( "__________________________________" )
663 main.case( "Uninstalling reactive forwarding app" )
664 # Unistall onos-app-fwd app to disable reactive forwarding
665 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
666 main.log.info( "onos-app-fwd uninstalled" )
667
668 # After reactive forwarding is disabled, the reactive flows on
669 # switches timeout in 10-15s
670 # So sleep for 15s
671 time.sleep( 15 )
672
673 flows = main.ONOS2.flows()
674 main.log.info( flows )
675
676 case10Result = appUninstallResult
677 utilities.assert_equals(
678 expect=main.TRUE,
679 actual=case10Result,
680 onpass="Reactive forwarding app uninstallation successful",
681 onfail="Reactive forwarding app uninstallation failed" )
682
683 def CASE6( self ):
684 main.log.report( "This testcase is testing the addition of \
685 host intents and then does pingall" )
686 main.log.report( "__________________________________" )
687 main.case( "Obtaining host id's" )
688 main.step( "Get hosts" )
689 hosts = main.ONOS2.hosts()
690 main.log.info( hosts )
691
692 main.step( "Get all devices id" )
693 devicesIdList = main.ONOS2.getAllDevicesId()
694 main.log.info( devicesIdList )
695
696 # ONOS displays the hosts in hex format unlike mininet which does
697 # in decimal format
698 # So take care while adding intents
699 """
700 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
701 ONOS hosts h8 and h12" )
702 hthIntentResult = main.ONOS2.addHostIntent(
703 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
704 hthIntentResult = main.ONOS2.addHostIntent(
705 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
706 hthIntentResult = main.ONOS2.addHostIntent(
707 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
708 hthIntentResult = main.ONOS2.addHostIntent(
709 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
710 hthIntentResult = main.ONOS2.addHostIntent(
711 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
712 hthIntentResult = main.ONOS2.addHostIntent(
713 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
714 hthIntentResult = main.ONOS2.addHostIntent(
715 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
716 hthIntentResult = main.ONOS2.addHostIntent(
717 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
718 hthIntentResult = main.ONOS2.addHostIntent(
719 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
720 hthIntentResult = main.ONOS2.addHostIntent(
721 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
722 print "______________________________________________________"
723 """
724 for i in range( 8, 18 ):
725 main.log.info(
726 "Adding host intent between h" + str( i ) +
727 " and h" + str( i + 10 ) )
728 host1 = "00:00:00:00:00:" + \
729 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
730 host2 = "00:00:00:00:00:" + \
731 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
732 # NOTE: get host can return None
733 # TODO: handle this
734 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
735 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
736 main.ONOS2.addHostIntent( host1Id, host2Id )
737
738 time.sleep( 10 )
739 hIntents = main.ONOS2.intents( jsonFormat=False )
740 main.log.info( "intents:" + hIntents )
741 main.ONOS2.flows()
742
743 count = 1
744 i = 8
745 PingResult = main.TRUE
746 # while i<10:
747 while i < 18:
748 main.log.info(
749 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
750 ping = main.Mininet1.pingHost(
751 src="h" + str( i ), target="h" + str( i + 10 ) )
752 if ping == main.FALSE and count < 5:
753 count += 1
754 # i = 8
755 PingResult = main.FALSE
756 main.log.report( "Ping between h" +
757 str( i ) +
758 " and h" +
759 str( i +
760 10 ) +
761 " failed. Making attempt number " +
762 str( count ) +
763 " in 2 seconds" )
764 time.sleep( 2 )
765 elif ping == main.FALSE:
766 main.log.report( "All ping attempts between h" +
767 str( i ) +
768 " and h" +
769 str( i +
770 10 ) +
771 "have failed" )
772 i = 19
773 PingResult = main.FALSE
774 elif ping == main.TRUE:
775 main.log.info( "Ping test between h" +
776 str( i ) +
777 " and h" +
778 str( i +
779 10 ) +
780 "passed!" )
781 i += 1
782 PingResult = main.TRUE
783 else:
784 main.log.info( "Unknown error" )
785 PingResult = main.ERROR
786 if PingResult == main.FALSE:
787 main.log.report(
788 "Ping all test after Host intent addition failed. Cleaning up" )
789 # main.cleanup()
790 # main.exit()
791 if PingResult == main.TRUE:
792 main.log.report(
793 "Ping all test after Host intent addition successful" )
794
795 case6Result = PingResult
796 utilities.assert_equals(
797 expect=main.TRUE,
798 actual=case6Result,
799 onpass="Pingall Test after Host intents addition successful",
800 onfail="Pingall Test after Host intents addition failed" )
801
802 def CASE5( self, main ):
803 import json
804 # assumes that sts is already in you PYTHONPATH
805 from sts.topology.testonTopology import TestONTopology
806 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
807 main.log.report( "This testcase is testing if all ONOS nodes \
808 are in topology sync with mininet" )
809 main.log.report( "__________________________________" )
810 main.case( "Comparing Mininet topology with the topology of ONOS" )
811 main.step( "Start continuous pings" )
812 main.Mininet2.pingLong(
813 src=main.params[ 'PING' ][ 'source1' ],
814 target=main.params[ 'PING' ][ 'target1' ],
815 pingTime=500 )
816 main.Mininet2.pingLong(
817 src=main.params[ 'PING' ][ 'source2' ],
818 target=main.params[ 'PING' ][ 'target2' ],
819 pingTime=500 )
820 main.Mininet2.pingLong(
821 src=main.params[ 'PING' ][ 'source3' ],
822 target=main.params[ 'PING' ][ 'target3' ],
823 pingTime=500 )
824 main.Mininet2.pingLong(
825 src=main.params[ 'PING' ][ 'source4' ],
826 target=main.params[ 'PING' ][ 'target4' ],
827 pingTime=500 )
828 main.Mininet2.pingLong(
829 src=main.params[ 'PING' ][ 'source5' ],
830 target=main.params[ 'PING' ][ 'target5' ],
831 pingTime=500 )
832 main.Mininet2.pingLong(
833 src=main.params[ 'PING' ][ 'source6' ],
834 target=main.params[ 'PING' ][ 'target6' ],
835 pingTime=500 )
836 main.Mininet2.pingLong(
837 src=main.params[ 'PING' ][ 'source7' ],
838 target=main.params[ 'PING' ][ 'target7' ],
839 pingTime=500 )
840 main.Mininet2.pingLong(
841 src=main.params[ 'PING' ][ 'source8' ],
842 target=main.params[ 'PING' ][ 'target8' ],
843 pingTime=500 )
844 main.Mininet2.pingLong(
845 src=main.params[ 'PING' ][ 'source9' ],
846 target=main.params[ 'PING' ][ 'target9' ],
847 pingTime=500 )
848 main.Mininet2.pingLong(
849 src=main.params[ 'PING' ][ 'source10' ],
850 target=main.params[ 'PING' ][ 'target10' ],
851 pingTime=500 )
852
853 main.step( "Create TestONTopology object" )
854 global ctrls
855 ctrls = []
856 count = 1
857 while True:
858 temp = ()
859 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
860 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
861 temp = temp + ( "ONOS" + str( count ), )
862 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
863 temp = temp + \
864 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
865 ctrls.append( temp )
866 count = count + 1
867 else:
868 break
869 global MNTopo
870 Topo = TestONTopology(
871 main.Mininet1,
872 ctrls ) # can also add Intent API info for intent operations
873 MNTopo = Topo
874
875 TopologyCheck = main.TRUE
876 main.step( "Compare ONOS Topology to MN Topology" )
877 devicesJson = main.ONOS2.devices()
878 linksJson = main.ONOS2.links()
879 # portsJson = main.ONOS2.ports()
880
881 result1 = main.Mininet1.compareSwitches(
882 MNTopo,
883 json.loads( devicesJson ) )
884 result2 = main.Mininet1.compareLinks(
885 MNTopo,
886 json.loads( linksJson ) )
887 # result3 = main.Mininet1.comparePorts(
888 # MNTopo, json.loads( portsJson ) )
889
890 # result = result1 and result2 and result3
891 result = result1 and result2
892
893 print "***********************"
894 if result == main.TRUE:
895 main.log.report( "ONOS" + " Topology matches MN Topology" )
896 else:
897 main.log.report( "ONOS" + " Topology does not match MN Topology" )
898
899 utilities.assert_equals(
900 expect=main.TRUE,
901 actual=result,
902 onpass="ONOS" +
903 " Topology matches MN Topology",
904 onfail="ONOS" +
905 " Topology does not match MN Topology" )
906
907 TopologyCheck = TopologyCheck and result
908 utilities.assert_equals(
909 expect=main.TRUE,
910 actual=TopologyCheck,
911 onpass="Topology checks passed",
912 onfail="Topology checks failed" )
913
914 def CASE7( self, main ):
915 from sts.topology.testonTopology import TestONTopology
916
917 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
918
919 main.log.report( "This testscase is killing a link to ensure that \
920 link discovery is consistent" )
921 main.log.report( "__________________________________" )
922 main.log.report( "Killing a link to ensure that link discovery \
923 is consistent" )
924 main.case( "Killing a link to Ensure that Link Discovery \
925 is Working Properly" )
926 """
927 main.step( "Start continuous pings" )
928
929 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
930 target=main.params[ 'PING' ][ 'target1' ],
931 pingTime=500 )
932 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
933 target=main.params[ 'PING' ][ 'target2' ],
934 pingTime=500 )
935 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
936 target=main.params[ 'PING' ][ 'target3' ],
937 pingTime=500 )
938 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
939 target=main.params[ 'PING' ][ 'target4' ],
940 pingTime=500 )
941 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
942 target=main.params[ 'PING' ][ 'target5' ],
943 pingTime=500 )
944 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
945 target=main.params[ 'PING' ][ 'target6' ],
946 pingTime=500 )
947 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
948 target=main.params[ 'PING' ][ 'target7' ],
949 pingTime=500 )
950 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
951 target=main.params[ 'PING' ][ 'target8' ],
952 pingTime=500 )
953 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
954 target=main.params[ 'PING' ][ 'target9' ],
955 pingTime=500 )
956 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
957 target=main.params[ 'PING' ][ 'target10' ],
958 pingTime=500 )
959 """
960 main.step( "Determine the current number of switches and links" )
961 topologyOutput = main.ONOS2.topology()
962 topologyResult = main.ONOS1.getTopology( topologyOutput )
963 activeSwitches = topologyResult[ 'devices' ]
964 links = topologyResult[ 'links' ]
965 print "activeSwitches = ", type( activeSwitches )
966 print "links = ", type( links )
967 main.log.info(
968 "Currently there are %s switches and %s links" %
969 ( str( activeSwitches ), str( links ) ) )
970
971 main.step( "Kill Link between s3 and s28" )
972 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
973 time.sleep( linkSleep )
974 topologyOutput = main.ONOS2.topology()
975 LinkDown = main.ONOS1.checkStatus(
976 topologyOutput, activeSwitches, str(
977 int( links ) - 2 ) )
978 if LinkDown == main.TRUE:
979 main.log.report( "Link Down discovered properly" )
980 utilities.assert_equals(
981 expect=main.TRUE,
982 actual=LinkDown,
983 onpass="Link Down discovered properly",
984 onfail="Link down was not discovered in " +
985 str( linkSleep ) +
986 " seconds" )
987
988 # Check ping result here..add code for it
989
990 main.step( "Bring link between s3 and s28 back up" )
991 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
992 time.sleep( linkSleep )
993 topologyOutput = main.ONOS2.topology()
994 LinkUp = main.ONOS1.checkStatus(
995 topologyOutput,
996 activeSwitches,
997 str( links ) )
998 if LinkUp == main.TRUE:
999 main.log.report( "Link up discovered properly" )
1000 utilities.assert_equals(
1001 expect=main.TRUE,
1002 actual=LinkUp,
1003 onpass="Link up discovered properly",
1004 onfail="Link up was not discovered in " +
1005 str( linkSleep ) +
1006 " seconds" )
1007
1008 # NOTE Check ping result here..add code for it
1009
1010 main.step( "Compare ONOS Topology to MN Topology" )
1011 Topo = TestONTopology(
1012 main.Mininet1,
1013 ctrls ) # can also add Intent API info for intent operations
1014 MNTopo = Topo
1015 TopologyCheck = main.TRUE
1016
1017 devicesJson = main.ONOS2.devices()
1018 linksJson = main.ONOS2.links()
1019 portsJson = main.ONOS2.ports()
1020
1021 result1 = main.Mininet1.compareSwitches(
1022 MNTopo,
1023 json.loads( devicesJson ) )
1024 result2 = main.Mininet1.compareLinks(
1025 MNTopo,
1026 json.loads( linksJson ) )
1027 # result3 = main.Mininet1.comparePorts(
1028 # MNTopo, json.loads( portsJson ) )
1029
1030 # result = result1 and result2 and result3
1031 result = result1 and result2
1032 print "***********************"
1033
1034 if result == main.TRUE:
1035 main.log.report( "ONOS" + " Topology matches MN Topology" )
1036 utilities.assert_equals(
1037 expect=main.TRUE,
1038 actual=result,
1039 onpass="ONOS" +
1040 " Topology matches MN Topology",
1041 onfail="ONOS" +
1042 " Topology does not match MN Topology" )
1043
1044 TopologyCheck = TopologyCheck and result
1045 utilities.assert_equals(
1046 expect=main.TRUE,
1047 actual=TopologyCheck,
1048 onpass="Topology checks passed",
1049 onfail="Topology checks failed" )
1050
1051 result = LinkDown and LinkUp and TopologyCheck
1052 utilities.assert_equals( expect=main.TRUE, actual=result,
1053 onpass="Link failure is discovered correctly",
1054 onfail="Link Discovery failed" )
1055
1056 def CASE8( self ):
1057 """
1058 Host intents removal
1059 """
1060 main.log.report( "This testcase removes any previously added intents \
1061 before adding the same intents or point intents" )
1062 main.log.report( "__________________________________" )
1063 main.log.info( "Host intents removal" )
1064 main.case( "Removing host intents" )
1065 main.step( "Obtain the intent id's" )
1066 intentResult = main.ONOS2.intents( jsonFormat=False )
1067 main.log.info( "intent_result = " + intentResult )
1068
1069 intentLinewise = intentResult.split( "\n" )
1070 intentList = []
1071 for line in intentLinewise:
1072 if line.startswith( "id=" ):
1073 intentList.append( line )
1074
1075 intentids = []
1076 for line in intentList:
1077 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
1078 for id in intentids:
1079 print "id = ", id
1080
1081 main.step(
1082 "Iterate through the intentids list and remove each intent" )
1083 for id in intentids:
1084 main.ONOS2.removeIntent( intentId=id )
1085
1086 intentResult = main.ONOS2.intents( jsonFormat=False )
1087 main.log.info( "intent_result = " + intentResult )
1088
1089 case8Result = main.TRUE
1090 if case8Result == main.TRUE:
1091 main.log.report( "Intent removal successful" )
1092 else:
1093 main.log.report( "Intent removal failed" )
1094
1095 PingResult = main.TRUE
1096 if case8Result == main.TRUE:
1097 i = 8
1098 while i < 18:
1099 main.log.info(
1100 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1101 ping = main.Mininet1.pingHost(
1102 src="h" + str( i ), target="h" + str( i + 10 ) )
1103 if ping == main.TRUE:
1104 i = 19
1105 PingResult = PingResult and main.TRUE
1106 elif ping == main.FALSE:
1107 i += 1
1108 PingResult = PingResult and main.FALSE
1109 else:
1110 main.log.info( "Unknown error" )
1111 PingResult = main.ERROR
1112
1113 # Note: If the ping result failed, that means the intents have been
1114 # withdrawn correctly.
1115 if PingResult == main.TRUE:
1116 main.log.report( "Host intents have not been withdrawn correctly" )
1117 # main.cleanup()
1118 # main.exit()
1119 if PingResult == main.FALSE:
1120 main.log.report( "Host intents have been withdrawn correctly" )
1121
1122 case8Result = case8Result and PingResult
1123
1124 if case8Result == main.FALSE:
1125 main.log.report( "Intent removal successful" )
1126 else:
1127 main.log.report( "Intent removal failed" )
1128
1129 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1130 onpass="Intent removal test failed",
1131 onfail="Intent removal test passed" )
1132
1133 def CASE9( self ):
1134 main.log.report(
1135 "This testcase adds point intents and then does pingall" )
1136 main.log.report( "__________________________________" )
1137 main.log.info( "Adding point intents" )
1138 main.case(
1139 "Adding bidirectional point for mn hosts \
1140 ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,\
1141 h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
1142 main.step(
1143 "Add point intents for mininet hosts h8 and h18 or \
1144 ONOS hosts h8 and h12" )
1145 ptpIntentResult = main.ONOS2.addPointIntent(
1146 "of:0000000000003008/1",
1147 "of:0000000000006018/1" )
1148 if ptpIntentResult == main.TRUE:
1149 getIntentResult = main.ONOS2.intents()
1150 main.log.info( "Point to point intent install successful" )
1151 # main.log.info( getIntentResult )
1152
1153 ptpIntentResult = main.ONOS2.addPointIntent(
1154 "of:0000000000006018/1",
1155 "of:0000000000003008/1" )
1156 if ptpIntentResult == main.TRUE:
1157 getIntentResult = main.ONOS2.intents()
1158 main.log.info( "Point to point intent install successful" )
1159 # main.log.info( getIntentResult )
1160
1161 main.step(
1162 "Add point intents for mininet hosts h9 and h19 or \
1163 ONOS hosts h9 and h13" )
1164 ptpIntentResult = main.ONOS2.addPointIntent(
1165 "of:0000000000003009/1",
1166 "of:0000000000006019/1" )
1167 if ptpIntentResult == main.TRUE:
1168 getIntentResult = main.ONOS2.intents()
1169 main.log.info( "Point to point intent install successful" )
1170 # main.log.info( getIntentResult )
1171
1172 ptpIntentResult = main.ONOS2.addPointIntent(
1173 "of:0000000000006019/1",
1174 "of:0000000000003009/1" )
1175 if ptpIntentResult == main.TRUE:
1176 getIntentResult = main.ONOS2.intents()
1177 main.log.info( "Point to point intent install successful" )
1178 # main.log.info( getIntentResult )
1179
1180 main.step(
1181 "Add point intents for mininet hosts h10 and h20 or \
1182 ONOS hosts hA and h14" )
1183 ptpIntentResult = main.ONOS2.addPointIntent(
1184 "of:0000000000003010/1",
1185 "of:0000000000006020/1" )
1186 if ptpIntentResult == main.TRUE:
1187 getIntentResult = main.ONOS2.intents()
1188 main.log.info( "Point to point intent install successful" )
1189 # main.log.info( getIntentResult )
1190
1191 ptpIntentResult = main.ONOS2.addPointIntent(
1192 "of:0000000000006020/1",
1193 "of:0000000000003010/1" )
1194 if ptpIntentResult == main.TRUE:
1195 getIntentResult = main.ONOS2.intents()
1196 main.log.info( "Point to point intent install successful" )
1197 # main.log.info( getIntentResult )
1198
1199 main.step(
1200 "Add point intents for mininet hosts h11 and h21 or \
1201 ONOS hosts hB and h15" )
1202 ptpIntentResult = main.ONOS2.addPointIntent(
1203 "of:0000000000003011/1",
1204 "of:0000000000006021/1" )
1205 if ptpIntentResult == main.TRUE:
1206 getIntentResult = main.ONOS2.intents()
1207 main.log.info( "Point to point intent install successful" )
1208 # main.log.info( getIntentResult )
1209
1210 ptpIntentResult = main.ONOS2.addPointIntent(
1211 "of:0000000000006021/1",
1212 "of:0000000000003011/1" )
1213 if ptpIntentResult == main.TRUE:
1214 getIntentResult = main.ONOS2.intents()
1215 main.log.info( "Point to point intent install successful" )
1216 # main.log.info( getIntentResult )
1217
1218 main.step(
1219 "Add point intents for mininet hosts h12 and h22 \
1220 ONOS hosts hC and h16" )
1221 ptpIntentResult = main.ONOS2.addPointIntent(
1222 "of:0000000000003012/1",
1223 "of:0000000000006022/1" )
1224 if ptpIntentResult == main.TRUE:
1225 getIntentResult = main.ONOS2.intents()
1226 main.log.info( "Point to point intent install successful" )
1227 # main.log.info( getIntentResult )
1228
1229 ptpIntentResult = main.ONOS2.addPointIntent(
1230 "of:0000000000006022/1",
1231 "of:0000000000003012/1" )
1232 if ptpIntentResult == main.TRUE:
1233 getIntentResult = main.ONOS2.intents()
1234 main.log.info( "Point to point intent install successful" )
1235 # main.log.info( getIntentResult )
1236
1237 main.step(
1238 "Add point intents for mininet hosts h13 and h23 or \
1239 ONOS hosts hD and h17" )
1240 ptpIntentResult = main.ONOS2.addPointIntent(
1241 "of:0000000000003013/1",
1242 "of:0000000000006023/1" )
1243 if ptpIntentResult == main.TRUE:
1244 getIntentResult = main.ONOS2.intents()
1245 main.log.info( "Point to point intent install successful" )
1246 # main.log.info( getIntentResult )
1247
1248 ptpIntentResult = main.ONOS2.addPointIntent(
1249 "of:0000000000006023/1",
1250 "of:0000000000003013/1" )
1251 if ptpIntentResult == main.TRUE:
1252 getIntentResult = main.ONOS2.intents()
1253 main.log.info( "Point to point intent install successful" )
1254 # main.log.info( getIntentResult )
1255
1256 main.step(
1257 "Add point intents for mininet hosts h14 and h24 or \
1258 ONOS hosts hE and h18" )
1259 ptpIntentResult = main.ONOS2.addPointIntent(
1260 "of:0000000000003014/1",
1261 "of:0000000000006024/1" )
1262 if ptpIntentResult == main.TRUE:
1263 getIntentResult = main.ONOS2.intents()
1264 main.log.info( "Point to point intent install successful" )
1265 # main.log.info( getIntentResult )
1266
1267 ptpIntentResult = main.ONOS2.addPointIntent(
1268 "of:0000000000006024/1",
1269 "of:0000000000003014/1" )
1270 if ptpIntentResult == main.TRUE:
1271 getIntentResult = main.ONOS2.intents()
1272 main.log.info( "Point to point intent install successful" )
1273 # main.log.info( getIntentResult )
1274
1275 main.step(
1276 "Add point intents for mininet hosts h15 and h25 or \
1277 ONOS hosts hF and h19" )
1278 ptpIntentResult = main.ONOS2.addPointIntent(
1279 "of:0000000000003015/1",
1280 "of:0000000000006025/1" )
1281 if ptpIntentResult == main.TRUE:
1282 getIntentResult = main.ONOS2.intents()
1283 main.log.info( "Point to point intent install successful" )
1284 # main.log.info( getIntentResult )
1285
1286 ptpIntentResult = main.ONOS2.addPointIntent(
1287 "of:0000000000006025/1",
1288 "of:0000000000003015/1" )
1289 if ptpIntentResult == main.TRUE:
1290 getIntentResult = main.ONOS2.intents()
1291 main.log.info( "Point to point intent install successful" )
1292 # main.log.info( getIntentResult )
1293
1294 main.step(
1295 "Add intents for mininet hosts h16 and h26 or \
1296 ONOS hosts h10 and h1A" )
1297 ptpIntentResult = main.ONOS2.addPointIntent(
1298 "of:0000000000003016/1",
1299 "of:0000000000006026/1" )
1300 if ptpIntentResult == main.TRUE:
1301 getIntentResult = main.ONOS2.intents()
1302 main.log.info( "Point to point intent install successful" )
1303 # main.log.info( getIntentResult )
1304
1305 ptpIntentResult = main.ONOS2.addPointIntent(
1306 "of:0000000000006026/1",
1307 "of:0000000000003016/1" )
1308 if ptpIntentResult == main.TRUE:
1309 getIntentResult = main.ONOS2.intents()
1310 main.log.info( "Point to point intent install successful" )
1311 # main.log.info( getIntentResult )
1312
1313 main.step(
1314 "Add point intents for mininet hosts h17 and h27 or \
1315 ONOS hosts h11 and h1B" )
1316 ptpIntentResult = main.ONOS2.addPointIntent(
1317 "of:0000000000003017/1",
1318 "of:0000000000006027/1" )
1319 if ptpIntentResult == main.TRUE:
1320 getIntentResult = main.ONOS2.intents()
1321 main.log.info( "Point to point intent install successful" )
1322 main.log.info( getIntentResult )
1323
1324 ptpIntentResult = main.ONOS2.addPointIntent(
1325 "of:0000000000006027/1",
1326 "of:0000000000003017/1" )
1327 if ptpIntentResult == main.TRUE:
1328 getIntentResult = main.ONOS2.intents()
1329 main.log.info( "Point to point intent install successful" )
1330 main.log.info( getIntentResult )
1331
1332 print(
1333 "___________________________________________________________" )
1334
1335 flowHandle = main.ONOS2.flows()
1336 # print "flowHandle = ", flowHandle
1337 main.log.info( "flows :" + flowHandle )
1338
1339 count = 1
1340 i = 8
1341 PingResult = main.TRUE
1342 while i < 18:
1343 main.log.info(
1344 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1345 ping = main.Mininet1.pingHost(
1346 src="h" + str( i ), target="h" + str( i + 10 ) )
1347 if ping == main.FALSE and count < 5:
1348 count += 1
1349 # i = 8
1350 PingResult = main.FALSE
1351 main.log.report( "Ping between h" +
1352 str( i ) +
1353 " and h" +
1354 str( i +
1355 10 ) +
1356 " failed. Making attempt number " +
1357 str( count ) +
1358 " in 2 seconds" )
1359 time.sleep( 2 )
1360 elif ping == main.FALSE:
1361 main.log.report( "All ping attempts between h" +
1362 str( i ) +
1363 " and h" +
1364 str( i +
1365 10 ) +
1366 "have failed" )
1367 i = 19
1368 PingResult = main.FALSE
1369 elif ping == main.TRUE:
1370 main.log.info( "Ping test between h" +
1371 str( i ) +
1372 " and h" +
1373 str( i +
1374 10 ) +
1375 "passed!" )
1376 i += 1
1377 PingResult = main.TRUE
1378 else:
1379 main.log.info( "Unknown error" )
1380 PingResult = main.ERROR
1381
1382 if PingResult == main.FALSE:
1383 main.log.report(
1384 "Point intents have not ben installed correctly. Cleaning up" )
1385 # main.cleanup()
1386 # main.exit()
1387 if PingResult == main.TRUE:
1388 main.log.report( "Point Intents have been installed correctly" )
1389
1390 case9Result = PingResult
1391 utilities.assert_equals(
1392 expect=main.TRUE,
1393 actual=case9Result,
1394 onpass="Point intents addition and Pingall Test successful",
1395 onfail="Point intents addition and Pingall Test NOT successful" )