kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing network scalability, this test suite scales up a network topology |
| 3 | # using mininet and verifies ONOS stability |
| 4 | |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 5 | class SCPFscaleTopo: |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
| 10 | def CASE1( self, main ): |
| 11 | import time |
| 12 | import os |
| 13 | import imp |
Jon Hall | f632d20 | 2015-07-30 15:45:11 -0700 | [diff] [blame] | 14 | import re |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 15 | |
| 16 | """ |
| 17 | - Construct tests variables |
| 18 | - GIT ( optional ) |
| 19 | - Checkout ONOS master branch |
| 20 | - Pull latest ONOS code |
| 21 | - Building ONOS ( optional ) |
| 22 | - Install ONOS package |
| 23 | - Build ONOS package |
| 24 | """ |
| 25 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 26 | main.case( "Constructing test variables" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 27 | main.step( "Constructing test variables" ) |
| 28 | stepResult = main.FALSE |
| 29 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 30 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 31 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 32 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 33 | main.dependencyPath = main.testOnDirectory + \ |
| 34 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 35 | main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ] |
| 36 | main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ] |
| 37 | main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] ) |
| 38 | main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," ) |
| 39 | main.topoScaleSize = len( main.topoScale ) |
| 40 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 41 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 42 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 43 | main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] ) |
| 44 | main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] ) |
| 45 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 46 | main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 47 | main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 48 | main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 49 | main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 50 | main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 51 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 52 | main.homeDir = os.path.expanduser('~') |
| 53 | main.cellData = {} # for creating cell file |
| 54 | main.hostsData = {} |
| 55 | main.CLIs = [] |
| 56 | main.ONOSip = [] |
| 57 | main.activeNodes = [] |
| 58 | main.ONOSip = main.ONOSbench.getOnosIps() |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 59 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 60 | for i in range(main.numCtrls): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 61 | main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) ) |
| 62 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 63 | main.startUp = imp.load_source( wrapperFile1, |
| 64 | main.dependencyPath + |
| 65 | wrapperFile1 + |
| 66 | ".py" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 67 | main.scaleTopoFunction = imp.load_source( wrapperFile2, |
| 68 | main.dependencyPath + |
| 69 | wrapperFile2 + |
| 70 | ".py" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 71 | main.topo = imp.load_source( wrapperFile3, |
| 72 | main.dependencyPath + |
| 73 | wrapperFile3 + |
| 74 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 75 | main.ONOSbench.scp( main.Mininet1, |
| 76 | main.dependencyPath + |
| 77 | main.multiovs, |
| 78 | main.Mininet1.home, |
| 79 | direction="to" ) |
| 80 | |
| 81 | if main.CLIs: |
| 82 | stepResult = main.TRUE |
| 83 | else: |
| 84 | main.log.error( "Did not properly created list of " + |
| 85 | "ONOS CLI handle" ) |
| 86 | stepResult = main.FALSE |
| 87 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 88 | utilities.assert_equals( expect=main.TRUE, |
| 89 | actual=stepResult, |
| 90 | onpass="Successfully construct " + |
| 91 | "test variables ", |
| 92 | onfail="Failed to construct test variables" ) |
| 93 | |
| 94 | if gitPull == 'True': |
| 95 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 96 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 97 | stepResult = onosBuildResult |
| 98 | utilities.assert_equals( expect=main.TRUE, |
| 99 | actual=stepResult, |
| 100 | onpass="Successfully compiled " + |
| 101 | "latest ONOS", |
| 102 | onfail="Failed to compile " + |
| 103 | "latest ONOS" ) |
| 104 | else: |
| 105 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 106 | "clean install" ) |
| 107 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 108 | |
| 109 | def CASE2( self, main): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 110 | """ |
| 111 | - Set up cell |
| 112 | - Create cell file |
| 113 | - Set cell file |
| 114 | - Verify cell file |
| 115 | - Kill ONOS process |
| 116 | - Uninstall ONOS cluster |
| 117 | - Verify ONOS start up |
| 118 | - Install ONOS cluster |
| 119 | - Connect to cli |
| 120 | """ |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 121 | main.log.info( "Checking if mininet is already running" ) |
| 122 | if len( main.topoScale ) < main.topoScaleSize: |
| 123 | main.log.info( "Mininet is already running. Stopping mininet." ) |
| 124 | main.Mininet1.stopNet() |
| 125 | time.sleep(main.MNSleep) |
| 126 | else: |
| 127 | main.log.info( "Mininet was not running" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 128 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 129 | main.case( "Starting up " + str( main.numCtrls ) + |
| 130 | " node(s) ONOS cluster" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 131 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 132 | " node(s) ONOS cluster" |
| 133 | |
| 134 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 135 | |
| 136 | #kill off all onos processes |
| 137 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 138 | " before initiating environment setup" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 139 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 140 | for i in range( main.numCtrls ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 141 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 142 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 143 | tempOnosIp = [] |
| 144 | for i in range( main.numCtrls ): |
| 145 | tempOnosIp.append( main.ONOSip[i] ) |
| 146 | |
| 147 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 148 | "temp", main.Mininet1.ip_address, |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 149 | main.apps, tempOnosIp ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 150 | |
| 151 | main.step( "Apply cell to environment" ) |
| 152 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 153 | verifyResult = main.ONOSbench.verifyCell() |
| 154 | stepResult = cellResult and verifyResult |
| 155 | utilities.assert_equals( expect=main.TRUE, |
| 156 | actual=stepResult, |
| 157 | onpass="Successfully applied cell to " + \ |
| 158 | "environment", |
| 159 | onfail="Failed to apply cell to environment " ) |
| 160 | |
| 161 | main.step( "Creating ONOS package" ) |
| 162 | packageResult = main.ONOSbench.onosPackage() |
| 163 | stepResult = packageResult |
| 164 | utilities.assert_equals( expect=main.TRUE, |
| 165 | actual=stepResult, |
| 166 | onpass="Successfully created ONOS package", |
| 167 | onfail="Failed to create ONOS package" ) |
| 168 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 169 | time.sleep( main.startUpSleep ) |
| 170 | main.step( "Uninstalling ONOS package" ) |
| 171 | onosUninstallResult = main.TRUE |
| 172 | for ip in main.ONOSip: |
| 173 | onosUninstallResult = onosUninstallResult and \ |
| 174 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 175 | stepResult = onosUninstallResult |
| 176 | utilities.assert_equals( expect=main.TRUE, |
| 177 | actual=stepResult, |
| 178 | onpass="Successfully uninstalled ONOS package", |
| 179 | onfail="Failed to uninstall ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 180 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 181 | time.sleep( main.startUpSleep ) |
| 182 | main.step( "Installing ONOS package" ) |
| 183 | onosInstallResult = main.TRUE |
| 184 | for i in range( main.numCtrls ): |
| 185 | onosInstallResult = onosInstallResult and \ |
| 186 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 187 | stepResult = onosInstallResult |
| 188 | utilities.assert_equals( expect=main.TRUE, |
| 189 | actual=stepResult, |
| 190 | onpass="Successfully installed ONOS package", |
| 191 | onfail="Failed to install ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 192 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 193 | time.sleep( main.startUpSleep ) |
| 194 | main.step( "Starting ONOS service" ) |
| 195 | stopResult = main.TRUE |
| 196 | startResult = main.TRUE |
| 197 | onosIsUp = main.TRUE |
| 198 | |
| 199 | for i in range( main.numCtrls ): |
| 200 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 201 | if onosIsUp == main.TRUE: |
| 202 | main.log.report( "ONOS instance is up and ready" ) |
| 203 | else: |
| 204 | main.log.report( "ONOS instance may not be up, stop and " + |
| 205 | "start ONOS again " ) |
| 206 | |
| 207 | for i in range( main.numCtrls ): |
| 208 | stopResult = stopResult and \ |
| 209 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 210 | for i in range( main.numCtrls ): |
| 211 | startResult = startResult and \ |
| 212 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 213 | stepResult = onosIsUp and stopResult and startResult |
| 214 | utilities.assert_equals( expect=main.TRUE, |
| 215 | actual=stepResult, |
| 216 | onpass="ONOS service is ready", |
| 217 | onfail="ONOS service did not start properly" ) |
| 218 | |
| 219 | main.step( "Start ONOS cli" ) |
| 220 | cliResult = main.TRUE |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 221 | main.activeNodes = [] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 222 | for i in range( main.numCtrls ): |
| 223 | cliResult = cliResult and \ |
| 224 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 225 | main.activeNodes.append( i ) |
| 226 | stepResult = cliResult |
| 227 | utilities.assert_equals( expect=main.TRUE, |
| 228 | actual=stepResult, |
| 229 | onpass="Successfully start ONOS cli", |
| 230 | onfail="Failed to start ONOS cli" ) |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 231 | time.sleep( main.startUpSleep ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 232 | |
| 233 | def CASE10( self, main ): |
| 234 | """ |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 235 | Starting up torus topology |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 236 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 237 | import json |
| 238 | |
| 239 | main.case( "Starting up Mininet and verifying topology" ) |
| 240 | main.caseExplanation = "Starting Mininet with a scalling topology and " +\ |
| 241 | "comparing topology elements between Mininet and ONOS" |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 242 | if main.topoScale: |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 243 | main.currScale = main.topoScale.pop(0) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 244 | else: main.log.error( "topology scale is empty" ) |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 245 | main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 246 | |
| 247 | main.log.info( "Constructing Mininet command" ) |
| 248 | mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs +\ |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 249 | " --switch ovsm --topo " + main.topoName + ","+ main.currScale + "," + main.currScale |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 250 | |
| 251 | for i in range( main.numCtrls ): |
| 252 | mnCmd += " --controller remote,ip=" + main.ONOSip[ i ] |
| 253 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 254 | stepResult = main.Mininet1.startNet(mnCmd=mnCmd) |
| 255 | utilities.assert_equals( expect=main.TRUE, |
| 256 | actual=stepResult, |
| 257 | onpass=main.topoName + |
| 258 | " topology started successfully", |
| 259 | onfail=main.topoName + |
| 260 | " topology failed to start" ) |
| 261 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 262 | time.sleep( main.MNSleep ) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 263 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 264 | def CASE11( self, main ): |
| 265 | """ |
| 266 | Pingall, and compare topo |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 267 | We don't care the pingall result, |
| 268 | if the topology is same, then Pass. |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 269 | """ |
| 270 | import json |
| 271 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 272 | main.case( "Verifying topology: TORUS %sx%s" % (main.currScale, main.currScale) ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 273 | main.caseExplanation = "Pinging all hosts and comparing topology " +\ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 274 | "elements between Mininet and ONOS" |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 275 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 276 | main.log.info( "Gathering topology information" ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 277 | time.sleep( main.MNSleep ) |
| 278 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 279 | devicesResults = main.TRUE |
| 280 | linksResults = main.TRUE |
| 281 | hostsResults = main.TRUE |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 282 | stepResult = main.TRUE |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 283 | main.step( "Comparing MN topology to ONOS topology" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 284 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 285 | compareRetry=0 |
| 286 | while compareRetry <3: |
| 287 | #While loop for retry |
| 288 | devices = main.topo.getAllDevices( main ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 289 | ports = main.topo.getAllPorts( main ) |
| 290 | links = main.topo.getAllLinks( main) |
| 291 | clusters = main.topo.getAllClusters( main ) |
| 292 | mnSwitches = main.Mininet1.getSwitches() |
| 293 | mnLinks = main.Mininet1.getLinks(timeout=180) |
| 294 | mnHosts = main.Mininet1.getHosts() |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 295 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 296 | for controller in range(len(main.activeNodes)): |
| 297 | controllerStr = str( main.activeNodes[controller] + 1 ) |
| 298 | if devices[ controller ] and ports[ controller ] and\ |
| 299 | "Error" not in devices[ controller ] and\ |
| 300 | "Error" not in ports[ controller ]: |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 301 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 302 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 303 | mnSwitches, |
| 304 | json.loads( devices[ controller ] ), |
| 305 | json.loads( ports[ controller ] ) ) |
| 306 | else: |
| 307 | currentDevicesResult = main.FALSE |
| 308 | |
| 309 | if links[ controller ] and "Error" not in links[ controller ]: |
| 310 | currentLinksResult = main.Mininet1.compareLinks( |
| 311 | mnSwitches, mnLinks, |
| 312 | json.loads( links[ controller ] ) ) |
| 313 | else: |
| 314 | currentLinksResult = main.FALSE |
| 315 | |
YPZhang | 0f08438 | 2016-04-19 17:29:12 -0700 | [diff] [blame] | 316 | stepResult = currentDevicesResult and currentLinksResult |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 317 | if stepResult: |
| 318 | break |
| 319 | compareRetry += 1 |
| 320 | |
| 321 | # host discover |
| 322 | hostList=[] |
| 323 | for i in range( 1, int(main.currScale)+1 ): |
| 324 | for j in range( 1, int(main.currScale)+1 ): |
| 325 | hoststr = "h" + str(i)+ "x" + str(j) |
| 326 | hostList.append(hoststr) |
| 327 | totalNum = main.topo.sendArpPackage(main, hostList) |
| 328 | # check host number |
| 329 | main.log.info("{} hosts has been discovered".format( totalNum )) |
| 330 | if int(totalNum) == ( int(main.currScale) * int(main.currScale) ): |
| 331 | main.log.info("All hosts has been discovered") |
| 332 | stepResult = stepResult and main.TRUE |
| 333 | else: |
| 334 | main.log.warn("Hosts number is not correct!") |
| 335 | stepResult = stepResult and main.FALSE |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 336 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 337 | utilities.assert_equals( expect=main.TRUE, |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 338 | actual=stepResult, |
| 339 | onpass=" Topology match Mininet", |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 340 | onfail="ONOS" + controllerStr + |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 341 | " Topology doesn't match Mininet" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 342 | |
| 343 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 344 | def CASE100( self, main ): |
| 345 | ''' |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 346 | Bring Down node 3 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 347 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 348 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 349 | main.case("Balancing Masters and bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale)) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 350 | main.caseExplanation = "Balance masters to make sure " +\ |
| 351 | "each controller has some devices and " +\ |
| 352 | "stop ONOS node 3 service. " |
| 353 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 354 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 355 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 356 | # Always bring down the third node |
| 357 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 358 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 359 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 360 | main.log.info( "Stopping node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 361 | stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 362 | main.log.info( "Removing dead node from list of active nodes" ) |
| 363 | main.activeNodes.pop( main.deadNode ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 364 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 365 | utilities.assert_equals( expect=main.TRUE, |
| 366 | actual=stepResult, |
| 367 | onpass="Successfully bring down node 3", |
| 368 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 369 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 370 | def CASE200( self, main ): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 371 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 372 | Bring up onos node and balance masters |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 373 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 374 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 375 | main.case("Bring ONOS node 3 up and balance masters: TORUS %sx%s" % (main.currScale, main.currScale)) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 376 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 377 | |
| 378 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 379 | main.log.info( "Starting node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 380 | stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 381 | main.log.info( "Starting onos cli" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 382 | stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 383 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 384 | main.log.info( "Adding previously dead node to list of active nodes" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 385 | main.activeNodes.append( main.deadNode ) |
| 386 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 387 | utilities.assert_equals( expect=main.TRUE, |
| 388 | actual=stepResult, |
| 389 | onpass="Successfully brought up onos node %s" % node, |
| 390 | onfail="Failed to bring up onos node %s" % node ) |
| 391 | |
| 392 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 393 | time.sleep(main.nodeSleep) |
| 394 | |
| 395 | def CASE300( self, main ): |
| 396 | ''' |
| 397 | |
| 398 | Balancing Masters |
| 399 | ''' |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 400 | time.sleep(main.balanceSleep) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 401 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 402 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 403 | stepResult = main.FALSE |
| 404 | if main.activeNodes: |
| 405 | controller = main.activeNodes[0] |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 406 | stepResult = utilities.retry( main.CLIs[controller].balanceMasters, |
| 407 | main.FALSE, |
| 408 | [], |
| 409 | sleep=3, |
| 410 | attempts=3 ) |
| 411 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 412 | else: |
| 413 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 414 | utilities.assert_equals( expect=main.TRUE, |
| 415 | actual=stepResult, |
| 416 | onpass="Balance masters was successfull", |
| 417 | onfail="Failed to balance masters") |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 418 | time.sleep(main.balanceSleep) |
| 419 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 420 | def CASE1000( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 421 | ''' |
| 422 | Report errors/warnings/exceptions |
| 423 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 424 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 425 | main.log.info("Error report: \n" ) |
| 426 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 427 | [ "INFO", |
| 428 | "FOLLOWER", |
| 429 | "WARN", |
| 430 | "flow", |
| 431 | "ERROR", |
| 432 | "Except" ], |
| 433 | "s" ) |