blob: c79143bda82d170726611ab4b1c44b4bfe46dc42 [file] [log] [blame]
shahshreya74cca802015-02-26 12:24:01 -08001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6# import sys
7# import os
8# import re
9import json
10
11time.sleep( 1 )
12
13
14class ProdFunc:
15
16 def __init__( self ):
17 self.default = ''
18
19 def CASE1( self, main ):
20 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
83 main.step( "Starting Mininet CLI..." )
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, 29 ):
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 < 18:
554 main.Mininet1.assignSwController(
555 sw=str( i ),
556 ip1=ONOS1Ip,
557 port1=ONOS1Port )
558 elif i >= 18 and i < 28:
559 main.Mininet1.assignSwController(
560 sw=str( i ),
561 ip1=ONOS1Ip,
562 port1=ONOS1Port )
563 else:
564 main.Mininet1.assignSwController(
565 sw=str( i ),
566 ip1=ONOS1Ip,
567 port1=ONOS1Port )
568 SwitchMastership = main.TRUE
569 for i in range( 1, 29 ):
570 if i == 1:
571 response = main.Mininet1.getSwController( "s" + str( i ) )
572 print( "Response is " + str( response ) )
573 if re.search( "tcp:" + ONOS1Ip, response ):
574 SwitchMastership = SwitchMastership and main.TRUE
575 else:
576 SwitchMastership = main.FALSE
577 elif i >= 2 and i < 5:
578 response = main.Mininet1.getSwController( "s" + str( i ) )
579 print( "Response is " + str( response ) )
580 if re.search( "tcp:" + ONOS1Ip, response ):
581 SwitchMastership = SwitchMastership and main.TRUE
582 else:
583 SwitchMastership = main.FALSE
584 elif i >= 5 and i < 8:
585 response = main.Mininet1.getSwController( "s" + str( i ) )
586 print( "Response is " + str( response ) )
587 if re.search( "tcp:" + ONOS1Ip, response ):
588 SwitchMastership = SwitchMastership and main.TRUE
589 else:
590 SwitchMastership = main.FALSE
591 elif i >= 8 and i < 18:
592 response = main.Mininet1.getSwController( "s" + str( i ) )
593 print( "Response is " + str( response ) )
594 if re.search( "tcp:" + ONOS1Ip, response ):
595 SwitchMastership = SwitchMastership and main.TRUE
596 else:
597 SwitchMastership = main.FALSE
598 elif i >= 18 and i < 28:
599 response = main.Mininet1.getSwController( "s" + str( i ) )
600 print( "Response is " + str( response ) )
601 if re.search( "tcp:" + ONOS1Ip, response ):
602 SwitchMastership = SwitchMastership and main.TRUE
603 else:
604 SwitchMastership = main.FALSE
605 else:
606 response = main.Mininet1.getSwController( "s" + str( i ) )
607 print( "Response is" + str( response ) )
608 if re.search( "tcp:" + ONOS1Ip, response ):
609 SwitchMastership = SwitchMastership and main.TRUE
610 else:
611 SwitchMastership = main.FALSE
612
613 if SwitchMastership == main.TRUE:
614 main.log.report( "Controller assignmnet successful" )
615 else:
616 main.log.report( "Controller assignmnet failed" )
617 utilities.assert_equals(
618 expect=main.TRUE,
619 actual=SwitchMastership,
620 onpass="MasterControllers assigned correctly" )
621 """
622 for i in range ( 1,29 ):
623 main.Mininet1.assignSwController( sw=str( i ),count=5,
624 ip1=ONOS1Ip,port1=ONOS1Port,
625 ip2=ONOS2Ip,port2=ONOS2Port,
626 ip3=ONOS3Ip,port3=ONOS3Port,
627 ip4=ONOS4Ip,port4=ONOS4Port,
628 ip5=ONOS5Ip,port5=ONOS5Port )
629 """
630 # REACTIVE FWD test
631
632 main.step( "Get list of hosts from Mininet" )
633 hostList = main.Mininet1.getHosts()
634 main.log.info( hostList )
635
636 main.step( "Get host list in ONOS format" )
637 hostOnosList = main.ONOS2.getHostsId( hostList )
638 main.log.info( hostOnosList )
639 # time.sleep( 5 )
640
641 main.step( "Pingall" )
642 pingResult = main.FALSE
643 time1 = time.time()
644 pingResult = main.Mininet1.pingall()
645 time2 = time.time()
646 print "Time for pingall: %2f seconds" % ( time2 - time1 )
647
648 # Start onos cli again because u might have dropped out of
649 # onos prompt to the shell prompt
650 # if there was no activity
651 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
652
653 case4Result = SwitchMastership and pingResult
654 if pingResult == main.TRUE:
655 main.log.report( "Pingall Test in reactive mode to" +
656 " discover the hosts successful" )
657 else:
658 main.log.report( "Pingall Test in reactive mode to" +
659 " discover the hosts failed" )
660
661 utilities.assert_equals(
662 expect=main.TRUE,
663 actual=case4Result,
664 onpass="Controller assignment and Pingall Test successful",
665 onfail="Controller assignment and Pingall Test NOT successful" )
666
667 def CASE10( self ):
668 main.log.report(
669 "This testcase uninstalls the reactive forwarding app" )
670 main.log.report( "__________________________________" )
671 main.case( "Uninstalling reactive forwarding app" )
672 main.step( "Uninstalling reactive forwarding app" )
673 # Unistall onos-app-fwd app to disable reactive forwarding
674 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
675 main.log.info( "onos-app-fwd uninstalled" )
676
677 # After reactive forwarding is disabled, the reactive flows on
678 # switches timeout in 10-15s
679 # So sleep for 15s
680 time.sleep( 15 )
681
682 flows = main.ONOS2.flows()
683 #main.log.info( flows )
684
685 case10Result = appUninstallResult
686 utilities.assert_equals(
687 expect=main.TRUE,
688 actual=case10Result,
689 onpass="Reactive forwarding app uninstallation successful",
690 onfail="Reactive forwarding app uninstallation failed" )
691
692 def CASE6( self ):
693 main.log.report( "This testcase is testing the addition of" +
694 " host intents and then does pingall" )
695 main.log.report( "__________________________________" )
696 main.case( "Obtaining host id's" )
697 main.step( "Get hosts" )
698 hosts = main.ONOS2.hosts()
699 main.log.info( hosts )
700
701 main.step( "Get all devices id" )
702 devicesIdList = main.ONOS2.getAllDevicesId()
703 main.log.info( devicesIdList )
704
705 # ONOS displays the hosts in hex format unlike mininet which does
706 # in decimal format
707 # So take care while adding intents
708 """
709 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
710 ONOS hosts h8 and h12" )
711 hthIntentResult = main.ONOS2.addHostIntent(
712 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
713 hthIntentResult = main.ONOS2.addHostIntent(
714 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
715 hthIntentResult = main.ONOS2.addHostIntent(
716 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
717 hthIntentResult = main.ONOS2.addHostIntent(
718 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
719 hthIntentResult = main.ONOS2.addHostIntent(
720 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
721 hthIntentResult = main.ONOS2.addHostIntent(
722 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
723 hthIntentResult = main.ONOS2.addHostIntent(
724 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
725 hthIntentResult = main.ONOS2.addHostIntent(
726 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
727 hthIntentResult = main.ONOS2.addHostIntent(
728 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
729 hthIntentResult = main.ONOS2.addHostIntent(
730 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
731 print "______________________________________________________"
732 """
733 for i in range( 8, 18 ):
734 main.log.info(
735 "Adding host intent between h" + str( i ) +
736 " and h" + str( i + 10 ) )
737 host1 = "00:00:00:00:00:" + \
738 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
739 host2 = "00:00:00:00:00:" + \
740 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
741 # NOTE: get host can return None
742 # TODO: handle this
743 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
744 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
745 main.ONOS2.addHostIntent( host1Id, host2Id )
746 hIntents = main.ONOS2.intents( jsonFormat=False )
747 main.log.info( "intents:" + hIntents )
748
749 time.sleep( 10 )
750 hIntents = main.ONOS2.intents( jsonFormat=False )
751 main.log.info( "intents:" + hIntents )
752 main.ONOS2.flows()
753
754 count = 1
755 i = 8
756 PingResult = main.TRUE
757 # while i<10:
758 while i < 18:
759 main.log.info(
760 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
761 ping = main.Mininet1.pingHost(
762 src="h" + str( i ), target="h" + str( i + 10 ) )
763 if ping == main.FALSE and count < 5:
764 count += 1
765 # i = 8
766 PingResult = main.FALSE
767 main.log.report( "Ping between h" +
768 str( i ) +
769 " and h" +
770 str( i +
771 10 ) +
772 " failed. Making attempt number " +
773 str( count ) +
774 " in 2 seconds" )
775 time.sleep( 2 )
776 elif ping == main.FALSE:
777 main.log.report( "All ping attempts between h" +
778 str( i ) +
779 " and h" +
780 str( i +
781 10 ) +
782 "have failed" )
783 i = 19
784 PingResult = main.FALSE
785 elif ping == main.TRUE:
786 main.log.info( "Ping test between h" +
787 str( i ) +
788 " and h" +
789 str( i +
790 10 ) +
791 "passed!" )
792 i += 1
793 PingResult = main.TRUE
794 else:
795 main.log.info( "Unknown error" )
796 PingResult = main.ERROR
797 if PingResult == main.FALSE:
798 main.log.report(
799 "Ping all test after Host intent addition failed.Cleaning up" )
800 # main.cleanup()
801 # main.exit()
802 if PingResult == main.TRUE:
803 main.log.report(
804 "Ping all test after Host intent addition successful" )
805
806 case6Result = PingResult
807 utilities.assert_equals(
808 expect=main.TRUE,
809 actual=case6Result,
810 onpass="Pingall Test after Host intents addition successful",
811 onfail="Pingall Test after Host intents addition failed" )
812
813 def CASE5( self, main ):
814 import json
815 # assumes that sts is already in you PYTHONPATH
816 from sts.topology.teston_topology import TestONTopology
817 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
818 main.log.report( "This testcase is testing if all ONOS nodes" +
819 " are in topology sync with mininet" )
820 main.log.report( "__________________________________" )
821 main.case( "Comparing Mininet topology with the topology of ONOS" )
822 main.step( "Start continuous pings" )
823 main.Mininet2.pingLong(
824 src=main.params[ 'PING' ][ 'source1' ],
825 target=main.params[ 'PING' ][ 'target1' ],
826 pingTime=500 )
827 main.Mininet2.pingLong(
828 src=main.params[ 'PING' ][ 'source2' ],
829 target=main.params[ 'PING' ][ 'target2' ],
830 pingTime=500 )
831 main.Mininet2.pingLong(
832 src=main.params[ 'PING' ][ 'source3' ],
833 target=main.params[ 'PING' ][ 'target3' ],
834 pingTime=500 )
835 main.Mininet2.pingLong(
836 src=main.params[ 'PING' ][ 'source4' ],
837 target=main.params[ 'PING' ][ 'target4' ],
838 pingTime=500 )
839 main.Mininet2.pingLong(
840 src=main.params[ 'PING' ][ 'source5' ],
841 target=main.params[ 'PING' ][ 'target5' ],
842 pingTime=500 )
843 main.Mininet2.pingLong(
844 src=main.params[ 'PING' ][ 'source6' ],
845 target=main.params[ 'PING' ][ 'target6' ],
846 pingTime=500 )
847 main.Mininet2.pingLong(
848 src=main.params[ 'PING' ][ 'source7' ],
849 target=main.params[ 'PING' ][ 'target7' ],
850 pingTime=500 )
851 main.Mininet2.pingLong(
852 src=main.params[ 'PING' ][ 'source8' ],
853 target=main.params[ 'PING' ][ 'target8' ],
854 pingTime=500 )
855 main.Mininet2.pingLong(
856 src=main.params[ 'PING' ][ 'source9' ],
857 target=main.params[ 'PING' ][ 'target9' ],
858 pingTime=500 )
859 main.Mininet2.pingLong(
860 src=main.params[ 'PING' ][ 'source10' ],
861 target=main.params[ 'PING' ][ 'target10' ],
862 pingTime=500 )
863
864 main.step( "Create TestONTopology object" )
865 global ctrls
866 ctrls = []
867 count = 1
868 while True:
869 temp = ()
870 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
871 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
872 temp = temp + ( "ONOS" + str( count ), )
873 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
874 temp = temp + \
875 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
876 ctrls.append( temp )
877 count = count + 1
878 else:
879 break
880 global MNTopo
881 Topo = TestONTopology(
882 main.Mininet1,
883 ctrls ) # can also add Intent API info for intent operations
884 MNTopo = Topo
885
886 TopologyCheck = main.TRUE
887 main.step( "Compare ONOS Topology to MN Topology" )
888 devicesJson = main.ONOS2.devices()
889 linksJson = main.ONOS2.links()
890 # portsJson = main.ONOS2.ports()
891
892 result1 = main.Mininet1.compareSwitches(
893 MNTopo,
894 json.loads( devicesJson ) )
895 result2 = main.Mininet1.compareLinks(
896 MNTopo,
897 json.loads( linksJson ) )
898 # result3 = main.Mininet1.comparePorts(
899 # MNTopo, json.loads( portsJson ) )
900
901 # result = result1 and result2 and result3
902 result = result1 and result2
903
904 print "***********************"
905 if result == main.TRUE:
906 main.log.report( "ONOS" + " Topology matches MN Topology" )
907 else:
908 main.log.report( "ONOS" + " Topology does not match MN Topology" )
909
910 utilities.assert_equals(
911 expect=main.TRUE,
912 actual=result,
913 onpass="ONOS" +
914 " Topology matches MN Topology",
915 onfail="ONOS" +
916 " Topology does not match MN Topology" )
917
918 TopologyCheck = TopologyCheck and result
919 utilities.assert_equals(
920 expect=main.TRUE,
921 actual=TopologyCheck,
922 onpass="Topology checks passed",
923 onfail="Topology checks failed" )
924
925 def CASE7( self, main ):
926 from sts.topology.teston_topology import TestONTopology
927
928 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
929
930 main.log.report( "This testscase is killing a link to ensure that" +
931 " link discovery is consistent" )
932 main.log.report( "__________________________________" )
933 main.log.report( "Killing a link to ensure that link discovery" +
934 " is consistent" )
935 main.case( "Killing a link to Ensure that Link Discovery" +
936 "is Working Properly" )
937 """
938 main.step( "Start continuous pings" )
939
940 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
941 target=main.params[ 'PING' ][ 'target1' ],
942 pingTime=500 )
943 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
944 target=main.params[ 'PING' ][ 'target2' ],
945 pingTime=500 )
946 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
947 target=main.params[ 'PING' ][ 'target3' ],
948 pingTime=500 )
949 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
950 target=main.params[ 'PING' ][ 'target4' ],
951 pingTime=500 )
952 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
953 target=main.params[ 'PING' ][ 'target5' ],
954 pingTime=500 )
955 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
956 target=main.params[ 'PING' ][ 'target6' ],
957 pingTime=500 )
958 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
959 target=main.params[ 'PING' ][ 'target7' ],
960 pingTime=500 )
961 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
962 target=main.params[ 'PING' ][ 'target8' ],
963 pingTime=500 )
964 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
965 target=main.params[ 'PING' ][ 'target9' ],
966 pingTime=500 )
967 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
968 target=main.params[ 'PING' ][ 'target10' ],
969 pingTime=500 )
970 """
971 main.step( "Determine the current number of switches and links" )
972 topologyOutput = main.ONOS2.topology()
973 topologyResult = main.ONOS1.getTopology( topologyOutput )
974 activeSwitches = topologyResult[ 'devices' ]
975 links = topologyResult[ 'links' ]
976 print "activeSwitches = ", type( activeSwitches )
977 print "links = ", type( links )
978 main.log.info(
979 "Currently there are %s switches and %s links" %
980 ( str( activeSwitches ), str( links ) ) )
981
982 main.step( "Kill Link between s3 and s28" )
983 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
984 time.sleep( linkSleep )
985 topologyOutput = main.ONOS2.topology()
986 LinkDown = main.ONOS1.checkStatus(
987 topologyOutput, activeSwitches, str(
988 int( links ) - 2 ) )
989 if LinkDown == main.TRUE:
990 main.log.report( "Link Down discovered properly" )
991 utilities.assert_equals(
992 expect=main.TRUE,
993 actual=LinkDown,
994 onpass="Link Down discovered properly",
995 onfail="Link down was not discovered in " +
996 str( linkSleep ) +
997 " seconds" )
998
999 # Check ping result here..add code for it
1000
1001 main.step( "Bring link between s3 and s28 back up" )
1002 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1003 time.sleep( linkSleep )
1004 topologyOutput = main.ONOS2.topology()
1005 LinkUp = main.ONOS1.checkStatus(
1006 topologyOutput,
1007 activeSwitches,
1008 str( links ) )
1009 if LinkUp == main.TRUE:
1010 main.log.report( "Link up discovered properly" )
1011 utilities.assert_equals(
1012 expect=main.TRUE,
1013 actual=LinkUp,
1014 onpass="Link up discovered properly",
1015 onfail="Link up was not discovered in " +
1016 str( linkSleep ) +
1017 " seconds" )
1018
1019 # NOTE Check ping result here..add code for it
1020
1021 main.step( "Compare ONOS Topology to MN Topology" )
1022 Topo = TestONTopology(
1023 main.Mininet1,
1024 ctrls ) # can also add Intent API info for intent operations
1025 MNTopo = Topo
1026 TopologyCheck = main.TRUE
1027
1028 devicesJson = main.ONOS2.devices()
1029 linksJson = main.ONOS2.links()
1030 portsJson = main.ONOS2.ports()
1031
1032 result1 = main.Mininet1.compareSwitches(
1033 MNTopo,
1034 json.loads( devicesJson ) )
1035 result2 = main.Mininet1.compareLinks(
1036 MNTopo,
1037 json.loads( linksJson ) )
1038 # result3 = main.Mininet1.comparePorts(
1039 # MNTopo, json.loads( portsJson ) )
1040
1041 # result = result1 and result2 and result3
1042 result = result1 and result2
1043 print "***********************"
1044
1045 if result == main.TRUE:
1046 main.log.report( "ONOS" + " Topology matches MN Topology" )
1047 utilities.assert_equals(
1048 expect=main.TRUE,
1049 actual=result,
1050 onpass="ONOS" +
1051 " Topology matches MN Topology",
1052 onfail="ONOS" +
1053 " Topology does not match MN Topology" )
1054
1055 TopologyCheck = TopologyCheck and result
1056 utilities.assert_equals(
1057 expect=main.TRUE,
1058 actual=TopologyCheck,
1059 onpass="Topology checks passed",
1060 onfail="Topology checks failed" )
1061
1062 result = LinkDown and LinkUp and TopologyCheck
1063 utilities.assert_equals( expect=main.TRUE, actual=result,
1064 onpass="Link failure is discovered correctly",
1065 onfail="Link Discovery failed" )
1066
1067 def CASE8( self ):
1068 """
1069 Intent removal
1070 """
1071 import time
1072 main.log.report( "This testcase removes any previously added intents" +
1073 " before adding any new set of intents" )
1074 main.log.report( "__________________________________" )
1075 main.log.info( "intent removal" )
1076 main.case( "Removing installed intents" )
1077 main.step( "Obtain the intent id's" )
1078 intentResult = main.ONOS2.intents( jsonFormat=False )
1079 main.log.info( "intent_result = " + intentResult )
1080 intentLinewise = intentResult.split( "\n" )
1081 intentList = []
1082 for line in intentLinewise:
1083 if line.startswith( "id=" ):
1084 intentList.append( line )
1085
1086 intentids = []
1087 for line in intentList:
1088 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
1089 for id in intentids:
1090 print "id = ", id
1091
1092 main.step(
1093 "Iterate through the intentids list and remove each intent" )
1094 for id in intentids:
1095 main.ONOS2.removeIntent( intentId=id )
1096
1097 intentResult = main.ONOS2.intents( jsonFormat=False )
1098 main.log.info( "intent_result = " + intentResult )
1099
1100 case8Result = main.TRUE
1101 if case8Result == main.TRUE:
1102 main.log.report( "Intent removal successful" )
1103 else:
1104 main.log.report( "Intent removal failed" )
1105
1106 PingResult = main.TRUE
1107 if case8Result == main.TRUE:
1108 i = 8
1109 while i < 18:
1110 main.log.info(
1111 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1112 ping = main.Mininet1.pingHost(
1113 src="h" + str( i ), target="h" + str( i + 10 ) )
1114 if ping == main.TRUE:
1115 i = 19
1116 PingResult = PingResult and main.TRUE
1117 elif ping == main.FALSE:
1118 i += 1
1119 PingResult = PingResult and main.FALSE
1120 else:
1121 main.log.info( "Unknown error" )
1122 PingResult = main.ERROR
1123
1124 # Note: If the ping result failed, that means the intents have been
1125 # withdrawn correctly.
1126 if PingResult == main.TRUE:
1127 main.log.report( "Installed intents have not been withdrawn correctly" )
1128 # main.cleanup()
1129 # main.exit()
1130 if PingResult == main.FALSE:
1131 main.log.report( "Installed intents have been withdrawn correctly" )
1132
1133 case8Result = case8Result and PingResult
1134
1135 if case8Result == main.FALSE:
1136 main.log.report( "Intent removal successful" )
1137 else:
1138 main.log.report( "Intent removal failed" )
1139
1140 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1141 onpass="Intent removal test passed",
1142 onfail="Intent removal test failed" )
1143
1144 def CASE9( self ):
1145 main.log.report(
1146 "This testcase adds point intents and then does pingall" )
1147 main.log.report( "__________________________________" )
1148 main.log.info( "Adding point intents" )
1149 main.case(
1150 "Adding bidirectional point for mn hosts" +
1151 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1152 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
1153
1154 main.step( "Add point intents for mn hosts h8 and h18 or" +
1155 "ONOS hosts h8 and h12" )
1156 # main.step(var1)
1157 ptpIntentResult = main.ONOS2.addPointIntent(
1158 "of:0000000000003008/1",
1159 "of:0000000000006018/1" )
1160 if ptpIntentResult == main.TRUE:
1161 getIntentResult = main.ONOS2.intents()
1162 main.log.info( "Point to point intent install successful" )
1163 # main.log.info( getIntentResult )
1164
1165 ptpIntentResult = main.ONOS2.addPointIntent(
1166 "of:0000000000006018/1",
1167 "of:0000000000003008/1" )
1168 if ptpIntentResult == main.TRUE:
1169 getIntentResult = main.ONOS2.intents()
1170 main.log.info( "Point to point intent install successful" )
1171 # main.log.info( getIntentResult )
1172
1173 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1174 main.step(var2)
1175 ptpIntentResult = main.ONOS2.addPointIntent(
1176 "of:0000000000003009/1",
1177 "of:0000000000006019/1" )
1178 if ptpIntentResult == main.TRUE:
1179 getIntentResult = main.ONOS2.intents()
1180 main.log.info( "Point to point intent install successful" )
1181 # main.log.info( getIntentResult )
1182
1183 ptpIntentResult = main.ONOS2.addPointIntent(
1184 "of:0000000000006019/1",
1185 "of:0000000000003009/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 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1192 main.step(var3)
1193 ptpIntentResult = main.ONOS2.addPointIntent(
1194 "of:0000000000003010/1",
1195 "of:0000000000006020/1" )
1196 if ptpIntentResult == main.TRUE:
1197 getIntentResult = main.ONOS2.intents()
1198 main.log.info( "Point to point intent install successful" )
1199 # main.log.info( getIntentResult )
1200
1201 ptpIntentResult = main.ONOS2.addPointIntent(
1202 "of:0000000000006020/1",
1203 "of:0000000000003010/1" )
1204 if ptpIntentResult == main.TRUE:
1205 getIntentResult = main.ONOS2.intents()
1206 main.log.info( "Point to point intent install successful" )
1207 # main.log.info( getIntentResult )
1208
1209 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1210 " ONOS hosts hB and h15"
1211 main.case(var4)
1212 ptpIntentResult = main.ONOS2.addPointIntent(
1213 "of:0000000000003011/1",
1214 "of:0000000000006021/1" )
1215 if ptpIntentResult == main.TRUE:
1216 getIntentResult = main.ONOS2.intents()
1217 main.log.info( "Point to point intent install successful" )
1218 # main.log.info( getIntentResult )
1219
1220 ptpIntentResult = main.ONOS2.addPointIntent(
1221 "of:0000000000006021/1",
1222 "of:0000000000003011/1" )
1223 if ptpIntentResult == main.TRUE:
1224 getIntentResult = main.ONOS2.intents()
1225 main.log.info( "Point to point intent install successful" )
1226 # main.log.info( getIntentResult )
1227
1228 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1229 "ONOS hosts hC and h16"
1230 main.case(var5)
1231 ptpIntentResult = main.ONOS2.addPointIntent(
1232 "of:0000000000003012/1",
1233 "of:0000000000006022/1" )
1234 if ptpIntentResult == main.TRUE:
1235 getIntentResult = main.ONOS2.intents()
1236 main.log.info( "Point to point intent install successful" )
1237 # main.log.info( getIntentResult )
1238
1239 ptpIntentResult = main.ONOS2.addPointIntent(
1240 "of:0000000000006022/1",
1241 "of:0000000000003012/1" )
1242 if ptpIntentResult == main.TRUE:
1243 getIntentResult = main.ONOS2.intents()
1244 main.log.info( "Point to point intent install successful" )
1245 # main.log.info( getIntentResult )
1246
1247 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1248 " ONOS hosts hD and h17"
1249 main.case(var6)
1250 ptpIntentResult = main.ONOS2.addPointIntent(
1251 "of:0000000000003013/1",
1252 "of:0000000000006023/1" )
1253 if ptpIntentResult == main.TRUE:
1254 getIntentResult = main.ONOS2.intents()
1255 main.log.info( "Point to point intent install successful" )
1256 # main.log.info( getIntentResult )
1257
1258 ptpIntentResult = main.ONOS2.addPointIntent(
1259 "of:0000000000006023/1",
1260 "of:0000000000003013/1" )
1261 if ptpIntentResult == main.TRUE:
1262 getIntentResult = main.ONOS2.intents()
1263 main.log.info( "Point to point intent install successful" )
1264 # main.log.info( getIntentResult )
1265
1266 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1267 " ONOS hosts hE and h18"
1268 main.case(var7)
1269 ptpIntentResult = main.ONOS2.addPointIntent(
1270 "of:0000000000003014/1",
1271 "of:0000000000006024/1" )
1272 if ptpIntentResult == main.TRUE:
1273 getIntentResult = main.ONOS2.intents()
1274 main.log.info( "Point to point intent install successful" )
1275 # main.log.info( getIntentResult )
1276
1277 ptpIntentResult = main.ONOS2.addPointIntent(
1278 "of:0000000000006024/1",
1279 "of:0000000000003014/1" )
1280 if ptpIntentResult == main.TRUE:
1281 getIntentResult = main.ONOS2.intents()
1282 main.log.info( "Point to point intent install successful" )
1283 # main.log.info( getIntentResult )
1284
1285 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1286 " ONOS hosts hF and h19"
1287 main.case(var8)
1288 ptpIntentResult = main.ONOS2.addPointIntent(
1289 "of:0000000000003015/1",
1290 "of:0000000000006025/1" )
1291 if ptpIntentResult == main.TRUE:
1292 getIntentResult = main.ONOS2.intents()
1293 main.log.info( "Point to point intent install successful" )
1294 # main.log.info( getIntentResult )
1295
1296 ptpIntentResult = main.ONOS2.addPointIntent(
1297 "of:0000000000006025/1",
1298 "of:0000000000003015/1" )
1299 if ptpIntentResult == main.TRUE:
1300 getIntentResult = main.ONOS2.intents()
1301 main.log.info( "Point to point intent install successful" )
1302 # main.log.info( getIntentResult )
1303
1304 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1305 " ONOS hosts h10 and h1A"
1306 main.case(var9)
1307 ptpIntentResult = main.ONOS2.addPointIntent(
1308 "of:0000000000003016/1",
1309 "of:0000000000006026/1" )
1310 if ptpIntentResult == main.TRUE:
1311 getIntentResult = main.ONOS2.intents()
1312 main.log.info( "Point to point intent install successful" )
1313 # main.log.info( getIntentResult )
1314
1315 ptpIntentResult = main.ONOS2.addPointIntent(
1316 "of:0000000000006026/1",
1317 "of:0000000000003016/1" )
1318 if ptpIntentResult == main.TRUE:
1319 getIntentResult = main.ONOS2.intents()
1320 main.log.info( "Point to point intent install successful" )
1321 # main.log.info( getIntentResult )
1322
1323 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1324 " ONOS hosts h11 and h1B"
1325 main.case(var10)
1326 ptpIntentResult = main.ONOS2.addPointIntent(
1327 "of:0000000000003017/1",
1328 "of:0000000000006027/1" )
1329 if ptpIntentResult == main.TRUE:
1330 getIntentResult = main.ONOS2.intents()
1331 main.log.info( "Point to point intent install successful" )
1332 main.log.info( getIntentResult )
1333
1334 ptpIntentResult = main.ONOS2.addPointIntent(
1335 "of:0000000000006027/1",
1336 "of:0000000000003017/1" )
1337 if ptpIntentResult == main.TRUE:
1338 getIntentResult = main.ONOS2.intents()
1339 main.log.info( "Point to point intent install successful" )
1340 main.log.info( getIntentResult )
1341
1342 print(
1343 "___________________________________________________________" )
1344
1345 flowHandle = main.ONOS2.flows()
1346 #main.log.info( "flows :" + flowHandle )
1347
1348 count = 1
1349 i = 8
1350 PingResult = main.TRUE
1351 while i < 18:
1352 main.log.info(
1353 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1354 ping = main.Mininet1.pingHost(
1355 src="h" + str( i ), target="h" + str( i + 10 ) )
1356 if ping == main.FALSE and count < 5:
1357 count += 1
1358 # i = 8
1359 PingResult = main.FALSE
1360 main.log.report( "Ping between h" +
1361 str( i ) +
1362 " and h" +
1363 str( i +
1364 10 ) +
1365 " failed. Making attempt number " +
1366 str( count ) +
1367 " in 2 seconds" )
1368 time.sleep( 2 )
1369 elif ping == main.FALSE:
1370 main.log.report( "All ping attempts between h" +
1371 str( i ) +
1372 " and h" +
1373 str( i +
1374 10 ) +
1375 "have failed" )
1376 i = 19
1377 PingResult = main.FALSE
1378 elif ping == main.TRUE:
1379 main.log.info( "Ping test between h" +
1380 str( i ) +
1381 " and h" +
1382 str( i +
1383 10 ) +
1384 "passed!" )
1385 i += 1
1386 PingResult = main.TRUE
1387 else:
1388 main.log.info( "Unknown error" )
1389 PingResult = main.ERROR
1390
1391 if PingResult == main.FALSE:
1392 main.log.report(
1393 "Point intents have not ben installed correctly. Cleaning up" )
1394 # main.cleanup()
1395 # main.exit()
1396 if PingResult == main.TRUE:
1397 main.log.report( "Point Intents have been installed correctly" )
1398
1399 case9Result = PingResult
1400 utilities.assert_equals(
1401 expect=main.TRUE,
1402 actual=case9Result,
1403 onpass="Point intents addition and Pingall Test successful",
1404 onfail="Point intents addition and Pingall Test NOT successful" )
1405
1406
1407 def CASE11( self ):
1408 # NOTE: This testcase require reactive forwarding mode enabled
1409 # NOTE: in the beginning and then uninstall it before adding
1410 # NOTE: point intents. Again the app is installed so that
1411 # NOTE: testcase 10 can be ran successively
1412 import time
1413 main.log.report(
1414 "This testcase moves a host from one switch to another to add" +
1415 "point intents between them and then perform ping" )
1416 main.log.report( "__________________________________" )
1417 main.log.info( "Moving host from one switch to another" )
1418 main.case( "Moving host from a device and attach it to another device" )
1419 main.step( "Moving host h9 from device s9 and attach it to s8" )
1420 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
1421
1422 time.sleep(15) #Time delay to have all the flows ready
1423 main.step( "Pingall" )
1424 pingResult = main.FALSE
1425 time1 = time.time()
1426 pingResult = main.Mininet1.pingall()
1427 time2 = time.time()
1428 print "Time for pingall: %2f seconds" % ( time2 - time1 )
1429
1430 hosts = main.ONOS2.hosts( jsonFormat = False )
1431 main.log.info( hosts )
1432
1433 main.case( "Uninstalling reactive forwarding app" )
1434 # Unistall onos-app-fwd app to disable reactive forwarding
1435 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
1436 main.log.info( "onos-app-fwd uninstalled" )
1437
1438 main.step( "Add point intents between hosts on the same device")
1439 ptpIntentResult = main.ONOS2.addPointIntent(
1440 "of:0000000000003008/1",
1441 "of:0000000000003008/3" )
1442 if ptpIntentResult == main.TRUE:
1443 getIntentResult = main.ONOS2.intents()
1444 main.log.info( "Point to point intent install successful" )
1445 # main.log.info( getIntentResult )
1446
1447 ptpIntentResult = main.ONOS2.addPointIntent(
1448 "of:0000000000003008/3",
1449 "of:0000000000003008/1" )
1450 if ptpIntentResult == main.TRUE:
1451 getIntentResult = main.ONOS2.intents()
1452 main.log.info( "Point to point intent install successful" )
1453 # main.log.info( getIntentResult )
1454
1455 main.case( "Ping hosts on the same devices" )
1456 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
1457
1458 main.case( "Installing reactive forwarding app" )
1459 # Install onos-app-fwd app to enable reactive forwarding
1460 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
1461 main.log.info( "onos-app-fwd installed" )
1462
1463
1464 if ping == main.FALSE:
1465 main.log.report(
1466 "Point intents for hosts on same devices haven't" +
1467 " been installed correctly. Cleaning up" )
1468 if ping == main.TRUE:
1469 main.log.report(
1470 "Point intents for hosts on same devices" +
1471 "installed correctly. Cleaning up" )
1472
1473 case11Result = ping and pingResult
1474 utilities.assert_equals(
1475 expect=main.TRUE,
1476 actual=case11Result,
1477 onpass= "Point intents for hosts on same devices" +
1478 "Ping Test successful",
1479 onfail= "Point intents for hosts on same devices" +
1480 "Ping Test NOT successful" )