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