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