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