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