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