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 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 23 | main.case( "Constructing test variables" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 24 | main.step( "Constructing test variables" ) |
| 25 | stepResult = main.FALSE |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 26 | # The variable to decide if the data should be written into data base. |
| 27 | # 1 means Yes and -1 means No. |
| 28 | main.writeData = 1 |
| 29 | main.searchTerm = main.params[ 'SearchTerm' ] |
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' ] ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 51 | main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ] |
| 52 | main.hostDiscoverSleep = float( main.params['SLEEP']['host'] ) |
| 53 | if main.hostDiscover == 'True': |
| 54 | main.hostDiscover = True |
| 55 | else: |
| 56 | main.hostDiscover = False |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 57 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 58 | main.homeDir = os.path.expanduser('~') |
| 59 | main.cellData = {} # for creating cell file |
| 60 | main.hostsData = {} |
| 61 | main.CLIs = [] |
| 62 | main.ONOSip = [] |
| 63 | main.activeNodes = [] |
| 64 | main.ONOSip = main.ONOSbench.getOnosIps() |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 65 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 66 | for i in range(main.numCtrls): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 67 | main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) ) |
| 68 | |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 69 | main.allinfo = {} # The dictionary to record all the data from karaf.log |
| 70 | for i in range( 2 ): |
| 71 | main.allinfo[ i ]={} |
| 72 | for w in range ( 3 ): |
| 73 | # Totaltime: the time from the new switchConnection to its end |
| 74 | # swConnection: the time from the first new switchConnection to the last new switchConnection |
| 75 | # disconnectRate: the rate that shows how many switch disconnect after connection |
Chiyu Cheng | 8800c7c | 2016-10-18 11:26:35 -0700 | [diff] [blame] | 76 | main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0,'lastSwToTopology': 0, 'disconnectRate': 0 } |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 77 | |
| 78 | main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ] |
| 79 | main.log.info( "Create Database file " + main.dbFilePath ) |
| 80 | resultDB = open(main.dbFilePath, 'w+' ) |
| 81 | resultDB.close() |
| 82 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 83 | main.startUp = imp.load_source( wrapperFile1, |
| 84 | main.dependencyPath + |
| 85 | wrapperFile1 + |
| 86 | ".py" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 87 | main.scaleTopoFunction = imp.load_source( wrapperFile2, |
| 88 | main.dependencyPath + |
| 89 | wrapperFile2 + |
| 90 | ".py" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 91 | main.topo = imp.load_source( wrapperFile3, |
| 92 | main.dependencyPath + |
| 93 | wrapperFile3 + |
| 94 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 95 | main.ONOSbench.scp( main.Mininet1, |
| 96 | main.dependencyPath + |
| 97 | main.multiovs, |
| 98 | main.Mininet1.home, |
| 99 | direction="to" ) |
| 100 | |
| 101 | if main.CLIs: |
| 102 | stepResult = main.TRUE |
| 103 | else: |
| 104 | main.log.error( "Did not properly created list of " + |
| 105 | "ONOS CLI handle" ) |
| 106 | stepResult = main.FALSE |
| 107 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 108 | utilities.assert_equals( expect=main.TRUE, |
| 109 | actual=stepResult, |
| 110 | onpass="Successfully construct " + |
| 111 | "test variables ", |
| 112 | onfail="Failed to construct test variables" ) |
| 113 | |
| 114 | if gitPull == 'True': |
| 115 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 116 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 117 | stepResult = onosBuildResult |
| 118 | utilities.assert_equals( expect=main.TRUE, |
| 119 | actual=stepResult, |
| 120 | onpass="Successfully compiled " + |
| 121 | "latest ONOS", |
| 122 | onfail="Failed to compile " + |
| 123 | "latest ONOS" ) |
| 124 | else: |
| 125 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 126 | "clean install" ) |
| 127 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 128 | |
| 129 | def CASE2( self, main): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 130 | """ |
| 131 | - Set up cell |
| 132 | - Create cell file |
| 133 | - Set cell file |
| 134 | - Verify cell file |
| 135 | - Kill ONOS process |
| 136 | - Uninstall ONOS cluster |
| 137 | - Verify ONOS start up |
| 138 | - Install ONOS cluster |
| 139 | - Connect to cli |
| 140 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 141 | import time |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 142 | main.log.info( "Checking if mininet is already running" ) |
| 143 | if len( main.topoScale ) < main.topoScaleSize: |
| 144 | main.log.info( "Mininet is already running. Stopping mininet." ) |
| 145 | main.Mininet1.stopNet() |
| 146 | time.sleep(main.MNSleep) |
| 147 | else: |
| 148 | main.log.info( "Mininet was not running" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 149 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 150 | main.case( "Starting up " + str( main.numCtrls ) + |
| 151 | " node(s) ONOS cluster" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 152 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 153 | " node(s) ONOS cluster" |
| 154 | |
| 155 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 156 | |
| 157 | #kill off all onos processes |
| 158 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 159 | " before initiating environment setup" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 160 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 161 | for i in range( main.numCtrls ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 162 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 163 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 164 | tempOnosIp = [] |
| 165 | for i in range( main.numCtrls ): |
| 166 | tempOnosIp.append( main.ONOSip[i] ) |
| 167 | |
| 168 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 169 | "temp", main.Mininet1.ip_address, |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 170 | main.apps, tempOnosIp ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 171 | |
| 172 | main.step( "Apply cell to environment" ) |
| 173 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 174 | verifyResult = main.ONOSbench.verifyCell() |
| 175 | stepResult = cellResult and verifyResult |
| 176 | utilities.assert_equals( expect=main.TRUE, |
| 177 | actual=stepResult, |
| 178 | onpass="Successfully applied cell to " + \ |
| 179 | "environment", |
| 180 | onfail="Failed to apply cell to environment " ) |
| 181 | |
| 182 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 183 | packageResult = main.ONOSbench.buckBuild() |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 184 | stepResult = packageResult |
| 185 | utilities.assert_equals( expect=main.TRUE, |
| 186 | actual=stepResult, |
| 187 | onpass="Successfully created ONOS package", |
| 188 | onfail="Failed to create ONOS package" ) |
| 189 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 190 | time.sleep( main.startUpSleep ) |
| 191 | main.step( "Uninstalling ONOS package" ) |
| 192 | onosUninstallResult = main.TRUE |
| 193 | for ip in main.ONOSip: |
| 194 | onosUninstallResult = onosUninstallResult and \ |
| 195 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 196 | stepResult = onosUninstallResult |
| 197 | utilities.assert_equals( expect=main.TRUE, |
| 198 | actual=stepResult, |
| 199 | onpass="Successfully uninstalled ONOS package", |
| 200 | onfail="Failed to uninstall ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 201 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 202 | time.sleep( main.startUpSleep ) |
| 203 | main.step( "Installing ONOS package" ) |
| 204 | onosInstallResult = main.TRUE |
| 205 | for i in range( main.numCtrls ): |
| 206 | onosInstallResult = onosInstallResult and \ |
| 207 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 208 | stepResult = onosInstallResult |
| 209 | utilities.assert_equals( expect=main.TRUE, |
| 210 | actual=stepResult, |
| 211 | onpass="Successfully installed ONOS package", |
| 212 | onfail="Failed to install ONOS package" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 213 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 214 | time.sleep( main.startUpSleep ) |
| 215 | main.step( "Starting ONOS service" ) |
| 216 | stopResult = main.TRUE |
| 217 | startResult = main.TRUE |
| 218 | onosIsUp = main.TRUE |
| 219 | |
| 220 | for i in range( main.numCtrls ): |
| 221 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 222 | if onosIsUp == main.TRUE: |
| 223 | main.log.report( "ONOS instance is up and ready" ) |
| 224 | else: |
| 225 | main.log.report( "ONOS instance may not be up, stop and " + |
| 226 | "start ONOS again " ) |
| 227 | |
| 228 | for i in range( main.numCtrls ): |
| 229 | stopResult = stopResult and \ |
| 230 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 231 | for i in range( main.numCtrls ): |
| 232 | startResult = startResult and \ |
| 233 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 234 | stepResult = onosIsUp and stopResult and startResult |
| 235 | utilities.assert_equals( expect=main.TRUE, |
| 236 | actual=stepResult, |
| 237 | onpass="ONOS service is ready", |
| 238 | onfail="ONOS service did not start properly" ) |
| 239 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame^] | 240 | main.step( "Set up ONOS secure SSH" ) |
| 241 | secureSshResult = main.TRUE |
| 242 | for i in range( int( main.numCtrls ) ): |
| 243 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 244 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 245 | onpass="Test step PASS", |
| 246 | onfail="Test step FAIL" ) |
| 247 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 248 | main.step( "Start ONOS cli" ) |
| 249 | cliResult = main.TRUE |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 250 | main.activeNodes = [] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 251 | for i in range( main.numCtrls ): |
| 252 | cliResult = cliResult and \ |
| 253 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 254 | main.activeNodes.append( i ) |
| 255 | stepResult = cliResult |
| 256 | utilities.assert_equals( expect=main.TRUE, |
| 257 | actual=stepResult, |
| 258 | onpass="Successfully start ONOS cli", |
| 259 | onfail="Failed to start ONOS cli" ) |
YPZhang | 29c2d64 | 2016-06-22 16:15:19 -0700 | [diff] [blame] | 260 | time.sleep( main.startUpSleep ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 261 | |
| 262 | def CASE10( self, main ): |
| 263 | """ |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 264 | Starting up torus topology |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 265 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 266 | |
| 267 | main.case( "Starting up Mininet and verifying topology" ) |
| 268 | main.caseExplanation = "Starting Mininet with a scalling topology and " +\ |
| 269 | "comparing topology elements between Mininet and ONOS" |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 270 | if main.topoScale: |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 271 | main.currScale = main.topoScale.pop(0) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 272 | else: main.log.error( "topology scale is empty" ) |
GlennRC | 90d4395 | 2015-10-27 11:36:15 -0700 | [diff] [blame] | 273 | main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 274 | |
| 275 | main.log.info( "Constructing Mininet command" ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 276 | mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \ |
| 277 | " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 278 | for i in range( main.numCtrls ): |
| 279 | mnCmd += " --controller remote,ip=" + main.ONOSip[ i ] |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 280 | stepResult = main.Mininet1.startNet( mnCmd=mnCmd ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 281 | utilities.assert_equals( expect=main.TRUE, |
| 282 | actual=stepResult, |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 283 | onpass=main.topoName + |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 284 | " topology started successfully", |
| 285 | onfail=main.topoName + |
| 286 | " topology failed to start" ) |
| 287 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 288 | time.sleep( main.MNSleep ) |
Chiyu Cheng | 8149942 | 2016-11-09 11:04:23 -0800 | [diff] [blame] | 289 | main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" ) |
| 290 | time.sleep( main.MNSleep ) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 291 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 292 | def CASE11( self, main ): |
| 293 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 294 | Compare topo, and sending Arping package |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 295 | if the topology is same, then Pass. |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 296 | """ |
| 297 | import json |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 298 | import time |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 299 | # First capture |
| 300 | for i in range( 3 ): |
| 301 | # Calculate total time |
| 302 | main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' ) |
| 303 | # Calculate switch connection time |
| 304 | main.allinfo[ 0 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' ) |
Chiyu Cheng | 8800c7c | 2016-10-18 11:26:35 -0700 | [diff] [blame] | 305 | # Calculate the time from last switch connection to the end |
| 306 | main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToTopology' ] = main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] - main.allinfo[ 0 ][ 'info' + str( i )][ 'swConnection' ] |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 307 | # Calculate the disconnecti rate |
| 308 | main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' ) |
| 309 | main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 310 | |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 311 | main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 312 | main.caseExplanation = "Pinging all hosts and comparing topology " +\ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 313 | "elements between Mininet and ONOS" |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 314 | |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 315 | main.log.info( "Gathering topology information") |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 316 | time.sleep( main.MNSleep ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 317 | stepResult = main.TRUE |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 318 | main.step( "Comparing MN topology to ONOS topology" ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 319 | compareRetry = 0 |
| 320 | while compareRetry < 3: |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 321 | #While loop for retry |
| 322 | devices = main.topo.getAllDevices( main ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 323 | ports = main.topo.getAllPorts( main ) |
| 324 | links = main.topo.getAllLinks( main) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 325 | mnSwitches = main.Mininet1.getSwitches() |
| 326 | mnLinks = main.Mininet1.getLinks(timeout=180) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 327 | |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 328 | for controller in range(len(main.activeNodes)): |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 329 | # controllerStr = str( main.activeNodes[controller] + 1 ) |
| 330 | if devices[ controller ] and ports[ controller ] and \ |
| 331 | "Error" not in devices[ controller ] and \ |
| 332 | "Error" not in ports[ controller ]: |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 333 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 334 | mnSwitches, |
| 335 | json.loads( devices[ controller ] ), |
| 336 | json.loads( ports[ controller ] ) ) |
| 337 | else: |
| 338 | currentDevicesResult = main.FALSE |
| 339 | |
| 340 | if links[ controller ] and "Error" not in links[ controller ]: |
| 341 | currentLinksResult = main.Mininet1.compareLinks( |
| 342 | mnSwitches, mnLinks, |
| 343 | json.loads( links[ controller ] ) ) |
| 344 | else: |
| 345 | currentLinksResult = main.FALSE |
| 346 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 347 | stepResult = stepResult and currentDevicesResult and currentLinksResult |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 348 | if stepResult: |
| 349 | break |
| 350 | compareRetry += 1 |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 351 | utilities.assert_equals(expect=main.TRUE, |
| 352 | actual=stepResult, |
| 353 | onpass=" Topology match Mininet", |
| 354 | onfail="ONOS Topology doesn't match Mininet") |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 355 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 356 | if stepResult: |
| 357 | if main.hostDiscover: |
| 358 | hostList = [] |
| 359 | for i in range( 1, int( main.currScale ) + 1 ): |
| 360 | for j in range( 1, int( main.currScale ) + 1) : |
| 361 | # Generate host list |
| 362 | hoststr = "h" + str(i) + "x" + str(j) |
| 363 | hostList.append(hoststr) |
| 364 | for i in range( len(hostList) ): |
| 365 | totalHost = main.topo.sendArpPackage( main, hostList[i] ) |
| 366 | time.sleep( main.hostDiscoverSleep ) |
| 367 | if totalHost < 0: |
| 368 | # if totalHost less than 0 which means dependence function has exception. |
| 369 | main.log.info( "Error when discover host!" ) |
| 370 | break |
| 371 | if totalHost == int( main.currScale ) * int( main.currScale ): |
| 372 | main.log.info( "Discovered all hosts" ) |
You Wang | 7bb9c46 | 2016-08-10 14:18:16 -0700 | [diff] [blame] | 373 | stepResult = stepResult and main.TRUE |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 374 | else: |
| 375 | main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" ) |
You Wang | 7bb9c46 | 2016-08-10 14:18:16 -0700 | [diff] [blame] | 376 | stepResult = main.FALSE |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 377 | utilities.assert_equals(expect=main.TRUE, |
| 378 | actual=stepResult, |
| 379 | onpass=" Topology match Mininet", |
| 380 | onfail="ONOS Topology doesn't match Mininet") |
| 381 | main.log.info( "Finished this iteration, continue to scale next topology." ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 382 | else: |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 383 | main.log.info( "Clean up and exit TestON. Finished this test." ) |
| 384 | main.cleanup() |
| 385 | main.exit() |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 386 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 387 | def CASE100( self, main ): |
| 388 | ''' |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 389 | Bring Down node 3 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 390 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 391 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 392 | 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] | 393 | main.caseExplanation = "Balance masters to make sure " +\ |
| 394 | "each controller has some devices and " +\ |
| 395 | "stop ONOS node 3 service. " |
| 396 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 397 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 398 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 399 | # Always bring down the third node |
| 400 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 401 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 402 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 403 | main.log.info( "Stopping node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 404 | stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 405 | main.log.info( "Removing dead node from list of active nodes" ) |
| 406 | main.activeNodes.pop( main.deadNode ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 407 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 408 | utilities.assert_equals( expect=main.TRUE, |
| 409 | actual=stepResult, |
| 410 | onpass="Successfully bring down node 3", |
| 411 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 412 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 413 | def CASE200( self, main ): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 414 | ''' |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 415 | Bring up onos node |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 416 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 417 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 418 | 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] | 419 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 420 | |
| 421 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 422 | main.log.info( "Starting node %s" % node ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 423 | stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 424 | main.log.info( "Starting onos cli" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 425 | stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 426 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 427 | main.log.info( "Adding previously dead node to list of active nodes" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 428 | main.activeNodes.append( main.deadNode ) |
| 429 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 430 | utilities.assert_equals( expect=main.TRUE, |
| 431 | actual=stepResult, |
| 432 | onpass="Successfully brought up onos node %s" % node, |
| 433 | onfail="Failed to bring up onos node %s" % node ) |
| 434 | |
| 435 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 436 | time.sleep(main.nodeSleep) |
| 437 | |
| 438 | def CASE300( self, main ): |
| 439 | ''' |
| 440 | |
| 441 | Balancing Masters |
| 442 | ''' |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 443 | time.sleep(main.balanceSleep) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 444 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 445 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 446 | stepResult = main.FALSE |
| 447 | if main.activeNodes: |
| 448 | controller = main.activeNodes[0] |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 449 | stepResult = utilities.retry( main.CLIs[controller].balanceMasters, |
| 450 | main.FALSE, |
| 451 | [], |
| 452 | sleep=3, |
| 453 | attempts=3 ) |
| 454 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 455 | else: |
| 456 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 457 | utilities.assert_equals( expect=main.TRUE, |
| 458 | actual=stepResult, |
| 459 | onpass="Balance masters was successfull", |
| 460 | onfail="Failed to balance masters") |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 461 | time.sleep(main.balanceSleep) |
| 462 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 463 | def CASE1000( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 464 | ''' |
| 465 | Report errors/warnings/exceptions |
| 466 | ''' |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 467 | # Compare the slowest Node through total time of each node |
| 468 | slowestNode = 0 |
| 469 | slowestTotalTime = 0 |
| 470 | # Second capture |
| 471 | for i in range( 3 ): |
| 472 | # Calculate total time |
| 473 | main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' ) |
| 474 | # Compare the total time |
| 475 | if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime: |
| 476 | slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] |
| 477 | slowestNode = i |
| 478 | # Calculate switch connection time |
| 479 | main.allinfo[ 1 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' ) |
Chiyu Cheng | 8800c7c | 2016-10-18 11:26:35 -0700 | [diff] [blame] | 480 | # Calculate the time from last switch connection to the end |
| 481 | main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToTopology' ] = main.allinfo[ 1 ][ |
| 482 | 'info' + str( i )][ 'totalTime' ] - main.allinfo[ 1 ][ 'info' + str( i )][ |
| 483 | 'swConnection' ] |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 484 | # Calculate the disconnecti rate |
| 485 | main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' ) |
| 486 | |
| 487 | if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ): |
| 488 | main.log.error( "The results of two capture are different!" ) |
| 489 | main.log.debug( "The data is " + str( main.allinfo ) ) |
| 490 | if main.writeData != -1: |
| 491 | main.log.info( "Write the date into database" ) |
| 492 | # write the date into data base |
| 493 | with open( main.dbFilePath, "a" ) as dbFile: |
| 494 | temp = str( main.currScale ) |
| 495 | temp += ",'baremetal1'" |
| 496 | # put result from second capture into data base |
| 497 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] ) |
| 498 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] ) |
Chiyu Cheng | 8800c7c | 2016-10-18 11:26:35 -0700 | [diff] [blame] | 499 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToTopology' ] ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 500 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] ) |
| 501 | temp += "\n" |
| 502 | dbFile.write( temp ) |
| 503 | else: |
| 504 | main.log.error( "The data from log is wrong!" ) |
| 505 | main.writeData = 1 |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 506 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 507 | main.log.info( "Error report: \n" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 508 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 509 | [ "INFO", |
| 510 | "FOLLOWER", |
| 511 | "WARN", |
| 512 | "flow", |
| 513 | "ERROR", |
| 514 | "Except" ], |
| 515 | "s" ) |