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