pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame^] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipFunctionCluster: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
| 8 | def CASE100( self, main ): |
| 9 | """ |
| 10 | Start mininet |
| 11 | """ |
| 12 | import imp |
| 13 | main.log.case( "Setup the Mininet testbed" ) |
| 14 | main.dependencyPath = main.testDir + \ |
| 15 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 16 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 17 | |
| 18 | main.step( "Starting Mininet Topology" ) |
| 19 | topology = main.dependencyPath + main.topology |
| 20 | topoResult = main.Mininet.startNet( topoFile = topology ) |
| 21 | utilities.assert_equals( expect = main.TRUE, |
| 22 | actual = topoResult, |
| 23 | onpass = "Successfully loaded topology", |
| 24 | onfail = "Failed to load topology" ) |
| 25 | # Exit if topology did not load properly |
| 26 | if not topoResult: |
| 27 | main.cleanup() |
| 28 | main.exit() |
| 29 | main.step( "Connect switches to controllers" ) |
| 30 | |
| 31 | # connect all switches to controllers |
| 32 | swResult = main.TRUE |
| 33 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 34 | sw = "sw%s" % ( i ) |
| 35 | swResult = swResult and main.Mininet.assignSwController( sw, |
| 36 | [ONOS1Ip, ONOS2Ip, ONOS3Ip] ) |
| 37 | |
| 38 | utilities.assert_equals( expect = main.TRUE, |
| 39 | actual = swResult, |
| 40 | onpass = "Successfully connect all switches to ONOS", |
| 41 | onfail = "Failed to connect all switches to ONOS" ) |
| 42 | if not swResult: |
| 43 | main.cleanup() |
| 44 | main.exit() |
| 45 | |
| 46 | |
| 47 | def CASE101( self, main ): |
| 48 | """ |
| 49 | Package ONOS and install it |
| 50 | Startup sequence: |
| 51 | cell <name> |
| 52 | onos-verify-cell |
| 53 | onos-package |
| 54 | onos-install -f |
| 55 | onos-wait-for-start |
| 56 | """ |
| 57 | import json |
| 58 | import time |
| 59 | import os |
| 60 | from operator import eq |
| 61 | |
| 62 | main.case( "Setting up ONOS environment" ) |
| 63 | |
| 64 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 65 | global ONOS1Ip |
| 66 | global ONOS2Ip |
| 67 | global ONOS3Ip |
| 68 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 69 | ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] ) |
| 70 | ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] ) |
| 71 | |
| 72 | global peer64514 |
| 73 | global peer64515 |
| 74 | global peer64516 |
| 75 | peer64514 = main.params['config']['peer64514'] |
| 76 | peer64515 = main.params['config']['peer64515'] |
| 77 | peer64516 = main.params['config']['peer64516'] |
| 78 | |
| 79 | main.step( "Applying cell variable to environment" ) |
| 80 | cellResult = main.ONOSbench.setCell( cellName ) |
| 81 | utilities.assert_equals( expect = main.TRUE, |
| 82 | actual = cellResult, |
| 83 | onpass = "Set cell succeeded", |
| 84 | onfail = "Set cell failed" ) |
| 85 | |
| 86 | verifyResult = main.ONOSbench.verifyCell() |
| 87 | utilities.assert_equals( expect = main.TRUE, |
| 88 | actual = verifyResult, |
| 89 | onpass = "Verify cell succeeded", |
| 90 | onfail = "Verify cell failed" ) |
| 91 | |
| 92 | branchName = main.ONOSbench.getBranchName() |
| 93 | main.log.report( "ONOS is on branch: " + branchName ) |
| 94 | |
| 95 | main.log.step( "Uninstalling ONOS" ) |
| 96 | uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \ |
| 97 | and main.ONOSbench.onosUninstall( ONOS2Ip ) \ |
| 98 | and main.ONOSbench.onosUninstall( ONOS3Ip ) |
| 99 | utilities.assert_equals( expect = main.TRUE, |
| 100 | actual = uninstallResult, |
| 101 | onpass = "Uninstall ONOS from nodes succeeded", |
| 102 | onfail = "Uninstall ONOS form nodes failed" ) |
| 103 | |
| 104 | main.ONOSbench.getVersion( report = True ) |
| 105 | |
| 106 | main.step( "Creating ONOS package" ) |
| 107 | packageResult = main.ONOSbench.onosPackage( opTimeout = 500 ) |
| 108 | utilities.assert_equals( expect = main.TRUE, |
| 109 | actual = packageResult, |
| 110 | onpass = "Package ONOS succeeded", |
| 111 | onfail = "Package ONOS failed" ) |
| 112 | |
| 113 | main.step( "Installing ONOS package" ) |
| 114 | onos1InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 115 | node = ONOS1Ip ) |
| 116 | onos2InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 117 | node = ONOS2Ip ) |
| 118 | onos3InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 119 | node = ONOS3Ip ) |
| 120 | onosInstallResult = onos1InstallResult and onos2InstallResult \ |
| 121 | and onos3InstallResult |
| 122 | utilities.assert_equals( expect = main.TRUE, |
| 123 | actual = onosInstallResult, |
| 124 | onpass = "Install ONOS to nodes succeeded", |
| 125 | onfail = "Install ONOS to nodes failed" ) |
| 126 | |
| 127 | main.step( "Checking if ONOS is up yet" ) |
| 128 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 ) |
| 129 | onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout = 420 ) |
| 130 | onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout = 420 ) |
| 131 | onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult |
| 132 | utilities.assert_equals( expect = main.TRUE, |
| 133 | actual = onos1UpResult and onosUpResult, |
| 134 | onpass = "ONOS nodes are up", |
| 135 | onfail = "ONOS nodes are NOT up" ) |
| 136 | |
| 137 | main.step( "Checking if ONOS CLI is ready" ) |
| 138 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
| 139 | commandlineTimeout = 100, onosStartTimeout = 600 ) |
| 140 | utilities.assert_equals( expect = main.TRUE, |
| 141 | actual = cliResult, |
| 142 | onpass = "ONOS CLI (on node1) is ready", |
| 143 | onfail = "ONOS CLI (on node1) ready" ) |
| 144 | |
| 145 | caseResult = ( cellResult and verifyResult and |
| 146 | packageResult and |
| 147 | onosInstallResult and onosUpResult and cliResult ) |
| 148 | |
| 149 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 150 | onpass = "ONOS startup successful", |
| 151 | onfail = "ONOS startup NOT successful" ) |
| 152 | |
| 153 | if caseResult == main.FALSE: |
| 154 | main.log.error( "ONOS startup failed!" ) |
| 155 | main.cleanup() |
| 156 | main.exit() |
| 157 | |
| 158 | |
| 159 | def CASE200( self, main ): |
| 160 | main.case( "Activate sdn-ip application" ) |
| 161 | main.log.info( "waiting link discovery......" ) |
| 162 | time.sleep( int ( main.params['timers']['TopoDiscovery'] ) ) |
| 163 | |
| 164 | main.log.info( "Get links in the network" ) |
| 165 | summaryResult = main.ONOScli.summary() |
| 166 | linkNum = json.loads( summaryResult )[ "links" ] |
| 167 | if linkNum < 100: |
| 168 | main.log.error( "Link number is wrong!" ) |
| 169 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 170 | main.log.info( listResult ) |
| 171 | main.cleanup() |
| 172 | main.exit() |
| 173 | |
| 174 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 175 | main.log.info( listResult ) |
| 176 | |
| 177 | main.step( "Activate sdn-ip application" ) |
| 178 | activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
| 179 | utilities.assert_equals( expect = main.TRUE, |
| 180 | actual = activeSDNIPresult, |
| 181 | onpass = "Activate SDN-IP succeeded", |
| 182 | onfail = "Activate SDN-IP failed" ) |
| 183 | if not activeSDNIPresult: |
| 184 | main.cleanup() |
| 185 | main.exit() |
| 186 | |
| 187 | # TODO should be deleted in the future after the SDN-IP bug is fixed |
| 188 | main.ONOScli.deactivateApp( "org.onosproject.sdnip" ) |
| 189 | main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
| 190 | |
| 191 | |
| 192 | def CASE102( self, main ): |
| 193 | ''' |
| 194 | This test case is to load the methods from other Python files, and create |
| 195 | tunnels from mininet host to onos nodes. |
| 196 | ''' |
| 197 | import time |
| 198 | main.case( "Load methods from other Python file and create tunnels" ) |
| 199 | # load the methods from other file |
| 200 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 201 | main.Functions = imp.load_source( wrapperFile1, |
| 202 | main.dependencyPath + |
| 203 | wrapperFile1 + |
| 204 | ".py" ) |
| 205 | # Create tunnels |
| 206 | main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 ) |
| 207 | main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 ) |
| 208 | main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 ) |
| 209 | |
| 210 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
| 211 | and the BGP paths in data plane are ready..." ) |
| 212 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
| 213 | |
| 214 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 215 | other and to sdn-ip, plus finish installing all intents..." ) |
| 216 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 217 | # TODO |
| 218 | # time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 219 | |
| 220 | ''' |
| 221 | # TODO: use for together with wrapperFile1 |
| 222 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 223 | main.USECASE_SdnipI2MN_Cluster = imp.load_source( wrapperFile2, |
| 224 | main.dependencyPath + |
| 225 | wrapperFile2 + |
| 226 | ".py" ) |
| 227 | ''' |
| 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"], |
| 237 | peers = ["peer64514", "peer64515", "peer64516"], |
| 238 | expectAllSuccess = True ) |
| 239 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 240 | peers = [peer64514, peer64515, peer64516], |
| 241 | expectAllSuccess = True ) |
| 242 | |
| 243 | |
| 244 | def CASE2( self, main ): |
| 245 | ''' |
| 246 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 247 | ''' |
| 248 | main.case( "Check point-to-point intents" ) |
| 249 | main.log.info( "There are %s BGP peers in total " |
| 250 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 251 | main.step( "Check P2P intents number from ONOS CLI" ) |
| 252 | |
| 253 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 254 | bgpIntentsActualNum = \ |
| 255 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 256 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2 |
| 257 | main.log.info( "bgpIntentsExpected num is:" ) |
| 258 | main.log.info( bgpIntentsExpectedNum ) |
| 259 | main.log.info( "bgpIntentsActual num is:" ) |
| 260 | main.log.info( bgpIntentsActualNum ) |
| 261 | utilities.assertEquals( \ |
| 262 | expect = True, |
| 263 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 264 | onpass = "PointToPointIntent Intent Num is correct!", |
| 265 | onfail = "PointToPointIntent Intent Num is wrong!" ) |
| 266 | |
| 267 | |
| 268 | def CASE3( self, main ): |
| 269 | ''' |
| 270 | routes and intents check to all BGP peers |
| 271 | ''' |
| 272 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 273 | |
| 274 | allRoutesExpected = [] |
| 275 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 276 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 277 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 278 | |
| 279 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 280 | allRoutesActual = \ |
| 281 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 282 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 283 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 284 | |
| 285 | main.step( "Check routes installed" ) |
| 286 | main.log.info( "Routes expected:" ) |
| 287 | main.log.info( allRoutesStrExpected ) |
| 288 | main.log.info( "Routes get from ONOS CLI:" ) |
| 289 | main.log.info( allRoutesStrActual ) |
| 290 | utilities.assertEquals( \ |
| 291 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 292 | onpass = "Routes are correct!", |
| 293 | onfail = "Routes are wrong!" ) |
| 294 | |
| 295 | main.step( "Check M2S intents installed" ) |
| 296 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 297 | routeIntentsActualNum = \ |
| 298 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 299 | routeIntentsExpectedNum = 3 |
| 300 | |
| 301 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 302 | main.log.info( routeIntentsExpectedNum ) |
| 303 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 304 | main.log.info( routeIntentsActualNum ) |
| 305 | utilities.assertEquals( \ |
| 306 | expect = True, |
| 307 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 308 | onpass = "MultiPointToSinglePoint Intent Num is correct!", |
| 309 | onfail = "MultiPointToSinglePoint Intent Num is wrong!" ) |
| 310 | |
| 311 | main.step( "Check whether all flow status are ADDED" ) |
| 312 | utilities.assertEquals( \ |
| 313 | expect = main.TRUE, |
| 314 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 315 | onpass = "Flow status is correct!", |
| 316 | onfail = "Flow status is wrong!" ) |
| 317 | |
| 318 | |
| 319 | def CASE4( self, main ): |
| 320 | ''' |
| 321 | Ping test in data plane for each route |
| 322 | ''' |
| 323 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 324 | main.Functions.pingHostToHost( main, |
| 325 | hosts = ["host64514", "host64515", "host64516"], |
| 326 | expectAllSuccess = True ) |
| 327 | |
| 328 | |
| 329 | def CASE5( self, main ): |
| 330 | ''' |
| 331 | Cut links to peers one by one, check routes/intents |
| 332 | ''' |
| 333 | import time |
| 334 | main.case( "Bring down links and check routes/intents" ) |
| 335 | main.step( "Bring down the link between sw32 and peer64514" ) |
| 336 | linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 337 | OPTION = "down" ) |
| 338 | utilities.assertEquals( expect = main.TRUE, |
| 339 | actual = linkResult1, |
| 340 | onpass = "Bring down link succeeded!", |
| 341 | onfail = "Bring down link failed!" ) |
| 342 | |
| 343 | if linkResult1 == main.TRUE: |
| 344 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 345 | main.Functions.checkRouteNum( main, 2 ) |
| 346 | main.Functions.checkM2SintentNum( main, 2 ) |
| 347 | else: |
| 348 | main.log.error( "Bring down link failed!" ) |
| 349 | main.cleanup() |
| 350 | main.exit() |
| 351 | |
| 352 | main.step( "Bring down the link between sw8 and peer64515" ) |
| 353 | linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 354 | OPTION = "down" ) |
| 355 | utilities.assertEquals( expect = main.TRUE, |
| 356 | actual = linkResult2, |
| 357 | onpass = "Bring down link succeeded!", |
| 358 | onfail = "Bring down link failed!" ) |
| 359 | if linkResult2 == main.TRUE: |
| 360 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 361 | main.Functions.checkRouteNum( main, 1 ) |
| 362 | main.Functions.checkM2SintentNum( main, 1 ) |
| 363 | else: |
| 364 | main.log.error( "Bring down link failed!" ) |
| 365 | main.cleanup() |
| 366 | main.exit() |
| 367 | |
| 368 | main.step( "Bring down the link between sw28 and peer64516" ) |
| 369 | linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 370 | OPTION = "down" ) |
| 371 | utilities.assertEquals( expect = main.TRUE, |
| 372 | actual = linkResult3, |
| 373 | onpass = "Bring down link succeeded!", |
| 374 | onfail = "Bring down link failed!" ) |
| 375 | if linkResult3 == main.TRUE: |
| 376 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 377 | main.Functions.checkRouteNum( main, 0 ) |
| 378 | main.Functions.checkM2SintentNum( main, 0 ) |
| 379 | else: |
| 380 | main.log.error( "Bring down link failed!" ) |
| 381 | main.cleanup() |
| 382 | main.exit() |
| 383 | |
| 384 | main.step( "Check whether all flow status are ADDED" ) |
| 385 | utilities.assertEquals( \ |
| 386 | expect = main.TRUE, |
| 387 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 388 | onpass = "Flow status is correct!", |
| 389 | onfail = "Flow status is wrong!" ) |
| 390 | |
| 391 | # Ping test |
| 392 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 393 | peers = ["peer64514", "peer64515", "peer64516"], |
| 394 | expectAllSuccess = False ) |
| 395 | main.Functions.pingHostToHost( main, |
| 396 | hosts = ["host64514", "host64515", "host64516"], |
| 397 | expectAllSuccess = False ) |
| 398 | |
| 399 | |
| 400 | def CASE6( self, main ): |
| 401 | ''' |
| 402 | Recover links to peers one by one, check routes/intents |
| 403 | ''' |
| 404 | import time |
| 405 | main.case( "Bring up links and check routes/intents" ) |
| 406 | main.step( "Bring up the link between sw32 and peer64514" ) |
| 407 | linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 408 | OPTION = "up" ) |
| 409 | utilities.assertEquals( expect = main.TRUE, |
| 410 | actual = linkResult1, |
| 411 | onpass = "Bring up link succeeded!", |
| 412 | onfail = "Bring up link failed!" ) |
| 413 | if linkResult1 == main.TRUE: |
| 414 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 415 | main.Functions.checkRouteNum( main, 1 ) |
| 416 | main.Functions.checkM2SintentNum( main, 1 ) |
| 417 | else: |
| 418 | main.log.error( "Bring up link failed!" ) |
| 419 | main.cleanup() |
| 420 | main.exit() |
| 421 | |
| 422 | main.step( "Bring up the link between sw8 and peer64515" ) |
| 423 | linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 424 | OPTION = "up" ) |
| 425 | utilities.assertEquals( expect = main.TRUE, |
| 426 | actual = linkResult2, |
| 427 | onpass = "Bring up link succeeded!", |
| 428 | onfail = "Bring up link failed!" ) |
| 429 | if linkResult2 == main.TRUE: |
| 430 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 431 | main.Functions.checkRouteNum( main, 2 ) |
| 432 | main.Functions.checkM2SintentNum( main, 2 ) |
| 433 | else: |
| 434 | main.log.error( "Bring up link failed!" ) |
| 435 | main.cleanup() |
| 436 | main.exit() |
| 437 | |
| 438 | main.step( "Bring up the link between sw28 and peer64516" ) |
| 439 | linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 440 | OPTION = "up" ) |
| 441 | utilities.assertEquals( expect = main.TRUE, |
| 442 | actual = linkResult3, |
| 443 | onpass = "Bring up link succeeded!", |
| 444 | onfail = "Bring up link failed!" ) |
| 445 | if linkResult3 == main.TRUE: |
| 446 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 447 | main.Functions.checkRouteNum( main, 3 ) |
| 448 | main.Functions.checkM2SintentNum( main, 3 ) |
| 449 | else: |
| 450 | main.log.error( "Bring up link failed!" ) |
| 451 | main.cleanup() |
| 452 | main.exit() |
| 453 | |
| 454 | main.step( "Check whether all flow status are ADDED" ) |
| 455 | utilities.assertEquals( \ |
| 456 | expect = main.TRUE, |
| 457 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 458 | onpass = "Flow status is correct!", |
| 459 | onfail = "Flow status is wrong!" ) |
| 460 | |
| 461 | # Ping test |
| 462 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 463 | peers = ["peer64514", "peer64515", "peer64516"], |
| 464 | expectAllSuccess = True ) |
| 465 | main.Functions.pingHostToHost( main, |
| 466 | hosts = ["host64514", "host64515", "host64516"], |
| 467 | expectAllSuccess = True ) |
| 468 | |
| 469 | |
| 470 | def CASE7( self, main ): |
| 471 | ''' |
| 472 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 473 | ''' |
| 474 | import time |
| 475 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 476 | main.step( "Stop sw32" ) |
| 477 | result = main.Mininet.switch( SW = "sw32", OPTION = "stop" ) |
| 478 | utilities.assertEquals( expect = main.TRUE, actual = result, |
| 479 | onpass = "Stopping switch succeeded!", |
| 480 | onfail = "Stopping switch failed!" ) |
| 481 | |
| 482 | if result == main.TRUE: |
| 483 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 484 | main.Functions.checkRouteNum( main, 2 ) |
| 485 | main.Functions.checkM2SintentNum( main, 2 ) |
| 486 | main.Functions.checkP2PintentNum( main, 12 * 2 ) |
| 487 | else: |
| 488 | main.log.error( "Stopping switch failed!" ) |
| 489 | main.cleanup() |
| 490 | main.exit() |
| 491 | |
| 492 | main.step( "Check ping between hosts behind BGP peers" ) |
| 493 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 494 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 495 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 496 | |
| 497 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 498 | and ( result3 == main.FALSE ) |
| 499 | utilities.assert_equals( expect = True, actual = pingResult1, |
| 500 | onpass = "Ping test result is correct", |
| 501 | onfail = "Ping test result is wrong" ) |
| 502 | |
| 503 | if pingResult1 == False: |
| 504 | main.cleanup() |
| 505 | main.exit() |
| 506 | |
| 507 | main.step( "Check ping between BGP peers and speaker1" ) |
| 508 | result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 509 | result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 510 | result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 511 | |
| 512 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 513 | and ( result6 == main.TRUE ) |
| 514 | utilities.assert_equals( expect = True, actual = pingResult2, |
| 515 | onpass = "Speaker1 ping peers successful", |
| 516 | onfail = "Speaker1 ping peers NOT successful" ) |
| 517 | |
| 518 | if pingResult2 == False: |
| 519 | main.cleanup() |
| 520 | main.exit() |
| 521 | |
| 522 | main.step( "Check ping between BGP peers and speaker2" ) |
| 523 | # TODO |
| 524 | result7 = main.Mininet.pingHost( src = "speaker2", target = peer64514 ) |
| 525 | result8 = main.Mininet.pingHost( src = "speaker2", target = peer64515 ) |
| 526 | result9 = main.Mininet.pingHost( src = "speaker2", target = peer64516 ) |
| 527 | |
| 528 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 529 | and ( result9 == main.TRUE ) |
| 530 | utilities.assert_equals( expect = True, actual = pingResult2, |
| 531 | onpass = "Speaker2 ping peers successful", |
| 532 | onfail = "Speaker2 ping peers NOT successful" ) |
| 533 | |
| 534 | if pingResult3 == False: |
| 535 | main.cleanup() |
| 536 | main.exit() |
| 537 | |
| 538 | main.step( "Check whether all flow status are ADDED" ) |
| 539 | utilities.assertEquals( \ |
| 540 | expect = main.TRUE, |
| 541 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 542 | onpass = "Flow status is correct!", |
| 543 | onfail = "Flow status is wrong!" ) |
| 544 | |
| 545 | |
| 546 | def CASE8( self, main ): |
| 547 | ''' |
| 548 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 549 | check P-2-P and M-2-S intents, ping test |
| 550 | ''' |
| 551 | import time |
| 552 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 553 | main.step( "Start sw32" ) |
| 554 | result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" ) |
| 555 | utilities.assertEquals( \ |
| 556 | expect = main.TRUE, |
| 557 | actual = result1, |
| 558 | onpass = "Starting switch succeeded!", |
| 559 | onfail = "Starting switch failed!" ) |
| 560 | |
| 561 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
| 562 | utilities.assertEquals( \ |
| 563 | expect = main.TRUE, |
| 564 | actual = result2, |
| 565 | onpass = "Connect switch to ONOS succeeded!", |
| 566 | onfail = "Connect switch to ONOS failed!" ) |
| 567 | |
| 568 | if result1 and result2: |
| 569 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 570 | main.Functions.checkRouteNum( main, 3 ) |
| 571 | main.Functions.checkM2SintentNum( main, 3 ) |
| 572 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 573 | else: |
| 574 | main.log.error( "Starting switch failed!" ) |
| 575 | main.cleanup() |
| 576 | main.exit() |
| 577 | |
| 578 | main.step( "Check whether all flow status are ADDED" ) |
| 579 | utilities.assertEquals( \ |
| 580 | expect = main.TRUE, |
| 581 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 582 | onpass = "Flow status is correct!", |
| 583 | onfail = "Flow status is wrong!" ) |
| 584 | |
| 585 | # Ping test |
| 586 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 587 | peers = ["peer64514", "peer64515", "peer64516"], |
| 588 | expectAllSuccess = True ) |
| 589 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 590 | peers = [peer64514, peer64515, peer64516], |
| 591 | expectAllSuccess = True ) |
| 592 | main.Functions.pingHostToHost( main, |
| 593 | hosts = ["host64514", "host64515", "host64516"], |
| 594 | expectAllSuccess = True ) |
| 595 | |
| 596 | |
| 597 | def CASE9( self, main ): |
| 598 | ''' |
| 599 | Bring down a switch in best path, check: |
| 600 | route number, P2P intent number, M2S intent number, ping test |
| 601 | ''' |
| 602 | main.case( "Stop sw11 located in best path, \ |
| 603 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 604 | |
| 605 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
| 606 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 607 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 608 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 609 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 610 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 611 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 612 | |
| 613 | main.step( "Stop sw11" ) |
| 614 | result = main.Mininet.switch( SW = "sw11", OPTION = "stop" ) |
| 615 | utilities.assertEquals( expect = main.TRUE, actual = result, |
| 616 | onpass = "Stopping switch succeeded!", |
| 617 | onfail = "Stopping switch failed!" ) |
| 618 | if result: |
| 619 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 620 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 621 | main.Functions.checkRouteNum( main, 3 ) |
| 622 | main.Functions.checkM2SintentNum( main, 3 ) |
| 623 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 624 | else: |
| 625 | main.log.error( "Stopping switch failed!" ) |
| 626 | main.cleanup() |
| 627 | main.exit() |
| 628 | |
| 629 | main.step( "Check whether all flow status are ADDED" ) |
| 630 | utilities.assertEquals( \ |
| 631 | expect = main.TRUE, |
| 632 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 633 | onpass = "Flow status is correct!", |
| 634 | onfail = "Flow status is wrong!" ) |
| 635 | # Ping test |
| 636 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 637 | peers = ["peer64514", "peer64515", "peer64516"], |
| 638 | expectAllSuccess = True ) |
| 639 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 640 | peers = [peer64514, peer64515, peer64516], |
| 641 | expectAllSuccess = True ) |
| 642 | main.Functions.pingHostToHost( main, |
| 643 | hosts = ["host64514", "host64515", "host64516"], |
| 644 | expectAllSuccess = True ) |
| 645 | |
| 646 | |
| 647 | def CASE10( self, main ): |
| 648 | ''' |
| 649 | Bring up the switch which was stopped in CASE9, check: |
| 650 | route number, P2P intent number, M2S intent number, ping test |
| 651 | ''' |
| 652 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 653 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 654 | |
| 655 | main.log.info( "Check the flow status before starting sw11" ) |
| 656 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 657 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 658 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 659 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 660 | |
| 661 | main.step( "Start sw11" ) |
| 662 | result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" ) |
| 663 | utilities.assertEquals( expect = main.TRUE, actual = result1, |
| 664 | onpass = "Starting switch succeeded!", |
| 665 | onfail = "Starting switch failed!" ) |
| 666 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
| 667 | utilities.assertEquals( expect = main.TRUE, actual = result2, |
| 668 | onpass = "Connect switch to ONOS succeeded!", |
| 669 | onfail = "Connect switch to ONOS failed!" ) |
| 670 | if result1 and result2: |
| 671 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 672 | main.Functions.checkRouteNum( main, 3 ) |
| 673 | main.Functions.checkM2SintentNum( main, 3 ) |
| 674 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 675 | |
| 676 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 677 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 678 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 679 | else: |
| 680 | main.log.error( "Starting switch failed!" ) |
| 681 | main.cleanup() |
| 682 | main.exit() |
| 683 | |
| 684 | main.step( "Check whether all flow status are ADDED" ) |
| 685 | utilities.assertEquals( \ |
| 686 | expect = main.TRUE, |
| 687 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 688 | onpass = "Flow status is correct!", |
| 689 | onfail = "Flow status is wrong!" ) |
| 690 | # Ping test |
| 691 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 692 | peers = ["peer64514", "peer64515", "peer64516"], |
| 693 | expectAllSuccess = True ) |
| 694 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 695 | peers = [peer64514, peer64515, peer64516], |
| 696 | expectAllSuccess = True ) |
| 697 | main.Functions.pingHostToHost( main, |
| 698 | hosts = ["host64514", "host64515", "host64516"], |
| 699 | expectAllSuccess = True ) |
| 700 | |
| 701 | |
| 702 | def CASE11(self, main): |
| 703 | import time |
| 704 | main.case( "Kill speaker1, check:\ |
| 705 | route number, P2P intent number, M2S intent number, ping test" ) |
| 706 | main.info( "Check network status before killing speaker1" ) |
| 707 | main.Functions.checkRouteNum( main, 3 ) |
| 708 | main.Functions.checkM2SintentNum( main, 3 ) |
| 709 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 710 | main.step( "Check whether all flow status are ADDED" ) |
| 711 | utilities.assertEquals( \ |
| 712 | expect = main.TRUE, |
| 713 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 714 | onpass = "Flow status is correct!", |
| 715 | onfail = "Flow status is wrong!" ) |
| 716 | |
| 717 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 718 | peers = ["peer64514", "peer64515", "peer64516"], |
| 719 | expectAllSuccess = True ) |
| 720 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 721 | peers = [peer64514, peer64515, peer64516], |
| 722 | expectAllSuccess = True ) |
| 723 | main.Functions.pingHostToHost( main, |
| 724 | hosts = ["host64514", "host64515", "host64516"], |
| 725 | expectAllSuccess = True ) |
| 726 | |
| 727 | main.step( "Kill speaker1" ) |
| 728 | result = main.TRUE |
| 729 | command = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`" |
| 730 | result = main.Mininet.node( "root", command ) |
| 731 | utilities.assert_equals( expect = True, |
| 732 | actual = ( "quagga-sdn.conf" in result ), |
| 733 | onpass = "Kill speaker1 succeeded", |
| 734 | onfail = "Kill speaker1 failed" ) |
| 735 | if ( "quagga-sdn.conf" not in result ) : |
| 736 | main.cleanup() |
| 737 | main.exit() |
| 738 | |
| 739 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 740 | main.Functions.checkRouteNum( main, 3 ) |
| 741 | main.Functions.checkM2SintentNum( main, 3 ) |
| 742 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 743 | |
| 744 | main.step( "Check whether all flow status are ADDED" ) |
| 745 | utilities.assertEquals( \ |
| 746 | expect = main.TRUE, |
| 747 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 748 | onpass = "Flow status is correct!", |
| 749 | onfail = "Flow status is wrong!" ) |
| 750 | |
| 751 | ''' |
| 752 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 753 | peers = ["peer64514", "peer64515", "peer64516"], |
| 754 | expectAllSuccess = False ) |
| 755 | ''' |
| 756 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 757 | peers = [peer64514, peer64515, peer64516], |
| 758 | expectAllSuccess = True ) |
| 759 | main.Functions.pingHostToHost( main, |
| 760 | hosts = ["host64514", "host64515", "host64516"], |
| 761 | expectAllSuccess = True ) |
| 762 | |
| 763 | |
| 764 | def CASE12( self, main ): |
| 765 | import time |
| 766 | main.case( "Bring down leader ONOS node, check: \ |
| 767 | route number, P2P intent number, M2S intent number, ping test" ) |
| 768 | main.step( "Find out ONOS leader node" ) |
| 769 | # TODO |
| 770 | main.step( "Uninstall ONOS leader node" ) |
| 771 | uninstallResult = main.ONOSbench.onosUninstall( ONOS2Ip ) |
| 772 | utilities.assert_equals( expect = main.TRUE, |
| 773 | actual = uninstallResult, |
| 774 | onpass = "Uninstall ONOS node2 succeeded", |
| 775 | onfail = "Uninstall ONOS node2 failed" ) |
| 776 | if uninstallResult != main.TRUE: |
| 777 | main.cleanup() |
| 778 | main.exit() |
| 779 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 780 | main.Functions.checkRouteNum( main, 3 ) |
| 781 | main.Functions.checkM2SintentNum( main, 3 ) |
| 782 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 783 | |
| 784 | main.step( "Check whether all flow status are ADDED" ) |
| 785 | utilities.assertEquals( \ |
| 786 | expect = main.TRUE, |
| 787 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 788 | onpass = "Flow status is correct!", |
| 789 | onfail = "Flow status is wrong!" ) |
| 790 | |
| 791 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 792 | peers = ["peer64514", "peer64515", "peer64516"], |
| 793 | expectAllSuccess = True ) |
| 794 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker2"], |
| 795 | peers = [peer64514, peer64515, peer64516], |
| 796 | expectAllSuccess = True ) |
| 797 | main.Functions.pingHostToHost( main, |
| 798 | hosts = ["host64514", "host64515", "host64516"], |
| 799 | expectAllSuccess = True ) |