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