pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipFunction_fsfw: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
| 8 | # This case is to setup Mininet testbed |
| 9 | def CASE100( self, main ): |
| 10 | """ |
| 11 | Start mininet |
| 12 | """ |
| 13 | import os |
| 14 | import imp |
| 15 | main.log.case( "Setup the Mininet testbed" ) |
| 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 | utilities.assert_equals( expect = main.TRUE, |
| 24 | actual = topoResult, |
| 25 | onpass = "Successfully loaded topology", |
| 26 | onfail = "Failed to load topology" ) |
| 27 | # Exit if topology did not load properly |
| 28 | if not topoResult: |
| 29 | main.cleanup() |
| 30 | main.exit() |
pingping-lin | 1477663 | 2015-12-16 12:05:30 -0800 | [diff] [blame] | 31 | main.step( "Connect switches to FSFW" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 32 | |
| 33 | global ONOS1Ip |
| 34 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
pingping-lin | 8c17880 | 2015-11-30 17:25:43 -0800 | [diff] [blame] | 35 | global fsfwIp |
pingping-lin | e9107e4 | 2015-11-30 19:19:38 -0800 | [diff] [blame] | 36 | # TDOO: there is some setup sequence issue, will fix it later |
| 37 | # fsfwIp = os.getenv( main.params[ 'CTRL' ][ 'ipN' ] ) |
| 38 | fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ] |
pingping-lin | 15fa4be | 2015-11-30 18:27:58 -0800 | [diff] [blame] | 39 | global fsfwPort |
pingping-lin | e9107e4 | 2015-11-30 19:19:38 -0800 | [diff] [blame] | 40 | fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ] |
pingping-lin | 8c17880 | 2015-11-30 17:25:43 -0800 | [diff] [blame] | 41 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 42 | # connect all switches to controller |
| 43 | swResult = main.TRUE |
| 44 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 45 | sw = "sw%s" % ( i ) |
pingping-lin | 15fa4be | 2015-11-30 18:27:58 -0800 | [diff] [blame] | 46 | swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp, |
| 47 | port = fsfwPort ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 48 | utilities.assert_equals( expect = main.TRUE, |
| 49 | actual = swResult, |
| 50 | onpass = "Successfully connect all switches to ONOS", |
| 51 | onfail = "Failed to connect all switches to ONOS" ) |
| 52 | if not swResult: |
| 53 | main.cleanup() |
| 54 | main.exit() |
| 55 | |
| 56 | main.step( "Set up tunnel from Mininet node to onos node" ) |
| 57 | forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip ) |
| 58 | command = 'ssh -nNT -o "PasswordAuthentication no" \ |
| 59 | -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip ) |
| 60 | |
| 61 | tunnelResult = main.TRUE |
| 62 | tunnelResult = main.Mininet.node( "root", command ) |
| 63 | utilities.assert_equals( expect = True, |
| 64 | actual = ( "PasswordAuthentication" in tunnelResult ), |
| 65 | onpass = "Created tunnel succeeded", |
| 66 | onfail = "Create tunnel failed" ) |
| 67 | if ("PasswordAuthentication" not in tunnelResult) : |
| 68 | main.cleanup() |
| 69 | main.exit() |
| 70 | |
| 71 | |
| 72 | # This case is to setup ONOS |
| 73 | def CASE101( self, main ): |
| 74 | """ |
| 75 | Package ONOS and install it |
| 76 | Startup sequence: |
| 77 | cell <name> |
| 78 | onos-verify-cell |
| 79 | onos-package |
| 80 | onos-install -f |
| 81 | onos-wait-for-start |
| 82 | """ |
| 83 | import json |
| 84 | import time |
| 85 | from operator import eq |
| 86 | |
| 87 | main.case( "Setting up test environment" ) |
| 88 | |
| 89 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 90 | |
| 91 | main.step( "Applying cell variable to environment" ) |
| 92 | cellResult = main.ONOSbench.setCell( cellName ) |
| 93 | utilities.assert_equals( expect = main.TRUE, |
| 94 | actual = cellResult, |
| 95 | onpass = "Set cell succeeded", |
| 96 | onfail = "Set cell failed" ) |
| 97 | |
| 98 | verifyResult = main.ONOSbench.verifyCell() |
| 99 | utilities.assert_equals( expect = main.TRUE, |
| 100 | actual = verifyResult, |
| 101 | onpass = "Verify cell succeeded", |
| 102 | onfail = "Verify cell failed" ) |
| 103 | |
| 104 | branchName = main.ONOSbench.getBranchName() |
| 105 | main.log.report( "ONOS is on branch: " + branchName ) |
| 106 | |
| 107 | main.log.step( "Uninstalling ONOS" ) |
| 108 | uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 109 | utilities.assert_equals( expect = main.TRUE, |
| 110 | actual = uninstallResult, |
| 111 | onpass = "Uninstall ONOS succeeded", |
| 112 | onfail = "Uninstall ONOS failed" ) |
| 113 | ''' |
| 114 | main.step( "Git pull" ) |
| 115 | gitPullResult = main.ONOSbench.gitPull() |
| 116 | main.log.info( "gitPullResult" ) |
| 117 | main.log.info( gitPullResult ) |
| 118 | gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 ) |
| 119 | utilities.assert_equals( expect = True, |
| 120 | actual = gitPullResult2, |
| 121 | onpass = "Git pull ONOS succeeded", |
| 122 | onfail = "Git pull ONOS failed" ) |
| 123 | |
| 124 | main.step( "Using mvn clean install" ) |
| 125 | if gitPullResult == main.TRUE: |
| 126 | mciResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 ) |
| 127 | utilities.assert_equals( expect = main.TRUE, |
| 128 | actual = mciResult, |
| 129 | onpass = "Maven clean install ONOS succeeded", |
| 130 | onfail = "Maven clean install ONOS failed" ) |
| 131 | else: |
| 132 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 133 | "clean install" ) |
| 134 | mciResult = main.TRUE |
| 135 | ''' |
| 136 | |
| 137 | main.ONOSbench.getVersion( report = True ) |
| 138 | |
| 139 | main.step( "Creating ONOS package" ) |
| 140 | packageResult = main.ONOSbench.onosPackage( opTimeout = 500 ) |
| 141 | utilities.assert_equals( expect = main.TRUE, |
| 142 | actual = packageResult, |
| 143 | onpass = "Package ONOS succeeded", |
| 144 | onfail = "Package ONOS failed" ) |
| 145 | |
| 146 | main.step( "Installing ONOS package" ) |
| 147 | onos1InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 148 | node = ONOS1Ip ) |
| 149 | utilities.assert_equals( expect = main.TRUE, |
| 150 | actual = onos1InstallResult, |
| 151 | onpass = "Install ONOS succeeded", |
| 152 | onfail = "Install ONOS failed" ) |
| 153 | |
| 154 | main.step( "Checking if ONOS is up yet" ) |
| 155 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 ) |
| 156 | utilities.assert_equals( expect = main.TRUE, |
| 157 | actual = onos1UpResult, |
| 158 | onpass = "ONOS is up", |
| 159 | onfail = "ONOS is NOT up" ) |
| 160 | |
| 161 | main.step( "Checking if ONOS CLI is ready" ) |
| 162 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
| 163 | commandlineTimeout = 100, onosStartTimeout = 600 ) |
| 164 | utilities.assert_equals( expect = main.TRUE, |
| 165 | actual = cliResult, |
| 166 | onpass = "ONOS CLI is ready", |
| 167 | onfail = "ONOS CLI is NOT ready" ) |
| 168 | |
| 169 | caseResult = ( cellResult and verifyResult and |
| 170 | packageResult and |
| 171 | onos1InstallResult and onos1UpResult and cliResult ) |
| 172 | |
| 173 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 174 | onpass = "ONOS startup successful", |
| 175 | onfail = "ONOS startup NOT successful" ) |
| 176 | |
| 177 | if caseResult == main.FALSE: |
| 178 | main.log.info( "ONOS startup failed!" ) |
| 179 | main.cleanup() |
| 180 | main.exit() |
| 181 | |
| 182 | main.log.info( "Get links in the network" ) |
| 183 | time.sleep( int ( main.params['timers']['TopoDiscovery'] ) ) |
| 184 | summaryResult = main.ONOScli.summary() |
| 185 | linkNum = json.loads( summaryResult )[ "links" ] |
| 186 | if linkNum < 100: |
| 187 | main.log.info( "Link number is wrong!" ) |
| 188 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 189 | main.log.info( listResult ) |
| 190 | main.cleanup() |
| 191 | main.exit() |
| 192 | |
| 193 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 194 | main.log.info( listResult ) |
| 195 | |
| 196 | main.step( "Activate sdn-ip application" ) |
| 197 | activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
| 198 | utilities.assert_equals( expect = main.TRUE, |
| 199 | actual = activeSDNIPresult, |
| 200 | onpass = "Activate SDN-IP succeeded", |
| 201 | onfail = "Activate SDN-IP failed" ) |
| 202 | if not activeSDNIPresult: |
| 203 | main.log.info( "Activate SDN-IP failed!" ) |
| 204 | main.cleanup() |
| 205 | main.exit() |
| 206 | |
| 207 | |
| 208 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
| 209 | and the BGP paths in data plane are ready..." ) |
| 210 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
| 211 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 212 | other and to sdn-ip, plus finish installing all intents..." ) |
| 213 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 214 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 215 | |
| 216 | |
| 217 | def CASE102( self, main ): |
| 218 | ''' |
| 219 | This test case is to load the methods from other Python files. |
| 220 | ''' |
| 221 | main.case( "Loading methods from other Python file" ) |
| 222 | # load the methods from other file |
| 223 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 224 | main.Functions = imp.load_source( wrapperFile, |
| 225 | main.dependencyPath + |
| 226 | wrapperFile + |
| 227 | ".py" ) |
| 228 | |
| 229 | |
| 230 | def CASE1( self, main ): |
| 231 | ''' |
| 232 | ping test from 3 bgp peers to BGP speaker |
| 233 | ''' |
| 234 | |
| 235 | main.case( "Ping tests between BGP peers and speakers" ) |
| 236 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 237 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 238 | expectAllSuccess = True ) |
| 239 | |
| 240 | |
| 241 | def CASE2( self, main ): |
| 242 | ''' |
| 243 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 244 | ''' |
| 245 | main.case( "Check point-to-point intents" ) |
| 246 | main.log.info( "There are %s BGP peers in total " |
| 247 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 248 | main.step( "Check P2P intents number from ONOS CLI" ) |
| 249 | |
| 250 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 251 | bgpIntentsActualNum = \ |
| 252 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 253 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
| 254 | main.log.info( "bgpIntentsExpected num is:" ) |
| 255 | main.log.info( bgpIntentsExpectedNum ) |
| 256 | main.log.info( "bgpIntentsActual num is:" ) |
| 257 | main.log.info( bgpIntentsActualNum ) |
| 258 | utilities.assertEquals( \ |
| 259 | expect = True, |
| 260 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 261 | onpass = "PointToPointIntent Intent Num is correct!", |
| 262 | onfail = "PointToPointIntent Intent Num is wrong!" ) |
| 263 | |
| 264 | |
| 265 | def CASE3( self, main ): |
| 266 | ''' |
| 267 | routes and intents check to all BGP peers |
| 268 | ''' |
| 269 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 270 | |
| 271 | allRoutesExpected = [] |
| 272 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 273 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 274 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 275 | |
| 276 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 277 | allRoutesActual = \ |
| 278 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 279 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 280 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 281 | |
| 282 | main.step( "Check routes installed" ) |
| 283 | main.log.info( "Routes expected:" ) |
| 284 | main.log.info( allRoutesStrExpected ) |
| 285 | main.log.info( "Routes get from ONOS CLI:" ) |
| 286 | main.log.info( allRoutesStrActual ) |
| 287 | utilities.assertEquals( \ |
| 288 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 289 | onpass = "Routes are correct!", |
| 290 | onfail = "Routes are wrong!" ) |
| 291 | |
| 292 | main.step( "Check M2S intents installed" ) |
| 293 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 294 | routeIntentsActualNum = \ |
| 295 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 296 | routeIntentsExpectedNum = 3 |
| 297 | |
| 298 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 299 | main.log.info( routeIntentsExpectedNum ) |
| 300 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 301 | main.log.info( routeIntentsActualNum ) |
| 302 | utilities.assertEquals( \ |
| 303 | expect = True, |
| 304 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 305 | onpass = "MultiPointToSinglePoint Intent Num is correct!", |
| 306 | onfail = "MultiPointToSinglePoint Intent Num is wrong!" ) |
| 307 | |
| 308 | main.step( "Check whether all flow status are ADDED" ) |
| 309 | utilities.assertEquals( \ |
| 310 | expect = main.TRUE, |
| 311 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 312 | onpass = "Flow status is correct!", |
| 313 | onfail = "Flow status is wrong!" ) |
| 314 | |
| 315 | |
| 316 | def CASE4( self, main ): |
| 317 | ''' |
| 318 | Ping test in data plane for each route |
| 319 | ''' |
| 320 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 321 | main.Functions.pingHostToHost( main, |
| 322 | hosts = ["host64514", "host64515", "host64516"], |
| 323 | expectAllSuccess = True ) |
| 324 | |
| 325 | |
| 326 | def CASE5( self, main ): |
| 327 | ''' |
| 328 | Cut links to peers one by one, check routes/intents |
| 329 | ''' |
| 330 | import time |
| 331 | main.case( "Bring down links and check routes/intents" ) |
| 332 | main.step( "Bring down the link between sw32 and peer64514" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 333 | linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "pr64514", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 334 | OPTION = "down" ) |
| 335 | utilities.assertEquals( expect = main.TRUE, |
| 336 | actual = linkResult1, |
| 337 | onpass = "Bring down link succeeded!", |
| 338 | onfail = "Bring down link failed!" ) |
| 339 | |
| 340 | if linkResult1 == main.TRUE: |
| 341 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 342 | main.Functions.checkRouteNum( main, 2 ) |
| 343 | main.Functions.checkM2SintentNum( main, 2 ) |
| 344 | else: |
| 345 | main.log.info( "Bring down link failed!" ) |
| 346 | main.cleanup() |
| 347 | main.exit() |
| 348 | |
| 349 | main.step( "Bring down the link between sw8 and peer64515" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 350 | linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "pr64515", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 351 | OPTION = "down" ) |
| 352 | utilities.assertEquals( expect = main.TRUE, |
| 353 | actual = linkResult2, |
| 354 | onpass = "Bring down link succeeded!", |
| 355 | onfail = "Bring down link failed!" ) |
| 356 | if linkResult2 == main.TRUE: |
| 357 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 358 | main.Functions.checkRouteNum( main, 1 ) |
| 359 | main.Functions.checkM2SintentNum( main, 1 ) |
| 360 | else: |
| 361 | main.log.info( "Bring down link failed!" ) |
| 362 | main.cleanup() |
| 363 | main.exit() |
| 364 | |
| 365 | main.step( "Bring down the link between sw28 and peer64516" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 366 | linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "pr64516", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 367 | OPTION = "down" ) |
| 368 | utilities.assertEquals( expect = main.TRUE, |
| 369 | actual = linkResult3, |
| 370 | onpass = "Bring down link succeeded!", |
| 371 | onfail = "Bring down link failed!" ) |
| 372 | if linkResult3 == main.TRUE: |
| 373 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 374 | main.Functions.checkRouteNum( main, 0 ) |
| 375 | main.Functions.checkM2SintentNum( main, 0 ) |
| 376 | else: |
| 377 | main.log.info( "Bring down link failed!" ) |
| 378 | main.cleanup() |
| 379 | main.exit() |
| 380 | |
| 381 | main.step( "Check whether all flow status are ADDED" ) |
| 382 | utilities.assertEquals( \ |
| 383 | expect = main.TRUE, |
| 384 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 385 | onpass = "Flow status is correct!", |
| 386 | onfail = "Flow status is wrong!" ) |
| 387 | |
| 388 | # Ping test |
| 389 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 390 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 391 | expectAllSuccess = False ) |
| 392 | main.Functions.pingHostToHost( main, |
| 393 | hosts = ["host64514", "host64515", "host64516"], |
| 394 | expectAllSuccess = False ) |
| 395 | |
| 396 | |
| 397 | def CASE6( self, main ): |
| 398 | ''' |
| 399 | Recover links to peers one by one, check routes/intents |
| 400 | ''' |
| 401 | import time |
| 402 | main.case( "Bring up links and check routes/intents" ) |
| 403 | main.step( "Bring up the link between sw32 and peer64514" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 404 | linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "pr64514", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 405 | OPTION = "up" ) |
| 406 | utilities.assertEquals( expect = main.TRUE, |
| 407 | actual = linkResult1, |
| 408 | onpass = "Bring up link succeeded!", |
| 409 | onfail = "Bring up link failed!" ) |
| 410 | if linkResult1 == main.TRUE: |
| 411 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 412 | main.Functions.checkRouteNum( main, 1 ) |
| 413 | main.Functions.checkM2SintentNum( main, 1 ) |
| 414 | else: |
| 415 | main.log.info( "Bring up link failed!" ) |
| 416 | main.cleanup() |
| 417 | main.exit() |
| 418 | |
| 419 | main.step( "Bring up the link between sw8 and peer64515" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 420 | linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "pr64515", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 421 | OPTION = "up" ) |
| 422 | utilities.assertEquals( expect = main.TRUE, |
| 423 | actual = linkResult2, |
| 424 | onpass = "Bring up link succeeded!", |
| 425 | onfail = "Bring up link failed!" ) |
| 426 | if linkResult2 == main.TRUE: |
| 427 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 428 | main.Functions.checkRouteNum( main, 2 ) |
| 429 | main.Functions.checkM2SintentNum( main, 2 ) |
| 430 | else: |
| 431 | main.log.info( "Bring up link failed!" ) |
| 432 | main.cleanup() |
| 433 | main.exit() |
| 434 | |
| 435 | main.step( "Bring up the link between sw28 and peer64516" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 436 | linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "pr64516", |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 437 | OPTION = "up" ) |
| 438 | utilities.assertEquals( expect = main.TRUE, |
| 439 | actual = linkResult3, |
| 440 | onpass = "Bring up link succeeded!", |
| 441 | onfail = "Bring up link failed!" ) |
| 442 | if linkResult3 == main.TRUE: |
| 443 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 444 | main.Functions.checkRouteNum( main, 3 ) |
| 445 | main.Functions.checkM2SintentNum( main, 3 ) |
| 446 | else: |
| 447 | main.log.info( "Bring up link failed!" ) |
| 448 | main.cleanup() |
| 449 | main.exit() |
| 450 | |
| 451 | main.step( "Check whether all flow status are ADDED" ) |
| 452 | utilities.assertEquals( \ |
| 453 | expect = main.TRUE, |
| 454 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 455 | onpass = "Flow status is correct!", |
| 456 | onfail = "Flow status is wrong!" ) |
| 457 | |
| 458 | # Ping test |
| 459 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 460 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 461 | expectAllSuccess = True ) |
| 462 | main.Functions.pingHostToHost( main, |
| 463 | hosts = ["host64514", "host64515", "host64516"], |
| 464 | expectAllSuccess = True ) |
| 465 | |
| 466 | |
| 467 | def CASE7( self, main ): |
| 468 | ''' |
| 469 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 470 | ''' |
| 471 | import time |
| 472 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 473 | main.step( "Stop sw32" ) |
| 474 | result = main.Mininet.switch( SW = "sw32", OPTION = "stop" ) |
| 475 | utilities.assertEquals( expect = main.TRUE, actual = result, |
| 476 | onpass = "Stopping switch succeeded!", |
| 477 | onfail = "Stopping switch failed!" ) |
| 478 | |
| 479 | if result == main.TRUE: |
| 480 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 481 | main.Functions.checkRouteNum( main, 2 ) |
| 482 | main.Functions.checkM2SintentNum( main, 2 ) |
| 483 | main.Functions.checkP2PintentNum( main, 12 ) |
| 484 | else: |
| 485 | main.log.info( "Stopping switch failed!" ) |
| 486 | main.cleanup() |
| 487 | main.exit() |
| 488 | |
| 489 | main.step( "Check ping between hosts behind BGP peers" ) |
| 490 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 491 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 492 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 493 | |
| 494 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 495 | and ( result3 == main.FALSE ) |
| 496 | utilities.assert_equals( expect = True, actual = pingResult1, |
| 497 | onpass = "Ping test result is correct", |
| 498 | onfail = "Ping test result is wrong" ) |
| 499 | |
| 500 | if pingResult1 == False: |
| 501 | main.cleanup() |
| 502 | main.exit() |
| 503 | |
| 504 | main.step( "Check ping between BGP peers and speakers" ) |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 505 | result4 = main.Mininet.pingHost( src = "speaker1", target = "pr64514" ) |
| 506 | result5 = main.Mininet.pingHost( src = "speaker1", target = "pr64515" ) |
| 507 | result6 = main.Mininet.pingHost( src = "speaker1", target = "pr64516" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 508 | |
| 509 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 510 | and ( result6 == main.TRUE ) |
| 511 | utilities.assert_equals( expect = True, actual = pingResult2, |
| 512 | onpass = "Speaker1 ping peers successful", |
| 513 | onfail = "Speaker1 ping peers NOT successful" ) |
| 514 | |
| 515 | if pingResult2 == False: |
| 516 | main.cleanup() |
| 517 | main.exit() |
| 518 | |
| 519 | main.step( "Check whether all flow status are ADDED" ) |
| 520 | utilities.assertEquals( \ |
| 521 | expect = main.TRUE, |
| 522 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 523 | onpass = "Flow status is correct!", |
| 524 | onfail = "Flow status is wrong!" ) |
| 525 | |
| 526 | |
| 527 | def CASE8( self, main ): |
| 528 | ''' |
| 529 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 530 | check P-2-P and M-2-S intents, ping test |
| 531 | ''' |
| 532 | import time |
| 533 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 534 | main.step( "Start sw32" ) |
| 535 | result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" ) |
| 536 | utilities.assertEquals( \ |
| 537 | expect = main.TRUE, |
| 538 | actual = result1, |
| 539 | onpass = "Starting switch succeeded!", |
| 540 | onfail = "Starting switch failed!" ) |
| 541 | |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 542 | result2 = main.Mininet.assignSwController( "sw32", fsfwIp, |
| 543 | port = fsfwPort ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 544 | utilities.assertEquals( \ |
| 545 | expect = main.TRUE, |
| 546 | actual = result2, |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 547 | onpass = "Connect switch to FSFW succeeded!", |
| 548 | onfail = "Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 549 | |
| 550 | if result1 and result2: |
| 551 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 552 | main.Functions.checkRouteNum( main, 3 ) |
| 553 | main.Functions.checkM2SintentNum( main, 3 ) |
| 554 | main.Functions.checkP2PintentNum( main, 18 ) |
| 555 | else: |
| 556 | main.log.info( "Starting switch failed!" ) |
| 557 | main.cleanup() |
| 558 | main.exit() |
| 559 | |
| 560 | main.step( "Check whether all flow status are ADDED" ) |
| 561 | utilities.assertEquals( \ |
| 562 | expect = main.TRUE, |
| 563 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 564 | onpass = "Flow status is correct!", |
| 565 | onfail = "Flow status is wrong!" ) |
| 566 | |
| 567 | # Ping test |
| 568 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 569 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 570 | expectAllSuccess = True ) |
| 571 | main.Functions.pingHostToHost( main, |
| 572 | hosts = ["host64514", "host64515", "host64516"], |
| 573 | expectAllSuccess = True ) |
| 574 | |
| 575 | |
| 576 | def CASE9( self, main ): |
| 577 | ''' |
| 578 | Bring down a switch in best path, check: |
| 579 | route number, P2P intent number, M2S intent number, ping test |
| 580 | ''' |
| 581 | main.case( "Stop sw11 located in best path, \ |
| 582 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 583 | |
| 584 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
| 585 | main.Functions.checkFlowNum( main, "sw11", 13 ) |
| 586 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 587 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 588 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 589 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 590 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 591 | |
| 592 | main.step( "Stop sw11" ) |
| 593 | result = main.Mininet.switch( SW = "sw11", OPTION = "stop" ) |
| 594 | utilities.assertEquals( expect = main.TRUE, actual = result, |
| 595 | onpass = "Stopping switch succeeded!", |
| 596 | onfail = "Stopping switch failed!" ) |
| 597 | if result: |
| 598 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 599 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 600 | main.Functions.checkRouteNum( main, 3 ) |
| 601 | main.Functions.checkM2SintentNum( main, 3 ) |
| 602 | main.Functions.checkP2PintentNum( main, 18 ) |
| 603 | else: |
| 604 | main.log.info( "Stopping switch failed!" ) |
| 605 | main.cleanup() |
| 606 | main.exit() |
| 607 | |
| 608 | main.step( "Check whether all flow status are ADDED" ) |
| 609 | utilities.assertEquals( \ |
| 610 | expect = main.TRUE, |
| 611 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 612 | onpass = "Flow status is correct!", |
| 613 | onfail = "Flow status is wrong!" ) |
| 614 | # Ping test |
| 615 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 616 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 617 | expectAllSuccess = True ) |
| 618 | main.Functions.pingHostToHost( main, |
| 619 | hosts = ["host64514", "host64515", "host64516"], |
| 620 | expectAllSuccess = True ) |
| 621 | |
| 622 | |
| 623 | def CASE10( self, main ): |
| 624 | ''' |
| 625 | Bring up the switch which was stopped in CASE9, check: |
| 626 | route number, P2P intent number, M2S intent number, ping test |
| 627 | ''' |
| 628 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 629 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 630 | |
| 631 | main.log.info( "Check the flow status before starting sw11" ) |
| 632 | main.Functions.checkFlowNum( main, "sw1", 11 ) |
| 633 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 634 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 635 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 636 | |
| 637 | main.step( "Start sw11" ) |
| 638 | result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" ) |
| 639 | utilities.assertEquals( expect = main.TRUE, actual = result1, |
| 640 | onpass = "Starting switch succeeded!", |
| 641 | onfail = "Starting switch failed!" ) |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 642 | result2 = main.Mininet.assignSwController( "sw11", fsfwIp, |
| 643 | port = fsfwPort ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 644 | utilities.assertEquals( expect = main.TRUE, actual = result2, |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 645 | onpass = "Connect switch to FSFW succeeded!", |
| 646 | onfail = "Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 647 | if result1 and result2: |
| 648 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 649 | main.Functions.checkRouteNum( main, 3 ) |
| 650 | main.Functions.checkM2SintentNum( main, 3 ) |
| 651 | main.Functions.checkP2PintentNum( main, 18 ) |
| 652 | |
| 653 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 654 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 655 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 656 | else: |
| 657 | main.log.info( "Starting switch failed!" ) |
| 658 | main.cleanup() |
| 659 | main.exit() |
| 660 | |
| 661 | main.step( "Check whether all flow status are ADDED" ) |
| 662 | utilities.assertEquals( \ |
| 663 | expect = main.TRUE, |
| 664 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 665 | onpass = "Flow status is correct!", |
| 666 | onfail = "Flow status is wrong!" ) |
| 667 | # Ping test |
| 668 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
pingping-lin | 8a6070a | 2015-12-15 17:55:17 -0800 | [diff] [blame] | 669 | peers = ["pr64514", "pr64515", "pr64516"], |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 670 | expectAllSuccess = True ) |
| 671 | main.Functions.pingHostToHost( main, |
| 672 | hosts = ["host64514", "host64515", "host64516"], |
| 673 | expectAllSuccess = True ) |