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