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 | |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 116 | main.step( "Uninstalling ONOS" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 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'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 274 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 275 | bgpIntentsActualNum = \ |
| 276 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 277 | main.log.info( "bgpIntentsExpected num is:" ) |
| 278 | main.log.info( bgpIntentsExpectedNum ) |
| 279 | main.log.info( "bgpIntentsActual num is:" ) |
| 280 | main.log.info( bgpIntentsActualNum ) |
| 281 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 282 | expect=True, |
| 283 | actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 284 | onpass="PointToPointIntent Intent Num is correct!", |
| 285 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 286 | |
| 287 | |
| 288 | def CASE3( self, main ): |
| 289 | ''' |
| 290 | routes and intents check to all BGP peers |
| 291 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 292 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 293 | main.case( "Check routes and M2S intents to all BGP peers" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 294 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 295 | allRoutesExpected = [] |
| 296 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 297 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 298 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 299 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 300 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 301 | allRoutesActual = \ |
| 302 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 303 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 304 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 305 | if allRoutesStrActual != allRoutesStrExpected: |
| 306 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 307 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 308 | allRoutesActual = \ |
| 309 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 310 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 311 | |
| 312 | main.step( "Check routes installed" ) |
| 313 | main.log.info( "Routes expected:" ) |
| 314 | main.log.info( allRoutesStrExpected ) |
| 315 | main.log.info( "Routes get from ONOS CLI:" ) |
| 316 | main.log.info( allRoutesStrActual ) |
| 317 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 318 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 319 | onpass="Routes are correct!", |
| 320 | onfail="Routes are wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 321 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 322 | main.step( "Check M2S intents installed" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 323 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 324 | routeIntentsActualNum = \ |
| 325 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 326 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 327 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 328 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 329 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 330 | routeIntentsActualNum = \ |
| 331 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 332 | |
| 333 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 334 | main.log.info( routeIntentsExpectedNum ) |
| 335 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 336 | main.log.info( routeIntentsActualNum ) |
| 337 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 338 | expect=routeIntentsExpectedNum, |
| 339 | actual=routeIntentsActualNum, |
| 340 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 341 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 342 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 343 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 344 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 345 | main.FALSE, |
| 346 | kwargs={'isPENDING':False}, |
| 347 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 348 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 349 | expect=main.TRUE, |
| 350 | actual=flowCheck, |
| 351 | onpass="Flow status is correct!", |
| 352 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 353 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 354 | |
| 355 | def CASE4( self, main ): |
| 356 | ''' |
| 357 | Ping test in data plane for each route |
| 358 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 359 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 360 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 361 | hosts=["host64514", "host64515", "host64516"], |
| 362 | expectAllSuccess=True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 363 | |
| 364 | |
| 365 | def CASE5( self, main ): |
| 366 | ''' |
| 367 | Cut links to peers one by one, check routes/intents |
| 368 | ''' |
| 369 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 370 | main.case( "Bring down links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 371 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 372 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 373 | OPTION="down" ) |
| 374 | utilities.assertEquals( expect=main.TRUE, |
| 375 | actual=linkResult1, |
| 376 | onpass="Bring down link succeeded!", |
| 377 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 378 | |
| 379 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 380 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 381 | main.Functions.checkRouteNum( main, 2 ) |
| 382 | main.Functions.checkM2SintentNum( main, 2 ) |
| 383 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 384 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 385 | main.cleanup() |
| 386 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 387 | |
| 388 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 389 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 390 | OPTION="down" ) |
| 391 | utilities.assertEquals( expect=main.TRUE, |
| 392 | actual=linkResult2, |
| 393 | onpass="Bring down link succeeded!", |
| 394 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 395 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 396 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 397 | main.Functions.checkRouteNum( main, 1 ) |
| 398 | main.Functions.checkM2SintentNum( main, 1 ) |
| 399 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 400 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 401 | main.cleanup() |
| 402 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 403 | |
| 404 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 405 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 406 | OPTION="down" ) |
| 407 | utilities.assertEquals( expect=main.TRUE, |
| 408 | actual=linkResult3, |
| 409 | onpass="Bring down link succeeded!", |
| 410 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 411 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 412 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 413 | main.Functions.checkRouteNum( main, 0 ) |
| 414 | main.Functions.checkM2SintentNum( main, 0 ) |
| 415 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 416 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 417 | main.cleanup() |
| 418 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 419 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 420 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 421 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 422 | main.FALSE, |
| 423 | kwargs={'isPENDING':False}, |
| 424 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 425 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 426 | expect=main.TRUE, |
| 427 | actual=flowCheck, |
| 428 | onpass="Flow status is correct!", |
| 429 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 430 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 431 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 432 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 433 | peers=["peer64514", "peer64515", "peer64516"], |
| 434 | expectAllSuccess=False ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 435 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 436 | hosts=["host64514", "host64515", "host64516"], |
| 437 | expectAllSuccess=False ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 438 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 439 | |
| 440 | def CASE6( self, main ): |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 441 | ''' |
| 442 | Recover links to peers one by one, check routes/intents |
| 443 | ''' |
| 444 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 445 | main.case( "Bring up links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 446 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 447 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 448 | OPTION="up" ) |
| 449 | utilities.assertEquals( expect=main.TRUE, |
| 450 | actual=linkResult1, |
| 451 | onpass="Bring up link succeeded!", |
| 452 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 453 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 454 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 455 | main.Functions.checkRouteNum( main, 1 ) |
| 456 | main.Functions.checkM2SintentNum( main, 1 ) |
| 457 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 458 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 459 | main.cleanup() |
| 460 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 461 | |
| 462 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 463 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 464 | OPTION="up" ) |
| 465 | utilities.assertEquals( expect=main.TRUE, |
| 466 | actual=linkResult2, |
| 467 | onpass="Bring up link succeeded!", |
| 468 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 469 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 470 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 471 | main.Functions.checkRouteNum( main, 2 ) |
| 472 | main.Functions.checkM2SintentNum( main, 2 ) |
| 473 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 474 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 475 | main.cleanup() |
| 476 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 477 | |
| 478 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 479 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 480 | OPTION="up" ) |
| 481 | utilities.assertEquals( expect=main.TRUE, |
| 482 | actual=linkResult3, |
| 483 | onpass="Bring up link succeeded!", |
| 484 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 485 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 486 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 487 | main.Functions.checkRouteNum( main, 3 ) |
| 488 | main.Functions.checkM2SintentNum( main, 3 ) |
| 489 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 490 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 491 | main.cleanup() |
| 492 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 493 | |
| 494 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 495 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 496 | main.FALSE, |
| 497 | kwargs={'isPENDING':False}, |
| 498 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 499 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 500 | expect=main.TRUE, |
| 501 | actual=flowCheck, |
| 502 | onpass="Flow status is correct!", |
| 503 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 504 | |
| 505 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 506 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 507 | peers=["peer64514", "peer64515", "peer64516"], |
| 508 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 509 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 510 | hosts=["host64514", "host64515", "host64516"], |
| 511 | expectAllSuccess=True ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 512 | |
| 513 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 514 | def CASE7( self, main ): |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 515 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 516 | 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] | 517 | ''' |
| 518 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 519 | 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] | 520 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 521 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 522 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 523 | onpass="Stopping switch succeeded!", |
| 524 | onfail="Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 525 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 526 | if result == main.TRUE: |
| 527 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 528 | main.Functions.checkRouteNum( main, 2 ) |
| 529 | main.Functions.checkM2SintentNum( main, 2 ) |
| 530 | main.Functions.checkP2PintentNum( main, 12 ) |
| 531 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 532 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 533 | main.cleanup() |
| 534 | main.exit() |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 535 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 536 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 537 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 538 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 539 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 540 | |
| 541 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 542 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 543 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 544 | onpass="Ping test result is correct", |
| 545 | onfail="Ping test result is wrong" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 546 | |
| 547 | if pingResult1 == False: |
| 548 | main.cleanup() |
| 549 | main.exit() |
| 550 | |
| 551 | main.step( "Check ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 552 | result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" ) |
| 553 | result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" ) |
| 554 | result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 555 | |
| 556 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 557 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 558 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 559 | onpass="Speaker1 ping peers successful", |
| 560 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 561 | |
| 562 | if pingResult2 == False: |
| 563 | main.cleanup() |
| 564 | main.exit() |
| 565 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 566 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 567 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 568 | main.FALSE, |
| 569 | kwargs={'isPENDING':False}, |
| 570 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 571 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 572 | expect=main.TRUE, |
| 573 | actual=flowCheck, |
| 574 | onpass="Flow status is correct!", |
| 575 | onfail="Flow status is wrong!" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 576 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 577 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 578 | def CASE8( self, main ): |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 579 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 580 | Bring up the edge switch (sw32) which was shut down in CASE7, |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 581 | check P-2-P and M-2-S intents, ping test |
| 582 | ''' |
| 583 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 584 | 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] | 585 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 586 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 587 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 588 | expect=main.TRUE, |
| 589 | actual=result1, |
| 590 | onpass="Starting switch succeeded!", |
| 591 | onfail="Starting switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 592 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 593 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 594 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 595 | expect=main.TRUE, |
| 596 | actual=result2, |
| 597 | onpass="Connect switch to ONOS succeeded!", |
| 598 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 599 | |
| 600 | if result1 and result2: |
| 601 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 602 | main.Functions.checkRouteNum( main, 3 ) |
| 603 | main.Functions.checkM2SintentNum( main, 3 ) |
| 604 | main.Functions.checkP2PintentNum( main, 18 ) |
| 605 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 606 | main.log.error( "Starting switch failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 607 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 608 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 609 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 610 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 611 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 612 | main.FALSE, |
| 613 | kwargs={'isPENDING':False}, |
| 614 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 615 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 616 | expect=main.TRUE, |
| 617 | actual=flowCheck, |
| 618 | onpass="Flow status is correct!", |
| 619 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 620 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 621 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 622 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 623 | peers=["peer64514", "peer64515", "peer64516"], |
| 624 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 625 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 626 | hosts=["host64514", "host64515", "host64516"], |
| 627 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 628 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 629 | |
| 630 | def CASE9( self, main ): |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 631 | ''' |
| 632 | Bring down a switch in best path, check: |
| 633 | route number, P2P intent number, M2S intent number, ping test |
| 634 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 635 | main.case( "Stop sw11 located in best path, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 636 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 637 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 638 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 639 | main.Functions.checkFlowNum( main, "sw11", 13 ) |
| 640 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 641 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 642 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 643 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 644 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 645 | |
| 646 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 647 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 648 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 649 | onpass="Stopping switch succeeded!", |
| 650 | onfail="Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 651 | if result: |
| 652 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 653 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 654 | main.Functions.checkRouteNum( main, 3 ) |
| 655 | main.Functions.checkM2SintentNum( main, 3 ) |
| 656 | main.Functions.checkP2PintentNum( main, 18 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 657 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 658 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 659 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 660 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 661 | |
| 662 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 663 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 664 | main.FALSE, |
| 665 | kwargs={'isPENDING':False}, |
| 666 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 667 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 668 | expect=main.TRUE, |
| 669 | actual=flowCheck, |
| 670 | onpass="Flow status is correct!", |
| 671 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 672 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 673 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 674 | peers=["peer64514", "peer64515", "peer64516"], |
| 675 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 676 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 677 | hosts=["host64514", "host64515", "host64516"], |
| 678 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 679 | |
| 680 | |
| 681 | def CASE10( self, main ): |
| 682 | ''' |
| 683 | Bring up the switch which was stopped in CASE9, check: |
| 684 | route number, P2P intent number, M2S intent number, ping test |
| 685 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 686 | main.case( "Start sw11 which was stopped in CASE9, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 687 | check route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 688 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 689 | main.log.info( "Check the flow status before starting sw11" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 690 | main.Functions.checkFlowNum( main, "sw1", 11 ) |
| 691 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 692 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 693 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 694 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 695 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 696 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 697 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 698 | onpass="Starting switch succeeded!", |
| 699 | onfail="Starting switch failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 700 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 701 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 702 | onpass="Connect switch to ONOS succeeded!", |
| 703 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 704 | if result1 and result2: |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 705 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 706 | main.Functions.checkRouteNum( main, 3 ) |
| 707 | main.Functions.checkM2SintentNum( main, 3 ) |
| 708 | main.Functions.checkP2PintentNum( main, 18 ) |
| 709 | |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 710 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 711 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 712 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 713 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 714 | main.log.error( "Starting switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 715 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 716 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 717 | |
| 718 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 719 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 720 | main.FALSE, |
| 721 | kwargs={'isPENDING':False}, |
| 722 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 723 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 724 | expect=main.TRUE, |
| 725 | actual=flowCheck, |
| 726 | onpass="Flow status is correct!", |
| 727 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 728 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 729 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 730 | peers=["peer64514", "peer64515", "peer64516"], |
| 731 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 732 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 733 | hosts=["host64514", "host64515", "host64516"], |
| 734 | expectAllSuccess=True ) |