pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipI2: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 8 | # This case is to setup Mininet testbed |
| 9 | def CASE100( self, main ): |
| 10 | """ |
| 11 | Start mininet |
| 12 | """ |
| 13 | import os |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 14 | import imp |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 15 | main.log.case( "Start Mininet topology" ) |
| 16 | main.dependencyPath = main.testDir + \ |
| 17 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 18 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 19 | |
| 20 | main.step( "Starting Mininet Topology" ) |
| 21 | topology = main.dependencyPath + main.topology |
| 22 | topoResult = main.Mininet.startNet( topoFile = topology ) |
| 23 | stepResult = topoResult |
| 24 | utilities.assert_equals( expect = main.TRUE, |
| 25 | actual = stepResult, |
| 26 | onpass = "Successfully loaded topology", |
| 27 | onfail = "Failed to load topology" ) |
| 28 | # Exit if topology did not load properly |
| 29 | if not topoResult: |
| 30 | main.cleanup() |
| 31 | main.exit() |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 32 | |
| 33 | # This case is to setup ONOS |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 34 | def CASE101( self, main ): |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 35 | """ |
| 36 | CASE100 is to compile ONOS and install it |
| 37 | Startup sequence: |
| 38 | cell <name> |
| 39 | onos-verify-cell |
| 40 | git pull |
| 41 | mvn clean install |
| 42 | onos-package |
| 43 | onos-install -f |
| 44 | onos-wait-for-start |
| 45 | """ |
| 46 | import json |
| 47 | import time |
| 48 | from operator import eq |
| 49 | |
| 50 | main.case( "Setting up test environment" ) |
| 51 | |
| 52 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 53 | global ONOS1Ip |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 54 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 55 | |
| 56 | main.step( "Applying cell variable to environment" ) |
| 57 | cellResult = main.ONOSbench.setCell( cellName ) |
| 58 | verifyResult = main.ONOSbench.verifyCell() |
| 59 | |
| 60 | branchName = main.ONOSbench.getBranchName() |
| 61 | main.log.info( "ONOS is on branch: " + branchName ) |
| 62 | |
| 63 | main.log.report( "Uninstalling ONOS" ) |
| 64 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 65 | |
| 66 | # cleanInstallResult = main.TRUE |
| 67 | # gitPullResult = main.TRUE |
| 68 | |
| 69 | main.step( "Git pull" ) |
| 70 | gitPullResult = main.ONOSbench.gitPull() |
| 71 | |
| 72 | main.step( "Using mvn clean install" ) |
| 73 | if gitPullResult == main.TRUE: |
| 74 | cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 ) |
| 75 | else: |
| 76 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 77 | "clean install" ) |
| 78 | cleanInstallResult = main.TRUE |
| 79 | |
| 80 | main.ONOSbench.getVersion( report = True ) |
| 81 | |
| 82 | main.step( "Creating ONOS package" ) |
| 83 | packageResult = main.ONOSbench.onosPackage( opTimeout = 500 ) |
| 84 | |
| 85 | main.step( "Installing ONOS package" ) |
| 86 | onos1InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 87 | node = ONOS1Ip ) |
| 88 | |
| 89 | main.step( "Checking if ONOS is up yet" ) |
| 90 | for i in range( 2 ): |
| 91 | onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 ) |
| 92 | if onos1Isup: |
| 93 | break |
| 94 | if not onos1Isup: |
| 95 | main.log.report( "ONOS1 didn't start!" ) |
| 96 | |
| 97 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
| 98 | commandlineTimeout = 100, onosStartTimeout = 600 ) |
| 99 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 100 | caseResult = ( cleanInstallResult and packageResult and |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 101 | cellResult and verifyResult and |
| 102 | onos1InstallResult and |
| 103 | onos1Isup and cliResult ) |
| 104 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 105 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 106 | onpass = "ONOS startup successful", |
| 107 | onfail = "ONOS startup NOT successful" ) |
| 108 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 109 | if caseResult == main.FALSE: |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 110 | main.cleanup() |
| 111 | main.exit() |
| 112 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 113 | main.step( "Get links in the network" ) |
| 114 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 115 | main.log.info( listResult ) |
| 116 | main.log.info( "Activate sdn-ip application" ) |
| 117 | main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 118 | |
| 119 | main.log.info( "Wait sdn-ip to finish installing connectivity intents, \ |
| 120 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 121 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 122 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 123 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 124 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 125 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 126 | |
| 127 | |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 128 | def CASE102( self, main ): |
| 129 | ''' |
| 130 | This test case is to load the methods from other Python files. |
| 131 | ''' |
| 132 | main.case( "Loading the methods from other Python file" ) |
| 133 | # load the methods from other file |
| 134 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 135 | main.Functions = imp.load_source( wrapperFile, |
| 136 | main.dependencyPath + |
| 137 | wrapperFile + |
| 138 | ".py" ) |
| 139 | |
| 140 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 141 | def CASE1( self, main ): |
| 142 | ''' |
| 143 | ping test from 3 bgp peers to BGP speaker |
| 144 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 145 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 146 | main.case( "This case is to check ping between BGP peers and speakers" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 147 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 148 | peers = ["peer64514", "peer64515", "peer64516"], |
| 149 | expectAllSuccess = True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 150 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 151 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 152 | def CASE2( self, main ): |
| 153 | ''' |
| 154 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 155 | ''' |
| 156 | main.case( "This case is to check point-to-point intents" ) |
| 157 | main.log.info( "There are %s BGP peers in total " |
| 158 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 159 | main.step( "Get point-to-point intents from ONOS CLI" ) |
| 160 | |
| 161 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 162 | bgpIntentsActualNum = \ |
| 163 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 164 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
| 165 | main.log.info( "bgpIntentsExpected num is:" ) |
| 166 | main.log.info( bgpIntentsExpectedNum ) |
| 167 | main.log.info( "bgpIntentsActual num is:" ) |
| 168 | main.log.info( bgpIntentsActualNum ) |
| 169 | utilities.assertEquals( \ |
| 170 | expect = True, |
| 171 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 172 | onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***", |
| 173 | onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" ) |
| 174 | |
| 175 | |
| 176 | def CASE3( self, main ): |
| 177 | ''' |
| 178 | routes and intents check to all BGP peers |
| 179 | ''' |
| 180 | main.case( "This case is to check routes and intents to all BGP peers" ) |
| 181 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 182 | allRoutesExpected = [] |
| 183 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 184 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 185 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 186 | |
| 187 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 188 | allRoutesActual = \ |
| 189 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 190 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 191 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 192 | |
| 193 | main.step( "Check routes installed" ) |
| 194 | main.log.info( "Routes expected:" ) |
| 195 | main.log.info( allRoutesStrExpected ) |
| 196 | main.log.info( "Routes get from ONOS CLI:" ) |
| 197 | main.log.info( allRoutesStrActual ) |
| 198 | utilities.assertEquals( \ |
| 199 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 200 | onpass = "***Routes in SDN-IP are correct!***", |
| 201 | onfail = "***Routes in SDN-IP are wrong!***" ) |
| 202 | |
| 203 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 204 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 205 | routeIntentsActualNum = \ |
| 206 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 207 | routeIntentsExpectedNum = 3 |
| 208 | |
| 209 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 210 | main.log.info( routeIntentsExpectedNum ) |
| 211 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 212 | main.log.info( routeIntentsActualNum ) |
| 213 | utilities.assertEquals( \ |
| 214 | expect = True, |
| 215 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 216 | onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 217 | correct!***", |
| 218 | onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 219 | wrong!***" ) |
| 220 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 221 | main.step( "Check whether all flow status are ADDED" ) |
| 222 | utilities.assertEquals( \ |
| 223 | expect = main.TRUE, |
| 224 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 225 | onpass = "***Flow status is correct!***", |
| 226 | onfail = "***Flow status is wrong!***" ) |
| 227 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 228 | |
| 229 | def CASE4( self, main ): |
| 230 | ''' |
| 231 | Ping test in data plane for each route |
| 232 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 233 | main.case( "This case is to check ping for each route, \ |
| 234 | all hosts behind BGP peers" ) |
| 235 | main.Functions.pingHostToHost( main, |
| 236 | hosts = ["host64514", "host64515", "host64516"], |
| 237 | expectAllSuccess = True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 238 | |
| 239 | |
| 240 | def CASE5( self, main ): |
| 241 | ''' |
| 242 | Cut links to peers one by one, check routes/intents |
| 243 | ''' |
| 244 | import time |
| 245 | main.case( "This case is to bring down links and check routes/intents" ) |
| 246 | main.step( "Bring down the link between sw32 and peer64514" ) |
| 247 | result = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 248 | OPTION = "down" ) |
| 249 | if result == main.TRUE: |
| 250 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 251 | main.Functions.checkRouteNum( main, 2 ) |
| 252 | main.Functions.checkM2SintentNum( main, 2 ) |
| 253 | else: |
| 254 | main.log.info( "Bring down link failed!!!" ) |
| 255 | main.exit(); |
| 256 | |
| 257 | main.step( "Bring down the link between sw8 and peer64515" ) |
| 258 | result = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 259 | OPTION = "down" ) |
| 260 | if result == main.TRUE: |
| 261 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 262 | main.Functions.checkRouteNum( main, 1 ) |
| 263 | main.Functions.checkM2SintentNum( main, 1 ) |
| 264 | else: |
| 265 | main.log.info( "Bring down link failed!!!" ) |
| 266 | main.exit(); |
| 267 | |
| 268 | main.step( "Bring down the link between sw28 and peer64516" ) |
| 269 | result = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 270 | OPTION = "down" ) |
| 271 | if result == main.TRUE: |
| 272 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 273 | main.Functions.checkRouteNum( main, 0 ) |
| 274 | main.Functions.checkM2SintentNum( main, 0 ) |
| 275 | else: |
| 276 | main.log.info( "Bring down link failed!!!" ) |
| 277 | main.exit(); |
| 278 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 279 | main.step( "Check whether all flow status are ADDED" ) |
| 280 | utilities.assertEquals( \ |
| 281 | expect = main.TRUE, |
| 282 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 283 | onpass = "***Flow status is correct!***", |
| 284 | onfail = "***Flow status is wrong!***" ) |
| 285 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 286 | # Ping test |
| 287 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 288 | peers = ["peer64514", "peer64515", "peer64516"], |
| 289 | expectAllSuccess = False ) |
| 290 | main.Functions.pingHostToHost( main, |
| 291 | hosts = ["host64514", "host64515", "host64516"], |
| 292 | expectAllSuccess = False ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 293 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 294 | |
| 295 | def CASE6( self, main ): |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 296 | ''' |
| 297 | Recover links to peers one by one, check routes/intents |
| 298 | ''' |
| 299 | import time |
| 300 | main.case( "This case is to bring up links and check routes/intents" ) |
| 301 | main.step( "Bring up the link between sw32 and peer64514" ) |
| 302 | result = main.Mininet.link( END1 = "sw32", END2 = "peer64514", |
| 303 | OPTION = "up" ) |
| 304 | if result == main.TRUE: |
| 305 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 306 | main.Functions.checkRouteNum( main, 1 ) |
| 307 | main.Functions.checkM2SintentNum( main, 1 ) |
| 308 | else: |
| 309 | main.log.info( "Bring up link failed!!!" ) |
| 310 | main.exit(); |
| 311 | |
| 312 | main.step( "Bring up the link between sw8 and peer64515" ) |
| 313 | result = main.Mininet.link( END1 = "sw8", END2 = "peer64515", |
| 314 | OPTION = "up" ) |
| 315 | if result == main.TRUE: |
| 316 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 317 | main.Functions.checkRouteNum( main, 2 ) |
| 318 | main.Functions.checkM2SintentNum( main, 2 ) |
| 319 | else: |
| 320 | main.log.info( "Bring up link failed!!!" ) |
| 321 | main.exit(); |
| 322 | |
| 323 | main.step( "Bring up the link between sw28 and peer64516" ) |
| 324 | result = main.Mininet.link( END1 = "sw28", END2 = "peer64516", |
| 325 | OPTION = "up" ) |
| 326 | if result == main.TRUE: |
| 327 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 328 | main.Functions.checkRouteNum( main, 3 ) |
| 329 | main.Functions.checkM2SintentNum( main, 3 ) |
| 330 | else: |
| 331 | main.log.info( "Bring up link failed!!!" ) |
| 332 | main.exit(); |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 333 | |
| 334 | main.step( "Check whether all flow status are ADDED" ) |
| 335 | utilities.assertEquals( \ |
| 336 | expect = main.TRUE, |
| 337 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 338 | onpass = "***Flow status is correct!***", |
| 339 | onfail = "***Flow status is wrong!***" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 340 | |
| 341 | # Ping test |
| 342 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 343 | peers = ["peer64514", "peer64515", "peer64516"], |
| 344 | expectAllSuccess = True ) |
| 345 | main.Functions.pingHostToHost( main, |
| 346 | hosts = ["host64514", "host64515", "host64516"], |
| 347 | expectAllSuccess = True ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 348 | |
| 349 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 350 | def CASE7( self, main ): |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 351 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 352 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 353 | ''' |
| 354 | import time |
| 355 | main.case( "This case is to stop 1 edge switch,\ |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 356 | check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 357 | main.step( "Stop sw32" ) |
| 358 | result = main.Mininet.switch( SW = "sw32", OPTION = "stop" ) |
| 359 | if result == main.TRUE: |
| 360 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 361 | main.Functions.checkRouteNum( main, 2 ) |
| 362 | main.Functions.checkM2SintentNum( main, 2 ) |
| 363 | main.Functions.checkP2PintentNum( main, 12 ) |
| 364 | else: |
| 365 | main.log.info( "Stop switch failed!!!" ) |
| 366 | main.exit(); |
| 367 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 368 | main.step( "Check ping between hosts behind BGP peers" ) |
| 369 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 370 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 371 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 372 | |
| 373 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 374 | and ( result3 == main.FALSE ) |
| 375 | utilities.assert_equals( expect = True, actual = pingResult1, |
| 376 | onpass = "Ping test result is correct", |
| 377 | onfail = "Ping test result is wrong" ) |
| 378 | |
| 379 | if pingResult1 == False: |
| 380 | main.cleanup() |
| 381 | main.exit() |
| 382 | |
| 383 | main.step( "Check ping between BGP peers and speakers" ) |
| 384 | result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 385 | result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 386 | result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 387 | |
| 388 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 389 | and ( result6 == main.TRUE ) |
| 390 | utilities.assert_equals( expect = True, actual = pingResult2, |
| 391 | onpass = "Speaker1 ping peers successful", |
| 392 | onfail = "Speaker1 ping peers NOT successful" ) |
| 393 | |
| 394 | if pingResult2 == False: |
| 395 | main.cleanup() |
| 396 | main.exit() |
| 397 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 398 | main.step( "Check whether all flow status are ADDED" ) |
| 399 | utilities.assertEquals( \ |
| 400 | expect = main.TRUE, |
| 401 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 402 | onpass = "***Flow status is correct!***", |
| 403 | onfail = "***Flow status is wrong!***" ) |
| 404 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 405 | ''' |
| 406 | main.step( "Stop sw8" ) |
| 407 | result = main.Mininet.switch( SW = "sw8", OPTION = "stop" ) |
| 408 | if result == main.TRUE: |
| 409 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 410 | main.Functions.checkRouteNum( main, 1 ) |
| 411 | |
| 412 | # Note: there should be 0 M2S intent, not 1. |
| 413 | main.Functions.checkM2SintentNum( main, 0 ) |
| 414 | main.Functions.checkP2PintentNum( main, 6 ) |
| 415 | else: |
| 416 | main.log.info( "Stop switch failed!!!" ) |
| 417 | main.exit(); |
| 418 | |
| 419 | main.step( "Stop sw28" ) |
| 420 | result = main.Mininet.switch( SW = "sw28", OPTION = "stop" ) |
| 421 | if result == main.TRUE: |
| 422 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 423 | main.Functions.checkRouteNum( main, 0 ) |
| 424 | main.Functions.checkM2SintentNum( main, 0 ) |
| 425 | main.Functions.checkP2PintentNum( main, 0 ) |
| 426 | else: |
| 427 | main.log.info( "Stop switch failed!!!" ) |
| 428 | main.exit(); |
| 429 | ''' |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 430 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 431 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 432 | def CASE8( self, main ): |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 433 | ''' |
| 434 | Bring up the edge switch which was shut down in CASE7, |
| 435 | check P-2-P and M-2-S intents, ping test |
| 436 | ''' |
| 437 | import time |
| 438 | main.case( "This case is to start the switch which was shut down in CASE7,\ |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 439 | check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 440 | main.step( "Start sw32" ) |
| 441 | result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" ) |
| 442 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
| 443 | |
| 444 | if result1 and result2: |
| 445 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 446 | main.Functions.checkRouteNum( main, 3 ) |
| 447 | main.Functions.checkM2SintentNum( main, 3 ) |
| 448 | main.Functions.checkP2PintentNum( main, 18 ) |
| 449 | else: |
| 450 | main.log.info( "Start switch failed!!!" ) |
| 451 | main.cleanup() |
| 452 | main.exit(); |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 453 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 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 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 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 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 468 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 469 | |
| 470 | def CASE9( self, main ): |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 471 | ''' |
| 472 | Bring down a switch in best path, check: |
| 473 | route number, P2P intent number, M2S intent number, ping test |
| 474 | ''' |
| 475 | main.case( "This case is to stop switch in best path, \ |
| 476 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 477 | |
| 478 | main.step( "Check the flow status before stopping sw11" ) |
| 479 | main.Functions.checkFlowNum( main, "sw11", 13 ) |
| 480 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 481 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 482 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 483 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 484 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 485 | |
| 486 | main.step( "Stop sw11" ) |
| 487 | result = main.Mininet.switch( SW = "sw11", OPTION = "stop" ) |
| 488 | if result: |
| 489 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 490 | main.Functions.checkRouteNum( main, 3 ) |
| 491 | main.Functions.checkM2SintentNum( main, 3 ) |
| 492 | main.Functions.checkP2PintentNum( main, 18 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 493 | else: |
| 494 | main.log.info( "Stop switch failed!!!" ) |
| 495 | main.cleanup() |
| 496 | main.exit(); |
| 497 | |
| 498 | main.step( "Check whether all flow status are ADDED" ) |
| 499 | utilities.assertEquals( \ |
| 500 | expect = main.TRUE, |
| 501 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 502 | onpass = "***Flow status is correct!***", |
| 503 | onfail = "***Flow status is wrong!***" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 504 | # Ping test |
| 505 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 506 | peers = ["peer64514", "peer64515", "peer64516"], |
| 507 | expectAllSuccess = True ) |
| 508 | main.Functions.pingHostToHost( main, |
| 509 | hosts = ["host64514", "host64515", "host64516"], |
| 510 | expectAllSuccess = True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 511 | |
| 512 | |
| 513 | def CASE10( self, main ): |
| 514 | ''' |
| 515 | Bring up the switch which was stopped in CASE9, check: |
| 516 | route number, P2P intent number, M2S intent number, ping test |
| 517 | ''' |
| 518 | main.case( "This case is to start switch which was stopped in CASE9, \ |
| 519 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 520 | main.step( "Start sw11" ) |
| 521 | result = main.Mininet.switch( SW = "sw11", OPTION = "start" ) |
| 522 | if result: |
| 523 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 524 | main.Functions.checkRouteNum( main, 3 ) |
| 525 | main.Functions.checkM2SintentNum( main, 3 ) |
| 526 | main.Functions.checkP2PintentNum( main, 18 ) |
| 527 | |
| 528 | main.step( "Check the flow status after stop and start sw11" ) |
| 529 | main.Functions.checkFlowNum( main, "sw11", 3 ) |
| 530 | main.Functions.checkFlowNum( main, "sw1", 11 ) |
| 531 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 532 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 533 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 534 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 535 | else: |
| 536 | main.log.info( "Start switch failed!!!" ) |
| 537 | main.cleanup() |
| 538 | main.exit(); |
| 539 | |
| 540 | main.step( "Check whether all flow status are ADDED" ) |
| 541 | utilities.assertEquals( \ |
| 542 | expect = main.TRUE, |
| 543 | actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ), |
| 544 | onpass = "***Flow status is correct!***", |
| 545 | onfail = "***Flow status is wrong!***" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame^] | 546 | # Ping test |
| 547 | main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 548 | peers = ["peer64514", "peer64515", "peer64516"], |
| 549 | expectAllSuccess = True ) |
| 550 | main.Functions.pingHostToHost( main, |
| 551 | hosts = ["host64514", "host64515", "host64516"], |
| 552 | expectAllSuccess = True ) |