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