blob: 7ab458b2631c835c001e2b2638181e575c52384e [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
shahshreyafac62b12015-01-20 16:16:13 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
shahshreyafac62b12015-01-20 16:16:13 -08006# import sys
7# import os
8# import re
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
shahshreyafac62b12015-01-20 16:16:13 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc:
shahshreyafac62b12015-01-20 16:16:13 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
shahshreyafac62b12015-01-20 16:16:13 -080019 def CASE1( self, main ):
shahshreya82ecd282015-02-05 16:48:03 -080020 import time
shahshreyafac62b12015-01-20 16:16:13 -080021 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
25 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
shahshreyafac62b12015-01-20 16:16:13 -080031 """
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
shahshreyafac62b12015-01-20 16:16:13 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080039
shahshreyafac62b12015-01-20 16:16:13 -080040 main.step( "Applying cell variable to environment" )
41 cellResult = main.ONOSbench.setCell( cellName )
42 verifyResult = main.ONOSbench.verifyCell()
43
shahshreyab512cd02015-01-27 17:01:47 -080044 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070045 main.ONOSbench.gitCheckout( "master" )
shahshreyafac62b12015-01-20 16:16:13 -080046 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080047 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyafac62b12015-01-20 16:16:13 -080048 main.ONOSbench.getVersion( report=True )
49
50 if gitPullResult == 1:
51 main.step( "Using mvn clean & install" )
52 main.ONOSbench.cleanInstall()
53 elif gitPullResult == 0:
54 main.log.report(
55 "Git Pull Failed, look into logs for detailed reason" )
shahshreya0e81ed92014-12-08 16:57:17 -080056 main.cleanup()
shahshreyafac62b12015-01-20 16:16:13 -080057 main.exit()
shahshreya4e13a062014-11-11 16:46:18 -080058
shahshreyafac62b12015-01-20 16:16:13 -080059 main.step( "Creating ONOS package" )
60 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080061
shahshreyaa47ebf42015-05-20 13:29:18 -070062 main.step( "Uninstalling ONOS package" )
63 onosInstallResult = main.ONOSbench.onosUninstall( )
64 if onosInstallResult == main.TRUE:
65 main.log.report( "Uninstalling ONOS package successful" )
66 else:
67 main.log.report( "Uninstalling ONOS package failed" )
68
shahshreyafac62b12015-01-20 16:16:13 -080069 main.step( "Installing ONOS package" )
70 onosInstallResult = main.ONOSbench.onosInstall()
71 if onosInstallResult == main.TRUE:
72 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080073 else:
shahshreyafac62b12015-01-20 16:16:13 -080074 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080075
shahshreyafac62b12015-01-20 16:16:13 -080076 onos1Isup = main.ONOSbench.isup()
77 if onos1Isup == main.TRUE:
78 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080079 else:
shahshreyafac62b12015-01-20 16:16:13 -080080 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080081
shahshreyafac62b12015-01-20 16:16:13 -080082 main.step( "Starting ONOS service" )
83 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080084
shahshreyafac62b12015-01-20 16:16:13 -080085 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya82ecd282015-02-05 16:48:03 -080086 main.step( "Starting Mininet CLI..." )
87
88 # Starting the mininet using the old way
89 main.step( "Starting Mininet ..." )
90 netIsUp = main.Mininet1.startNet()
91 if netIsUp:
92 main.log.info("Mininet CLI is up")
93
shahshreyafac62b12015-01-20 16:16:13 -080094 case1Result = ( packageResult and
95 cellResult and verifyResult
96 and onosInstallResult and
97 onos1Isup and startResult )
98 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -080099 onpass="Test startup successful",
100 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -0800101
102 def CASE2( self, main ):
103 """
shahshreya0e81ed92014-12-08 16:57:17 -0800104 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -0800105 """
106 # NOTE: You should probably run a topology check after this
107 import time
shahshreya0e81ed92014-12-08 16:57:17 -0800108
shahshreyafac62b12015-01-20 16:16:13 -0800109 main.case( "Switch down discovery" )
110 main.log.report( "This testcase is testing a switch down discovery" )
111 main.log.report( "__________________________________" )
112
113 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800114
115 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800116 main.log.report( description )
117 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800118
shahshreyafac62b12015-01-20 16:16:13 -0800119 # TODO: Make this switch parameterizable
120 main.step( "Kill s28 " )
121 main.log.report( "Deleting s28" )
122 # FIXME: use new dynamic topo functions
123 main.Mininet1.delSwitch( "s28" )
124 main.log.info(
125 "Waiting " +
126 str( switchSleep ) +
127 " seconds for switch down to be discovered" )
128 time.sleep( switchSleep )
129 # Peek at the deleted switch
130 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800131 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800132 if device[ u'available' ] == 'False':
133 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800134 else:
shahshreyafac62b12015-01-20 16:16:13 -0800135 case2Result = main.TRUE
136 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800137 onpass="Switch down discovery successful",
138 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800139
shahshreyadcb08e82015-02-25 10:16:42 -0800140 def CASE101( self, main ):
shahshreyafac62b12015-01-20 16:16:13 -0800141 """
shahshreya4e13a062014-11-11 16:46:18 -0800142 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800143 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800144 onos-uninstall
145
146 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800147
shahshreyafac62b12015-01-20 16:16:13 -0800148 """
149 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800150
shahshreyafac62b12015-01-20 16:16:13 -0800151 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800152
shahshreyafac62b12015-01-20 16:16:13 -0800153 main.step( "Testing ONOS kill function" )
154 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800155
shahshreyafac62b12015-01-20 16:16:13 -0800156 main.step( "Stopping ONOS service" )
157 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800158
shahshreyafac62b12015-01-20 16:16:13 -0800159 main.step( "Uninstalling ONOS service" )
160 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800161
shahshreyafac62b12015-01-20 16:16:13 -0800162 case11Result = killResult and stopResult and uninstallResult
163 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800164 onpass="Cleanup successful",
165 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800166
167 def CASE3( self, main ):
168 """
shahshreya4e13a062014-11-11 16:46:18 -0800169 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800170 """
171 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800172
shahshreyafac62b12015-01-20 16:16:13 -0800173 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800174
shahshreyafac62b12015-01-20 16:16:13 -0800175 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800176 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800177 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
178 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800179
shahshreyafac62b12015-01-20 16:16:13 -0800180 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800181 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800182 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
183 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800184
shahshreyafac62b12015-01-20 16:16:13 -0800185 def CASE20( self ):
186 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800187 Exit from mininet cli
188 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800189 """
190 cellName = main.params[ 'ENV' ][ 'cellName' ]
191 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800192
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800193 main.log.report( "This testcase exits the mininet cli and reinstalls" +
194 "ONOS to switch over to Packet Optical topology" )
shahshreyafac62b12015-01-20 16:16:13 -0800195 main.log.report( "_____________________________________________" )
196 main.case( "Disconnecting mininet and restarting ONOS" )
197 main.step( "Disconnecting mininet and restarting ONOS" )
198 mininetDisconnect = main.Mininet1.disconnect()
shahshreya3140b1a2015-04-28 14:22:15 -0700199 print "mininetDisconnect = ", mininetDisconnect
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800200
shahshreyafac62b12015-01-20 16:16:13 -0800201 main.step( "Removing raft logs before a clen installation of ONOS" )
202 main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -0800203
shahshreyafac62b12015-01-20 16:16:13 -0800204 main.step( "Applying cell variable to environment" )
205 cellResult = main.ONOSbench.setCell( cellName )
206 verifyResult = main.ONOSbench.verifyCell()
207
208 onosInstallResult = main.ONOSbench.onosInstall()
209 if onosInstallResult == main.TRUE:
210 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800211 else:
shahshreyafac62b12015-01-20 16:16:13 -0800212 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800213
shahshreyafac62b12015-01-20 16:16:13 -0800214 onos1Isup = main.ONOSbench.isup()
215 if onos1Isup == main.TRUE:
216 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800217 else:
shahshreyafac62b12015-01-20 16:16:13 -0800218 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800219
shahshreyafac62b12015-01-20 16:16:13 -0800220 main.step( "Starting ONOS service" )
221 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyae6c7cf42014-11-26 16:39:01 -0800222
shahshreyafac62b12015-01-20 16:16:13 -0800223 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
224 case20Result = mininetDisconnect and cellResult and verifyResult \
225 and onosInstallResult and onos1Isup and \
226 startResult
227 utilities.assert_equals(
228 expect=main.TRUE,
229 actual=case20Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800230 onpass= "Exiting functionality mininet topology and reinstalling" +
231 " ONOS successful",
232 onfail= "Exiting functionality mininet topology and reinstalling" +
233 " ONOS failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800234
235 def CASE21( self, main ):
236 """
237 On ONOS bench, run this command:
shahshreya1937ec12015-04-03 15:35:48 -0700238 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
239 which spawns packet optical topology and copies the links
shahshreyafac62b12015-01-20 16:16:13 -0800240 json file to the onos instance.
241 Note that in case of Packet Optical, the links are not learnt
242 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800243 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800244 """
245 main.log.report(
246 "This testcase starts the packet layer topology and REST" )
247 main.log.report( "_____________________________________________" )
248 main.case( "Starting LINC-OE and other components" )
249 main.step( "Starting LINC-OE and other components" )
shahshreyad524a942015-04-21 09:55:16 -0700250 main.log.info( "Activate optical app" )
251 appInstallResult = main.ONOS2.activateApp( "org.onosproject.optical" )
252 appCheck = main.ONOS2.appToIDCheck()
253 if appCheck != main.TRUE:
254 main.log.warn( main.ONOS2.apps() )
255 main.log.warn( main.ONOS2.appIDs() )
256
shahshreya215c48f2015-04-06 15:55:55 -0700257 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreyae6c7cf42014-11-26 16:39:01 -0800258
shahshreya1937ec12015-04-03 15:35:48 -0700259 case21Result = opticalMnScript and appInstallResult
shahshreyafac62b12015-01-20 16:16:13 -0800260 utilities.assert_equals(
261 expect=main.TRUE,
262 actual=case21Result,
263 onpass="Packet optical topology spawned successsfully",
264 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800265
shahshreyafac62b12015-01-20 16:16:13 -0800266 def CASE22( self, main ):
267 """
shahshreya1937ec12015-04-03 15:35:48 -0700268 Curretly we use, 10 optical switches(ROADM's) and
269 6 packet layer mininet switches each with one host.
270 Therefore, the roadmCount variable = 10,
271 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -0700272 links=46.
shahshreya1937ec12015-04-03 15:35:48 -0700273 All this is hardcoded in the testcase. If the topology changes,
shahshreyafac62b12015-01-20 16:16:13 -0800274 these hardcoded values need to be changed
275 """
276 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800277 "This testcase compares the optical+packet topology against what" +
278 " is expected" )
shahshreyafac62b12015-01-20 16:16:13 -0800279 main.case( "Topology comparision" )
280 main.step( "Topology comparision" )
281 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
282 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800283
shahshreyafac62b12015-01-20 16:16:13 -0800284 print "devices_result = ", devicesResult
285 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800286 roadmCount = 0
287 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800288 for line in devicesLinewise:
289 components = line.split( "," )
290 availability = components[ 1 ].split( "=" )[ 1 ]
291 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800292 if availability == 'true' and type == 'ROADM':
293 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800294 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800295 packetLayerSWCount += 1
shahshreya1937ec12015-04-03 15:35:48 -0700296 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800297 print "Number of Optical Switches = %d and is" % roadmCount +\
298 " correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800299 main.log.info(
300 "Number of Optical Switches = " +
301 str( roadmCount ) +
302 " and is correctly detected" )
303 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800304 else:
shahshreyafac62b12015-01-20 16:16:13 -0800305 print "Number of Optical Switches = %d and is wrong" % roadmCount
306 main.log.info(
307 "Number of Optical Switches = " +
308 str( roadmCount ) +
309 " and is wrong" )
310 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800311
shahshreya1937ec12015-04-03 15:35:48 -0700312 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800313 print "Number of Packet layer or mininet Switches = %d "\
314 % packetLayerSWCount + "and is correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800315 main.log.info(
316 "Number of Packet layer or mininet Switches = " +
317 str( packetLayerSWCount ) +
318 " and is correctly detected" )
319 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800320 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800321 print "Number of Packet layer or mininet Switches = %d and"\
322 % packetLayerSWCount + " is wrong"
shahshreyafac62b12015-01-20 16:16:13 -0800323 main.log.info(
324 "Number of Packet layer or mininet Switches = " +
325 str( packetLayerSWCount ) +
326 " and is wrong" )
327 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800328 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800329
330 linksResult = main.ONOS3.links( jsonFormat=False )
331 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800332 print "_________________________________"
shahshreya1937ec12015-04-03 15:35:48 -0700333 linkActiveCount = linksResult.count("state=ACTIVE")
334 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -0700335 if linkActiveCount == 46:
shahshreya1937ec12015-04-03 15:35:48 -0700336 linkActiveResult = main.TRUE
337 main.log.info(
338 "Number of links in ACTIVE state are correct")
339 else:
340 linkActiveResult = main.FALSE
341 main.log.info(
342 "Number of links in ACTIVE state are wrong")
shahshreyafac62b12015-01-20 16:16:13 -0800343
344 # NOTE:Since only point intents are added, there is no
345 # requirement to discover the hosts
346 # Therfore, the below portion of the code is commented.
347 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800348 #Discover hosts using pingall
shahshreyafac62b12015-01-20 16:16:13 -0800349 pingallResult = main.LincOE2.pingall()
350
351 hostsResult = main.ONOS3.hosts( jsonFormat=False )
352 main.log.info( "hosts_result = "+hostsResult )
353 main.log.info( "_________________________________" )
354 hostsLinewise = hostsResult.split( "\n" )
355 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800356 hostCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800357 for line in hostsLinewise:
358 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800359 hostCount +=1
360 if hostCount ==2:
361 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800362 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
363 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800364 hostDiscovery = main.TRUE
365 else:
366 print "Number of hosts = %d and is wrong" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800367 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
368 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800369 hostDiscovery = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800370 """
shahshreya1937ec12015-04-03 15:35:48 -0700371 case22Result = opticalSWResult and packetSWResult and \
372 linkActiveResult
shahshreyafac62b12015-01-20 16:16:13 -0800373 utilities.assert_equals(
374 expect=main.TRUE,
375 actual=case22Result,
376 onpass="Packet optical topology discovery successful",
377 onfail="Packet optical topology discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800378
shahshreyafac62b12015-01-20 16:16:13 -0800379 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800380 import time
shahshreyafac62b12015-01-20 16:16:13 -0800381 """
382 Add bidirectional point intents between 2 packet layer( mininet )
383 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800384 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800385 """
386 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800387 "This testcase adds bidirectional point intents between 2 " +
388 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreyafac62b12015-01-20 16:16:13 -0800389 main.case( "Topology comparision" )
390 main.step( "Adding point intents" )
391 ptpIntentResult = main.ONOS3.addPointIntent(
392 "of:0000ffffffff0001/1",
shahshreya1937ec12015-04-03 15:35:48 -0700393 "of:0000ffffffff0005/1" )
shahshreyafac62b12015-01-20 16:16:13 -0800394 if ptpIntentResult == main.TRUE:
395 main.ONOS3.intents( jsonFormat=False )
396 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800397
shahshreyafac62b12015-01-20 16:16:13 -0800398 ptpIntentResult = main.ONOS3.addPointIntent(
shahshreya1937ec12015-04-03 15:35:48 -0700399 "of:0000ffffffff0005/1",
shahshreyafac62b12015-01-20 16:16:13 -0800400 "of:0000ffffffff0001/1" )
401 if ptpIntentResult == main.TRUE:
402 main.ONOS3.intents( jsonFormat=False )
403 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800404
shahshreya1937ec12015-04-03 15:35:48 -0700405 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800406 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800407 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800408
409 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya1937ec12015-04-03 15:35:48 -0700410 time.sleep( 60 )
shahshreyafac62b12015-01-20 16:16:13 -0800411 intentHandle = main.ONOS3.intents( jsonFormat=False )
412 main.log.info( "intents :" + intentHandle )
413
414 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800415 count = 1
shahshreya1937ec12015-04-03 15:35:48 -0700416 main.log.info( "\n\nh1 is Pinging h5" )
417 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreyafac62b12015-01-20 16:16:13 -0800418 # ping = main.LincOE2.pinghost()
419 if ping == main.FALSE and count < 5:
420 count += 1
421 PingResult = main.FALSE
422 main.log.info(
shahshreya1937ec12015-04-03 15:35:48 -0700423 "Ping between h1 and h5 failed. Making attempt number " +
shahshreyafac62b12015-01-20 16:16:13 -0800424 str( count ) +
425 " in 2 seconds" )
426 time.sleep( 2 )
427 elif ping == main.FALSE:
shahshreya1937ec12015-04-03 15:35:48 -0700428 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800429 PingResult = main.FALSE
430 elif ping == main.TRUE:
shahshreya1937ec12015-04-03 15:35:48 -0700431 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreyafac62b12015-01-20 16:16:13 -0800432 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800433 else:
shahshreyafac62b12015-01-20 16:16:13 -0800434 main.log.info( "Unknown error" )
435 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800436
shahshreyafac62b12015-01-20 16:16:13 -0800437 if PingResult == main.FALSE:
438 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800439 "Point intents for packet optical have not ben installed" +
440 " correctly. Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -0800441 if PingResult == main.TRUE:
442 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800443 "Point Intents for packet optical have been " +
444 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800445
shahshreyafac62b12015-01-20 16:16:13 -0800446 case23Result = PingResult
447 utilities.assert_equals(
448 expect=main.TRUE,
449 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800450 onpass= "Point intents addition for packet optical and" +
451 "Pingall Test successful",
452 onfail= "Point intents addition for packet optical and" +
453 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800454
shahshreyafac62b12015-01-20 16:16:13 -0800455 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800456 import time
457 import json
shahshreyafac62b12015-01-20 16:16:13 -0800458 """
shahshreya1937ec12015-04-03 15:35:48 -0700459 LINC uses its own switch IDs. You can use the following
460 command on the LINC console to find the mapping between
461 DPIDs and LINC IDs.
462 rp(application:get_all_key(linc)).
463
shahshreyafac62b12015-01-20 16:16:13 -0800464 Test Rerouting of Packet Optical by bringing a port down
shahshreya1937ec12015-04-03 15:35:48 -0700465 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
466 so that link
467 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreyafac62b12015-01-20 16:16:13 -0800468 and do a ping test. If rerouting is successful,
469 ping should pass. also check the flows
470 """
471 main.log.report(
472 "This testcase tests rerouting and pings mininet hosts" )
473 main.case( "Test rerouting and pings mininet hosts" )
shahshreya1937ec12015-04-03 15:35:48 -0700474 main.step( "Attach to the Linc-OE session" )
475 attachConsole = main.LincOE1.attachLincOESession()
476 print "attachConsole = ", attachConsole
477
shahshreyafac62b12015-01-20 16:16:13 -0800478 main.step( "Bring a port down and verify the link state" )
shahshreya1937ec12015-04-03 15:35:48 -0700479 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreyafac62b12015-01-20 16:16:13 -0800480 linksNonjson = main.ONOS3.links( jsonFormat=False )
481 main.log.info( "links = " + linksNonjson )
shahshreyae6c7cf42014-11-26 16:39:01 -0800482
shahshreya1937ec12015-04-03 15:35:48 -0700483 linkInactiveCount = linksNonjson.count("state=INACTIVE")
484 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
485 if linkInactiveCount == 2:
486 main.log.info(
487 "Number of links in INACTIVE state are correct")
488 else:
489 main.log.info(
490 "Number of links in INACTIVE state are wrong")
491
shahshreya0e81ed92014-12-08 16:57:17 -0800492 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800493 main.log.info( "links = " + links )
494
495 linksResult = json.loads( links )
496 linksStateResult = main.FALSE
497 for item in linksResult:
498 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya1937ec12015-04-03 15:35:48 -0700499 'src' ][ 'port' ] == "20":
500 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
501 'dst' ][ 'port' ] == "50":
shahshreyafac62b12015-01-20 16:16:13 -0800502 linksState = item[ 'state' ]
503 if linksState == "INACTIVE":
504 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800505 "Links state is inactive as expected due to one" +
506 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800507 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800508 "Links state is inactive as expected due to one" +
509 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800510 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800511 break
512 else:
shahshreyafac62b12015-01-20 16:16:13 -0800513 main.log.info(
514 "Links state is not inactive as expected" )
515 main.log.report(
516 "Links state is not inactive as expected" )
517 linksStateResult = main.FALSE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800518
shahshreyafac62b12015-01-20 16:16:13 -0800519 print "links_state_result = ", linksStateResult
520 time.sleep( 10 )
shahshreya0e81ed92014-12-08 16:57:17 -0800521 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800522 main.log.info( "flows :" + flowHandle )
shahshreya0e81ed92014-12-08 16:57:17 -0800523
shahshreyafac62b12015-01-20 16:16:13 -0800524 main.step( "Verify Rerouting by a ping test" )
525 PingResult = main.TRUE
526 count = 1
shahshreya1937ec12015-04-03 15:35:48 -0700527 main.log.info( "\n\nh1 is Pinging h5" )
528 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreyafac62b12015-01-20 16:16:13 -0800529 # ping = main.LincOE2.pinghost()
530 if ping == main.FALSE and count < 5:
531 count += 1
532 PingResult = main.FALSE
533 main.log.info(
shahshreya1937ec12015-04-03 15:35:48 -0700534 "Ping between h1 and h5 failed. Making attempt number " +
shahshreyafac62b12015-01-20 16:16:13 -0800535 str( count ) +
536 " in 2 seconds" )
537 time.sleep( 2 )
538 elif ping == main.FALSE:
shahshreya1937ec12015-04-03 15:35:48 -0700539 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800540 PingResult = main.FALSE
541 elif ping == main.TRUE:
shahshreya1937ec12015-04-03 15:35:48 -0700542 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreyafac62b12015-01-20 16:16:13 -0800543 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800544 else:
shahshreyafac62b12015-01-20 16:16:13 -0800545 main.log.info( "Unknown error" )
546 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800547
shahshreyafac62b12015-01-20 16:16:13 -0800548 if PingResult == main.TRUE:
549 main.log.report( "Ping test successful " )
550 if PingResult == main.FALSE:
551 main.log.report( "Ping test failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800552
shahshreyafac62b12015-01-20 16:16:13 -0800553 case24Result = PingResult and linksStateResult
554 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800555 onpass="Packet optical rerouting successful",
556 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800557
shahshreyafac62b12015-01-20 16:16:13 -0800558 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800559 import re
560 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800561 main.log.report( "This testcase is testing the assignment of" +
562 " all the switches to all the controllers and" +
shahshreyadcb08e82015-02-25 10:16:42 -0800563 " discovering the hosts in reactive mode" )
shahshreyafac62b12015-01-20 16:16:13 -0800564 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700565
shahshreyafac62b12015-01-20 16:16:13 -0800566 main.case( "Pingall Test" )
567 main.step( "Assigning switches to controllers" )
568 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
569 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
570 for i in range( 1, 29 ):
571 if i == 1:
572 main.Mininet1.assignSwController(
573 sw=str( i ),
574 ip1=ONOS1Ip,
575 port1=ONOS1Port )
576 elif i >= 2 and i < 5:
577 main.Mininet1.assignSwController(
578 sw=str( i ),
579 ip1=ONOS1Ip,
580 port1=ONOS1Port )
581 elif i >= 5 and i < 8:
582 main.Mininet1.assignSwController(
583 sw=str( i ),
584 ip1=ONOS1Ip,
585 port1=ONOS1Port )
586 elif i >= 8 and i < 18:
587 main.Mininet1.assignSwController(
588 sw=str( i ),
589 ip1=ONOS1Ip,
590 port1=ONOS1Port )
591 elif i >= 18 and i < 28:
592 main.Mininet1.assignSwController(
593 sw=str( i ),
594 ip1=ONOS1Ip,
595 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800596 else:
shahshreyafac62b12015-01-20 16:16:13 -0800597 main.Mininet1.assignSwController(
598 sw=str( i ),
599 ip1=ONOS1Ip,
600 port1=ONOS1Port )
601 SwitchMastership = main.TRUE
602 for i in range( 1, 29 ):
603 if i == 1:
604 response = main.Mininet1.getSwController( "s" + str( i ) )
605 print( "Response is " + str( response ) )
606 if re.search( "tcp:" + ONOS1Ip, response ):
607 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800608 else:
shahshreyafac62b12015-01-20 16:16:13 -0800609 SwitchMastership = main.FALSE
610 elif i >= 2 and i < 5:
611 response = main.Mininet1.getSwController( "s" + str( i ) )
612 print( "Response is " + str( response ) )
613 if re.search( "tcp:" + ONOS1Ip, response ):
614 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800615 else:
shahshreyafac62b12015-01-20 16:16:13 -0800616 SwitchMastership = main.FALSE
617 elif i >= 5 and i < 8:
618 response = main.Mininet1.getSwController( "s" + str( i ) )
619 print( "Response is " + str( response ) )
620 if re.search( "tcp:" + ONOS1Ip, response ):
621 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800622 else:
shahshreyafac62b12015-01-20 16:16:13 -0800623 SwitchMastership = main.FALSE
624 elif i >= 8 and i < 18:
625 response = main.Mininet1.getSwController( "s" + str( i ) )
626 print( "Response is " + str( response ) )
627 if re.search( "tcp:" + ONOS1Ip, response ):
628 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800629 else:
shahshreyafac62b12015-01-20 16:16:13 -0800630 SwitchMastership = main.FALSE
631 elif i >= 18 and i < 28:
632 response = main.Mininet1.getSwController( "s" + str( i ) )
633 print( "Response is " + str( response ) )
634 if re.search( "tcp:" + ONOS1Ip, response ):
635 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800636 else:
shahshreyafac62b12015-01-20 16:16:13 -0800637 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800638 else:
shahshreyafac62b12015-01-20 16:16:13 -0800639 response = main.Mininet1.getSwController( "s" + str( i ) )
640 print( "Response is" + str( response ) )
641 if re.search( "tcp:" + ONOS1Ip, response ):
642 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800643 else:
shahshreyafac62b12015-01-20 16:16:13 -0800644 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800645
shahshreyafac62b12015-01-20 16:16:13 -0800646 if SwitchMastership == main.TRUE:
647 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800648 else:
shahshreyafac62b12015-01-20 16:16:13 -0800649 main.log.report( "Controller assignmnet failed" )
650 utilities.assert_equals(
651 expect=main.TRUE,
652 actual=SwitchMastership,
653 onpass="MasterControllers assigned correctly" )
654 """
655 for i in range ( 1,29 ):
656 main.Mininet1.assignSwController( sw=str( i ),count=5,
657 ip1=ONOS1Ip,port1=ONOS1Port,
658 ip2=ONOS2Ip,port2=ONOS2Port,
659 ip3=ONOS3Ip,port3=ONOS3Port,
660 ip4=ONOS4Ip,port4=ONOS4Port,
661 ip5=ONOS5Ip,port5=ONOS5Port )
662 """
663 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700664 main.log.info( "Activate fwd app" )
665 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
666 appCheck = main.ONOS2.appToIDCheck()
667 if appCheck != main.TRUE:
668 main.log.warn( main.ONOS2.apps() )
669 main.log.warn( main.ONOS2.appIDs() )
670 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800671
shahshreyafac62b12015-01-20 16:16:13 -0800672 main.step( "Get list of hosts from Mininet" )
673 hostList = main.Mininet1.getHosts()
674 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800675
shahshreyafac62b12015-01-20 16:16:13 -0800676 main.step( "Get host list in ONOS format" )
677 hostOnosList = main.ONOS2.getHostsId( hostList )
678 main.log.info( hostOnosList )
679 # time.sleep( 5 )
680
681 main.step( "Pingall" )
682 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800683 time1 = time.time()
684 pingResult = main.Mininet1.pingall()
685 time2 = time.time()
686 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800687
shahshreyafac62b12015-01-20 16:16:13 -0800688 # Start onos cli again because u might have dropped out of
689 # onos prompt to the shell prompt
690 # if there was no activity
691 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
692
693 case4Result = SwitchMastership and pingResult
694 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800695 main.log.report( "Pingall Test in reactive mode to" +
696 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800697 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800698 main.log.report( "Pingall Test in reactive mode to" +
699 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800700
shahshreyafac62b12015-01-20 16:16:13 -0800701 utilities.assert_equals(
702 expect=main.TRUE,
703 actual=case4Result,
704 onpass="Controller assignment and Pingall Test successful",
705 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800706
shahshreyafac62b12015-01-20 16:16:13 -0800707 def CASE10( self ):
708 main.log.report(
709 "This testcase uninstalls the reactive forwarding app" )
710 main.log.report( "__________________________________" )
711 main.case( "Uninstalling reactive forwarding app" )
712 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700713 main.log.info( "deactivate reactive forwarding app" )
714 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
715 appCheck = main.ONOS2.appToIDCheck()
716 if appCheck != main.TRUE:
717 main.log.warn( main.ONOS2.apps() )
718 main.log.warn( main.ONOS2.appIDs() )
shahshreyae6c7cf42014-11-26 16:39:01 -0800719
shahshreyafac62b12015-01-20 16:16:13 -0800720 # After reactive forwarding is disabled, the reactive flows on
721 # switches timeout in 10-15s
722 # So sleep for 15s
723 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800724
725 flows = main.ONOS2.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800726 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800727
shahshreyafac62b12015-01-20 16:16:13 -0800728 case10Result = appUninstallResult
729 utilities.assert_equals(
730 expect=main.TRUE,
731 actual=case10Result,
732 onpass="Reactive forwarding app uninstallation successful",
733 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800734
shahshreyadcb08e82015-02-25 10:16:42 -0800735
736 def CASE11( self ):
737 # NOTE: This testcase require reactive forwarding mode enabled
738 # NOTE: in the beginning and then uninstall it before adding
739 # NOTE: point intents. Again the app is installed so that
740 # NOTE: testcase 10 can be ran successively
741 import time
742 main.log.report(
743 "This testcase moves a host from one switch to another to add" +
744 "point intents between them and then perform ping" )
745 main.log.report( "__________________________________" )
746 main.log.info( "Moving host from one switch to another" )
747 main.case( "Moving host from a device and attach it to another device" )
748 main.step( "Moving host h9 from device s9 and attach it to s8" )
749 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
750
shahshreyad524a942015-04-21 09:55:16 -0700751 main.log.info( "Activate fwd app" )
752 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
753 appCheck = main.ONOS2.appToIDCheck()
754 if appCheck != main.TRUE:
755 main.log.warn( main.ONOS2.apps() )
756 main.log.warn( main.ONOS2.appIDs() )
757
shahshreyaa47ebf42015-05-20 13:29:18 -0700758 time.sleep(25) #Time delay to have all the flows ready
shahshreyadcb08e82015-02-25 10:16:42 -0800759 main.step( "Pingall" )
760 pingResult = main.FALSE
761 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700762 pingResult = main.Mininet1.pingall( timeout=120,
763 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700764 acceptableFailed=20 )
shahshreyadcb08e82015-02-25 10:16:42 -0800765 time2 = time.time()
766 print "Time for pingall: %2f seconds" % ( time2 - time1 )
767
768 hosts = main.ONOS2.hosts( jsonFormat = False )
769 main.log.info( hosts )
770
shahshreyad524a942015-04-21 09:55:16 -0700771 main.log.info( "deactivate reactive forwarding app" )
772 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
773 appCheck = main.ONOS2.appToIDCheck()
774 if appCheck != main.TRUE:
775 main.log.warn( main.ONOS2.apps() )
776 main.log.warn( main.ONOS2.appIDs() )
shahshreyadcb08e82015-02-25 10:16:42 -0800777
778 main.step( "Add point intents between hosts on the same device")
779 ptpIntentResult = main.ONOS2.addPointIntent(
780 "of:0000000000003008/1",
781 "of:0000000000003008/3" )
782 if ptpIntentResult == main.TRUE:
783 getIntentResult = main.ONOS2.intents()
784 main.log.info( "Point to point intent install successful" )
785 # main.log.info( getIntentResult )
786
787 ptpIntentResult = main.ONOS2.addPointIntent(
788 "of:0000000000003008/3",
789 "of:0000000000003008/1" )
790 if ptpIntentResult == main.TRUE:
791 getIntentResult = main.ONOS2.intents()
792 main.log.info( "Point to point intent install successful" )
793 # main.log.info( getIntentResult )
794
795 main.case( "Ping hosts on the same devices" )
796 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
797
798 '''
799 main.case( "Installing reactive forwarding app" )
800 # Install onos-app-fwd app to enable reactive forwarding
801 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
802 main.log.info( "onos-app-fwd installed" )
803 '''
804
805 if ping == main.FALSE:
806 main.log.report(
807 "Point intents for hosts on same devices haven't" +
808 " been installed correctly. Cleaning up" )
809 if ping == main.TRUE:
810 main.log.report(
811 "Point intents for hosts on same devices" +
812 "installed correctly. Cleaning up" )
813
shahshreyaa47ebf42015-05-20 13:29:18 -0700814 case11Result = ping
shahshreyadcb08e82015-02-25 10:16:42 -0800815 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800816 expect = main.TRUE,
817 actual = case11Result,
818 onpass = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800819 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800820 onfail = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800821 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800822
823
824 def CASE12( self ):
825 """
shahshreya1937ec12015-04-03 15:35:48 -0700826 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800827 """
828 main.log.report( "This testcase is verifying num of default" +
829 " flows on each switch" )
830 main.log.report( "__________________________________" )
831 main.case( "Verify num of default flows on each switch" )
832 main.step( "Obtaining the device id's and flowrule count on them" )
833
834 case12Result = main.TRUE
835 idList = main.ONOS2.getAllDevicesId()
836 for id in idList:
837 count = main.ONOS2.FlowAddedCount( id )
shahshreya531e2b52015-02-26 12:40:46 -0800838 main.log.info("count = " +count)
839 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800840 case12Result = main.FALSE
841 break
shahshreya74cca802015-02-26 12:24:01 -0800842 utilities.assert_equals(
843 expect=main.TRUE,
844 actual=case12Result,
845 onpass = "Expected default num of flows exist",
846 onfail = "Expected default num of flows do not exist")
shahshreyadcb08e82015-02-25 10:16:42 -0800847
shahshreyafac62b12015-01-20 16:16:13 -0800848 def CASE6( self ):
shahshreyadcb08e82015-02-25 10:16:42 -0800849 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800850 main.log.report( "This testcase is testing the addition of" +
851 " host intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -0800852 main.log.report( "__________________________________" )
853 main.case( "Obtaining host id's" )
854 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800855 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -0800856 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800857
shahshreyafac62b12015-01-20 16:16:13 -0800858 main.step( "Get all devices id" )
859 devicesIdList = main.ONOS2.getAllDevicesId()
860 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800861
shahshreyafac62b12015-01-20 16:16:13 -0800862 # ONOS displays the hosts in hex format unlike mininet which does
863 # in decimal format
864 # So take care while adding intents
865 """
866 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
867 ONOS hosts h8 and h12" )
868 hthIntentResult = main.ONOS2.addHostIntent(
869 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
870 hthIntentResult = main.ONOS2.addHostIntent(
871 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
872 hthIntentResult = main.ONOS2.addHostIntent(
873 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
874 hthIntentResult = main.ONOS2.addHostIntent(
875 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
876 hthIntentResult = main.ONOS2.addHostIntent(
877 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
878 hthIntentResult = main.ONOS2.addHostIntent(
879 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
880 hthIntentResult = main.ONOS2.addHostIntent(
881 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
882 hthIntentResult = main.ONOS2.addHostIntent(
883 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
884 hthIntentResult = main.ONOS2.addHostIntent(
885 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
886 hthIntentResult = main.ONOS2.addHostIntent(
887 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
888 print "______________________________________________________"
889 """
890 for i in range( 8, 18 ):
891 main.log.info(
892 "Adding host intent between h" + str( i ) +
893 " and h" + str( i + 10 ) )
894 host1 = "00:00:00:00:00:" + \
895 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
896 host2 = "00:00:00:00:00:" + \
897 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
898 # NOTE: get host can return None
shahshreya1937ec12015-04-03 15:35:48 -0700899 if host1:
900 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
901 if host2:
902 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
903 if host1Id and host2Id:
904 main.ONOS2.addHostIntent( host1Id, host2Id )
shahshreyafac62b12015-01-20 16:16:13 -0800905
906 time.sleep( 10 )
907 hIntents = main.ONOS2.intents( jsonFormat=False )
908 main.log.info( "intents:" + hIntents )
shahshreyadcb08e82015-02-25 10:16:42 -0800909 flows = main.ONOS2.flows()
910 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800911
912 count = 1
913 i = 8
shahshreyafac62b12015-01-20 16:16:13 -0800914 PingResult = main.TRUE
915 # while i<10:
916 while i < 18:
917 main.log.info(
918 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
919 ping = main.Mininet1.pingHost(
920 src="h" + str( i ), target="h" + str( i + 10 ) )
921 if ping == main.FALSE and count < 5:
922 count += 1
923 # i = 8
924 PingResult = main.FALSE
925 main.log.report( "Ping between h" +
926 str( i ) +
927 " and h" +
928 str( i +
929 10 ) +
930 " failed. Making attempt number " +
931 str( count ) +
932 " in 2 seconds" )
933 time.sleep( 2 )
934 elif ping == main.FALSE:
935 main.log.report( "All ping attempts between h" +
936 str( i ) +
937 " and h" +
938 str( i +
939 10 ) +
940 "have failed" )
941 i = 19
942 PingResult = main.FALSE
943 elif ping == main.TRUE:
944 main.log.info( "Ping test between h" +
945 str( i ) +
946 " and h" +
947 str( i +
948 10 ) +
949 "passed!" )
950 i += 1
951 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800952 else:
shahshreyafac62b12015-01-20 16:16:13 -0800953 main.log.info( "Unknown error" )
954 PingResult = main.ERROR
955 if PingResult == main.FALSE:
956 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800957 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -0800958 # main.cleanup()
959 # main.exit()
960 if PingResult == main.TRUE:
961 main.log.report(
962 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800963
shahshreyafac62b12015-01-20 16:16:13 -0800964 case6Result = PingResult
965 utilities.assert_equals(
966 expect=main.TRUE,
967 actual=case6Result,
968 onpass="Pingall Test after Host intents addition successful",
969 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800970
shahshreyafac62b12015-01-20 16:16:13 -0800971 def CASE5( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700972 """
973 Check ONOS topology matches with mininet
974 """
shahshreya4e13a062014-11-11 16:46:18 -0800975 import json
shahshreyafac62b12015-01-20 16:16:13 -0800976 # assumes that sts is already in you PYTHONPATH
shahshreya9294c8d2015-01-21 15:54:16 -0800977 from sts.topology.teston_topology import TestONTopology
shahshreyafac62b12015-01-20 16:16:13 -0800978 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800979 main.log.report( "This testcase is testing if all ONOS nodes" +
980 " are in topology sync with mininet" )
shahshreyafac62b12015-01-20 16:16:13 -0800981 main.log.report( "__________________________________" )
982 main.case( "Comparing Mininet topology with the topology of ONOS" )
983 main.step( "Start continuous pings" )
984 main.Mininet2.pingLong(
985 src=main.params[ 'PING' ][ 'source1' ],
986 target=main.params[ 'PING' ][ 'target1' ],
987 pingTime=500 )
988 main.Mininet2.pingLong(
989 src=main.params[ 'PING' ][ 'source2' ],
990 target=main.params[ 'PING' ][ 'target2' ],
991 pingTime=500 )
992 main.Mininet2.pingLong(
993 src=main.params[ 'PING' ][ 'source3' ],
994 target=main.params[ 'PING' ][ 'target3' ],
995 pingTime=500 )
996 main.Mininet2.pingLong(
997 src=main.params[ 'PING' ][ 'source4' ],
998 target=main.params[ 'PING' ][ 'target4' ],
999 pingTime=500 )
1000 main.Mininet2.pingLong(
1001 src=main.params[ 'PING' ][ 'source5' ],
1002 target=main.params[ 'PING' ][ 'target5' ],
1003 pingTime=500 )
1004 main.Mininet2.pingLong(
1005 src=main.params[ 'PING' ][ 'source6' ],
1006 target=main.params[ 'PING' ][ 'target6' ],
1007 pingTime=500 )
1008 main.Mininet2.pingLong(
1009 src=main.params[ 'PING' ][ 'source7' ],
1010 target=main.params[ 'PING' ][ 'target7' ],
1011 pingTime=500 )
1012 main.Mininet2.pingLong(
1013 src=main.params[ 'PING' ][ 'source8' ],
1014 target=main.params[ 'PING' ][ 'target8' ],
1015 pingTime=500 )
1016 main.Mininet2.pingLong(
1017 src=main.params[ 'PING' ][ 'source9' ],
1018 target=main.params[ 'PING' ][ 'target9' ],
1019 pingTime=500 )
1020 main.Mininet2.pingLong(
1021 src=main.params[ 'PING' ][ 'source10' ],
1022 target=main.params[ 'PING' ][ 'target10' ],
1023 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001024
shahshreyafac62b12015-01-20 16:16:13 -08001025 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001026 global ctrls
1027 ctrls = []
1028 count = 1
1029 while True:
1030 temp = ()
shahshreyafac62b12015-01-20 16:16:13 -08001031 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1032 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1033 temp = temp + ( "ONOS" + str( count ), )
1034 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1035 temp = temp + \
1036 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1037 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001038 count = count + 1
1039 else:
1040 break
1041 global MNTopo
shahshreyafac62b12015-01-20 16:16:13 -08001042 Topo = TestONTopology(
1043 main.Mininet1,
1044 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001045 MNTopo = Topo
1046
shahshreyafac62b12015-01-20 16:16:13 -08001047 TopologyCheck = main.TRUE
1048 main.step( "Compare ONOS Topology to MN Topology" )
1049 devicesJson = main.ONOS2.devices()
1050 linksJson = main.ONOS2.links()
1051 # portsJson = main.ONOS2.ports()
1052
1053 result1 = main.Mininet1.compareSwitches(
1054 MNTopo,
1055 json.loads( devicesJson ) )
1056 result2 = main.Mininet1.compareLinks(
1057 MNTopo,
1058 json.loads( linksJson ) )
1059 # result3 = main.Mininet1.comparePorts(
1060 # MNTopo, json.loads( portsJson ) )
1061
1062 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001063 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -08001064
shahshreya4e13a062014-11-11 16:46:18 -08001065 print "***********************"
1066 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001067 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001068 else:
shahshreyafac62b12015-01-20 16:16:13 -08001069 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001070
shahshreyafac62b12015-01-20 16:16:13 -08001071 utilities.assert_equals(
1072 expect=main.TRUE,
1073 actual=result,
1074 onpass="ONOS" +
1075 " Topology matches MN Topology",
1076 onfail="ONOS" +
1077 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001078
shahshreyafac62b12015-01-20 16:16:13 -08001079 TopologyCheck = TopologyCheck and result
1080 utilities.assert_equals(
1081 expect=main.TRUE,
1082 actual=TopologyCheck,
1083 onpass="Topology checks passed",
1084 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001085
shahshreyafac62b12015-01-20 16:16:13 -08001086 def CASE7( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001087 """
1088 Link discovery test case. Checks if ONOS can discover a link
1089 down or up properly.
1090 """
1091
shahshreya9294c8d2015-01-21 15:54:16 -08001092 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001093
shahshreyafac62b12015-01-20 16:16:13 -08001094 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001095
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001096 main.log.report( "This testscase is killing a link to ensure that" +
1097 " link discovery is consistent" )
shahshreyafac62b12015-01-20 16:16:13 -08001098 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001099 main.log.report( "Killing a link to ensure that link discovery" +
1100 " is consistent" )
1101 main.case( "Killing a link to Ensure that Link Discovery" +
1102 "is Working Properly" )
shahshreyafac62b12015-01-20 16:16:13 -08001103 """
1104 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -08001105
shahshreyafac62b12015-01-20 16:16:13 -08001106 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
1107 target=main.params[ 'PING' ][ 'target1' ],
1108 pingTime=500 )
1109 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
1110 target=main.params[ 'PING' ][ 'target2' ],
1111 pingTime=500 )
1112 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
1113 target=main.params[ 'PING' ][ 'target3' ],
1114 pingTime=500 )
1115 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
1116 target=main.params[ 'PING' ][ 'target4' ],
1117 pingTime=500 )
1118 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
1119 target=main.params[ 'PING' ][ 'target5' ],
1120 pingTime=500 )
1121 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
1122 target=main.params[ 'PING' ][ 'target6' ],
1123 pingTime=500 )
1124 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
1125 target=main.params[ 'PING' ][ 'target7' ],
1126 pingTime=500 )
1127 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
1128 target=main.params[ 'PING' ][ 'target8' ],
1129 pingTime=500 )
1130 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
1131 target=main.params[ 'PING' ][ 'target9' ],
1132 pingTime=500 )
1133 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
1134 target=main.params[ 'PING' ][ 'target10' ],
1135 pingTime=500 )
1136 """
1137 main.step( "Determine the current number of switches and links" )
1138 topologyOutput = main.ONOS2.topology()
1139 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001140 activeSwitches = topologyResult[ 'devices' ]
1141 links = topologyResult[ 'links' ]
shahshreyafac62b12015-01-20 16:16:13 -08001142 print "activeSwitches = ", type( activeSwitches )
1143 print "links = ", type( links )
1144 main.log.info(
1145 "Currently there are %s switches and %s links" %
1146 ( str( activeSwitches ), str( links ) ) )
1147
1148 main.step( "Kill Link between s3 and s28" )
1149 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
1150 time.sleep( linkSleep )
1151 topologyOutput = main.ONOS2.topology()
1152 LinkDown = main.ONOS1.checkStatus(
1153 topologyOutput, activeSwitches, str(
1154 int( links ) - 2 ) )
1155 if LinkDown == main.TRUE:
1156 main.log.report( "Link Down discovered properly" )
1157 utilities.assert_equals(
1158 expect=main.TRUE,
1159 actual=LinkDown,
1160 onpass="Link Down discovered properly",
1161 onfail="Link down was not discovered in " +
1162 str( linkSleep ) +
1163 " seconds" )
1164
1165 # Check ping result here..add code for it
1166
1167 main.step( "Bring link between s3 and s28 back up" )
1168 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1169 time.sleep( linkSleep )
1170 topologyOutput = main.ONOS2.topology()
1171 LinkUp = main.ONOS1.checkStatus(
1172 topologyOutput,
1173 activeSwitches,
1174 str( links ) )
1175 if LinkUp == main.TRUE:
1176 main.log.report( "Link up discovered properly" )
1177 utilities.assert_equals(
1178 expect=main.TRUE,
1179 actual=LinkUp,
1180 onpass="Link up discovered properly",
1181 onfail="Link up was not discovered in " +
1182 str( linkSleep ) +
1183 " seconds" )
1184
1185 # NOTE Check ping result here..add code for it
1186
1187 main.step( "Compare ONOS Topology to MN Topology" )
1188 Topo = TestONTopology(
1189 main.Mininet1,
1190 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001191 MNTopo = Topo
shahshreyafac62b12015-01-20 16:16:13 -08001192 TopologyCheck = main.TRUE
1193
1194 devicesJson = main.ONOS2.devices()
1195 linksJson = main.ONOS2.links()
1196 portsJson = main.ONOS2.ports()
1197
1198 result1 = main.Mininet1.compareSwitches(
1199 MNTopo,
1200 json.loads( devicesJson ) )
1201 result2 = main.Mininet1.compareLinks(
1202 MNTopo,
1203 json.loads( linksJson ) )
1204 # result3 = main.Mininet1.comparePorts(
1205 # MNTopo, json.loads( portsJson ) )
1206
1207 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001208 result = result1 and result2
1209 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001210
shahshreya4e13a062014-11-11 16:46:18 -08001211 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001212 main.log.report( "ONOS" + " Topology matches MN Topology" )
1213 utilities.assert_equals(
1214 expect=main.TRUE,
1215 actual=result,
1216 onpass="ONOS" +
1217 " Topology matches MN Topology",
1218 onfail="ONOS" +
1219 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001220
shahshreyafac62b12015-01-20 16:16:13 -08001221 TopologyCheck = TopologyCheck and result
1222 utilities.assert_equals(
1223 expect=main.TRUE,
1224 actual=TopologyCheck,
1225 onpass="Topology checks passed",
1226 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001227
shahshreyafac62b12015-01-20 16:16:13 -08001228 result = LinkDown and LinkUp and TopologyCheck
1229 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001230 onpass="Link failure is discovered correctly",
1231 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001232
1233 def CASE8( self ):
1234 """
shahshreya82ecd282015-02-05 16:48:03 -08001235 Intent removal
shahshreyafac62b12015-01-20 16:16:13 -08001236 """
shahshreya82ecd282015-02-05 16:48:03 -08001237 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001238 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001239 " before adding any new set of intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001240 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001241 main.log.info( "intent removal" )
1242 main.case( "Removing installed intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001243 main.step( "Obtain the intent id's" )
1244 intentResult = main.ONOS2.intents( jsonFormat=False )
1245 main.log.info( "intent_result = " + intentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001246 intentLinewise = intentResult.split( "\n" )
shahshreyafac62b12015-01-20 16:16:13 -08001247
shahshreyadcb08e82015-02-25 10:16:42 -08001248 intentList = [line for line in intentLinewise \
1249 if line.startswith( "id=")]
1250 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1251 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001252 for id in intentids:
1253 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001254
1255 main.step(
1256 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001257 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001258 main.ONOS2.removeIntent( intentId=id ,purge=True)
shahshreyae6c7cf42014-11-26 16:39:01 -08001259
shahshreyafac62b12015-01-20 16:16:13 -08001260 intentResult = main.ONOS2.intents( jsonFormat=False )
1261 main.log.info( "intent_result = " + intentResult )
shahshreyadcb08e82015-02-25 10:16:42 -08001262
1263 intentList = [line for line in intentResult.split( "\n" ) \
1264 if line.startswith( "id=")]
1265 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1266 intentList]
1267 for state in intentState:
1268 print state
1269
1270 case8Result = main.TRUE
1271 for state in intentState:
1272 if state != 'WITHDRAWN':
1273 case8Result = main.FALSE
1274 break
1275
shahshreyafac62b12015-01-20 16:16:13 -08001276 if case8Result == main.TRUE:
1277 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001278 else:
shahshreyafac62b12015-01-20 16:16:13 -08001279 main.log.report( "Intent removal failed" )
1280
1281 PingResult = main.TRUE
1282 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001283 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001284 while i < 18:
1285 main.log.info(
1286 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1287 ping = main.Mininet1.pingHost(
1288 src="h" + str( i ), target="h" + str( i + 10 ) )
1289 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001290 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001291 PingResult = PingResult and main.TRUE
1292 elif ping == main.FALSE:
1293 i += 1
1294 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001295 else:
shahshreyafac62b12015-01-20 16:16:13 -08001296 main.log.info( "Unknown error" )
1297 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001298
shahshreyafac62b12015-01-20 16:16:13 -08001299 # Note: If the ping result failed, that means the intents have been
1300 # withdrawn correctly.
1301 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001302 main.log.report( "Installed intents have not been withdrawn correctly" )
shahshreyafac62b12015-01-20 16:16:13 -08001303 # main.cleanup()
1304 # main.exit()
1305 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001306 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001307
shahshreyafac62b12015-01-20 16:16:13 -08001308 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001309
shahshreyafac62b12015-01-20 16:16:13 -08001310 if case8Result == main.FALSE:
1311 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001312 else:
shahshreyafac62b12015-01-20 16:16:13 -08001313 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001314
shahshreyafac62b12015-01-20 16:16:13 -08001315 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001316 onpass="Intent removal test passed",
1317 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001318
shahshreyafac62b12015-01-20 16:16:13 -08001319 def CASE9( self ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001320 """
1321 Testing Point intents
1322 """
shahshreyafac62b12015-01-20 16:16:13 -08001323 main.log.report(
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001324 "This test case adds point intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -08001325 main.log.report( "__________________________________" )
1326 main.log.info( "Adding point intents" )
1327 main.case(
shahshreya71162c62015-01-23 15:31:16 -08001328 "Adding bidirectional point for mn hosts" +
1329 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1330 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001331 macsDict = {}
1332 for i in range( 1,29 ):
1333 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1334 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001335 main.step( "Add point intents for mn hosts h8 and h18 or" +
1336 "ONOS hosts h8 and h12" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001337 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001338 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001339 ingressDevice="of:0000000000003008/1",
1340 egressDevice="of:0000000000006018/1",
1341 ethType='IPV4',
1342 ethSrc=macsDict.get( 'h8' ))
shahshreyafac62b12015-01-20 16:16:13 -08001343 if ptpIntentResult == main.TRUE:
1344 getIntentResult = main.ONOS2.intents()
1345 main.log.info( "Point to point intent install successful" )
1346 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001347
shahshreyafac62b12015-01-20 16:16:13 -08001348 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001349 ingressDevice="of:0000000000006018/1",
1350 egressDevice="of:0000000000003008/1",
1351 ethType='IPV4',
1352 ethSrc=macsDict.get( 'h18' ))
shahshreyafac62b12015-01-20 16:16:13 -08001353 if ptpIntentResult == main.TRUE:
1354 getIntentResult = main.ONOS2.intents()
1355 main.log.info( "Point to point intent install successful" )
1356 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001357
shahshreya9294c8d2015-01-21 15:54:16 -08001358 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1359 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001360 ptpIntentResult = main.ONOS2.addPointIntent(
1361 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001362 "of:0000000000006019/1",
1363 ethType='IPV4',
1364 ethSrc=macsDict.get( 'h9' ))
shahshreyafac62b12015-01-20 16:16:13 -08001365 if ptpIntentResult == main.TRUE:
1366 getIntentResult = main.ONOS2.intents()
1367 main.log.info( "Point to point intent install successful" )
1368 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001369
shahshreyafac62b12015-01-20 16:16:13 -08001370 ptpIntentResult = main.ONOS2.addPointIntent(
1371 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001372 "of:0000000000003009/1",
1373 ethType='IPV4',
1374 ethSrc=macsDict.get( 'h19' ))
shahshreyafac62b12015-01-20 16:16:13 -08001375 if ptpIntentResult == main.TRUE:
1376 getIntentResult = main.ONOS2.intents()
1377 main.log.info( "Point to point intent install successful" )
1378 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001379
shahshreya9294c8d2015-01-21 15:54:16 -08001380 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1381 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001382 ptpIntentResult = main.ONOS2.addPointIntent(
1383 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001384 "of:0000000000006020/1",
1385 ethType='IPV4',
1386 ethSrc=macsDict.get( 'h10' ))
1387
shahshreyafac62b12015-01-20 16:16:13 -08001388 if ptpIntentResult == main.TRUE:
1389 getIntentResult = main.ONOS2.intents()
1390 main.log.info( "Point to point intent install successful" )
1391 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001392
shahshreyafac62b12015-01-20 16:16:13 -08001393 ptpIntentResult = main.ONOS2.addPointIntent(
1394 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001395 "of:0000000000003010/1",
1396 ethType='IPV4',
1397 ethSrc=macsDict.get( 'h20' ))
1398
shahshreyafac62b12015-01-20 16:16:13 -08001399 if ptpIntentResult == main.TRUE:
1400 getIntentResult = main.ONOS2.intents()
1401 main.log.info( "Point to point intent install successful" )
1402 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001403
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001404 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1405 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001406 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001407 ptpIntentResult = main.ONOS2.addPointIntent(
1408 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001409 "of:0000000000006021/1",
1410 ethType='IPV4',
1411 ethSrc=macsDict.get( 'h11' ))
1412
shahshreyafac62b12015-01-20 16:16:13 -08001413 if ptpIntentResult == main.TRUE:
1414 getIntentResult = main.ONOS2.intents()
1415 main.log.info( "Point to point intent install successful" )
1416 # main.log.info( getIntentResult )
1417
1418 ptpIntentResult = main.ONOS2.addPointIntent(
1419 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001420 "of:0000000000003011/1",
1421 ethType='IPV4',
1422 ethSrc=macsDict.get( 'h21' ))
1423
shahshreyafac62b12015-01-20 16:16:13 -08001424 if ptpIntentResult == main.TRUE:
1425 getIntentResult = main.ONOS2.intents()
1426 main.log.info( "Point to point intent install successful" )
1427 # main.log.info( getIntentResult )
1428
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001429 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1430 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001431 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001432 ptpIntentResult = main.ONOS2.addPointIntent(
1433 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001434 "of:0000000000006022/1",
1435 ethType='IPV4',
1436 ethSrc=macsDict.get( 'h12' ))
1437
shahshreyafac62b12015-01-20 16:16:13 -08001438 if ptpIntentResult == main.TRUE:
1439 getIntentResult = main.ONOS2.intents()
1440 main.log.info( "Point to point intent install successful" )
1441 # main.log.info( getIntentResult )
1442
1443 ptpIntentResult = main.ONOS2.addPointIntent(
1444 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001445 "of:0000000000003012/1",
1446 ethType='IPV4',
1447 ethSrc=macsDict.get( 'h22' ))
1448
shahshreyafac62b12015-01-20 16:16:13 -08001449 if ptpIntentResult == main.TRUE:
1450 getIntentResult = main.ONOS2.intents()
1451 main.log.info( "Point to point intent install successful" )
1452 # main.log.info( getIntentResult )
1453
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001454 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1455 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001456 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001457 ptpIntentResult = main.ONOS2.addPointIntent(
1458 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001459 "of:0000000000006023/1",
1460 ethType='IPV4',
1461 ethSrc=macsDict.get( 'h13' ))
1462
shahshreyafac62b12015-01-20 16:16:13 -08001463 if ptpIntentResult == main.TRUE:
1464 getIntentResult = main.ONOS2.intents()
1465 main.log.info( "Point to point intent install successful" )
1466 # main.log.info( getIntentResult )
1467
1468 ptpIntentResult = main.ONOS2.addPointIntent(
1469 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001470 "of:0000000000003013/1",
1471 ethType='IPV4',
1472 ethSrc=macsDict.get( 'h23' ))
1473
shahshreyafac62b12015-01-20 16:16:13 -08001474 if ptpIntentResult == main.TRUE:
1475 getIntentResult = main.ONOS2.intents()
1476 main.log.info( "Point to point intent install successful" )
1477 # main.log.info( getIntentResult )
1478
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001479 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1480 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001481 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001482 ptpIntentResult = main.ONOS2.addPointIntent(
1483 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001484 "of:0000000000006024/1",
1485 ethType='IPV4',
1486 ethSrc=macsDict.get( 'h14' ))
1487
shahshreyafac62b12015-01-20 16:16:13 -08001488 if ptpIntentResult == main.TRUE:
1489 getIntentResult = main.ONOS2.intents()
1490 main.log.info( "Point to point intent install successful" )
1491 # main.log.info( getIntentResult )
1492
1493 ptpIntentResult = main.ONOS2.addPointIntent(
1494 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001495 "of:0000000000003014/1",
1496 ethType='IPV4',
1497 ethSrc=macsDict.get( 'h24' ))
1498
shahshreyafac62b12015-01-20 16:16:13 -08001499 if ptpIntentResult == main.TRUE:
1500 getIntentResult = main.ONOS2.intents()
1501 main.log.info( "Point to point intent install successful" )
1502 # main.log.info( getIntentResult )
1503
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001504 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1505 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001506 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001507 ptpIntentResult = main.ONOS2.addPointIntent(
1508 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001509 "of:0000000000006025/1",
1510 ethType='IPV4',
1511 ethSrc=macsDict.get( 'h15' ))
1512
shahshreyafac62b12015-01-20 16:16:13 -08001513 if ptpIntentResult == main.TRUE:
1514 getIntentResult = main.ONOS2.intents()
1515 main.log.info( "Point to point intent install successful" )
1516 # main.log.info( getIntentResult )
1517
1518 ptpIntentResult = main.ONOS2.addPointIntent(
1519 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001520 "of:0000000000003015/1",
1521 ethType='IPV4',
1522 ethSrc=macsDict.get( 'h25' ))
1523
shahshreyafac62b12015-01-20 16:16:13 -08001524 if ptpIntentResult == main.TRUE:
1525 getIntentResult = main.ONOS2.intents()
1526 main.log.info( "Point to point intent install successful" )
1527 # main.log.info( getIntentResult )
1528
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001529 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1530 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001531 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001532 ptpIntentResult = main.ONOS2.addPointIntent(
1533 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001534 "of:0000000000006026/1",
1535 ethType='IPV4',
1536 ethSrc=macsDict.get( 'h16' ))
1537
shahshreyafac62b12015-01-20 16:16:13 -08001538 if ptpIntentResult == main.TRUE:
1539 getIntentResult = main.ONOS2.intents()
1540 main.log.info( "Point to point intent install successful" )
1541 # main.log.info( getIntentResult )
1542
1543 ptpIntentResult = main.ONOS2.addPointIntent(
1544 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001545 "of:0000000000003016/1",
1546 ethType='IPV4',
1547 ethSrc=macsDict.get( 'h26' ))
1548
shahshreyafac62b12015-01-20 16:16:13 -08001549 if ptpIntentResult == main.TRUE:
1550 getIntentResult = main.ONOS2.intents()
1551 main.log.info( "Point to point intent install successful" )
1552 # main.log.info( getIntentResult )
1553
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001554 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1555 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001556 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001557 ptpIntentResult = main.ONOS2.addPointIntent(
1558 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001559 "of:0000000000006027/1",
1560 ethType='IPV4',
1561 ethSrc=macsDict.get( 'h17' ))
1562
shahshreyafac62b12015-01-20 16:16:13 -08001563 if ptpIntentResult == main.TRUE:
1564 getIntentResult = main.ONOS2.intents()
1565 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001566 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001567
1568 ptpIntentResult = main.ONOS2.addPointIntent(
1569 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001570 "of:0000000000003017/1",
1571 ethType='IPV4',
1572 ethSrc=macsDict.get( 'h27' ))
1573
shahshreyafac62b12015-01-20 16:16:13 -08001574 if ptpIntentResult == main.TRUE:
1575 getIntentResult = main.ONOS2.intents()
1576 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001577 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001578
1579 print(
1580 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001581
1582 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001583 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001584
1585 count = 1
1586 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001587 PingResult = main.TRUE
1588 while i < 18:
1589 main.log.info(
1590 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1591 ping = main.Mininet1.pingHost(
1592 src="h" + str( i ), target="h" + str( i + 10 ) )
1593 if ping == main.FALSE and count < 5:
1594 count += 1
1595 # i = 8
1596 PingResult = main.FALSE
1597 main.log.report( "Ping between h" +
1598 str( i ) +
1599 " and h" +
1600 str( i +
1601 10 ) +
1602 " failed. Making attempt number " +
1603 str( count ) +
1604 " in 2 seconds" )
1605 time.sleep( 2 )
1606 elif ping == main.FALSE:
1607 main.log.report( "All ping attempts between h" +
1608 str( i ) +
1609 " and h" +
1610 str( i +
1611 10 ) +
1612 "have failed" )
1613 i = 19
1614 PingResult = main.FALSE
1615 elif ping == main.TRUE:
1616 main.log.info( "Ping test between h" +
1617 str( i ) +
1618 " and h" +
1619 str( i +
1620 10 ) +
1621 "passed!" )
1622 i += 1
1623 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001624 else:
shahshreyafac62b12015-01-20 16:16:13 -08001625 main.log.info( "Unknown error" )
1626 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001627
shahshreyafac62b12015-01-20 16:16:13 -08001628 if PingResult == main.FALSE:
1629 main.log.report(
1630 "Point intents have not ben installed correctly. Cleaning up" )
1631 # main.cleanup()
1632 # main.exit()
1633 if PingResult == main.TRUE:
1634 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001635
shahshreyafac62b12015-01-20 16:16:13 -08001636 case9Result = PingResult
1637 utilities.assert_equals(
1638 expect=main.TRUE,
1639 actual=case9Result,
1640 onpass="Point intents addition and Pingall Test successful",
1641 onfail="Point intents addition and Pingall Test NOT successful" )