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