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 | """ |
| 121 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 122 | main.case( "Starting up " + str( main.numCtrls ) + |
| 123 | " node(s) ONOS cluster" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 124 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 125 | " node(s) ONOS cluster" |
| 126 | |
| 127 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 128 | |
| 129 | #kill off all onos processes |
| 130 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 131 | " before initiating environment setup" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 132 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 133 | for i in range( main.numCtrls ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 134 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 135 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 136 | tempOnosIp = [] |
| 137 | for i in range( main.numCtrls ): |
| 138 | tempOnosIp.append( main.ONOSip[i] ) |
| 139 | |
| 140 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 141 | "temp", main.Mininet1.ip_address, |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 142 | main.apps, tempOnosIp ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 143 | |
| 144 | main.step( "Apply cell to environment" ) |
| 145 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 146 | verifyResult = main.ONOSbench.verifyCell() |
| 147 | stepResult = cellResult and verifyResult |
| 148 | utilities.assert_equals( expect=main.TRUE, |
| 149 | actual=stepResult, |
| 150 | onpass="Successfully applied cell to " + \ |
| 151 | "environment", |
| 152 | onfail="Failed to apply cell to environment " ) |
| 153 | |
| 154 | main.step( "Creating ONOS package" ) |
| 155 | packageResult = main.ONOSbench.onosPackage() |
| 156 | stepResult = packageResult |
| 157 | utilities.assert_equals( expect=main.TRUE, |
| 158 | actual=stepResult, |
| 159 | onpass="Successfully created ONOS package", |
| 160 | onfail="Failed to create ONOS package" ) |
| 161 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 162 | time.sleep( main.startUpSleep ) |
| 163 | main.step( "Uninstalling ONOS package" ) |
| 164 | onosUninstallResult = main.TRUE |
| 165 | for ip in main.ONOSip: |
| 166 | onosUninstallResult = onosUninstallResult and \ |
| 167 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 168 | stepResult = onosUninstallResult |
| 169 | utilities.assert_equals( expect=main.TRUE, |
| 170 | actual=stepResult, |
| 171 | onpass="Successfully uninstalled ONOS package", |
| 172 | onfail="Failed to uninstall ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 173 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 174 | time.sleep( main.startUpSleep ) |
| 175 | main.step( "Installing ONOS package" ) |
| 176 | onosInstallResult = main.TRUE |
| 177 | for i in range( main.numCtrls ): |
| 178 | onosInstallResult = onosInstallResult and \ |
| 179 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 180 | stepResult = onosInstallResult |
| 181 | utilities.assert_equals( expect=main.TRUE, |
| 182 | actual=stepResult, |
| 183 | onpass="Successfully installed ONOS package", |
| 184 | onfail="Failed to install ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 185 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 186 | time.sleep( main.startUpSleep ) |
| 187 | main.step( "Starting ONOS service" ) |
| 188 | stopResult = main.TRUE |
| 189 | startResult = main.TRUE |
| 190 | onosIsUp = main.TRUE |
| 191 | |
| 192 | for i in range( main.numCtrls ): |
| 193 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 194 | if onosIsUp == main.TRUE: |
| 195 | main.log.report( "ONOS instance is up and ready" ) |
| 196 | else: |
| 197 | main.log.report( "ONOS instance may not be up, stop and " + |
| 198 | "start ONOS again " ) |
| 199 | |
| 200 | for i in range( main.numCtrls ): |
| 201 | stopResult = stopResult and \ |
| 202 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 203 | for i in range( main.numCtrls ): |
| 204 | startResult = startResult and \ |
| 205 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 206 | stepResult = onosIsUp and stopResult and startResult |
| 207 | utilities.assert_equals( expect=main.TRUE, |
| 208 | actual=stepResult, |
| 209 | onpass="ONOS service is ready", |
| 210 | onfail="ONOS service did not start properly" ) |
| 211 | |
| 212 | main.step( "Start ONOS cli" ) |
| 213 | cliResult = main.TRUE |
| 214 | for i in range( main.numCtrls ): |
| 215 | cliResult = cliResult and \ |
| 216 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 217 | main.activeNodes.append( i ) |
| 218 | stepResult = cliResult |
| 219 | utilities.assert_equals( expect=main.TRUE, |
| 220 | actual=stepResult, |
| 221 | onpass="Successfully start ONOS cli", |
| 222 | onfail="Failed to start ONOS cli" ) |
| 223 | |
| 224 | |
| 225 | def CASE10( self, main ): |
| 226 | """ |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 227 | Starting up torus topology |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 228 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 229 | import json |
| 230 | |
| 231 | main.case( "Starting up Mininet and verifying topology" ) |
| 232 | main.caseExplanation = "Starting Mininet with a scalling topology and " +\ |
| 233 | "comparing topology elements between Mininet and ONOS" |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 234 | |
| 235 | main.log.info( "Checking if mininet is already running" ) |
| 236 | if len( main.topoScale ) < main.topoScaleSize: |
| 237 | main.log.info( "Mininet is already running. Stopping mininet." ) |
| 238 | main.Mininet1.stopNet() |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 239 | time.sleep(main.MNSleep) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 240 | else: |
| 241 | main.log.info( "Mininet was not running" ) |
| 242 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 243 | if main.topoScale: |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 244 | main.currScale = main.topoScale.pop(0) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 245 | else: main.log.error( "topology scale is empty" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 246 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 247 | # remove device before setup topology |
| 248 | devices = main.topo.getAllDevices( main ) |
| 249 | if( devices[0] != '[]' ): # because devices is a list witch contain 3 string, not contain list! |
| 250 | temp = json.loads( devices[0] ) |
| 251 | devicesIdList = [] |
| 252 | for d in temp: |
| 253 | main.CLIs[0].deviceRemove( d.get('id').encode() ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 254 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 255 | main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 256 | |
| 257 | main.log.info( "Constructing Mininet command" ) |
| 258 | mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs +\ |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 259 | " --switch ovsm --topo " + main.topoName + ","+ main.currScale + "," + main.currScale |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 260 | |
| 261 | for i in range( main.numCtrls ): |
| 262 | mnCmd += " --controller remote,ip=" + main.ONOSip[ i ] |
| 263 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 264 | stepResult = main.Mininet1.startNet(mnCmd=mnCmd) |
| 265 | utilities.assert_equals( expect=main.TRUE, |
| 266 | actual=stepResult, |
| 267 | onpass=main.topoName + |
| 268 | " topology started successfully", |
| 269 | onfail=main.topoName + |
| 270 | " topology failed to start" ) |
| 271 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 272 | time.sleep( main.MNSleep ) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 273 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 274 | def CASE11( self, main ): |
| 275 | """ |
| 276 | Pingall, and compare topo |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 277 | We don't care the pingall result, |
| 278 | if the topology is same, then Pass. |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 279 | """ |
| 280 | import json |
| 281 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 282 | main.case( "Verifying topology: TORUS %sx%s" % (main.currScale, main.currScale) ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 283 | main.caseExplanation = "Pinging all hosts and comparing topology " +\ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 284 | "elements between Mininet and ONOS" |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 285 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 286 | main.log.info( "Gathering topology information" ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 287 | time.sleep( main.MNSleep ) |
| 288 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 289 | devicesResults = main.TRUE |
| 290 | linksResults = main.TRUE |
| 291 | hostsResults = main.TRUE |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 292 | stepResult = main.TRUE |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 293 | main.step( "Comparing MN topology to ONOS topology" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 294 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 295 | compareRetry=0 |
| 296 | while compareRetry <3: |
| 297 | #While loop for retry |
| 298 | devices = main.topo.getAllDevices( main ) |
| 299 | hosts = main.topo.getAllHosts( main ) |
| 300 | ports = main.topo.getAllPorts( main ) |
| 301 | links = main.topo.getAllLinks( main) |
| 302 | clusters = main.topo.getAllClusters( main ) |
| 303 | mnSwitches = main.Mininet1.getSwitches() |
| 304 | mnLinks = main.Mininet1.getLinks(timeout=180) |
| 305 | mnHosts = main.Mininet1.getHosts() |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 306 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 307 | for controller in range(len(main.activeNodes)): |
| 308 | controllerStr = str( main.activeNodes[controller] + 1 ) |
| 309 | if devices[ controller ] and ports[ controller ] and\ |
| 310 | "Error" not in devices[ controller ] and\ |
| 311 | "Error" not in ports[ controller ]: |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 312 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 313 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 314 | mnSwitches, |
| 315 | json.loads( devices[ controller ] ), |
| 316 | json.loads( ports[ controller ] ) ) |
| 317 | else: |
| 318 | currentDevicesResult = main.FALSE |
| 319 | |
| 320 | if links[ controller ] and "Error" not in links[ controller ]: |
| 321 | currentLinksResult = main.Mininet1.compareLinks( |
| 322 | mnSwitches, mnLinks, |
| 323 | json.loads( links[ controller ] ) ) |
| 324 | else: |
| 325 | currentLinksResult = main.FALSE |
| 326 | |
| 327 | if hosts[ controller ] or "Error" not in hosts[ controller ]: |
| 328 | currentHostsResult = main.Mininet1.compareHosts( |
| 329 | mnHosts, |
| 330 | json.loads( hosts[ controller ] ) ) |
| 331 | else: |
| 332 | currentHostsResult = main.FALSE |
| 333 | |
| 334 | stepResult = currentDevicesResult and currentLinksResult and currentHostsResult |
| 335 | if stepResult: |
| 336 | break |
| 337 | compareRetry += 1 |
| 338 | |
| 339 | # host discover |
| 340 | hostList=[] |
| 341 | for i in range( 1, int(main.currScale)+1 ): |
| 342 | for j in range( 1, int(main.currScale)+1 ): |
| 343 | hoststr = "h" + str(i)+ "x" + str(j) |
| 344 | hostList.append(hoststr) |
| 345 | totalNum = main.topo.sendArpPackage(main, hostList) |
| 346 | # check host number |
| 347 | main.log.info("{} hosts has been discovered".format( totalNum )) |
| 348 | if int(totalNum) == ( int(main.currScale) * int(main.currScale) ): |
| 349 | main.log.info("All hosts has been discovered") |
| 350 | stepResult = stepResult and main.TRUE |
| 351 | else: |
| 352 | main.log.warn("Hosts number is not correct!") |
| 353 | stepResult = stepResult and main.FALSE |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 354 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 355 | utilities.assert_equals( expect=main.TRUE, |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 356 | actual=stepResult, |
| 357 | onpass=" Topology match Mininet", |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 358 | onfail="ONOS" + controllerStr + |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 359 | " Topology doesn't match Mininet" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 360 | |
| 361 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 362 | def CASE100( self, main ): |
| 363 | ''' |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 364 | Bring Down node 3 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 365 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 366 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 367 | 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] | 368 | main.caseExplanation = "Balance masters to make sure " +\ |
| 369 | "each controller has some devices and " +\ |
| 370 | "stop ONOS node 3 service. " |
| 371 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 372 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 373 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 374 | # Always bring down the third node |
| 375 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 376 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 377 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 378 | main.log.info( "Stopping node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 379 | stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 380 | main.log.info( "Removing dead node from list of active nodes" ) |
| 381 | main.activeNodes.pop( main.deadNode ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 382 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 383 | utilities.assert_equals( expect=main.TRUE, |
| 384 | actual=stepResult, |
| 385 | onpass="Successfully bring down node 3", |
| 386 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 387 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 388 | def CASE200( self, main ): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 389 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 390 | Bring up onos node and balance masters |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 391 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 392 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 393 | 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] | 394 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 395 | |
| 396 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 397 | main.log.info( "Starting node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 398 | stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 399 | main.log.info( "Starting onos cli" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 400 | stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 401 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 402 | main.log.info( "Adding previously dead node to list of active nodes" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 403 | main.activeNodes.append( main.deadNode ) |
| 404 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 405 | utilities.assert_equals( expect=main.TRUE, |
| 406 | actual=stepResult, |
| 407 | onpass="Successfully brought up onos node %s" % node, |
| 408 | onfail="Failed to bring up onos node %s" % node ) |
| 409 | |
| 410 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 411 | time.sleep(main.nodeSleep) |
| 412 | |
| 413 | def CASE300( self, main ): |
| 414 | ''' |
| 415 | |
| 416 | Balancing Masters |
| 417 | ''' |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 418 | time.sleep(main.balanceSleep) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 419 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 420 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 421 | stepResult = main.FALSE |
| 422 | if main.activeNodes: |
| 423 | controller = main.activeNodes[0] |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 424 | stepResult = utilities.retry( main.CLIs[controller].balanceMasters, |
| 425 | main.FALSE, |
| 426 | [], |
| 427 | sleep=3, |
| 428 | attempts=3 ) |
| 429 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 430 | else: |
| 431 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 432 | utilities.assert_equals( expect=main.TRUE, |
| 433 | actual=stepResult, |
| 434 | onpass="Balance masters was successfull", |
| 435 | onfail="Failed to balance masters") |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 436 | time.sleep(main.balanceSleep) |
| 437 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 438 | def CASE1000( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 439 | ''' |
| 440 | Report errors/warnings/exceptions |
| 441 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 442 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 443 | main.log.info("Error report: \n" ) |
| 444 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 445 | [ "INFO", |
| 446 | "FOLLOWER", |
| 447 | "WARN", |
| 448 | "flow", |
| 449 | "ERROR", |
| 450 | "Except" ], |
| 451 | "s" ) |