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 ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 299 | ports = main.topo.getAllPorts( main ) |
| 300 | links = main.topo.getAllLinks( main) |
| 301 | clusters = main.topo.getAllClusters( main ) |
| 302 | mnSwitches = main.Mininet1.getSwitches() |
| 303 | mnLinks = main.Mininet1.getLinks(timeout=180) |
| 304 | mnHosts = main.Mininet1.getHosts() |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 305 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 306 | for controller in range(len(main.activeNodes)): |
| 307 | controllerStr = str( main.activeNodes[controller] + 1 ) |
| 308 | if devices[ controller ] and ports[ controller ] and\ |
| 309 | "Error" not in devices[ controller ] and\ |
| 310 | "Error" not in ports[ controller ]: |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 311 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 312 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 313 | mnSwitches, |
| 314 | json.loads( devices[ controller ] ), |
| 315 | json.loads( ports[ controller ] ) ) |
| 316 | else: |
| 317 | currentDevicesResult = main.FALSE |
| 318 | |
| 319 | if links[ controller ] and "Error" not in links[ controller ]: |
| 320 | currentLinksResult = main.Mininet1.compareLinks( |
| 321 | mnSwitches, mnLinks, |
| 322 | json.loads( links[ controller ] ) ) |
| 323 | else: |
| 324 | currentLinksResult = main.FALSE |
| 325 | |
YPZhang | 0f08438 | 2016-04-19 17:29:12 -0700 | [diff] [blame] | 326 | stepResult = currentDevicesResult and currentLinksResult |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 327 | if stepResult: |
| 328 | break |
| 329 | compareRetry += 1 |
| 330 | |
| 331 | # host discover |
| 332 | hostList=[] |
| 333 | for i in range( 1, int(main.currScale)+1 ): |
| 334 | for j in range( 1, int(main.currScale)+1 ): |
| 335 | hoststr = "h" + str(i)+ "x" + str(j) |
| 336 | hostList.append(hoststr) |
| 337 | totalNum = main.topo.sendArpPackage(main, hostList) |
| 338 | # check host number |
| 339 | main.log.info("{} hosts has been discovered".format( totalNum )) |
| 340 | if int(totalNum) == ( int(main.currScale) * int(main.currScale) ): |
| 341 | main.log.info("All hosts has been discovered") |
| 342 | stepResult = stepResult and main.TRUE |
| 343 | else: |
| 344 | main.log.warn("Hosts number is not correct!") |
| 345 | stepResult = stepResult and main.FALSE |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 346 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 347 | utilities.assert_equals( expect=main.TRUE, |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 348 | actual=stepResult, |
| 349 | onpass=" Topology match Mininet", |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 350 | onfail="ONOS" + controllerStr + |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 351 | " Topology doesn't match Mininet" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 352 | |
| 353 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 354 | def CASE100( self, main ): |
| 355 | ''' |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 356 | Bring Down node 3 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 357 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 358 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 359 | 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] | 360 | main.caseExplanation = "Balance masters to make sure " +\ |
| 361 | "each controller has some devices and " +\ |
| 362 | "stop ONOS node 3 service. " |
| 363 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 364 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 365 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 366 | # Always bring down the third node |
| 367 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 368 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 369 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 370 | main.log.info( "Stopping node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 371 | stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 372 | main.log.info( "Removing dead node from list of active nodes" ) |
| 373 | main.activeNodes.pop( main.deadNode ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 374 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 375 | utilities.assert_equals( expect=main.TRUE, |
| 376 | actual=stepResult, |
| 377 | onpass="Successfully bring down node 3", |
| 378 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 379 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 380 | def CASE200( self, main ): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 381 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 382 | Bring up onos node and balance masters |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 383 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 384 | |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 385 | 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] | 386 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 387 | |
| 388 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 389 | main.log.info( "Starting node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 390 | stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 391 | main.log.info( "Starting onos cli" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 392 | stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 393 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 394 | main.log.info( "Adding previously dead node to list of active nodes" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 395 | main.activeNodes.append( main.deadNode ) |
| 396 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 397 | utilities.assert_equals( expect=main.TRUE, |
| 398 | actual=stepResult, |
| 399 | onpass="Successfully brought up onos node %s" % node, |
| 400 | onfail="Failed to bring up onos node %s" % node ) |
| 401 | |
| 402 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 403 | time.sleep(main.nodeSleep) |
| 404 | |
| 405 | def CASE300( self, main ): |
| 406 | ''' |
| 407 | |
| 408 | Balancing Masters |
| 409 | ''' |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 410 | time.sleep(main.balanceSleep) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 411 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 412 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 413 | stepResult = main.FALSE |
| 414 | if main.activeNodes: |
| 415 | controller = main.activeNodes[0] |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 416 | stepResult = utilities.retry( main.CLIs[controller].balanceMasters, |
| 417 | main.FALSE, |
| 418 | [], |
| 419 | sleep=3, |
| 420 | attempts=3 ) |
| 421 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 422 | else: |
| 423 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 424 | utilities.assert_equals( expect=main.TRUE, |
| 425 | actual=stepResult, |
| 426 | onpass="Balance masters was successfull", |
| 427 | onfail="Failed to balance masters") |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 428 | time.sleep(main.balanceSleep) |
| 429 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 430 | def CASE1000( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 431 | ''' |
| 432 | Report errors/warnings/exceptions |
| 433 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 434 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 435 | main.log.info("Error report: \n" ) |
| 436 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 437 | [ "INFO", |
| 438 | "FOLLOWER", |
| 439 | "WARN", |
| 440 | "flow", |
| 441 | "ERROR", |
| 442 | "Except" ], |
| 443 | "s" ) |