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