pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipI2: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 8 | # This case is to setup Mininet testbed |
| 9 | def CASE100( self, main ): |
| 10 | """ |
| 11 | Start mininet |
| 12 | """ |
| 13 | import os |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 14 | import imp |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 15 | main.log.case( "Start Mininet topology" ) |
| 16 | main.dependencyPath = main.testDir + \ |
| 17 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 18 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 19 | |
| 20 | main.step( "Starting Mininet Topology" ) |
| 21 | topology = main.dependencyPath + main.topology |
| 22 | topoResult = main.Mininet.startNet( topoFile = topology ) |
| 23 | stepResult = topoResult |
| 24 | utilities.assert_equals( expect = main.TRUE, |
| 25 | actual = stepResult, |
| 26 | onpass = "Successfully loaded topology", |
| 27 | onfail = "Failed to load topology" ) |
| 28 | # Exit if topology did not load properly |
| 29 | if not topoResult: |
| 30 | main.cleanup() |
| 31 | main.exit() |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 32 | |
| 33 | # This case is to setup ONOS |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 34 | def CASE101( self, main ): |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 35 | """ |
| 36 | CASE100 is to compile ONOS and install it |
| 37 | Startup sequence: |
| 38 | cell <name> |
| 39 | onos-verify-cell |
| 40 | git pull |
| 41 | mvn clean install |
| 42 | onos-package |
| 43 | onos-install -f |
| 44 | onos-wait-for-start |
| 45 | """ |
| 46 | import json |
| 47 | import time |
| 48 | from operator import eq |
| 49 | |
| 50 | main.case( "Setting up test environment" ) |
| 51 | |
| 52 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 53 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 54 | |
| 55 | main.step( "Applying cell variable to environment" ) |
| 56 | cellResult = main.ONOSbench.setCell( cellName ) |
| 57 | verifyResult = main.ONOSbench.verifyCell() |
| 58 | |
| 59 | branchName = main.ONOSbench.getBranchName() |
| 60 | main.log.info( "ONOS is on branch: " + branchName ) |
| 61 | |
| 62 | main.log.report( "Uninstalling ONOS" ) |
| 63 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 64 | |
| 65 | # cleanInstallResult = main.TRUE |
| 66 | # gitPullResult = main.TRUE |
| 67 | |
| 68 | main.step( "Git pull" ) |
| 69 | gitPullResult = main.ONOSbench.gitPull() |
| 70 | |
| 71 | main.step( "Using mvn clean install" ) |
| 72 | if gitPullResult == main.TRUE: |
| 73 | cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 ) |
| 74 | else: |
| 75 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 76 | "clean install" ) |
| 77 | cleanInstallResult = main.TRUE |
| 78 | |
| 79 | main.ONOSbench.getVersion( report = True ) |
| 80 | |
| 81 | main.step( "Creating ONOS package" ) |
| 82 | packageResult = main.ONOSbench.onosPackage( opTimeout = 500 ) |
| 83 | |
| 84 | main.step( "Installing ONOS package" ) |
| 85 | onos1InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 86 | node = ONOS1Ip ) |
| 87 | |
| 88 | main.step( "Checking if ONOS is up yet" ) |
| 89 | for i in range( 2 ): |
| 90 | onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 ) |
| 91 | if onos1Isup: |
| 92 | break |
| 93 | if not onos1Isup: |
| 94 | main.log.report( "ONOS1 didn't start!" ) |
| 95 | |
| 96 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
| 97 | commandlineTimeout = 100, onosStartTimeout = 600 ) |
| 98 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 99 | caseResult = ( cleanInstallResult and packageResult and |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 100 | cellResult and verifyResult and |
| 101 | onos1InstallResult and |
| 102 | onos1Isup and cliResult ) |
| 103 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 104 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 105 | onpass = "ONOS startup successful", |
| 106 | onfail = "ONOS startup NOT successful" ) |
| 107 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 108 | if caseResult == main.FALSE: |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 109 | main.cleanup() |
| 110 | main.exit() |
| 111 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 112 | main.step( "Get links in the network" ) |
| 113 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 114 | main.log.info( listResult ) |
| 115 | main.log.info( "Activate sdn-ip application" ) |
| 116 | main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 117 | |
| 118 | main.log.info( "Wait sdn-ip to finish installing connectivity intents, \ |
| 119 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 120 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 121 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 122 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 123 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 124 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 125 | |
| 126 | |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 127 | def CASE102( self, main ): |
| 128 | ''' |
| 129 | This test case is to load the methods from other Python files. |
| 130 | ''' |
| 131 | main.case( "Loading the methods from other Python file" ) |
| 132 | # load the methods from other file |
| 133 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 134 | main.Functions = imp.load_source( wrapperFile, |
| 135 | main.dependencyPath + |
| 136 | wrapperFile + |
| 137 | ".py" ) |
| 138 | |
| 139 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 140 | def CASE1( self, main ): |
| 141 | ''' |
| 142 | ping test from 3 bgp peers to BGP speaker |
| 143 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 144 | |
| 145 | m2SIntentsNumberActual = main.ONOScli.m2SIntentInstalledNumber() |
| 146 | main.log.info( "MultiPointToSinglePoint intent number actual is:" ) |
| 147 | main.log.info( m2SIntentsNumberActual ) |
| 148 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 149 | main.case( "This case is to check ping between BGP peers and speakers" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 150 | result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 151 | result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 152 | result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 153 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 154 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 155 | caseResult = result1 and result2 and result3 |
| 156 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 157 | onpass = "Speaker1 ping peers successful", |
| 158 | onfail = "Speaker1 ping peers NOT successful" ) |
| 159 | |
| 160 | if caseResult == main.FALSE: |
| 161 | main.cleanup() |
| 162 | main.exit() |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 163 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 164 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 165 | def CASE2( self, main ): |
| 166 | ''' |
| 167 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 168 | ''' |
| 169 | main.case( "This case is to check point-to-point intents" ) |
| 170 | main.log.info( "There are %s BGP peers in total " |
| 171 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 172 | main.step( "Get point-to-point intents from ONOS CLI" ) |
| 173 | |
| 174 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 175 | bgpIntentsActualNum = \ |
| 176 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 177 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
| 178 | main.log.info( "bgpIntentsExpected num is:" ) |
| 179 | main.log.info( bgpIntentsExpectedNum ) |
| 180 | main.log.info( "bgpIntentsActual num is:" ) |
| 181 | main.log.info( bgpIntentsActualNum ) |
| 182 | utilities.assertEquals( \ |
| 183 | expect = True, |
| 184 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 185 | onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***", |
| 186 | onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" ) |
| 187 | |
| 188 | |
| 189 | def CASE3( self, main ): |
| 190 | ''' |
| 191 | routes and intents check to all BGP peers |
| 192 | ''' |
| 193 | main.case( "This case is to check routes and intents to all BGP peers" ) |
| 194 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 195 | allRoutesExpected = [] |
| 196 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 197 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 198 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 199 | |
| 200 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 201 | allRoutesActual = \ |
| 202 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 203 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 204 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 205 | |
| 206 | main.step( "Check routes installed" ) |
| 207 | main.log.info( "Routes expected:" ) |
| 208 | main.log.info( allRoutesStrExpected ) |
| 209 | main.log.info( "Routes get from ONOS CLI:" ) |
| 210 | main.log.info( allRoutesStrActual ) |
| 211 | utilities.assertEquals( \ |
| 212 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 213 | onpass = "***Routes in SDN-IP are correct!***", |
| 214 | onfail = "***Routes in SDN-IP are wrong!***" ) |
| 215 | |
| 216 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 217 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 218 | routeIntentsActualNum = \ |
| 219 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 220 | routeIntentsExpectedNum = 3 |
| 221 | |
| 222 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 223 | main.log.info( routeIntentsExpectedNum ) |
| 224 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 225 | main.log.info( routeIntentsActualNum ) |
| 226 | utilities.assertEquals( \ |
| 227 | expect = True, |
| 228 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 229 | onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 230 | correct!***", |
| 231 | onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 232 | wrong!***" ) |
| 233 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 234 | |
| 235 | def CASE4( self, main ): |
| 236 | ''' |
| 237 | Ping test in data plane for each route |
| 238 | ''' |
| 239 | main.case( "This case is to check ping for each route" ) |
| 240 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 241 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 242 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 243 | |
| 244 | caseResult = result1 and result2 and result3 |
| 245 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 246 | onpass = "Ping test for each route successful", |
| 247 | onfail = "Ping test for each route NOT successful" ) |
| 248 | |
| 249 | if caseResult == main.FALSE: |
| 250 | main.cleanup() |
| 251 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 252 | |
| 253 | |
| 254 | def CASE5( self, main ): |
| 255 | ''' |
| 256 | Cut links to peers one by one, check routes/intents |
| 257 | ''' |
| 258 | import time |
| 259 | main.case( "This case is to bring down links and check routes/intents" ) |
| 260 | main.step( "Bring down the link between sw32 and peer64514" ) |
| 261 | result = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 262 | OPTION = "down" ) |
| 263 | if result == main.TRUE: |
| 264 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 265 | main.Functions.checkRouteNum( main, 2 ) |
| 266 | main.Functions.checkM2SintentNum( main, 2 ) |
| 267 | else: |
| 268 | main.log.info( "Bring down link failed!!!" ) |
| 269 | main.exit(); |
| 270 | |
| 271 | main.step( "Bring down the link between sw8 and peer64515" ) |
| 272 | result = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 273 | OPTION = "down" ) |
| 274 | if result == main.TRUE: |
| 275 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 276 | main.Functions.checkRouteNum( main, 1 ) |
| 277 | main.Functions.checkM2SintentNum( main, 1 ) |
| 278 | else: |
| 279 | main.log.info( "Bring down link failed!!!" ) |
| 280 | main.exit(); |
| 281 | |
| 282 | main.step( "Bring down the link between sw28 and peer64516" ) |
| 283 | result = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 284 | OPTION = "down" ) |
| 285 | if result == main.TRUE: |
| 286 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 287 | main.Functions.checkRouteNum( main, 0 ) |
| 288 | main.Functions.checkM2SintentNum( main, 0 ) |
| 289 | else: |
| 290 | main.log.info( "Bring down link failed!!!" ) |
| 291 | main.exit(); |
| 292 | |
| 293 | |
| 294 | def CASE6(self, main): |
| 295 | ''' |
| 296 | Recover links to peers one by one, check routes/intents |
| 297 | ''' |
| 298 | import time |
| 299 | main.case( "This case is to bring up links and check routes/intents" ) |
| 300 | main.step( "Bring up the link between sw32 and peer64514" ) |
| 301 | result = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 302 | OPTION = "up" ) |
| 303 | if result == main.TRUE: |
| 304 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 305 | main.Functions.checkRouteNum( main, 1 ) |
| 306 | main.Functions.checkM2SintentNum( main, 1 ) |
| 307 | else: |
| 308 | main.log.info( "Bring up link failed!!!" ) |
| 309 | main.exit(); |
| 310 | |
| 311 | main.step( "Bring up the link between sw8 and peer64515" ) |
| 312 | result = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 313 | OPTION = "up" ) |
| 314 | if result == main.TRUE: |
| 315 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 316 | main.Functions.checkRouteNum( main, 2 ) |
| 317 | main.Functions.checkM2SintentNum( main, 2 ) |
| 318 | else: |
| 319 | main.log.info( "Bring up link failed!!!" ) |
| 320 | main.exit(); |
| 321 | |
| 322 | main.step( "Bring up the link between sw28 and peer64516" ) |
| 323 | result = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 324 | OPTION = "up" ) |
| 325 | if result == main.TRUE: |
| 326 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 327 | main.Functions.checkRouteNum( main, 3 ) |
| 328 | main.Functions.checkM2SintentNum( main, 3 ) |
| 329 | else: |
| 330 | main.log.info( "Bring up link failed!!!" ) |
| 331 | main.exit(); |
| 332 | |
pingping-lin | 9563aec | 2015-09-16 17:20:07 -0700 | [diff] [blame^] | 333 | |
| 334 | def CASE20( self, main ): |
| 335 | ''' |
| 336 | ping test from 3 bgp peers to BGP speaker |
| 337 | ''' |
| 338 | main.case( "This case is to check ping between BGP peers and speakers" ) |
| 339 | result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 340 | result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 341 | result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 342 | |
| 343 | |
| 344 | caseResult = result1 or result2 or result3 |
| 345 | utilities.assert_equals( expect = main.FALSE, actual = caseResult, |
| 346 | onpass = "Speaker1 failed to ping all peers - Correct", |
| 347 | onfail = "Speaker1 did not fail to ping all peers- NOT Correct" ) |
| 348 | |
| 349 | if caseResult == main.TRUE: |
| 350 | main.cleanup() |
| 351 | main.exit() |
| 352 | |
| 353 | |
| 354 | def CASE21( self, main ): |
| 355 | ''' |
| 356 | Ping test in data plane for each route |
| 357 | ''' |
| 358 | main.case( "This case is to check ping for each route" ) |
| 359 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 360 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 361 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 362 | |
| 363 | caseResult = result1 or result2 or result3 |
| 364 | utilities.assert_equals( expect = main.FALSE, actual = caseResult, |
| 365 | onpass = "Ping test for all routes failed- Correct", |
| 366 | onfail = "Ping test for all routes NOT failed- NOT Correct" ) |
| 367 | |
| 368 | if caseResult == main.TRUE: |
| 369 | main.cleanup() |
| 370 | main.exit() |
| 371 | |