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