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