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 | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 149 | packageResult = main.ONOSbench.buckBuild() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 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 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 170 | main.step( "Set up ONOS secure SSH" ) |
| 171 | secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip ) |
| 172 | utilities.assert_equals( expect=main.TRUE, |
| 173 | actual=secureSshResult, |
| 174 | onpass="Set up ONOS secure SSH succeeded", |
| 175 | onfail="Set up ONOS secure SSH failed " ) |
| 176 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 177 | main.step( "Checking if ONOS CLI is ready" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 178 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 179 | commandlineTimeout=100, onosStartTimeout=600 ) |
| 180 | utilities.assert_equals( expect=main.TRUE, |
| 181 | actual=cliResult, |
| 182 | onpass="ONOS CLI is ready", |
| 183 | onfail="ONOS CLI is not ready" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 184 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 185 | for i in range( 10 ): |
| 186 | ready = True |
| 187 | output = main.ONOScli.summary() |
| 188 | if not output: |
| 189 | ready = False |
| 190 | if ready: |
| 191 | break |
| 192 | time.sleep( 30 ) |
| 193 | utilities.assert_equals( expect=True, actual=ready, |
| 194 | onpass="ONOS summary command succeded", |
| 195 | onfail="ONOS summary command failed" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 196 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 197 | if not ready: |
| 198 | main.log.error( "ONOS startup failed!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 199 | main.cleanup() |
| 200 | main.exit() |
| 201 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 202 | def CASE200( self, main ): |
| 203 | main.case( "Activate sdn-ip application" ) |
| 204 | main.log.info( "waiting link discovery......" ) |
| 205 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 206 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 207 | main.log.info( "Get links in the network" ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 208 | summaryResult = main.ONOScli.summary() |
| 209 | linkNum = json.loads( summaryResult )[ "links" ] |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 210 | listResult = main.ONOScli.links( jsonFormat=False ) |
| 211 | main.log.info( listResult ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 212 | if linkNum < 100: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 213 | main.log.error( "Link number is wrong!" ) |
| 214 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 215 | listResult = main.ONOScli.links( jsonFormat=False ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 216 | main.log.info( listResult ) |
| 217 | main.cleanup() |
| 218 | main.exit() |
| 219 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 220 | main.step( "Activate sdn-ip application" ) |
| 221 | activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 222 | utilities.assert_equals( expect=main.TRUE, |
| 223 | actual=activeSDNIPresult, |
| 224 | onpass="Activate SDN-IP succeeded", |
| 225 | onfail="Activate SDN-IP failed" ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 226 | if not activeSDNIPresult: |
| 227 | main.log.info( "Activate SDN-IP failed!" ) |
| 228 | main.cleanup() |
| 229 | main.exit() |
| 230 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 231 | |
| 232 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 233 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 234 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 235 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 236 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 237 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 238 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 239 | |
| 240 | |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 241 | def CASE102( self, main ): |
| 242 | ''' |
| 243 | This test case is to load the methods from other Python files. |
| 244 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 245 | main.case( "Loading methods from other Python file" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 246 | # load the methods from other file |
| 247 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 248 | main.Functions = imp.load_source( wrapperFile, |
| 249 | main.dependencyPath + |
| 250 | wrapperFile + |
| 251 | ".py" ) |
| 252 | |
| 253 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 254 | def CASE1( self, main ): |
| 255 | ''' |
| 256 | ping test from 3 bgp peers to BGP speaker |
| 257 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 258 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 259 | main.case( "Ping tests between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 260 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 261 | peers=["peer64514", "peer64515", "peer64516"], |
| 262 | expectAllSuccess=True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 263 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 264 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 265 | def CASE2( self, main ): |
| 266 | ''' |
| 267 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 268 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 269 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 270 | main.case( "Check point-to-point intents" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 271 | main.log.info( "There are %s BGP peers in total " |
| 272 | % main.params[ 'config' ][ 'peerNum' ] ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 273 | main.step( "Check P2P intents number from ONOS CLI" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 274 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 275 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 276 | bgpIntentsActualNum = \ |
| 277 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 278 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 279 | if bgpIntentsActualNum != bgpIntentsExpectedNum: |
| 280 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 281 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 282 | bgpIntentsActualNum = \ |
| 283 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 284 | main.log.info( "bgpIntentsExpected num is:" ) |
| 285 | main.log.info( bgpIntentsExpectedNum ) |
| 286 | main.log.info( "bgpIntentsActual num is:" ) |
| 287 | main.log.info( bgpIntentsActualNum ) |
| 288 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 289 | expect=True, |
| 290 | actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 291 | onpass="PointToPointIntent Intent Num is correct!", |
| 292 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 293 | |
| 294 | |
| 295 | def CASE3( self, main ): |
| 296 | ''' |
| 297 | routes and intents check to all BGP peers |
| 298 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 299 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 300 | main.case( "Check routes and M2S intents to all BGP peers" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 301 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 302 | allRoutesExpected = [] |
| 303 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 304 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 305 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 306 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 307 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 308 | allRoutesActual = \ |
| 309 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 310 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 311 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 312 | if allRoutesStrActual != allRoutesStrExpected: |
| 313 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 314 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 315 | allRoutesActual = \ |
| 316 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 317 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 318 | |
| 319 | main.step( "Check routes installed" ) |
| 320 | main.log.info( "Routes expected:" ) |
| 321 | main.log.info( allRoutesStrExpected ) |
| 322 | main.log.info( "Routes get from ONOS CLI:" ) |
| 323 | main.log.info( allRoutesStrActual ) |
| 324 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 325 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 326 | onpass="Routes are correct!", |
| 327 | onfail="Routes are wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 328 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 329 | main.step( "Check M2S intents installed" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 330 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 331 | routeIntentsActualNum = \ |
| 332 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 333 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 334 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 335 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 336 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 337 | routeIntentsActualNum = \ |
| 338 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 339 | |
| 340 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 341 | main.log.info( routeIntentsExpectedNum ) |
| 342 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 343 | main.log.info( routeIntentsActualNum ) |
| 344 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 345 | expect=routeIntentsExpectedNum, |
| 346 | actual=routeIntentsActualNum, |
| 347 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 348 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 349 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 350 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 351 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 352 | main.FALSE, |
| 353 | kwargs={'isPENDING':False}, |
| 354 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 355 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 356 | expect=main.TRUE, |
| 357 | actual=flowCheck, |
| 358 | onpass="Flow status is correct!", |
| 359 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 360 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 361 | |
| 362 | def CASE4( self, main ): |
| 363 | ''' |
| 364 | Ping test in data plane for each route |
| 365 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 366 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 367 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 368 | hosts=["host64514", "host64515", "host64516"], |
| 369 | expectAllSuccess=True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 370 | |
| 371 | |
| 372 | def CASE5( self, main ): |
| 373 | ''' |
| 374 | Cut links to peers one by one, check routes/intents |
| 375 | ''' |
| 376 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 377 | main.case( "Bring down links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 378 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 379 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 380 | OPTION="down" ) |
| 381 | utilities.assertEquals( expect=main.TRUE, |
| 382 | actual=linkResult1, |
| 383 | onpass="Bring down link succeeded!", |
| 384 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 385 | |
| 386 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 387 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 388 | main.Functions.checkRouteNum( main, 2 ) |
| 389 | main.Functions.checkM2SintentNum( main, 2 ) |
| 390 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 391 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 392 | main.cleanup() |
| 393 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 394 | |
| 395 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 396 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 397 | OPTION="down" ) |
| 398 | utilities.assertEquals( expect=main.TRUE, |
| 399 | actual=linkResult2, |
| 400 | onpass="Bring down link succeeded!", |
| 401 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 402 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 403 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 404 | main.Functions.checkRouteNum( main, 1 ) |
| 405 | main.Functions.checkM2SintentNum( main, 1 ) |
| 406 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 407 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 408 | main.cleanup() |
| 409 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 410 | |
| 411 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 412 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 413 | OPTION="down" ) |
| 414 | utilities.assertEquals( expect=main.TRUE, |
| 415 | actual=linkResult3, |
| 416 | onpass="Bring down link succeeded!", |
| 417 | onfail="Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 418 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 419 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 420 | main.Functions.checkRouteNum( main, 0 ) |
| 421 | main.Functions.checkM2SintentNum( main, 0 ) |
| 422 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 423 | main.log.error( "Bring down link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 424 | main.cleanup() |
| 425 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 426 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 427 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 428 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 429 | main.FALSE, |
| 430 | kwargs={'isPENDING':False}, |
| 431 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 432 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 433 | expect=main.TRUE, |
| 434 | actual=flowCheck, |
| 435 | onpass="Flow status is correct!", |
| 436 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 437 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 438 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 439 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 440 | peers=["peer64514", "peer64515", "peer64516"], |
| 441 | expectAllSuccess=False ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 442 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 443 | hosts=["host64514", "host64515", "host64516"], |
| 444 | expectAllSuccess=False ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 445 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 446 | |
| 447 | def CASE6( self, main ): |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 448 | ''' |
| 449 | Recover links to peers one by one, check routes/intents |
| 450 | ''' |
| 451 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 452 | main.case( "Bring up links and check routes/intents" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 453 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 454 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 455 | OPTION="up" ) |
| 456 | utilities.assertEquals( expect=main.TRUE, |
| 457 | actual=linkResult1, |
| 458 | onpass="Bring up link succeeded!", |
| 459 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 460 | if linkResult1 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 461 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 462 | main.Functions.checkRouteNum( main, 1 ) |
| 463 | main.Functions.checkM2SintentNum( main, 1 ) |
| 464 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 465 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 466 | main.cleanup() |
| 467 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 468 | |
| 469 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 470 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 471 | OPTION="up" ) |
| 472 | utilities.assertEquals( expect=main.TRUE, |
| 473 | actual=linkResult2, |
| 474 | onpass="Bring up link succeeded!", |
| 475 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 476 | if linkResult2 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 477 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 478 | main.Functions.checkRouteNum( main, 2 ) |
| 479 | main.Functions.checkM2SintentNum( main, 2 ) |
| 480 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 481 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 482 | main.cleanup() |
| 483 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 484 | |
| 485 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 486 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 487 | OPTION="up" ) |
| 488 | utilities.assertEquals( expect=main.TRUE, |
| 489 | actual=linkResult3, |
| 490 | onpass="Bring up link succeeded!", |
| 491 | onfail="Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 492 | if linkResult3 == main.TRUE: |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 493 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 494 | main.Functions.checkRouteNum( main, 3 ) |
| 495 | main.Functions.checkM2SintentNum( main, 3 ) |
| 496 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 497 | main.log.error( "Bring up link failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 498 | main.cleanup() |
| 499 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 500 | |
| 501 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 502 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 503 | main.FALSE, |
| 504 | kwargs={'isPENDING':False}, |
| 505 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 506 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 507 | expect=main.TRUE, |
| 508 | actual=flowCheck, |
| 509 | onpass="Flow status is correct!", |
| 510 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 511 | |
| 512 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 513 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 514 | peers=["peer64514", "peer64515", "peer64516"], |
| 515 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 516 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 517 | hosts=["host64514", "host64515", "host64516"], |
| 518 | expectAllSuccess=True ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 519 | |
| 520 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 521 | def CASE7( self, main ): |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 522 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 523 | 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] | 524 | ''' |
| 525 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 526 | 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] | 527 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 528 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 529 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 530 | onpass="Stopping switch succeeded!", |
| 531 | onfail="Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 532 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 533 | if result == main.TRUE: |
| 534 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 535 | main.Functions.checkRouteNum( main, 2 ) |
| 536 | main.Functions.checkM2SintentNum( main, 2 ) |
| 537 | main.Functions.checkP2PintentNum( main, 12 ) |
| 538 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 539 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 540 | main.cleanup() |
| 541 | main.exit() |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 542 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 543 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 544 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 545 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 546 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 547 | |
| 548 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 549 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 550 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 551 | onpass="Ping test result is correct", |
| 552 | onfail="Ping test result is wrong" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 553 | |
| 554 | if pingResult1 == False: |
| 555 | main.cleanup() |
| 556 | main.exit() |
| 557 | |
| 558 | main.step( "Check ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 559 | result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" ) |
| 560 | result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" ) |
| 561 | result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 562 | |
| 563 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 564 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 565 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 566 | onpass="Speaker1 ping peers successful", |
| 567 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 568 | |
| 569 | if pingResult2 == False: |
| 570 | main.cleanup() |
| 571 | main.exit() |
| 572 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 573 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 574 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 575 | main.FALSE, |
| 576 | kwargs={'isPENDING':False}, |
| 577 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 578 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 579 | expect=main.TRUE, |
| 580 | actual=flowCheck, |
| 581 | onpass="Flow status is correct!", |
| 582 | onfail="Flow status is wrong!" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 583 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 584 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 585 | def CASE8( self, main ): |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 586 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 587 | Bring up the edge switch (sw32) which was shut down in CASE7, |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 588 | check P-2-P and M-2-S intents, ping test |
| 589 | ''' |
| 590 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 591 | 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] | 592 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 593 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
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=result1, |
| 597 | onpass="Starting switch succeeded!", |
| 598 | onfail="Starting switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 599 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 600 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 601 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 602 | expect=main.TRUE, |
| 603 | actual=result2, |
| 604 | onpass="Connect switch to ONOS succeeded!", |
| 605 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 606 | |
| 607 | if result1 and result2: |
| 608 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 609 | main.Functions.checkRouteNum( main, 3 ) |
| 610 | main.Functions.checkM2SintentNum( main, 3 ) |
| 611 | main.Functions.checkP2PintentNum( main, 18 ) |
| 612 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 613 | main.log.error( "Starting switch failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 614 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 615 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 616 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 617 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 618 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 619 | main.FALSE, |
| 620 | kwargs={'isPENDING':False}, |
| 621 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 622 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 623 | expect=main.TRUE, |
| 624 | actual=flowCheck, |
| 625 | onpass="Flow status is correct!", |
| 626 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 627 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 628 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 629 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 630 | peers=["peer64514", "peer64515", "peer64516"], |
| 631 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 632 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 633 | hosts=["host64514", "host64515", "host64516"], |
| 634 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 635 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 636 | |
| 637 | def CASE9( self, main ): |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 638 | ''' |
| 639 | Bring down a switch in best path, check: |
| 640 | route number, P2P intent number, M2S intent number, ping test |
| 641 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 642 | main.case( "Stop sw11 located in best path, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 643 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 644 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 645 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 646 | main.Functions.checkFlowNum( main, "sw11", 13 ) |
| 647 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 648 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 649 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 650 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 651 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 652 | |
| 653 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 654 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 655 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 656 | onpass="Stopping switch succeeded!", |
| 657 | onfail="Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 658 | if result: |
| 659 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 660 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 661 | main.Functions.checkRouteNum( main, 3 ) |
| 662 | main.Functions.checkM2SintentNum( main, 3 ) |
| 663 | main.Functions.checkP2PintentNum( main, 18 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 664 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 665 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 666 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 667 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 668 | |
| 669 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 670 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 671 | main.FALSE, |
| 672 | kwargs={'isPENDING':False}, |
| 673 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 674 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 675 | expect=main.TRUE, |
| 676 | actual=flowCheck, |
| 677 | onpass="Flow status is correct!", |
| 678 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 679 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 680 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 681 | peers=["peer64514", "peer64515", "peer64516"], |
| 682 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 683 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 684 | hosts=["host64514", "host64515", "host64516"], |
| 685 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 686 | |
| 687 | |
| 688 | def CASE10( self, main ): |
| 689 | ''' |
| 690 | Bring up the switch which was stopped in CASE9, check: |
| 691 | route number, P2P intent number, M2S intent number, ping test |
| 692 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 693 | main.case( "Start sw11 which was stopped in CASE9, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 694 | check route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 695 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 696 | main.log.info( "Check the flow status before starting sw11" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 697 | main.Functions.checkFlowNum( main, "sw1", 11 ) |
| 698 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 699 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 700 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 701 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 702 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 703 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 704 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 705 | onpass="Starting switch succeeded!", |
| 706 | onfail="Starting switch failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 707 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 708 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 709 | onpass="Connect switch to ONOS succeeded!", |
| 710 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 711 | if result1 and result2: |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 712 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 713 | main.Functions.checkRouteNum( main, 3 ) |
| 714 | main.Functions.checkM2SintentNum( main, 3 ) |
| 715 | main.Functions.checkP2PintentNum( main, 18 ) |
| 716 | |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 717 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 718 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 719 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 720 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 721 | main.log.error( "Starting switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 722 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 723 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 724 | |
| 725 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 1aa0560 | 2016-04-05 10:25:39 -0700 | [diff] [blame] | 726 | flowCheck = utilities.retry( main.ONOScli.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 727 | main.FALSE, |
| 728 | kwargs={'isPENDING':False}, |
| 729 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 730 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 731 | expect=main.TRUE, |
| 732 | actual=flowCheck, |
| 733 | onpass="Flow status is correct!", |
| 734 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 735 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 736 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 737 | peers=["peer64514", "peer64515", "peer64516"], |
| 738 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 739 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 740 | hosts=["host64514", "host64515", "host64516"], |
| 741 | expectAllSuccess=True ) |