pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 2 | class USECASE_SdnipFunction: |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 8 | def CASE100( self, main ): |
| 9 | """ |
| 10 | Start mininet |
| 11 | """ |
| 12 | import os |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 13 | import imp |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 14 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [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 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 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" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 26 | # Exit if topology did not load properly |
| 27 | if not topoResult: |
| 28 | main.cleanup() |
| 29 | main.exit() |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 30 | main.step( "Connect switches to controller" ) |
| 31 | |
| 32 | global ONOS1Ip |
| 33 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 34 | # connect all switches to controller |
| 35 | swResult = main.TRUE |
| 36 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 37 | sw = "sw%s" % ( i ) |
| 38 | swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -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" ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 43 | if not swResult: |
| 44 | main.cleanup() |
| 45 | main.exit() |
| 46 | |
| 47 | main.step( "Set up tunnel from Mininet node to onos node" ) |
| 48 | forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip ) |
| 49 | command = 'ssh -nNT -o "PasswordAuthentication no" \ |
| 50 | -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip ) |
| 51 | |
| 52 | tunnelResult = main.TRUE |
| 53 | tunnelResult = main.Mininet.node( "root", command ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 54 | utilities.assert_equals( expect=True, |
| 55 | actual=( "PasswordAuthentication" in tunnelResult ), |
| 56 | onpass="Created tunnel succeeded", |
| 57 | onfail="Create tunnel failed" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 58 | if ("PasswordAuthentication" not in tunnelResult) : |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 59 | main.cleanup() |
| 60 | main.exit() |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 61 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 62 | def CASE101( self, main ): |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 63 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 64 | Package ONOS and install it |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 65 | Startup sequence: |
| 66 | cell <name> |
| 67 | onos-verify-cell |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 68 | onos-package |
| 69 | onos-install -f |
| 70 | onos-wait-for-start |
| 71 | """ |
| 72 | import json |
| 73 | import time |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 74 | import os |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 75 | from operator import eq |
| 76 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 77 | main.case( "Setting up ONOS environment" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 78 | |
| 79 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 80 | global ONOS1Ip |
| 81 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 82 | ipList = [ ONOS1Ip ] |
| 83 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 84 | main.step( "Copying config files" ) |
| 85 | src = os.path.dirname( main.testFile ) + "/network-cfg.json" |
| 86 | dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json" |
| 87 | status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" ) |
| 88 | utilities.assert_equals( expect=main.TRUE, |
| 89 | actual=status, |
| 90 | onpass="Copy config file succeeded", |
| 91 | onfail="Copy config file failed" ) |
| 92 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 93 | main.step( "Create cell file" ) |
| 94 | cellAppString = main.params[ 'ENV' ][ 'appString' ] |
| 95 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 96 | main.Mininet.ip_address, |
| 97 | cellAppString, ipList ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 98 | |
| 99 | main.step( "Applying cell variable to environment" ) |
| 100 | cellResult = main.ONOSbench.setCell( cellName ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 101 | utilities.assert_equals( expect=main.TRUE, |
| 102 | actual=cellResult, |
| 103 | onpass="Set cell succeeded", |
| 104 | onfail="Set cell failed" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 105 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 106 | main.step( "Verify cell connectivity" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 107 | verifyResult = main.ONOSbench.verifyCell() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 108 | utilities.assert_equals( expect=main.TRUE, |
| 109 | actual=verifyResult, |
| 110 | onpass="Verify cell succeeded", |
| 111 | onfail="Verify cell failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 112 | |
| 113 | branchName = main.ONOSbench.getBranchName() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 114 | main.log.report( "ONOS is on branch: " + branchName ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 115 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 116 | main.log.step( "Uninstalling ONOS" ) |
| 117 | uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 118 | utilities.assert_equals( expect=main.TRUE, |
| 119 | actual=uninstallResult, |
| 120 | onpass="Uninstall ONOS succeeded", |
| 121 | onfail="Uninstall ONOS failed" ) |
pingping-lin | aede031 | 2015-09-30 17:53:19 -0700 | [diff] [blame] | 122 | ''' |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 123 | main.step( "Git pull" ) |
| 124 | gitPullResult = main.ONOSbench.gitPull() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 125 | main.log.info( "gitPullResult" ) |
| 126 | main.log.info( gitPullResult ) |
| 127 | gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 128 | utilities.assert_equals( expect=True, |
| 129 | actual=gitPullResult2, |
| 130 | onpass="Git pull ONOS succeeded", |
| 131 | onfail="Git pull ONOS failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 132 | |
| 133 | main.step( "Using mvn clean install" ) |
| 134 | if gitPullResult == main.TRUE: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 135 | mciResult = main.ONOSbench.cleanInstall( mciTimeout=1000 ) |
| 136 | utilities.assert_equals( expect=main.TRUE, |
| 137 | actual=mciResult, |
| 138 | onpass="Maven clean install ONOS succeeded", |
| 139 | onfail="Maven clean install ONOS failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 140 | else: |
| 141 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 142 | "clean install" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 143 | mciResult = main.TRUE |
pingping-lin | aede031 | 2015-09-30 17:53:19 -0700 | [diff] [blame] | 144 | ''' |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 145 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 146 | main.ONOSbench.getVersion( report=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 147 | |
| 148 | main.step( "Creating ONOS package" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 149 | packageResult = main.ONOSbench.onosPackage( opTimeout=500 ) |
| 150 | utilities.assert_equals( expect=main.TRUE, |
| 151 | actual=packageResult, |
| 152 | onpass="Package ONOS succeeded", |
| 153 | onfail="Package ONOS failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 154 | |
| 155 | main.step( "Installing ONOS package" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 156 | onos1InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 157 | node=ONOS1Ip ) |
| 158 | utilities.assert_equals( expect=main.TRUE, |
| 159 | actual=onos1InstallResult, |
| 160 | onpass="Install ONOS succeeded", |
| 161 | onfail="Install ONOS failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 162 | |
| 163 | main.step( "Checking if ONOS is up yet" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 164 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 ) |
| 165 | utilities.assert_equals( expect=main.TRUE, |
| 166 | actual=onos1UpResult, |
| 167 | onpass="ONOS is up", |
| 168 | onfail="ONOS is NOT up" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 169 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 170 | main.step( "Checking if ONOS CLI is ready" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 171 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 172 | commandlineTimeout=100, onosStartTimeout=600 ) |
| 173 | utilities.assert_equals( expect=main.TRUE, |
| 174 | actual=cliResult, |
| 175 | onpass="ONOS CLI is ready", |
| 176 | onfail="ONOS CLI is not ready" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 177 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 178 | for i in range( 10 ): |
| 179 | ready = True |
| 180 | output = main.ONOScli.summary() |
| 181 | if not output: |
| 182 | ready = False |
| 183 | if ready: |
| 184 | break |
| 185 | time.sleep( 30 ) |
| 186 | utilities.assert_equals( expect=True, actual=ready, |
| 187 | onpass="ONOS summary command succeded", |
| 188 | onfail="ONOS summary command failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 189 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 190 | if not ready: |
| 191 | main.log.error( "ONOS startup failed!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 192 | main.cleanup() |
| 193 | main.exit() |
| 194 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 195 | def CASE200( self, main ): |
| 196 | main.case( "Activate sdn-ip application" ) |
| 197 | main.log.info( "waiting link discovery......" ) |
| 198 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 199 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 200 | main.log.info( "Get links in the network" ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 201 | summaryResult = main.ONOScli.summary() |
| 202 | linkNum = json.loads( summaryResult )[ "links" ] |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 203 | listResult = main.ONOScli.links( jsonFormat=False ) |
| 204 | main.log.info( listResult ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 205 | if linkNum < 100: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 206 | main.log.error( "Link number is wrong!" ) |
| 207 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 208 | listResult = main.ONOScli.links( jsonFormat=False ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 209 | main.log.info( listResult ) |
| 210 | main.cleanup() |
| 211 | main.exit() |
| 212 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 213 | main.step( "Activate sdn-ip application" ) |
| 214 | activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 215 | utilities.assert_equals( expect=main.TRUE, |
| 216 | actual=activeSDNIPresult, |
| 217 | onpass="Activate SDN-IP succeeded", |
| 218 | onfail="Activate SDN-IP failed" ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 219 | if not activeSDNIPresult: |
| 220 | main.log.info( "Activate SDN-IP failed!" ) |
| 221 | main.cleanup() |
| 222 | main.exit() |
| 223 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 224 | |
| 225 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 226 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 227 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 228 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 229 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 230 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 231 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 232 | |
| 233 | |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 234 | def CASE102( self, main ): |
| 235 | ''' |
| 236 | This test case is to load the methods from other Python files. |
| 237 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 238 | main.case( "Loading methods from other Python file" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 239 | # load the methods from other file |
| 240 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 241 | main.Functions = imp.load_source( wrapperFile, |
| 242 | main.dependencyPath + |
| 243 | wrapperFile + |
| 244 | ".py" ) |
| 245 | |
| 246 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 247 | def CASE1( self, main ): |
| 248 | ''' |
| 249 | ping test from 3 bgp peers to BGP speaker |
| 250 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 251 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 252 | main.case( "Ping tests between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 253 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 254 | peers=["peer64514", "peer64515", "peer64516"], |
| 255 | expectAllSuccess=True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 256 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 257 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 258 | def CASE2( self, main ): |
| 259 | ''' |
| 260 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 261 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 262 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 263 | main.case( "Check point-to-point intents" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 264 | main.log.info( "There are %s BGP peers in total " |
| 265 | % main.params[ 'config' ][ 'peerNum' ] ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 266 | main.step( "Check P2P intents number from ONOS CLI" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 267 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 268 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 269 | bgpIntentsActualNum = \ |
| 270 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 271 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 272 | if bgpIntentsActualNum != bgpIntentsExpectedNum: |
| 273 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
| 274 | bgpIntentsActualNum = \ |
| 275 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 276 | main.log.info( "bgpIntentsExpected num is:" ) |
| 277 | main.log.info( bgpIntentsExpectedNum ) |
| 278 | main.log.info( "bgpIntentsActual num is:" ) |
| 279 | main.log.info( bgpIntentsActualNum ) |
| 280 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 281 | expect=True, |
| 282 | actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 283 | onpass="PointToPointIntent Intent Num is correct!", |
| 284 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 285 | |
| 286 | |
| 287 | def CASE3( self, main ): |
| 288 | ''' |
| 289 | routes and intents check to all BGP peers |
| 290 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 291 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 292 | main.case( "Check routes and M2S intents to all BGP peers" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 293 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 294 | allRoutesExpected = [] |
| 295 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 296 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 297 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 298 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 299 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 300 | allRoutesActual = \ |
| 301 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 302 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 303 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 304 | if allRoutesStrActual != allRoutesStrExpected: |
| 305 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
| 306 | allRoutesActual = \ |
| 307 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 308 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 309 | |
| 310 | main.step( "Check routes installed" ) |
| 311 | main.log.info( "Routes expected:" ) |
| 312 | main.log.info( allRoutesStrExpected ) |
| 313 | main.log.info( "Routes get from ONOS CLI:" ) |
| 314 | main.log.info( allRoutesStrActual ) |
| 315 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 316 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 317 | onpass="Routes are correct!", |
| 318 | onfail="Routes are wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 319 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 320 | main.step( "Check M2S intents installed" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 321 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 322 | routeIntentsActualNum = \ |
| 323 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 324 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 325 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 326 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
| 327 | routeIntentsActualNum = \ |
| 328 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 329 | |
| 330 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 331 | main.log.info( routeIntentsExpectedNum ) |
| 332 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 333 | main.log.info( routeIntentsActualNum ) |
| 334 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 335 | expect=routeIntentsExpectedNum, |
| 336 | actual=routeIntentsActualNum, |
| 337 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 338 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 339 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 340 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 341 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 342 | main.FALSE, |
| 343 | kwargs={'isPENDING':False}, |
| 344 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 345 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 346 | expect=main.TRUE, |
| 347 | actual=flowCheck, |
| 348 | onpass="Flow status is correct!", |
| 349 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 350 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 351 | |
| 352 | def CASE4( self, main ): |
| 353 | ''' |
| 354 | Ping test in data plane for each route |
| 355 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 356 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 357 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 358 | hosts=["host64514", "host64515", "host64516"], |
| 359 | expectAllSuccess=True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 360 | |
| 361 | |
| 362 | def CASE5( self, main ): |
| 363 | ''' |
| 364 | Cut links to peers one by one, check routes/intents |
| 365 | ''' |
| 366 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 367 | main.case( "Bring down links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 368 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 369 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 370 | OPTION="down" ) |
| 371 | utilities.assertEquals( expect=main.TRUE, |
| 372 | actual=linkResult1, |
| 373 | onpass="Bring down link succeeded!", |
| 374 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 375 | |
| 376 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 377 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 378 | main.Functions.checkRouteNum( main, 2 ) |
| 379 | main.Functions.checkM2SintentNum( main, 2 ) |
| 380 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 381 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 382 | main.cleanup() |
| 383 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 384 | |
| 385 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 386 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 387 | OPTION="down" ) |
| 388 | utilities.assertEquals( expect=main.TRUE, |
| 389 | actual=linkResult2, |
| 390 | onpass="Bring down link succeeded!", |
| 391 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 392 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 393 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 394 | main.Functions.checkRouteNum( main, 1 ) |
| 395 | main.Functions.checkM2SintentNum( main, 1 ) |
| 396 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 397 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 398 | main.cleanup() |
| 399 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 400 | |
| 401 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 402 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 403 | OPTION="down" ) |
| 404 | utilities.assertEquals( expect=main.TRUE, |
| 405 | actual=linkResult3, |
| 406 | onpass="Bring down link succeeded!", |
| 407 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 408 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 409 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 410 | main.Functions.checkRouteNum( main, 0 ) |
| 411 | main.Functions.checkM2SintentNum( main, 0 ) |
| 412 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 413 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 414 | main.cleanup() |
| 415 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 416 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 417 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 418 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 419 | main.FALSE, |
| 420 | kwargs={'isPENDING':False}, |
| 421 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 422 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 423 | expect=main.TRUE, |
| 424 | actual=flowCheck, |
| 425 | onpass="Flow status is correct!", |
| 426 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 427 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 428 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 429 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 430 | peers=["peer64514", "peer64515", "peer64516"], |
| 431 | expectAllSuccess=False ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 432 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 433 | hosts=["host64514", "host64515", "host64516"], |
| 434 | expectAllSuccess=False ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 435 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 436 | |
| 437 | def CASE6( self, main ): |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 438 | ''' |
| 439 | Recover links to peers one by one, check routes/intents |
| 440 | ''' |
| 441 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 442 | main.case( "Bring up links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 443 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 444 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 445 | OPTION="up" ) |
| 446 | utilities.assertEquals( expect=main.TRUE, |
| 447 | actual=linkResult1, |
| 448 | onpass="Bring up link succeeded!", |
| 449 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 450 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 451 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 452 | main.Functions.checkRouteNum( main, 1 ) |
| 453 | main.Functions.checkM2SintentNum( main, 1 ) |
| 454 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 455 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 456 | main.cleanup() |
| 457 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 458 | |
| 459 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 460 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 461 | OPTION="up" ) |
| 462 | utilities.assertEquals( expect=main.TRUE, |
| 463 | actual=linkResult2, |
| 464 | onpass="Bring up link succeeded!", |
| 465 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 466 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 467 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 468 | main.Functions.checkRouteNum( main, 2 ) |
| 469 | main.Functions.checkM2SintentNum( main, 2 ) |
| 470 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 471 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 472 | main.cleanup() |
| 473 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 474 | |
| 475 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 476 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 477 | OPTION="up" ) |
| 478 | utilities.assertEquals( expect=main.TRUE, |
| 479 | actual=linkResult3, |
| 480 | onpass="Bring up link succeeded!", |
| 481 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 482 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 483 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 484 | main.Functions.checkRouteNum( main, 3 ) |
| 485 | main.Functions.checkM2SintentNum( main, 3 ) |
| 486 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 487 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 488 | main.cleanup() |
| 489 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 490 | |
| 491 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 492 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 493 | main.FALSE, |
| 494 | kwargs={'isPENDING':False}, |
| 495 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 496 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 497 | expect=main.TRUE, |
| 498 | actual=flowCheck, |
| 499 | onpass="Flow status is correct!", |
| 500 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 501 | |
| 502 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 503 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 504 | peers=["peer64514", "peer64515", "peer64516"], |
| 505 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 506 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 507 | hosts=["host64514", "host64515", "host64516"], |
| 508 | expectAllSuccess=True ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 509 | |
| 510 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 511 | def CASE7( self, main ): |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 512 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 513 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 514 | ''' |
| 515 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 516 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 517 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 518 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 519 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 520 | onpass="Stopping switch succeeded!", |
| 521 | onfail="Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 522 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 523 | if result == main.TRUE: |
| 524 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 525 | main.Functions.checkRouteNum( main, 2 ) |
| 526 | main.Functions.checkM2SintentNum( main, 2 ) |
| 527 | main.Functions.checkP2PintentNum( main, 12 ) |
| 528 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 529 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 530 | main.cleanup() |
| 531 | main.exit() |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 532 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 533 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 534 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 535 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 536 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 537 | |
| 538 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 539 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 540 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 541 | onpass="Ping test result is correct", |
| 542 | onfail="Ping test result is wrong" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 543 | |
| 544 | if pingResult1 == False: |
| 545 | main.cleanup() |
| 546 | main.exit() |
| 547 | |
| 548 | main.step( "Check ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 549 | result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" ) |
| 550 | result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" ) |
| 551 | result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 552 | |
| 553 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 554 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 555 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 556 | onpass="Speaker1 ping peers successful", |
| 557 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 558 | |
| 559 | if pingResult2 == False: |
| 560 | main.cleanup() |
| 561 | main.exit() |
| 562 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 563 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 564 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 565 | main.FALSE, |
| 566 | kwargs={'isPENDING':False}, |
| 567 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 568 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 569 | expect=main.TRUE, |
| 570 | actual=flowCheck, |
| 571 | onpass="Flow status is correct!", |
| 572 | onfail="Flow status is wrong!" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 573 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 574 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 575 | def CASE8( self, main ): |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 576 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 577 | Bring up the edge switch (sw32) which was shut down in CASE7, |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 578 | check P-2-P and M-2-S intents, ping test |
| 579 | ''' |
| 580 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 581 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 582 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 583 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 584 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 585 | expect=main.TRUE, |
| 586 | actual=result1, |
| 587 | onpass="Starting switch succeeded!", |
| 588 | onfail="Starting switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 589 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 590 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 591 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 592 | expect=main.TRUE, |
| 593 | actual=result2, |
| 594 | onpass="Connect switch to ONOS succeeded!", |
| 595 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 596 | |
| 597 | if result1 and result2: |
| 598 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 599 | main.Functions.checkRouteNum( main, 3 ) |
| 600 | main.Functions.checkM2SintentNum( main, 3 ) |
| 601 | main.Functions.checkP2PintentNum( main, 18 ) |
| 602 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 603 | main.log.error( "Starting switch failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 604 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 605 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 606 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 607 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 608 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 609 | main.FALSE, |
| 610 | kwargs={'isPENDING':False}, |
| 611 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 612 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 613 | expect=main.TRUE, |
| 614 | actual=flowCheck, |
| 615 | onpass="Flow status is correct!", |
| 616 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 617 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 618 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 619 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 620 | peers=["peer64514", "peer64515", "peer64516"], |
| 621 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 622 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 623 | hosts=["host64514", "host64515", "host64516"], |
| 624 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 625 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 626 | |
| 627 | def CASE9( self, main ): |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 628 | ''' |
| 629 | Bring down a switch in best path, check: |
| 630 | route number, P2P intent number, M2S intent number, ping test |
| 631 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 632 | main.case( "Stop sw11 located in best path, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 633 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 634 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 635 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 636 | main.Functions.checkFlowNum( main, "sw11", 13 ) |
| 637 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 638 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 639 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 640 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 641 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 642 | |
| 643 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 644 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 645 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 646 | onpass="Stopping switch succeeded!", |
| 647 | onfail="Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 648 | if result: |
| 649 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 650 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 651 | main.Functions.checkRouteNum( main, 3 ) |
| 652 | main.Functions.checkM2SintentNum( main, 3 ) |
| 653 | main.Functions.checkP2PintentNum( main, 18 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 654 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 655 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 656 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 657 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 658 | |
| 659 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 660 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 661 | main.FALSE, |
| 662 | kwargs={'isPENDING':False}, |
| 663 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 664 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 665 | expect=main.TRUE, |
| 666 | actual=flowCheck, |
| 667 | onpass="Flow status is correct!", |
| 668 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 669 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 670 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 671 | peers=["peer64514", "peer64515", "peer64516"], |
| 672 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 673 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 674 | hosts=["host64514", "host64515", "host64516"], |
| 675 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 676 | |
| 677 | |
| 678 | def CASE10( self, main ): |
| 679 | ''' |
| 680 | Bring up the switch which was stopped in CASE9, check: |
| 681 | route number, P2P intent number, M2S intent number, ping test |
| 682 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 683 | main.case( "Start sw11 which was stopped in CASE9, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 684 | check route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 685 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 686 | main.log.info( "Check the flow status before starting sw11" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 687 | main.Functions.checkFlowNum( main, "sw1", 11 ) |
| 688 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 689 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 690 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 691 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 692 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 693 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 694 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 695 | onpass="Starting switch succeeded!", |
| 696 | onfail="Starting switch failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 697 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 698 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 699 | onpass="Connect switch to ONOS succeeded!", |
| 700 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 701 | if result1 and result2: |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 702 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 703 | main.Functions.checkRouteNum( main, 3 ) |
| 704 | main.Functions.checkM2SintentNum( main, 3 ) |
| 705 | main.Functions.checkP2PintentNum( main, 18 ) |
| 706 | |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 707 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 708 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 709 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 710 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 711 | main.log.error( "Starting switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 712 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 713 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 714 | |
| 715 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 716 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 717 | main.FALSE, |
| 718 | kwargs={'isPENDING':False}, |
| 719 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 720 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 721 | expect=main.TRUE, |
| 722 | actual=flowCheck, |
| 723 | onpass="Flow status is correct!", |
| 724 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 725 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 726 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 727 | peers=["peer64514", "peer64515", "peer64516"], |
| 728 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 729 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 730 | hosts=["host64514", "host64515", "host64516"], |
| 731 | expectAllSuccess=True ) |