andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1 | # Intent Performance Test for ONOS-next |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 2 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 3 | # andrew@onlab.us |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 4 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 5 | # November 5, 2014 |
| 6 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 7 | |
| 8 | class IntentPerfNext: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 9 | |
| 10 | def __init__( self ): |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 11 | self.default = "" |
| 12 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 13 | def CASE1( self, main ): |
| 14 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 15 | ONOS startup sequence |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 16 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 17 | import time |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 18 | global clusterCount |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 19 | global timeToPost |
| 20 | global runNum |
| 21 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 22 | clusterCount = 1 |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 23 | timeToPost = time.strftime("%Y-%m-%d %H:%M:%S") |
| 24 | runNum = time.strftime("%d%H%M%S") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 25 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 26 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 27 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 28 | gitPull = main.params[ 'GIT' ][ 'autoPull' ] |
| 29 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 30 | intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 31 | |
andrewonlab | 082dfc3 | 2015-02-06 13:59:51 -0500 | [diff] [blame] | 32 | ONOSIp = [] |
| 33 | for i in range(1, 8): |
| 34 | ONOSIp.append(main.params[ 'CTRL' ][ 'ip'+str(i) ]) |
| 35 | main.ONOSbench.onosUninstall( nodeIp = ONOSIp[i-1] ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 36 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 37 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 38 | BENCHIp = main.params[ 'BENCH' ][ 'ip' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 39 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 40 | main.case( "Setting up test environment" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 41 | |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 42 | main.step( "Clearing previous DB log file" ) |
| 43 | fIntentLog = open(intentFilePath, 'w') |
| 44 | # Overwrite with empty line and close |
| 45 | fIntentLog.write('') |
| 46 | fIntentLog.close() |
| 47 | |
andrewonlab | 5b954b0 | 2015-02-05 13:03:46 -0500 | [diff] [blame] | 48 | main.step( "Starting mininet topology" ) |
| 49 | main.Mininet1.startNet() |
| 50 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 51 | main.step( "Creating cell file" ) |
| 52 | cellFileResult = main.ONOSbench.createCellFile( |
| 53 | BENCHIp, cellName, MN1Ip, |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 54 | ("onos-core,webconsole,onos-api,onos-app-metrics,onos-gui," |
| 55 | "onos-cli,onos-openflow"), |
andrewonlab | 082dfc3 | 2015-02-06 13:59:51 -0500 | [diff] [blame] | 56 | ONOSIp[0] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 57 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 58 | main.step( "Applying cell file to environment" ) |
| 59 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 60 | verifyCellResult = main.ONOSbench.verifyCell() |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 61 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 62 | main.step( "Removing raft logs" ) |
| 63 | main.ONOSbench.onosRemoveRaftLogs() |
| 64 | |
| 65 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 66 | if gitPull == 'on': |
| 67 | checkoutResult = \ |
| 68 | main.ONOSbench.gitCheckout( checkoutBranch ) |
| 69 | pullResult = main.ONOSbench.gitPull() |
| 70 | |
| 71 | # If you used git pull, auto compile |
| 72 | main.step( "Using onos-build to compile ONOS" ) |
| 73 | buildResult = main.ONOSbench.onosBuild() |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 74 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 75 | checkoutResult = main.TRUE |
| 76 | pullResult = main.TRUE |
| 77 | buildResult = main.TRUE |
| 78 | main.log.info( "Git pull skipped by configuration" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 79 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 80 | main.log.report( "Commit information - " ) |
| 81 | main.ONOSbench.getVersion( report=True ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 82 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 83 | main.step( "Creating ONOS package" ) |
| 84 | packageResult = main.ONOSbench.onosPackage() |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 85 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 86 | main.step( "Installing ONOS package" ) |
andrewonlab | 082dfc3 | 2015-02-06 13:59:51 -0500 | [diff] [blame] | 87 | install1Result = main.ONOSbench.onosInstall( node=ONOSIp[0] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 88 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 89 | main.step( "Set cell for ONOScli env" ) |
| 90 | main.ONOS1cli.setCell( cellName ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 91 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 92 | time.sleep( 5 ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 93 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 94 | main.step( "Start onos cli" ) |
andrewonlab | 082dfc3 | 2015-02-06 13:59:51 -0500 | [diff] [blame] | 95 | cli1 = main.ONOS1cli.startOnosCli( ONOSIp[0] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 96 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 97 | utilities.assert_equals( expect=main.TRUE, |
| 98 | actual=cellFileResult and cellApplyResult and |
| 99 | verifyCellResult and checkoutResult and |
| 100 | pullResult and buildResult and |
| 101 | install1Result, # and install2Result and |
| 102 | # install3Result, |
| 103 | onpass="ONOS started successfully", |
| 104 | onfail="Failed to start ONOS" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 105 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 106 | def CASE2( self, main ): |
| 107 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 108 | Single intent add latency |
| 109 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 110 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 111 | import time |
| 112 | import json |
| 113 | import requests |
| 114 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 115 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 116 | global clusterCount |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 117 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 118 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 119 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 120 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 121 | ONOSIpList = [] |
| 122 | for i in range( 1, 8 ): |
| 123 | ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 124 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 125 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 126 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 127 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 128 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 129 | # number of iterations of case |
| 130 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 131 | numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
| 132 | |
| 133 | # Timestamp keys for json metrics output |
| 134 | submitTime = main.params[ 'JSON' ][ 'submittedTime' ] |
| 135 | installTime = main.params[ 'JSON' ][ 'installedTime' ] |
| 136 | wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ] |
| 137 | withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ] |
| 138 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 139 | assertion = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 140 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 141 | intentAddLatList = [] |
| 142 | |
| 143 | # Distribute switches according to cluster count |
| 144 | for i in range( 1, 9 ): |
| 145 | if clusterCount == 1: |
| 146 | main.Mininet1.assignSwController( |
| 147 | sw=str( i ), ip1=ONOSIpList[ 0 ], |
| 148 | port1=defaultSwPort |
| 149 | ) |
| 150 | elif clusterCount == 3: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 151 | if i < 3: |
| 152 | index = 0 |
| 153 | elif i < 6 and i >= 3: |
| 154 | index = 1 |
| 155 | else: |
| 156 | index = 2 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 157 | main.Mininet1.assignSwController( |
| 158 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 159 | port1=defaultSwPort |
| 160 | ) |
| 161 | elif clusterCount == 5: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 162 | if i < 3: |
| 163 | index = 0 |
| 164 | elif i < 5 and i >= 3: |
| 165 | index = 1 |
| 166 | elif i < 7 and i >= 5: |
| 167 | index = 2 |
| 168 | elif i == 7: |
| 169 | index = 3 |
| 170 | else: |
| 171 | index = 4 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 172 | main.Mininet1.assignSwController( |
| 173 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 174 | port1=defaultSwPort |
| 175 | ) |
| 176 | elif clusterCount == 7: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 177 | if i < 6: |
| 178 | index = i |
| 179 | else: |
| 180 | index = 6 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 181 | main.Mininet1.assignSwController( |
| 182 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 183 | port1=defaultSwPort |
| 184 | ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 185 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 186 | time.sleep( 10 ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 187 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 188 | main.log.report( "Single intent add latency test" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 189 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 190 | devicesJsonStr = main.ONOS1cli.devices() |
| 191 | devicesJsonObj = json.loads( devicesJsonStr ) |
| 192 | |
| 193 | if not devicesJsonObj: |
| 194 | main.log.report( "Devices not discovered" ) |
| 195 | main.log.report( "Aborting test" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 196 | main.exit() |
| 197 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 198 | main.log.info( "Devices discovered successfully" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 199 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 200 | deviceIdList = [] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 201 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 202 | # Obtain device id list in ONOS format. |
| 203 | # They should already be in order ( 1,2,3,10,11,12,13, etc ) |
| 204 | for device in devicesJsonObj: |
| 205 | deviceIdList.append( device[ 'id' ] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 206 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 207 | for i in range( 0, int( numIter ) ): |
| 208 | # addPointIntent( ingrDevice, egrDevice, |
| 209 | # ingrPort, egrPort ) |
| 210 | main.ONOS1cli.addPointIntent( |
| 211 | deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" ) |
| 212 | |
| 213 | # Allow some time for intents to propagate |
| 214 | time.sleep( 5 ) |
| 215 | |
| 216 | intentsStr = main.ONOS1cli.intents( jsonFormat=True ) |
| 217 | intentsObj = json.loads( intentsStr ) |
| 218 | for intent in intentsObj: |
| 219 | if intent[ 'state' ] == "INSTALLED": |
| 220 | main.log.info( "Intent installed successfully" ) |
| 221 | intentId = intent[ 'id' ] |
| 222 | main.log.info( "Intent id: " + str( intentId ) ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 223 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 224 | # TODO: Add error handling |
| 225 | main.log.info( "Intent installation failed" ) |
| 226 | intentId = "" |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 227 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 228 | # Obtain metrics from ONOS 1, 2, 3 |
| 229 | intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics() |
| 230 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 231 | # Parse values from the json object |
| 232 | intentSubmit1 = \ |
| 233 | intentsJsonObj1[ submitTime ][ 'value' ] |
| 234 | intentInstall1 = \ |
| 235 | intentsJsonObj1[ installTime ][ 'value' ] |
| 236 | intentInstallLat1 = \ |
| 237 | int( intentInstall1 ) - int( intentSubmit1 ) |
| 238 | |
| 239 | if clusterCount == 3: |
| 240 | intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics() |
| 241 | intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics() |
| 242 | intentsJsonObj2 = json.loads( intentsJsonStr2 ) |
| 243 | intentsJsonObj3 = json.loads( intentsJsonStr3 ) |
| 244 | intentSubmit2 = \ |
| 245 | intentsJsonObj2[ submitTime ][ 'value' ] |
| 246 | intentSubmit3 = \ |
| 247 | intentsJsonObj3[ submitTime ][ 'value' ] |
| 248 | intentInstall2 = \ |
| 249 | intentsJsonObj2[ installTime ][ 'value' ] |
| 250 | intentInstall3 = \ |
| 251 | intentsJsonObj3[ installTime ][ 'value' ] |
| 252 | intentInstallLat2 = \ |
| 253 | int( intentInstall2 ) - int( intentSubmit2 ) |
| 254 | intentInstallLat3 = \ |
| 255 | int( intentInstall3 ) - int( intentSubmit3 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 256 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 257 | intentInstallLat2 = 0 |
| 258 | intentInstallLat3 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 259 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 260 | if clusterCount == 5: |
| 261 | intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics() |
| 262 | intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics() |
| 263 | intentsJsonObj4 = json.loads( intentsJsonStr4 ) |
| 264 | intentsJsonObj5 = json.loads( intentsJsonStr5 ) |
| 265 | intentSubmit4 = \ |
| 266 | intentsJsonObj4[ submitTime ][ 'value' ] |
| 267 | intentSubmit5 = \ |
| 268 | intentsJsonObj5[ submitTime ][ 'value' ] |
| 269 | intentInstall4 = \ |
| 270 | intentsJsonObj5[ installTime ][ 'value' ] |
| 271 | intentInstall5 = \ |
| 272 | intentsJsonObj5[ installTime ][ 'value' ] |
| 273 | intentInstallLat4 = \ |
| 274 | int( intentInstall4 ) - int( intentSubmit4 ) |
| 275 | intentInstallLat5 = \ |
| 276 | int( intentInstall5 ) - int( intentSubmit5 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 277 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 278 | intentInstallLat4 = 0 |
| 279 | intentInstallLat5 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 280 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 281 | if clusterCount == 7: |
| 282 | intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics() |
| 283 | intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics() |
| 284 | intentsJsonObj6 = json.loads( intentsJsonStr6 ) |
| 285 | intentsJsonObj7 = json.loads( intentsJsonStr7 ) |
| 286 | intentSubmit6 = \ |
| 287 | intentsJsonObj6[ submitTime ][ 'value' ] |
| 288 | intentSubmit7 = \ |
| 289 | intentsJsonObj6[ submitTime ][ 'value' ] |
| 290 | intentInstall6 = \ |
| 291 | intentsJsonObj6[ installTime ][ 'value' ] |
| 292 | intentInstall7 = \ |
| 293 | intentsJsonObj7[ installTime ][ 'value' ] |
| 294 | intentInstallLat6 = \ |
| 295 | int( intentInstall6 ) - int( intentSubmit6 ) |
| 296 | intentInstallLat7 = \ |
| 297 | int( intentInstall7 ) - int( intentSubmit7 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 298 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 299 | intentInstallLat6 = 0 |
| 300 | intentInstallLat7 = 0 |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 301 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 302 | intentInstallLatAvg = \ |
| 303 | ( intentInstallLat1 + |
| 304 | intentInstallLat2 + |
| 305 | intentInstallLat3 + |
| 306 | intentInstallLat4 + |
| 307 | intentInstallLat5 + |
| 308 | intentInstallLat6 + |
| 309 | intentInstallLat7 ) / clusterCount |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 310 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 311 | main.log.info( "Intent add latency avg for iteration " + str( i ) + |
| 312 | ": " + str( intentInstallLatAvg ) + " ms" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 313 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 314 | if intentInstallLatAvg > 0.0 and \ |
| 315 | intentInstallLatAvg < 1000 and i > numIgnore: |
| 316 | intentAddLatList.append( intentInstallLatAvg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 317 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 318 | main.log.info( "Intent add latency exceeded " + |
| 319 | "threshold. Skipping iteration " + str( i ) ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 320 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 321 | time.sleep( 3 ) |
| 322 | |
| 323 | # TODO: Only remove intents that were installed |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 324 | # in this case... Otherwise many other intents |
| 325 | # may show up distorting the results |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 326 | main.log.info( "Removing intents for next iteration" ) |
| 327 | jsonTemp = \ |
| 328 | main.ONOS1cli.intents( jsonFormat=True ) |
| 329 | jsonObjIntents = json.loads( jsonTemp ) |
| 330 | if jsonObjIntents: |
| 331 | for intents in jsonObjIntents: |
| 332 | tempId = intents[ 'id' ] |
| 333 | # main.ONOS1cli.removeIntent( tempId ) |
| 334 | main.log.info( "Removing intent id: " + |
| 335 | str( tempId ) ) |
| 336 | main.ONOS1cli.removeIntent( tempId ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 337 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 338 | main.log.info( "Intents were not installed correctly" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 339 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 340 | time.sleep( 5 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 341 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 342 | if intentAddLatList: |
| 343 | intentAddLatAvg = sum( intentAddLatList ) /\ |
| 344 | len( intentAddLatList ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 345 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 346 | main.log.report( "Intent installation latency test failed" ) |
| 347 | intentAddLatAvg = "NA" |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 348 | assertion = main.FALSE |
| 349 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 350 | intentAddLatStd = \ |
| 351 | round( numpy.std( intentAddLatList ), 1 ) |
| 352 | # END ITERATION FOR LOOP |
| 353 | main.log.report( "Single intent add latency - " ) |
| 354 | main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" ) |
| 355 | main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" ) |
| 356 | |
| 357 | utilities.assert_equals( |
| 358 | expect=main.TRUE, |
| 359 | actual=assertion, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 360 | onpass="Single intent install latency test successful", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 361 | onfail="Single intent install latency test failed" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 362 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 363 | def CASE3( self, main ): |
| 364 | """ |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 365 | Intent Reroute latency |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 366 | """ |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 367 | import time |
| 368 | import json |
| 369 | import requests |
| 370 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 371 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 372 | global clusterCount |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 373 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 374 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 375 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 376 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 377 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 378 | |
| 379 | ONOSIpList = [] |
| 380 | for i in range( 1, 8 ): |
| 381 | ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 382 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 383 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 384 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 385 | # number of iterations of case |
| 386 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 387 | numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 388 | assertion = main.TRUE |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 389 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 390 | # Timestamp keys for json metrics output |
| 391 | submitTime = main.params[ 'JSON' ][ 'submittedTime' ] |
| 392 | installTime = main.params[ 'JSON' ][ 'installedTime' ] |
| 393 | wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ] |
| 394 | withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 395 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 396 | # NOTE: May need to configure interface depending on topology |
| 397 | intfs = main.params[ 'TEST' ][ 'intfs' ] |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 398 | |
| 399 | # Distribute switches according to cluster count |
| 400 | for i in range( 1, 9 ): |
| 401 | if clusterCount == 1: |
| 402 | main.Mininet1.assignSwController( |
| 403 | sw=str( i ), ip1=ONOSIpList[ 0 ], |
| 404 | port1=defaultSwPort |
| 405 | ) |
| 406 | elif clusterCount == 3: |
| 407 | if i < 3: |
| 408 | index = 0 |
| 409 | elif i < 6 and i >= 3: |
| 410 | index = 1 |
| 411 | else: |
| 412 | index = 2 |
| 413 | main.Mininet1.assignSwController( |
| 414 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 415 | port1=defaultSwPort |
| 416 | ) |
| 417 | elif clusterCount == 5: |
| 418 | if i < 3: |
| 419 | index = 0 |
| 420 | elif i < 5 and i >= 3: |
| 421 | index = 1 |
| 422 | elif i < 7 and i >= 5: |
| 423 | index = 2 |
| 424 | elif i == 7: |
| 425 | index = 3 |
| 426 | else: |
| 427 | index = 4 |
| 428 | main.Mininet1.assignSwController( |
| 429 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 430 | port1=defaultSwPort |
| 431 | ) |
| 432 | elif clusterCount == 7: |
| 433 | if i < 6: |
| 434 | index = i |
| 435 | else: |
| 436 | index = 6 |
| 437 | main.Mininet1.assignSwController( |
| 438 | sw=str( i ), ip1=ONOSIpList[ index ], |
| 439 | port1=defaultSwPort |
| 440 | ) |
| 441 | |
| 442 | time.sleep(10) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 443 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 444 | devicesJsonStr = main.ONOS1cli.devices() |
| 445 | devicesJsonObj = json.loads( devicesJsonStr ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 446 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 447 | deviceIdList = [] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 448 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 449 | # Obtain device id list in ONOS format. |
| 450 | # They should already be in order ( 1,2,3,10,11,12,13, etc ) |
| 451 | for device in devicesJsonObj: |
| 452 | deviceIdList.append( device[ 'id' ] ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 453 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 454 | intentRerouteLatList = [] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 455 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 456 | for i in range( 0, int( numIter ) ): |
| 457 | # addPointIntent( ingrDevice, ingrPort, |
| 458 | # egrDevice, egrPort ) |
| 459 | if len( deviceIdList ) > 0: |
| 460 | main.ONOS1cli.addPointIntent( |
| 461 | deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 462 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 463 | main.log.info( "Failed to fetch devices from ONOS" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 464 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 465 | time.sleep( 5 ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 466 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 467 | intentsStr = main.ONOS1cli.intents( jsonFormat=True ) |
| 468 | intentsObj = json.loads( intentsStr ) |
| 469 | for intent in intentsObj: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 470 | main.log.info(intent) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 471 | if intent[ 'state' ] == "INSTALLED": |
| 472 | main.log.info( "Intent installed successfully" ) |
| 473 | intentId = intent[ 'id' ] |
| 474 | main.log.info( "Intent id: " + str( intentId ) ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 475 | #else: |
| 476 | #TODO: Add error handling |
| 477 | #main.log.info( "Intent installation failed" ) |
| 478 | #intentId = "" |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 479 | |
| 480 | main.log.info( "Disabling interface " + intfs ) |
| 481 | t0System = time.time() * 1000 |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 482 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 483 | "sh ifconfig " + intfs + " down" ) |
| 484 | main.Mininet1.handle.expect( "mininet>" ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 485 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 486 | # TODO: Check for correct intent reroute |
| 487 | time.sleep( 1 ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 488 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 489 | # Obtain metrics from ONOS 1, 2, 3 |
| 490 | intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics() |
| 491 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 492 | # Parse values from the json object |
| 493 | intentInstall1 = \ |
| 494 | intentsJsonObj1[ installTime ][ 'value' ] |
| 495 | intentRerouteLat1 = \ |
| 496 | int( intentInstall1 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 497 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 498 | if clusterCount == 3: |
| 499 | intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics() |
| 500 | intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics() |
| 501 | |
| 502 | intentsJsonObj2 = json.loads( intentsJsonStr2 ) |
| 503 | intentsJsonObj3 = json.loads( intentsJsonStr3 ) |
| 504 | intentInstall2 = \ |
| 505 | intentsJsonObj2[ installTime ][ 'value' ] |
| 506 | intentInstall3 = \ |
| 507 | intentsJsonObj3[ installTime ][ 'value' ] |
| 508 | intentRerouteLat2 = \ |
| 509 | int( intentInstall2 ) - int( t0System ) |
| 510 | intentRerouteLat3 = \ |
| 511 | int( intentInstall3 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 512 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 513 | intentRerouteLat2 = 0 |
| 514 | intentRerouteLat3 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 515 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 516 | if clusterCount == 5: |
| 517 | intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics() |
| 518 | intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 519 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 520 | intentsJsonObj4 = json.loads( intentsJsonStr4 ) |
| 521 | intentsJsonObj5 = json.loads( intentsJsonStr5 ) |
| 522 | intentInstall4 = \ |
| 523 | intentsJsonObj4[ installTime ][ 'value' ] |
| 524 | intentInstall5 = \ |
| 525 | intentsJsonObj5[ installTime ][ 'value' ] |
| 526 | intentRerouteLat4 = \ |
| 527 | int( intentInstall4 ) - int( t0System ) |
| 528 | intentRerouteLat5 = \ |
| 529 | int( intentInstall5 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 530 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 531 | intentRerouteLat4 = 0 |
| 532 | intentRerouteLat5 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 533 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 534 | if clusterCount == 7: |
| 535 | intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics() |
| 536 | intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 537 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 538 | intentsJsonObj6 = json.loads( intentsJsonStr6 ) |
| 539 | intentsJsonObj7 = json.loads( intentsJsonStr7 ) |
| 540 | intentInstall6 = \ |
| 541 | intentsJsonObj6[ installTime ][ 'value' ] |
| 542 | intentInstall7 = \ |
| 543 | intentsJsonObj7[ installTime ][ 'value' ] |
| 544 | intentRerouteLat6 = \ |
| 545 | int( intentInstall6 ) - int( t0System ) |
| 546 | intentRerouteLat7 = \ |
| 547 | int( intentInstall7 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 548 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 549 | intentRerouteLat6 = 0 |
| 550 | intentRerouteLat7 = 0 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 551 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 552 | intentRerouteLatAvg = \ |
| 553 | ( intentRerouteLat1 + |
| 554 | intentRerouteLat2 + |
| 555 | intentRerouteLat3 + |
| 556 | intentRerouteLat4 + |
| 557 | intentRerouteLat5 + |
| 558 | intentRerouteLat6 + |
| 559 | intentRerouteLat7 ) / clusterCount |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 560 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 561 | main.log.info( "Intent reroute latency avg for iteration " + |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 562 | str( i ) + ": " + str( intentRerouteLatAvg )+ " ms") |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 563 | |
| 564 | if intentRerouteLatAvg > 0.0 and \ |
| 565 | intentRerouteLatAvg < 1000 and i > numIgnore: |
| 566 | intentRerouteLatList.append( intentRerouteLatAvg ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 567 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 568 | main.log.info( "Intent reroute latency exceeded " + |
| 569 | "threshold. Skipping iteration " + str( i ) ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 570 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 571 | main.log.info( "Removing intents for next iteration" ) |
| 572 | main.ONOS1cli.removeIntent( intentId ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 573 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 574 | main.log.info( "Bringing Mininet interface up for next " + |
| 575 | "iteration" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 576 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 577 | "sh ifconfig " + intfs + " up" ) |
| 578 | main.Mininet1.handle.expect( "mininet>" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 579 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 580 | if intentRerouteLatList: |
| 581 | intentRerouteLatAvg = sum( intentRerouteLatList ) /\ |
| 582 | len( intentRerouteLatList ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 583 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 584 | main.log.report( "Intent reroute test failed. Results NA" ) |
| 585 | intentRerouteLatAvg = "NA" |
| 586 | # NOTE: fails test when list is empty |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 587 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 588 | |
| 589 | intentRerouteLatStd = \ |
| 590 | round( numpy.std( intentRerouteLatList ), 1 ) |
| 591 | # END ITERATION FOR LOOP |
| 592 | main.log.report( "Single intent reroute latency - " ) |
| 593 | main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" ) |
| 594 | main.log.report( |
| 595 | "Std Deviation: " + |
| 596 | str( intentRerouteLatStd ) + |
| 597 | " ms" ) |
| 598 | |
| 599 | utilities.assert_equals( |
| 600 | expect=main.TRUE, |
| 601 | actual=assertion, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 602 | onpass="Single intent reroute latency test successful", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 603 | onfail="Single intent reroute latency test failed" ) |
| 604 | |
| 605 | def CASE4( self, main ): |
| 606 | """ |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 607 | Batch intent install |
andrewonlab | 082dfc3 | 2015-02-06 13:59:51 -0500 | [diff] [blame] | 608 | |
| 609 | Supports scale-out scenarios and increasing |
| 610 | number of intents within each iteration |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 611 | """ |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 612 | import time |
| 613 | import json |
| 614 | import requests |
| 615 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 616 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 617 | global clusterCount |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 618 | global timeToPost |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 619 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 620 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 621 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 622 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 623 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 624 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 625 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 626 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 627 | |
| 628 | assertion = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 629 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 630 | ONOSIpList = [] |
| 631 | for i in range( 1, 8 ): |
| 632 | ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 633 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 634 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 635 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 636 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 637 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 638 | batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] ) |
| 639 | batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] ) |
| 640 | batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 641 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 642 | # number of iterations of case |
| 643 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 644 | numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
| 645 | numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] ) |
| 646 | nThread = main.params[ 'TEST' ][ 'numMult' ] |
| 647 | #nThread = 105 |
| 648 | |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 649 | # DB operation variables |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 650 | intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ] |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 651 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 652 | # Switch assignment NOTE: hardcoded |
| 653 | if clusterCount == 1: |
| 654 | for i in range( 1, numSwitch + 1 ): |
| 655 | main.Mininet1.assignSwController( |
| 656 | sw=str( i ), |
| 657 | ip1=ONOS1Ip, |
| 658 | port1=defaultSwPort ) |
| 659 | if clusterCount == 3: |
| 660 | for i in range( 1, 3 ): |
| 661 | main.Mininet1.assignSwController( |
| 662 | sw=str( i ), |
| 663 | ip1=ONOS1Ip, |
| 664 | port1=defaultSwPort ) |
| 665 | for i in range( 3, 6 ): |
| 666 | main.Mininet1.assignSwController( |
| 667 | sw=str( i ), |
| 668 | ip1=ONOS2Ip, |
| 669 | port1=defaultSwPort ) |
| 670 | for i in range( 6, 9 ): |
| 671 | main.Mininet1.assignSwController( |
| 672 | sw=str( i ), |
| 673 | ip1=ONOS3Ip, |
| 674 | port1=defaultSwPort ) |
| 675 | if clusterCount == 5: |
| 676 | main.Mininet1.assignSwController( |
| 677 | sw="1", |
| 678 | ip1=ONOS1Ip, |
| 679 | port1=defaultSwPort ) |
| 680 | main.Mininet1.assignSwController( |
| 681 | sw="2", |
| 682 | ip1=ONOS2Ip, |
| 683 | port1=defaultSwPort ) |
| 684 | for i in range( 3, 6 ): |
| 685 | main.Mininet1.assignSwController( |
| 686 | sw=str( i ), |
| 687 | ip1=ONOS3Ip, |
| 688 | port1=defaultSwPort ) |
| 689 | main.Mininet1.assignSwController( |
| 690 | sw="6", |
| 691 | ip1=ONOS4Ip, |
| 692 | port1=defaultSwPort ) |
| 693 | main.Mininet1.assignSwController( |
| 694 | sw="7", |
| 695 | ip1=ONOS5Ip, |
| 696 | port1=defaultSwPort ) |
| 697 | main.Mininet1.assignSwController( |
| 698 | sw="8", |
| 699 | ip1=ONOS5Ip, |
| 700 | port1=defaultSwPort ) |
| 701 | |
| 702 | if clusterCount == 7: |
| 703 | for i in range( 1, 9 ): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 704 | if i < 8: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 705 | main.Mininet1.assignSwController( |
| 706 | sw=str( i ), |
| 707 | ip1=ONOSIpList[ i - 1 ], |
| 708 | port1=defaultSwPort ) |
| 709 | elif i >= 8: |
| 710 | main.Mininet1.assignSwController( |
| 711 | sw=str( i ), |
| 712 | ip1=ONOSIpList[ 6 ], |
| 713 | port1=defaultSwPort ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 714 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 715 | time.sleep( 20 ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 716 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 717 | main.log.report( "Batch intent installation test of " + |
| 718 | str( batchIntentSize ) + " intent(s)" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 719 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 720 | batchResultList = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 721 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 722 | main.log.info( "Getting list of available devices" ) |
| 723 | deviceIdList = [] |
| 724 | jsonStr = main.ONOS1cli.devices() |
| 725 | jsonObj = json.loads( jsonStr ) |
| 726 | for device in jsonObj: |
| 727 | deviceIdList.append( device[ 'id' ] ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 728 | |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 729 | # List of install / witdhraw latencies for each batch |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 730 | batchInstallLat = [] |
| 731 | batchWithdrawLat = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 732 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 733 | sleepTime = 10 |
| 734 | |
| 735 | baseDir = "/tmp/" |
| 736 | |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 737 | # Batch size increase loop |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 738 | for batch in range( 0, 5 ): |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 739 | # Max intent install measurement of all nodes |
| 740 | # Resets after each batch calculation |
| 741 | maxInstallLat = [] |
| 742 | maxWithdrawLat = [] |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 743 | # Max single intent install measurement of all nodes |
| 744 | # For example, if batch size is 1000, result latency |
| 745 | # will be divided by 1000 |
| 746 | maxSingleInstallLat = [] |
| 747 | maxSingleWithdrawLat = [] |
andrewonlab | e07f856 | 2015-02-20 12:23:07 -0500 | [diff] [blame] | 748 | # Statistical gathering loop over number of iterations |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 749 | for i in range( 0, int( numIter ) ): |
| 750 | main.log.info( "Pushing " + |
| 751 | str( int( batchIntentSize ) * int( nThread ) ) + |
| 752 | " intents. Iteration " + str( i ) ) |
| 753 | |
| 754 | for node in range( 1, clusterCount + 1 ): |
| 755 | saveDir = baseDir + "batch_intent_" + str( node ) + ".txt" |
| 756 | main.ONOSbench.pushTestIntentsShell( |
| 757 | deviceIdList[ 0 ] + "/2", |
| 758 | deviceIdList[ 7 ] + "/2", |
| 759 | batchIntentSize, |
| 760 | saveDir, ONOSIpList[ node - 1 ], |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 761 | numMult=nThread ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 762 | |
| 763 | # Wait sufficient time for intents to start |
| 764 | # installing |
| 765 | time.sleep( sleepTime ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 766 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 767 | intent = "" |
| 768 | counter = 300 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 769 | while len( intent ) > 0 and counter > 0: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 770 | main.ONOS1cli.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 771 | "intents | wc -l" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 772 | main.ONOS1cli.handle.expect( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 773 | "intents | wc -l" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 774 | main.ONOS1cli.handle.expect( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 775 | "onos>" ) |
| 776 | intentTemp = main.ONOS1cli.handle.before() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 777 | intent = main.ONOS1cli.intents() |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 778 | intent = json.loads( intent ) |
| 779 | counter = counter - 1 |
| 780 | time.sleep( 1 ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 781 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 782 | time.sleep( 5 ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 783 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 784 | for node in range( 1, clusterCount + 1 ): |
| 785 | saveDir = baseDir + "batch_intent_" + str( node ) + ".txt" |
| 786 | with open( saveDir ) as fOnos: |
| 787 | lineCount = 0 |
| 788 | for line in fOnos: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 789 | line_temp = "" |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 790 | main.log.info( "Line read: " + str( line ) ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 791 | line_temp = line[ 1: ] |
| 792 | line_temp = line_temp.split( ": " ) |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 793 | #Prevent split method if line doesn't have |
| 794 | #space |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 795 | if " " in str(line_temp): |
| 796 | result = line_temp[ 1 ].split( " " )[ 0 ] |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 797 | else: |
| 798 | main.log.warn( "Empty line read" ) |
| 799 | result = 0 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 800 | # TODO: add parameters before appending latency |
| 801 | if lineCount == 0: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 802 | if "Failure" in str(line): |
| 803 | main.log.warn("Intent installation failed") |
| 804 | result = 'NA' |
| 805 | else: |
| 806 | main.log.info("Install result: "+result) |
| 807 | batchInstallLat.append( int( result ) ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 808 | installResult = result |
| 809 | elif lineCount == 1: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 810 | if "Failure" in str(line): |
| 811 | main.log.warn("Intent withdraw failed") |
| 812 | result = 'NA' |
| 813 | else: |
| 814 | main.log.info("Withdraw result: "+result) |
| 815 | batchWithdrawLat.append( int( result ) ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 816 | withdrawResult = result |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 817 | else: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 818 | main.log.warn("Invalid results: excess lines") |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 819 | installResult = 'NA' |
| 820 | withdrawResult = 'NA' |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 821 | lineCount += 1 |
| 822 | main.log.info( "Batch install latency for ONOS" + |
| 823 | str( node ) + " with " + |
| 824 | str( batchIntentSize ) + "intents: " + |
| 825 | str( installResult ) + " ms" ) |
| 826 | main.log.info( "Batch withdraw latency for ONOS" + |
| 827 | str( node ) + " with " + |
| 828 | str( batchIntentSize ) + "intents: " + |
| 829 | str( withdrawResult ) + " ms" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 830 | |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 831 | main.log.info( "Single intent install latency ONOS" + |
| 832 | str( node ) + " with " + |
| 833 | str( batchIntentSize ) + "intents: " + |
| 834 | str( float(installResult) /\ |
| 835 | int(batchIntentSize) ) + " ms" ) |
| 836 | main.log.info( "Single intent withdraw latency ONOS" + |
| 837 | str( node ) + " with " + |
| 838 | str( batchIntentSize ) + "intents: " + |
| 839 | str( float(withdrawResult) /\ |
| 840 | int(batchIntentSize) ) + " ms" ) |
| 841 | |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 842 | #NOTE: END node loop |
| 843 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 844 | if len( batchInstallLat ) > 0 and int( i ) > numIgnore: |
| 845 | maxInstallLat.append( max( batchInstallLat ) ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 846 | maxSingleInstallLat.append( |
| 847 | max( batchInstallLat ) / int( batchIntentSize ) |
| 848 | ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 849 | elif len( batchInstallLat ) == 0: |
| 850 | # If I failed to read anything from the file, |
| 851 | # increase the wait time before checking intents |
| 852 | sleepTime += 30 |
| 853 | if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore: |
| 854 | maxWithdrawLat.append( max( batchWithdrawLat ) ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 855 | maxSingleWithdrawLat.append( |
| 856 | max( batchWithdrawLat ) / int( batchIntentSize ) |
| 857 | ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 858 | batchInstallLat = [] |
| 859 | batchWithdrawLat = [] |
| 860 | |
| 861 | # Sleep in between iterations |
| 862 | time.sleep( 5 ) |
| 863 | |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 864 | #NOTE: END iteration loop |
| 865 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 866 | if maxInstallLat: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 867 | avgInstallLat = str( round( numpy.average(maxInstallLat) |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 868 | , 2 )) |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 869 | stdInstallLat = str( round( |
| 870 | numpy.std(maxInstallLat), 2)) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 871 | avgSingleInstallLat = str( round( |
| 872 | numpy.average(maxSingleInstallLat) |
| 873 | , 3 )) |
| 874 | stdSingleInstallLat = str( round( |
| 875 | numpy.std(maxSingleInstallLat), |
| 876 | 3 )) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 877 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 878 | avgInstallLat = "NA" |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 879 | stdInstallLat = "NA" |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 880 | main.log.report( "Batch installation failed" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 881 | assertion = main.FALSE |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 882 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 883 | if maxWithdrawLat: |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 884 | avgWithdrawLat = str( round( numpy.average(maxWithdrawLat) |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 885 | , 2 )) |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 886 | stdWithdrawLat = str( round( |
| 887 | numpy.std(maxWithdrawLat), 2)) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 888 | avgSingleWithdrawLat = str( round( |
| 889 | numpy.average(maxSingleWithdrawLat) |
| 890 | , 3 )) |
| 891 | stdSingleWithdrawLat = str( round( |
| 892 | numpy.std(maxSingleWithdrawLat), |
| 893 | 3 )) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 894 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 895 | avgWithdrawLat = "NA" |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 896 | stdWithdrawLat = "NA" |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 897 | main.log.report( "Batch withdraw failed" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 898 | assertion = main.FALSE |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 899 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 900 | main.log.report( "Avg of batch installation latency " + |
| 901 | "of size " + str( batchIntentSize ) + ": " + |
| 902 | str( avgInstallLat ) + " ms" ) |
| 903 | main.log.report( "Std Deviation of batch installation latency " + |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 904 | ": " + |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 905 | str( stdInstallLat ) + " ms" ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 906 | main.log.report( "Avg of single installation latency " + |
| 907 | "of size " + str( batchIntentSize ) + ": " + |
| 908 | str( avgSingleInstallLat ) + " ms" ) |
| 909 | main.log.report( "Std Deviation of single installation latency " + |
| 910 | ": " + |
| 911 | str( stdSingleInstallLat ) + " ms" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 912 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 913 | main.log.report( "Avg of batch withdraw latency " + |
| 914 | "of size " + str( batchIntentSize ) + ": " + |
| 915 | str( avgWithdrawLat ) + " ms" ) |
| 916 | main.log.report( "Std Deviation of batch withdraw latency " + |
| 917 | ": " + |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 918 | str( stdWithdrawLat ) + " ms" ) |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 919 | main.log.report( "Avg of single withdraw latency " + |
| 920 | "of size " + str( batchIntentSize ) + ": " + |
| 921 | str( avgSingleWithdrawLat ) + " ms" ) |
| 922 | main.log.report( "Std Deviation of single withdraw latency " + |
| 923 | ": " + |
| 924 | str( stdSingleWithdrawLat ) + " ms" ) |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 925 | |
| 926 | dbCmd = ( |
andrewonlab | c3336d5 | 2015-02-26 18:54:56 -0500 | [diff] [blame] | 927 | "INSERT INTO intents_latency_tests VALUES(" |
| 928 | "'"+timeToPost+"','intents_latency_results'," |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 929 | ""+runNum+","+str(clusterCount)+","+str(batchIntentSize)+"," |
| 930 | ""+str(avgInstallLat)+","+str(stdInstallLat)+"," |
| 931 | ""+str(avgWithdrawLat)+","+str(stdWithdrawLat)+");" |
| 932 | ) |
| 933 | |
| 934 | # Write result to file (which is posted to DB by jenkins) |
| 935 | fResult = open(intentFilePath, 'a') |
| 936 | if dbCmd: |
| 937 | fResult.write(dbCmd+"\n") |
| 938 | fResult.close() |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 939 | |
andrewonlab | d019a6b | 2015-02-05 00:05:22 -0500 | [diff] [blame] | 940 | if batch == 0: |
| 941 | batchIntentSize = 10 |
| 942 | elif batch == 1: |
| 943 | batchIntentSize = 100 |
| 944 | elif batch == 2: |
| 945 | batchIntentSize = 1000 |
| 946 | elif batch == 3: |
| 947 | batchIntentSize = 2000 |
| 948 | if batch < 4: |
| 949 | main.log.report( "Increasing batch intent size to " + |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 950 | str(batchIntentSize) ) |
| 951 | |
andrewonlab | 302cd53 | 2015-02-20 13:59:50 -0500 | [diff] [blame] | 952 | #NOTE: END batch loop |
| 953 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 954 | #main.log.info( "Removing all intents for next test case" ) |
| 955 | #jsonTemp = main.ONOS1cli.intents( jsonFormat=True ) |
| 956 | #jsonObjIntents = json.loads( jsonTemp ) |
| 957 | # if jsonObjIntents: |
| 958 | # for intents in jsonObjIntents: |
| 959 | # tempId = intents[ 'id' ] |
| 960 | # main.ONOS1cli.removeIntent( tempId ) |
| 961 | # main.ONOS1cli.removeIntent( tempId ) |
| 962 | |
| 963 | utilities.assert_equals( |
| 964 | expect=main.TRUE, |
| 965 | actual=assertion, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 966 | onpass="Batch intent install/withdraw test successful", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 967 | onfail="Batch intent install/withdraw test failed" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 968 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 969 | def CASE5( self, main ): |
| 970 | """ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 971 | Increase number of nodes and initiate CLI |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 972 | """ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 973 | import time |
| 974 | import json |
| 975 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 976 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 977 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 978 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 979 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 980 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 981 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 982 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 983 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 984 | global clusterCount |
| 985 | clusterCount += 2 |
| 986 | main.log.report( "Increasing cluster size to " + |
| 987 | str( clusterCount ) ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 988 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 989 | installResult = main.FALSE |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 990 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 991 | if clusterCount == 3: |
| 992 | installResult1 = \ |
| 993 | main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 994 | installResult2 = \ |
| 995 | main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 996 | time.sleep( 5 ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 997 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 998 | main.log.info( "Starting ONOS CLI" ) |
| 999 | main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 1000 | main.ONOS3cli.startOnosCli( ONOS3Ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1001 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1002 | installResult = installResult1 and installResult2 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1003 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1004 | if clusterCount == 5: |
| 1005 | main.log.info( "Installing ONOS on node 4 and 5" ) |
| 1006 | installResult1 = \ |
| 1007 | main.ONOSbench.onosInstall( node=ONOS4Ip ) |
| 1008 | installResult2 = \ |
| 1009 | main.ONOSbench.onosInstall( node=ONOS5Ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1010 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1011 | main.log.info( "Starting ONOS CLI" ) |
| 1012 | main.ONOS4cli.startOnosCli( ONOS4Ip ) |
| 1013 | main.ONOS5cli.startOnosCli( ONOS5Ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1014 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1015 | installResult = installResult1 and installResult2 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1016 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1017 | if clusterCount == 7: |
| 1018 | main.log.info( "Installing ONOS on node 6 and 7" ) |
| 1019 | installResult1 = \ |
| 1020 | main.ONOSbench.onosInstall( node=ONOS6Ip ) |
| 1021 | installResult2 = \ |
| 1022 | main.ONOSbench.onosInstall( node=ONOS7Ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1023 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1024 | main.log.info( "Starting ONOS CLI" ) |
| 1025 | main.ONOS6cli.startOnosCli( ONOS6Ip ) |
| 1026 | main.ONOS7cli.startOnosCli( ONOS7Ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1027 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1028 | installResult = installResult1 and installResult2 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1029 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1030 | time.sleep( 5 ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1031 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1032 | if installResult == main.TRUE: |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1033 | assertion = main.TRUE |
| 1034 | else: |
| 1035 | assertion = main.FALSE |
| 1036 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1037 | utilities.assert_equals( expect=main.TRUE, actual=assertion, |
| 1038 | onpass="Scale out to " + str( clusterCount ) + |
| 1039 | " nodes successful", |
| 1040 | onfail="Scale out to " + str( clusterCount ) + |
| 1041 | " nodes failed" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 1042 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1043 | def CASE7( self, main ): |
| 1044 | # TODO: Fix for scale-out scenario |
| 1045 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1046 | Batch intent reroute latency |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1047 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1048 | import time |
| 1049 | import json |
| 1050 | import requests |
| 1051 | import os |
| 1052 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1053 | global clusterCount |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1054 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1055 | ONOSIpList = [] |
| 1056 | for i in range( 1, 8 ): |
| 1057 | ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1058 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1059 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
| 1060 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1061 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1062 | batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ] |
| 1063 | batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] ) |
| 1064 | batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] ) |
| 1065 | intfs = main.params[ 'TEST' ][ 'intfs' ] |
| 1066 | installTime = main.params[ 'JSON' ][ 'installedTime' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1067 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1068 | # number of iterations of case |
| 1069 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 1070 | numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
| 1071 | numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] ) |
| 1072 | nThread = main.params[ 'TEST' ][ 'numMult' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1073 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1074 | main.log.report( "Batch intent installation test of " + |
| 1075 | batchIntentSize + " intents" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1076 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1077 | batchResultList = [] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1078 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1079 | time.sleep( 10 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1080 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1081 | main.log.info( "Getting list of available devices" ) |
| 1082 | deviceIdList = [] |
| 1083 | jsonStr = main.ONOS1cli.devices() |
| 1084 | jsonObj = json.loads( jsonStr ) |
| 1085 | for device in jsonObj: |
| 1086 | deviceIdList.append( device[ 'id' ] ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1087 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1088 | batchInstallLat = [] |
| 1089 | batchWithdrawLat = [] |
| 1090 | sleepTime = 10 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1091 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1092 | baseDir = "/tmp/" |
| 1093 | maxInstallLat = [] |
| 1094 | |
| 1095 | for i in range( 0, int( numIter ) ): |
| 1096 | main.log.info( "Pushing " + |
| 1097 | str( int( batchIntentSize ) * int( nThread ) ) + |
| 1098 | " intents. Iteration " + str( i ) ) |
| 1099 | |
| 1100 | main.ONOSbench.pushTestIntentsShell( |
| 1101 | deviceIdList[ 0 ] + "/2", |
| 1102 | deviceIdList[ 7 ] + "/2", |
| 1103 | batchIntentSize, "/tmp/batch_install.txt", |
| 1104 | ONOSIpList[ 0 ], numMult="1", appId="1", |
| 1105 | report=False, options="--install" ) |
| 1106 | # main.ONOSbench.pushTestIntentsShell( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1107 | # "of:0000000000001002/1", |
| 1108 | # "of:0000000000002002/1", |
| 1109 | # 133, "/tmp/temp2.txt", "10.128.174.2", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1110 | # numMult="6", appId="2",report=False ) |
| 1111 | |
| 1112 | # TODO: Check for installation success then proceed |
| 1113 | time.sleep( 30 ) |
| 1114 | |
| 1115 | # NOTE: this interface is specific to |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1116 | # topo-intentFlower.py topology |
| 1117 | # reroute case. |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1118 | main.log.info( "Disabling interface " + intfs ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1119 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1120 | "sh ifconfig " + intfs + " down" ) |
| 1121 | t0System = time.time() * 1000 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1122 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1123 | # TODO: Wait sufficient time for intents to install |
| 1124 | time.sleep( 10 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1125 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1126 | # TODO: get intent installation time |
| 1127 | |
| 1128 | # Obtain metrics from ONOS 1, 2, 3 |
| 1129 | intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics() |
| 1130 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 1131 | # Parse values from the json object |
| 1132 | intentInstall1 = \ |
| 1133 | intentsJsonObj1[ installTime ][ 'value' ] |
| 1134 | intentRerouteLat1 = \ |
| 1135 | int( intentInstall1 ) - int( t0System ) |
| 1136 | |
| 1137 | if clusterCount == 3: |
| 1138 | intentsJsonStr2 =\ |
| 1139 | main.ONOS2cli.intentsEventsMetrics() |
| 1140 | intentsJsonStr3 =\ |
| 1141 | main.ONOS3cli.intentsEventsMetrics() |
| 1142 | intentsJsonObj2 = json.loads( intentsJsonStr2 ) |
| 1143 | intentsJsonObj3 = json.loads( intentsJsonStr3 ) |
| 1144 | intentInstall2 = \ |
| 1145 | intentsJsonObj2[ installTime ][ 'value' ] |
| 1146 | intentInstall3 = \ |
| 1147 | intentsJsonObj3[ installTime ][ 'value' ] |
| 1148 | intentRerouteLat2 = \ |
| 1149 | int( intentInstall2 ) - int( t0System ) |
| 1150 | intentRerouteLat3 = \ |
| 1151 | int( intentInstall3 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1152 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1153 | intentRerouteLat2 = 0 |
| 1154 | intentRerouteLat3 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1155 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1156 | if clusterCount == 5: |
| 1157 | intentsJsonStr4 =\ |
| 1158 | main.ONOS4cli.intentsEventsMetrics() |
| 1159 | intentsJsonStr5 =\ |
| 1160 | main.ONOS5cli.intentsEventsMetrics() |
| 1161 | intentsJsonObj4 = json.loads( intentsJsonStr4 ) |
| 1162 | intentsJsonObj5 = json.loads( intentsJsonStr5 ) |
| 1163 | intentInstall4 = \ |
| 1164 | intentsJsonObj4[ installTime ][ 'value' ] |
| 1165 | intentInstall5 = \ |
| 1166 | intentsJsonObj5[ installTime ][ 'value' ] |
| 1167 | intentRerouteLat4 = \ |
| 1168 | int( intentInstall4 ) - int( t0System ) |
| 1169 | intentRerouteLat5 = \ |
| 1170 | int( intentInstall5 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1171 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1172 | intentRerouteLat4 = 0 |
| 1173 | intentRerouteLat5 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1174 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1175 | if clusterCount == 7: |
| 1176 | intentsJsonStr6 =\ |
| 1177 | main.ONOS6cli.intentsEventsMetrics() |
| 1178 | intentsJsonStr7 =\ |
| 1179 | main.ONOS7cli.intentsEventsMetrics() |
| 1180 | intentsJsonObj6 = json.loads( intentsJsonStr6 ) |
| 1181 | intentsJsonObj7 = json.loads( intentsJsonStr7 ) |
| 1182 | intentInstall6 = \ |
| 1183 | intentsJsonObj6[ installTime ][ 'value' ] |
| 1184 | intentInstall7 = \ |
| 1185 | intentsJsonObj7[ installTime ][ 'value' ] |
| 1186 | intentRerouteLat6 = \ |
| 1187 | int( intentInstall6 ) - int( t0System ) |
| 1188 | intentRerouteLat7 = \ |
| 1189 | int( intentInstall7 ) - int( t0System ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1190 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1191 | intentRerouteLat6 = 0 |
| 1192 | intentRerouteLat7 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1193 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1194 | intentRerouteLatAvg = \ |
| 1195 | ( intentRerouteLat1 + |
| 1196 | intentRerouteLat2 + |
| 1197 | intentRerouteLat3 + |
| 1198 | intentRerouteLat4 + |
| 1199 | intentRerouteLat5 + |
| 1200 | intentRerouteLat6 + |
| 1201 | intentRerouteLat7 ) / clusterCount |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1202 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1203 | main.log.info( "Intent reroute latency avg for iteration " + |
| 1204 | str( i ) + ": " + str( intentRerouteLatAvg ) ) |
| 1205 | # TODO: Remove intents for next iteration |
| 1206 | |
| 1207 | time.sleep( 5 ) |
| 1208 | |
| 1209 | intentsStr = main.ONOS1cli.intents() |
| 1210 | intentsJson = json.loads( intentsStr ) |
| 1211 | for intents in intentsJson: |
| 1212 | intentId = intents[ 'id' ] |
| 1213 | # TODO: make sure this removes all intents |
| 1214 | # print intentId |
| 1215 | if intentId: |
| 1216 | main.ONOS1cli.removeIntent( intentId ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1217 | |
| 1218 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1219 | "sh ifconfig " + intfs + " up" ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1220 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1221 | main.log.info( "Intents removed and port back up" ) |
| 1222 | |
| 1223 | def CASE9( self, main ): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1224 | count = 0 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1225 | swNum1 = 1 |
| 1226 | swNum2 = 1 |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1227 | appid = 0 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1228 | portNum1 = 1 |
| 1229 | portNum2 = 1 |
| 1230 | |
| 1231 | time.sleep( 30 ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 1232 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1233 | while True: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1234 | # main.ONOS1cli.pushTestIntents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1235 | #"of:0000000000001001/1", |
| 1236 | #"of:0000000000002001/1", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1237 | # 100, numMult="10", appId="1" ) |
| 1238 | # main.ONOS2cli.pushTestIntents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1239 | # "of:0000000000001002/1", |
| 1240 | # "of:0000000000002002/1", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1241 | # 100, numMult="10", appId="2" ) |
| 1242 | # main.ONOS2cli.pushTestIntents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1243 | # "of:0000000000001003/1", |
| 1244 | # "of:0000000000002003/1", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1245 | # 100, numMult="10", appId="3" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1246 | count += 1 |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1247 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1248 | if count >= 100: |
| 1249 | main.ONOSbench.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1250 | "onos 10.128.174.1 intents-events-metrics >>" + |
| 1251 | " /tmp/metrics_intents_temp.txt &" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1252 | count = 0 |
| 1253 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1254 | arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 ) |
| 1255 | arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1256 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1257 | swNum1 += 1 |
| 1258 | |
| 1259 | if swNum1 > 7: |
| 1260 | swNum1 = 1 |
| 1261 | swNum2 += 1 |
| 1262 | if swNum2 > 7: |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1263 | appid += 1 |
| 1264 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1265 | if swNum2 > 7: |
| 1266 | swNum2 = 1 |
| 1267 | |
| 1268 | main.ONOSbench.pushTestIntentsShell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1269 | arg1, |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1270 | arg2, |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 1271 | 100, "/tmp/temp.txt", "10.128.174.1", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1272 | numMult="10", appId=appid, report=False ) |
| 1273 | # main.ONOSbench.pushTestIntentsShell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1274 | # "of:0000000000001002/1", |
| 1275 | # "of:0000000000002002/1", |
| 1276 | # 133, "/tmp/temp2.txt", "10.128.174.2", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1277 | # numMult="6", appId="2",report=False ) |
| 1278 | # main.ONOSbench.pushTestIntentsShell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1279 | # "of:0000000000001003/1", |
| 1280 | # "of:0000000000002003/1", |
| 1281 | # 133, "/tmp/temp3.txt", "10.128.174.3", |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1282 | # numMult="6", appId="3",report=False ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 1283 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1284 | time.sleep( 0.2 ) |