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