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