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