andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1 | # TopoPerfNext |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 2 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 3 | # Topology Performance test for ONOS-next |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 4 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 5 | # andrew@onlab.us |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 6 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 7 | # If your machine does not come with numpy |
| 8 | # run the following command: |
| 9 | # sudo apt-get install python-numpy python-scipy |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 10 | |
| 11 | import time |
| 12 | import sys |
| 13 | import os |
| 14 | import re |
| 15 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 16 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 17 | class TopoPerfNext: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 18 | |
| 19 | def __init__( self ): |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 20 | self.default = '' |
| 21 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 22 | def CASE1( self, main ): |
| 23 | """ |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 24 | ONOS startup sequence |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 25 | """ |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 26 | import time |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 27 | |
| 28 | # Global cluster count for scale-out purposes |
| 29 | global clusterCount |
| 30 | # Set initial cluster count |
| 31 | clusterCount = 1 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 32 | ## |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 33 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 34 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 35 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 36 | gitPull = main.params[ 'GIT' ][ 'autoPull' ] |
| 37 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 38 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 39 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 40 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 41 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 42 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 43 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 44 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 45 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 46 | |
| 47 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 48 | BENCHIp = main.params[ 'BENCH' ][ 'ip' ] |
| 49 | |
| 50 | topoCfgFile = main.params[ 'TEST' ][ 'topoConfigFile' ] |
| 51 | topoCfgName = main.params[ 'TEST' ][ 'topoConfigName' ] |
| 52 | |
| 53 | mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 54 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 55 | main.case( "Setting up test environment" ) |
| 56 | main.log.info( "Copying topology event accumulator config" + |
| 57 | " to ONOS /package/etc" ) |
| 58 | main.ONOSbench.handle.sendline( "cp ~/" + |
| 59 | topoCfgFile + |
| 60 | " ~/ONOS/tools/package/etc/" + |
| 61 | topoCfgName ) |
| 62 | main.ONOSbench.handle.expect( "\$" ) |
andrewonlab | 6c8bbeb | 2014-11-14 12:43:48 -0500 | [diff] [blame] | 63 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 64 | main.log.report( "Setting up test environment" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 65 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 66 | main.step( "Cleaning previously installed ONOS if any" ) |
| 67 | main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip ) |
| 68 | main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip ) |
| 69 | main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip ) |
| 70 | main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip ) |
| 71 | main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip ) |
| 72 | #main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip ) |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 73 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 74 | main.step( "Creating cell file" ) |
| 75 | cellFileResult = main.ONOSbench.createCellFile( |
| 76 | BENCHIp, cellName, MN1Ip, |
| 77 | "onos-core,onos-app-metrics,onos-app-gui", |
| 78 | ONOS1Ip ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 79 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 80 | main.step( "Applying cell file to environment" ) |
| 81 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 82 | verifyCellResult = main.ONOSbench.verifyCell() |
andrewonlab | 6c8bbeb | 2014-11-14 12:43:48 -0500 | [diff] [blame] | 83 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 84 | # NOTE: This step may be removed after proper |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 85 | # copy cat log functionality |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 86 | main.step( "Removing raft/copy-cat logs from ONOS nodes" ) |
| 87 | main.ONOSbench.onosRemoveRaftLogs() |
| 88 | time.sleep( 30 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 89 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 90 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 91 | if gitPull == 'on': |
| 92 | # checkoutResult = \ |
| 93 | # main.ONOSbench.gitCheckout( checkoutBranch ) |
| 94 | checkoutResult = main.TRUE |
| 95 | pullResult = main.ONOSbench.gitPull() |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 96 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 97 | checkoutResult = main.TRUE |
| 98 | pullResult = main.TRUE |
| 99 | main.log.info( "Skipped git checkout and pull" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 100 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 101 | main.log.report( "Commit information - " ) |
| 102 | main.ONOSbench.getVersion( report=True ) |
andrewonlab | 9284434 | 2014-11-18 16:39:11 -0500 | [diff] [blame] | 103 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 104 | main.step( "Using mvn clean & install" ) |
| 105 | if mvnCleanInstall == 'on': |
| 106 | mvnResult = main.ONOSbench.cleanInstall() |
| 107 | elif mvnCleanInstall == 'off': |
| 108 | main.log.info("mci turned off by settings") |
| 109 | mvnResult = main.TRUE |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 110 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 111 | main.step( "Set cell for ONOS cli env" ) |
| 112 | main.ONOS1cli.setCell( cellName ) |
| 113 | # main.ONOS2cli.setCell( cellName ) |
| 114 | # main.ONOS3cli.setCell( cellName ) |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 115 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 116 | main.step( "Creating ONOS package" ) |
| 117 | packageResult = main.ONOSbench.onosPackage() |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 118 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 119 | main.step( "Installing ONOS package" ) |
| 120 | install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip ) |
| 121 | #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 122 | #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 123 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 124 | time.sleep( 10 ) |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 125 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 126 | main.step( "Start onos cli" ) |
| 127 | cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip ) |
| 128 | #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 129 | #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip ) |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 130 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 131 | utilities.assert_equals( expect=main.TRUE, |
| 132 | actual=cellFileResult and cellApplyResult and |
| 133 | verifyCellResult and checkoutResult and |
| 134 | pullResult and mvnResult and |
| 135 | install1Result, # and install2Result and |
| 136 | # install3Result, |
| 137 | onpass="Test Environment setup successful", |
| 138 | onfail="Failed to setup test environment" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 139 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 140 | def CASE2( self, main ): |
| 141 | """ |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 142 | Assign s1 to ONOS1 and measure latency |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 143 | |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 144 | There are 4 levels of latency measurements to this test: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 145 | 1 ) End-to-end measurement: Complete end-to-end measurement |
| 146 | from TCP ( SYN/ACK ) handshake to Graph change |
| 147 | 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 148 | measurement from OFP Vendor message to Graph change |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 149 | 3 ) OFP-to-device measurement: 'ONOS processing without |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 150 | graph change' snippet of measurement from OFP vendor |
| 151 | message to Device change timestamp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 152 | 4 ) T0-to-device measurement: Measurement that includes |
| 153 | the switch handshake to devices timestamp without |
| 154 | the graph view change. ( TCP handshake -> Device |
| 155 | change ) |
| 156 | """ |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 157 | import time |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 158 | import subprocess |
| 159 | import json |
| 160 | import requests |
| 161 | import os |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 162 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 163 | global clusterCount |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 164 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 165 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 166 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 167 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 168 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 169 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 170 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 171 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 172 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 173 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 4b5c8b9 | 2014-11-10 16:04:33 -0500 | [diff] [blame] | 174 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 175 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 176 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 177 | # Number of iterations of case |
| 178 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 179 | # Number of first 'x' iterations to ignore: |
| 180 | iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] ) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 181 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 182 | # Timestamp 'keys' for json metrics output. |
| 183 | # These are subject to change, hence moved into params |
| 184 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 185 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 186 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 187 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
| 188 | onosLog = main.params[ 'TEST' ][ 'onosLogFile' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 189 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 190 | # Threshold for the test |
| 191 | thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ] |
| 192 | thresholdObj = thresholdStr.split( "," ) |
| 193 | thresholdMin = int( thresholdObj[ 0 ] ) |
| 194 | thresholdMax = int( thresholdObj[ 1 ] ) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 195 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 196 | # List of switch add latency collected from |
| 197 | # all iterations |
| 198 | latencyEndToEndList = [] |
| 199 | latencyOfpToGraphList = [] |
| 200 | latencyOfpToDeviceList = [] |
| 201 | latencyT0ToDeviceList = [] |
| 202 | latencyTcpToOfpList = [] |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 203 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 204 | # Directory/file to store tshark results |
| 205 | tsharkOfOutput = "/tmp/tshark_of_topo.txt" |
| 206 | tsharkTcpOutput = "/tmp/tshark_tcp_topo.txt" |
| 207 | |
| 208 | # String to grep in tshark output |
| 209 | tsharkTcpString = "TCP 74 " + defaultSwPort |
| 210 | tsharkOfString = "OFP 86 Vendor" |
| 211 | |
| 212 | # Initialize assertion to TRUE |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 213 | assertion = main.TRUE |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 214 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 215 | localTime = time.strftime( '%x %X' ) |
| 216 | localTime = localTime.replace( "/", "" ) |
| 217 | localTime = localTime.replace( " ", "_" ) |
| 218 | localTime = localTime.replace( ":", "" ) |
| 219 | if debugMode == 'on': |
| 220 | main.ONOS1.tsharkPcap( "eth0", |
| 221 | "/tmp/single_sw_lat_pcap_" + localTime ) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 222 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 223 | main.log.info( "Debug mode is on" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 224 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 225 | main.log.report( "Latency of adding one switch to controller" ) |
| 226 | main.log.report( "First " + str( iterIgnore ) + " iterations ignored" + |
| 227 | " for jvm warmup time" ) |
| 228 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 229 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 230 | for i in range( 0, int( numIter ) ): |
| 231 | main.log.info( "Starting tshark capture" ) |
| 232 | |
| 233 | #* TCP [ ACK, SYN ] is used as t0A, the |
| 234 | # very first "exchange" between ONOS and |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 235 | # the switch for end-to-end measurement |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 236 | #* OFP [ Stats Reply ] is used for t0B |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 237 | # the very last OFP message between ONOS |
| 238 | # and the switch for ONOS measurement |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 239 | main.ONOS1.tsharkGrep( tsharkTcpString, |
| 240 | tsharkTcpOutput ) |
| 241 | main.ONOS1.tsharkGrep( tsharkOfString, |
| 242 | tsharkOfOutput ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 243 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 244 | # Wait and ensure tshark is started and |
| 245 | # capturing |
| 246 | time.sleep( 10 ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 247 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 248 | main.log.info( "Assigning s1 to controller" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 249 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 250 | main.Mininet1.assignSwController( |
| 251 | sw="1", |
| 252 | ip1=ONOS1Ip, |
| 253 | port1=defaultSwPort ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 254 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 255 | # Wait and ensure switch is assigned |
| 256 | # before stopping tshark |
| 257 | time.sleep( 30 ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 258 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 259 | main.log.info( "Stopping all Tshark processes" ) |
| 260 | main.ONOS1.stopTshark() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 261 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 262 | # tshark output is saved in ONOS. Use subprocess |
| 263 | # to copy over files to TestON for parsing |
| 264 | main.log.info( "Copying over tshark files" ) |
| 265 | |
| 266 | # TCP CAPTURE **** |
| 267 | # Copy the tshark output from ONOS machine to |
| 268 | # TestON machine in tsharkTcpOutput directory>file |
| 269 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 270 | tsharkTcpOutput + " /tmp/" ) |
| 271 | tcpFile = open( tsharkTcpOutput, 'r' ) |
| 272 | tempText = tcpFile.readline() |
| 273 | tempText = tempText.split( " " ) |
| 274 | |
| 275 | main.log.info( "Object read in from TCP capture: " + |
| 276 | str( tempText ) ) |
| 277 | if len( tempText ) > 1: |
| 278 | t0Tcp = float( tempText[ 1 ] ) * 1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 279 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 280 | main.log.error( "Tshark output file for TCP" + |
| 281 | " returned unexpected results" ) |
| 282 | t0Tcp = 0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 283 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 284 | |
| 285 | tcpFile.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 286 | #**************** |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 287 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 288 | # OF CAPTURE **** |
| 289 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 290 | tsharkOfOutput + " /tmp/" ) |
| 291 | ofFile = open( tsharkOfOutput, 'r' ) |
| 292 | |
| 293 | lineOfp = "" |
| 294 | # Read until last line of file |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 295 | while True: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 296 | tempText = ofFile.readline() |
| 297 | if tempText != '': |
| 298 | lineOfp = tempText |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 299 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 300 | break |
| 301 | obj = lineOfp.split( " " ) |
| 302 | |
| 303 | main.log.info( "Object read in from OFP capture: " + |
| 304 | str( lineOfp ) ) |
| 305 | |
| 306 | if len( lineOfp ) > 1: |
| 307 | t0Ofp = float( obj[ 1 ] ) * 1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 308 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 309 | main.log.error( "Tshark output file for OFP" + |
| 310 | " returned unexpected results" ) |
| 311 | t0Ofp = 0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 312 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 313 | |
| 314 | ofFile.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 315 | #**************** |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 316 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 317 | jsonStr1 = main.ONOS1cli.topologyEventsMetrics() |
| 318 | # Initialize scale-out variables |
| 319 | jsonStr2 = "" |
| 320 | jsonStr3 = "" |
| 321 | jsonStr4 = "" |
| 322 | jsonStr5 = "" |
| 323 | jsonStr6 = "" |
| 324 | jsonStr7 = "" |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 325 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 326 | jsonObj1 = json.loads( jsonStr1 ) |
| 327 | # Initialize scale-out variables |
| 328 | jsonObj2 = "" |
| 329 | jsonObj3 = "" |
| 330 | jsonObj4 = "" |
| 331 | jsonObj5 = "" |
| 332 | jsonObj6 = "" |
| 333 | jsonObj7 = "" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 334 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 335 | # Obtain graph timestamp. This timestsamp captures |
| 336 | # the epoch time at which the topology graph was updated. |
| 337 | graphTimestamp1 = \ |
| 338 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 339 | # Obtain device timestamp. This timestamp captures |
| 340 | # the epoch time at which the device event happened |
| 341 | deviceTimestamp1 = \ |
| 342 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 343 | |
| 344 | # t0 to device processing latency |
| 345 | deltaDevice1 = int( deviceTimestamp1 ) - int( t0Tcp ) |
| 346 | |
| 347 | # t0 to graph processing latency ( end-to-end ) |
| 348 | deltaGraph1 = int( graphTimestamp1 ) - int( t0Tcp ) |
| 349 | |
| 350 | # ofp to graph processing latency ( ONOS processing ) |
| 351 | deltaOfpGraph1 = int( graphTimestamp1 ) - int( t0Ofp ) |
| 352 | |
| 353 | # ofp to device processing latency ( ONOS processing ) |
| 354 | deltaOfpDevice1 = float( deviceTimestamp1 ) - float( t0Ofp ) |
| 355 | |
| 356 | # TODO: Create even cluster number events |
| 357 | |
| 358 | # Include scale-out measurements when applicable |
| 359 | if clusterCount >= 3: |
| 360 | jsonStr2 = main.ONOS2cli.topologyEventsMetrics() |
| 361 | jsonStr3 = main.ONOS3cli.topologyEventsMetrics() |
| 362 | jsonObj2 = json.loads( jsonStr2 ) |
| 363 | jsonObj3 = json.loads( jsonStr3 ) |
| 364 | graphTimestamp2 = \ |
| 365 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 366 | graphTimestamp3 = \ |
| 367 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 368 | deviceTimestamp2 = \ |
| 369 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 370 | deviceTimestamp3 = \ |
| 371 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 372 | deltaDevice2 = int( deviceTimestamp2 ) - int( t0Tcp ) |
| 373 | deltaDevice3 = int( deviceTimestamp3 ) - int( t0Tcp ) |
| 374 | deltaGraph2 = int( graphTimestamp2 ) - int( t0Tcp ) |
| 375 | deltaGraph3 = int( graphTimestamp3 ) - int( t0Tcp ) |
| 376 | deltaOfpGraph2 = int( graphTimestamp2 ) - int( t0Ofp ) |
| 377 | deltaOfpGraph3 = int( graphTimestamp3 ) - int( t0Ofp ) |
| 378 | deltaOfpDevice2 = float( deviceTimestamp2 ) -\ |
| 379 | float( t0Ofp ) |
| 380 | deltaOfpDevice3 = float( deviceTimestamp3 ) -\ |
| 381 | float( t0Ofp ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 382 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 383 | deltaDevice2 = 0 |
| 384 | deltaDevice3 = 0 |
| 385 | deltaGraph2 = 0 |
| 386 | deltaGraph3 = 0 |
| 387 | deltaOfpGraph2 = 0 |
| 388 | deltaOfpGraph3 = 0 |
| 389 | deltaOfpDevice2 = 0 |
| 390 | deltaOfpDevice3 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 391 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 392 | if clusterCount >= 5: |
| 393 | jsonStr4 = main.ONOS4cli.topologyEventsMetrics() |
| 394 | jsonStr5 = main.ONOS5cli.topologyEventsMetrics() |
| 395 | jsonObj4 = json.loads( jsonStr4 ) |
| 396 | jsonObj5 = json.loads( jsonStr5 ) |
| 397 | graphTimestamp4 = \ |
| 398 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 399 | graphTimestamp5 = \ |
| 400 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 401 | deviceTimestamp4 = \ |
| 402 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 403 | deviceTimestamp5 = \ |
| 404 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 405 | deltaDevice4 = int( deviceTimestamp4 ) - int( t0Tcp ) |
| 406 | deltaDevice5 = int( deviceTimestamp5 ) - int( t0Tcp ) |
| 407 | deltaGraph4 = int( graphTimestamp4 ) - int( t0Tcp ) |
| 408 | deltaGraph5 = int( graphTimestamp5 ) - int( t0Tcp ) |
| 409 | deltaOfpGraph4 = int( graphTimestamp4 ) - int( t0Ofp ) |
| 410 | deltaOfpGraph5 = int( graphTimestamp5 ) - int( t0Ofp ) |
| 411 | deltaOfpDevice4 = float( deviceTimestamp4 ) -\ |
| 412 | float( t0Ofp ) |
| 413 | deltaOfpDevice5 = float( deviceTimestamp5 ) -\ |
| 414 | float( t0Ofp ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 415 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 416 | deltaDevice4 = 0 |
| 417 | deltaDevice5 = 0 |
| 418 | deltaGraph4 = 0 |
| 419 | deltaGraph5 = 0 |
| 420 | deltaOfpGraph4 = 0 |
| 421 | deltaOfpGraph5 = 0 |
| 422 | deltaOfpDevice4 = 0 |
| 423 | deltaOfpDevice5 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 424 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 425 | if clusterCount >= 7: |
| 426 | jsonStr6 = main.ONOS6cli.topologyEventsMetrics() |
| 427 | jsonStr7 = main.ONOS7cli.topologyEventsMetrics() |
| 428 | jsonObj6 = json.loads( jsonStr6 ) |
| 429 | jsonObj7 = json.loads( jsonStr7 ) |
| 430 | graphTimestamp6 = \ |
| 431 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 432 | graphTimestamp7 = \ |
| 433 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 434 | deviceTimestamp6 = \ |
| 435 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 436 | deviceTimestamp7 = \ |
| 437 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 438 | deltaDevice6 = int( deviceTimestamp6 ) - int( t0Tcp ) |
| 439 | deltaDevice7 = int( deviceTimestamp7 ) - int( t0Tcp ) |
| 440 | deltaGraph6 = int( graphTimestamp6 ) - int( t0Tcp ) |
| 441 | deltaGraph7 = int( graphTimestamp7 ) - int( t0Tcp ) |
| 442 | deltaOfpGraph6 = int( graphTimestamp6 ) - int( t0Ofp ) |
| 443 | deltaOfpGraph7 = int( graphTimestamp7 ) - int( t0Ofp ) |
| 444 | deltaOfpDevice6 = float( deviceTimestamp6 ) -\ |
| 445 | float( t0Ofp ) |
| 446 | deltaOfpDevice7 = float( deviceTimestamp7 ) -\ |
| 447 | float( t0Ofp ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 448 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 449 | deltaDevice6 = 0 |
| 450 | deltaDevice7 = 0 |
| 451 | deltaGraph6 = 0 |
| 452 | deltaGraph7 = 0 |
| 453 | deltaOfpGraph6 = 0 |
| 454 | deltaOfpGraph7 = 0 |
| 455 | deltaOfpDevice6 = 0 |
| 456 | deltaOfpDevice7 = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 457 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 458 | # Get average of delta from all instances |
| 459 | avgDeltaDevice = \ |
| 460 | ( int( deltaDevice1 ) + |
| 461 | int( deltaDevice2 ) + |
| 462 | int( deltaDevice3 ) + |
| 463 | int( deltaDevice4 ) + |
| 464 | int( deltaDevice5 ) + |
| 465 | int( deltaDevice6 ) + |
| 466 | int( deltaDevice7 ) ) / clusterCount |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 467 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 468 | # Ensure avg delta meets the threshold before appending |
| 469 | if avgDeltaDevice > 0.0 and avgDeltaDevice < 10000\ |
| 470 | and int( i ) > iterIgnore: |
| 471 | latencyT0ToDeviceList.append( avgDeltaDevice ) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 472 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 473 | main.log.info( |
| 474 | "Results for t0-to-device ignored" + |
| 475 | "due to excess in threshold / warmup iteration." ) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 476 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 477 | # Get average of delta from all instances |
| 478 | # TODO: use max delta graph |
| 479 | #maxDeltaGraph = max( three ) |
| 480 | avgDeltaGraph = \ |
| 481 | ( int( deltaGraph1 ) + |
| 482 | int( deltaGraph2 ) + |
| 483 | int( deltaGraph3 ) + |
| 484 | int( deltaGraph4 ) + |
| 485 | int( deltaGraph5 ) + |
| 486 | int( deltaGraph6 ) + |
| 487 | int( deltaGraph7 ) ) / clusterCount |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 488 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 489 | # Ensure avg delta meets the threshold before appending |
| 490 | if avgDeltaGraph > 0.0 and avgDeltaGraph < 10000\ |
| 491 | and int( i ) > iterIgnore: |
| 492 | latencyEndToEndList.append( avgDeltaGraph ) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 493 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 494 | main.log.info( "Results for end-to-end ignored" + |
| 495 | "due to excess in threshold" ) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 496 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 497 | avgDeltaOfpGraph = \ |
| 498 | ( int( deltaOfpGraph1 ) + |
| 499 | int( deltaOfpGraph2 ) + |
| 500 | int( deltaOfpGraph3 ) + |
| 501 | int( deltaOfpGraph4 ) + |
| 502 | int( deltaOfpGraph5 ) + |
| 503 | int( deltaOfpGraph6 ) + |
| 504 | int( deltaOfpGraph7 ) ) / clusterCount |
| 505 | |
| 506 | if avgDeltaOfpGraph > thresholdMin \ |
| 507 | and avgDeltaOfpGraph < thresholdMax\ |
| 508 | and int( i ) > iterIgnore: |
| 509 | latencyOfpToGraphList.append( avgDeltaOfpGraph ) |
| 510 | elif avgDeltaOfpGraph > ( -10 ) and \ |
| 511 | avgDeltaOfpGraph < 0.0 and\ |
| 512 | int( i ) > iterIgnore: |
| 513 | main.log.info( "Sub-millisecond result likely; " + |
| 514 | "negative result was rounded to 0" ) |
| 515 | # NOTE: Current metrics framework does not |
| 516 | # support sub-millisecond accuracy. Therefore, |
| 517 | # if the result is negative, we can reasonably |
| 518 | # conclude sub-millisecond results and just |
| 519 | # append the best rounded effort - 0 ms. |
| 520 | latencyOfpToGraphList.append( 0 ) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 521 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 522 | main.log.info( "Results for ofp-to-graph " + |
| 523 | "ignored due to excess in threshold" ) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 524 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 525 | avgDeltaOfpDevice = \ |
| 526 | ( float( deltaOfpDevice1 ) + |
| 527 | float( deltaOfpDevice2 ) + |
| 528 | float( deltaOfpDevice3 ) + |
| 529 | float( deltaOfpDevice4 ) + |
| 530 | float( deltaOfpDevice5 ) + |
| 531 | float( deltaOfpDevice6 ) + |
| 532 | float( deltaOfpDevice7 ) ) / clusterCount |
| 533 | |
| 534 | # NOTE: ofp - delta measurements are occasionally negative |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 535 | # due to system time misalignment. |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 536 | latencyOfpToDeviceList.append( avgDeltaOfpDevice ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 537 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 538 | deltaOfpTcp = int( t0Ofp ) - int( t0Tcp ) |
| 539 | if deltaOfpTcp > thresholdMin \ |
| 540 | and deltaOfpTcp < thresholdMax and\ |
| 541 | int( i ) > iterIgnore: |
| 542 | latencyTcpToOfpList.append( deltaOfpTcp ) |
andrewonlab | 65d7389 | 2014-11-10 17:36:00 -0500 | [diff] [blame] | 543 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 544 | main.log.info( "Results fo tcp-to-ofp " + |
| 545 | "ignored due to excess in threshold" ) |
andrewonlab | 65d7389 | 2014-11-10 17:36:00 -0500 | [diff] [blame] | 546 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 547 | # TODO: |
| 548 | # Fetch logs upon threshold excess |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 549 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 550 | main.log.info( "ONOS1 delta end-to-end: " + |
| 551 | str( deltaGraph1 ) + " ms" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 552 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 553 | main.log.info( "ONOS1 delta OFP - graph: " + |
| 554 | str( deltaOfpGraph1 ) + " ms" ) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 555 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 556 | main.log.info( "ONOS1 delta device - t0: " + |
| 557 | str( deltaDevice1 ) + " ms" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 558 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 559 | main.log.info( "TCP to OFP delta: " + |
| 560 | str( deltaOfpTcp ) + " ms" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 561 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 562 | main.step( "Remove switch from controller" ) |
| 563 | main.Mininet1.deleteSwController( "s1" ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 564 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 565 | time.sleep( 5 ) |
| 566 | |
| 567 | # END of for loop iteration |
| 568 | |
| 569 | # If there is at least 1 element in each list, |
| 570 | # pass the test case |
| 571 | if len( latencyEndToEndList ) > 0 and\ |
| 572 | len( latencyOfpToGraphList ) > 0 and\ |
| 573 | len( latencyOfpToDeviceList ) > 0 and\ |
| 574 | len( latencyT0ToDeviceList ) > 0 and\ |
| 575 | len( latencyTcpToOfpList ) > 0: |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 576 | assertion = main.TRUE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 577 | elif len( latencyEndToEndList ) == 0: |
| 578 | # The appending of 0 here is to prevent |
| 579 | # the min,max,sum functions from failing |
| 580 | # below |
| 581 | latencyEndToEndList.append( 0 ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 582 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 583 | elif len( latencyOfpToGraphList ) == 0: |
| 584 | latencyOfpToGraphList.append( 0 ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 585 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 586 | elif len( latencyOfpToDeviceList ) == 0: |
| 587 | latencyOfpToDeviceList.append( 0 ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 588 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 589 | elif len( latencyT0ToDeviceList ) == 0: |
| 590 | latencyT0ToDeviceList.append( 0 ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 591 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 592 | elif len( latencyTcpToOfpList ) == 0: |
| 593 | latencyTcpToOfpList.append( 0 ) |
andrewonlab | 65d7389 | 2014-11-10 17:36:00 -0500 | [diff] [blame] | 594 | assertion = main.FALSE |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 595 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 596 | # Calculate min, max, avg of latency lists |
| 597 | latencyEndToEndMax = \ |
| 598 | int( max( latencyEndToEndList ) ) |
| 599 | latencyEndToEndMin = \ |
| 600 | int( min( latencyEndToEndList ) ) |
| 601 | latencyEndToEndAvg = \ |
| 602 | ( int( sum( latencyEndToEndList ) ) / |
| 603 | len( latencyEndToEndList ) ) |
| 604 | latencyEndToEndStdDev = \ |
| 605 | str( round( numpy.std( latencyEndToEndList ), 1 ) ) |
andrewonlab | 6986416 | 2014-11-11 16:28:48 -0500 | [diff] [blame] | 606 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 607 | latencyOfpToGraphMax = \ |
| 608 | int( max( latencyOfpToGraphList ) ) |
| 609 | latencyOfpToGraphMin = \ |
| 610 | int( min( latencyOfpToGraphList ) ) |
| 611 | latencyOfpToGraphAvg = \ |
| 612 | ( int( sum( latencyOfpToGraphList ) ) / |
| 613 | len( latencyOfpToGraphList ) ) |
| 614 | latencyOfpToGraphStdDev = \ |
| 615 | str( round( numpy.std( latencyOfpToGraphList ), 1 ) ) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 616 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 617 | latencyOfpToDeviceMax = \ |
| 618 | int( max( latencyOfpToDeviceList ) ) |
| 619 | latencyOfpToDeviceMin = \ |
| 620 | int( min( latencyOfpToDeviceList ) ) |
| 621 | latencyOfpToDeviceAvg = \ |
| 622 | ( int( sum( latencyOfpToDeviceList ) ) / |
| 623 | len( latencyOfpToDeviceList ) ) |
| 624 | latencyOfpToDeviceStdDev = \ |
| 625 | str( round( numpy.std( latencyOfpToDeviceList ), 1 ) ) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 626 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 627 | latencyT0ToDeviceMax = \ |
| 628 | int( max( latencyT0ToDeviceList ) ) |
| 629 | latencyT0ToDeviceMin = \ |
| 630 | int( min( latencyT0ToDeviceList ) ) |
| 631 | latencyT0ToDeviceAvg = \ |
| 632 | ( int( sum( latencyT0ToDeviceList ) ) / |
| 633 | len( latencyT0ToDeviceList ) ) |
| 634 | latencyOfpToDeviceStdDev = \ |
| 635 | str( round( numpy.std( latencyT0ToDeviceList ), 1 ) ) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 636 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 637 | latencyTcpToOfpMax = \ |
| 638 | int( max( latencyTcpToOfpList ) ) |
| 639 | latencyTcpToOfpMin = \ |
| 640 | int( min( latencyTcpToOfpList ) ) |
| 641 | latencyTcpToOfpAvg = \ |
| 642 | ( int( sum( latencyTcpToOfpList ) ) / |
| 643 | len( latencyTcpToOfpList ) ) |
| 644 | latencyTcpToOfpStdDev = \ |
| 645 | str( round( numpy.std( latencyTcpToOfpList ), 1 ) ) |
andrewonlab | 65d7389 | 2014-11-10 17:36:00 -0500 | [diff] [blame] | 646 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 647 | main.log.report( "Cluster size: " + str( clusterCount ) + |
| 648 | " node(s)" ) |
| 649 | main.log.report( "Switch add - End-to-end latency: " + |
| 650 | "Avg: " + str( latencyEndToEndAvg ) + " ms " + |
| 651 | "Std Deviation: " + latencyEndToEndStdDev + " ms" ) |
| 652 | main.log.report( |
| 653 | "Switch add - OFP-to-Graph latency: " + |
| 654 | "Note: results are not accurate to sub-millisecond. " + |
| 655 | "Any sub-millisecond results are rounded to 0 ms. " ) |
| 656 | main.log.report( "Avg: " + str( latencyOfpToGraphAvg ) + " ms " + |
| 657 | "Std Deviation: " + latencyOfpToGraphStdDev + " ms" ) |
| 658 | main.log.report( "Switch add - TCP-to-OFP latency: " + |
| 659 | "Avg: " + str( latencyTcpToOfpAvg ) + " ms " + |
| 660 | "Std Deviation: " + latencyTcpToOfpStdDev + " ms" ) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 661 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 662 | if debugMode == 'on': |
| 663 | main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log", |
| 664 | "/tmp/", copyFileName="sw_lat_karaf" ) |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 665 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 666 | utilities.assert_equals( expect=main.TRUE, actual=assertion, |
| 667 | onpass="Switch latency test successful", |
| 668 | onfail="Switch latency test failed" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 669 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 670 | def CASE3( self, main ): |
| 671 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 672 | Bring port up / down and measure latency. |
| 673 | Port enable / disable is simulated by ifconfig up / down |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 674 | |
| 675 | In ONOS-next, we must ensure that the port we are |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 676 | manipulating is connected to another switch with a valid |
| 677 | connection. Otherwise, graph view will not be updated. |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 678 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 679 | import time |
| 680 | import subprocess |
| 681 | import os |
| 682 | import requests |
| 683 | import json |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 684 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 685 | global clusterCount |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 686 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 687 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 688 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 689 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 690 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 691 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 692 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
| 693 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 694 | assertion = main.TRUE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 695 | # Number of iterations of case |
| 696 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 697 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 698 | # Timestamp 'keys' for json metrics output. |
| 699 | # These are subject to change, hence moved into params |
| 700 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 701 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 702 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 703 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 704 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 705 | localTime = time.strftime( '%x %X' ) |
| 706 | localTime = localTime.replace( "/", "" ) |
| 707 | localTime = localTime.replace( " ", "_" ) |
| 708 | localTime = localTime.replace( ":", "" ) |
| 709 | if debugMode == 'on': |
| 710 | main.ONOS1.tsharkPcap( "eth0", |
| 711 | "/tmp/port_lat_pcap_" + localTime ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 712 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 713 | # Threshold for this test case |
| 714 | upThresholdStr = main.params[ 'TEST' ][ 'portUpThreshold' ] |
| 715 | downThresholdStr = main.params[ 'TEST' ][ 'portDownThreshold' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 716 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 717 | upThresholdObj = upThresholdStr.split( "," ) |
| 718 | downThresholdObj = downThresholdStr.split( "," ) |
| 719 | |
| 720 | upThresholdMin = int( upThresholdObj[ 0 ] ) |
| 721 | upThresholdMax = int( upThresholdObj[ 1 ] ) |
| 722 | |
| 723 | downThresholdMin = int( downThresholdObj[ 0 ] ) |
| 724 | downThresholdMax = int( downThresholdObj[ 1 ] ) |
| 725 | |
| 726 | # NOTE: Some hardcoded variables you may need to configure |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 727 | # besides the params |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 728 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 729 | tsharkPortStatus = "OFP 130 Port Status" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 730 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 731 | tsharkPortUp = "/tmp/tshark_port_up.txt" |
| 732 | tsharkPortDown = "/tmp/tshark_port_down.txt" |
| 733 | interfaceConfig = "s1-eth1" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 734 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 735 | main.log.report( "Port enable / disable latency" ) |
| 736 | main.log.report( "Simulated by ifconfig up / down" ) |
| 737 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 738 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 739 | main.step( "Assign switches s1 and s2 to controller 1" ) |
| 740 | main.Mininet1.assignSwController( sw="1", ip1=ONOS1Ip, |
| 741 | port1=defaultSwPort ) |
| 742 | main.Mininet1.assignSwController( sw="2", ip1=ONOS1Ip, |
| 743 | port1=defaultSwPort ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 744 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 745 | # Give enough time for metrics to propagate the |
| 746 | # assign controller event. Otherwise, these events may |
| 747 | # carry over to our measurements |
| 748 | time.sleep( 15 ) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 749 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 750 | portUpDeviceToOfpList = [] |
| 751 | portUpGraphToOfpList = [] |
| 752 | portDownDeviceToOfpList = [] |
| 753 | portDownGraphToOfpList = [] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 754 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 755 | for i in range( 0, int( numIter ) ): |
| 756 | main.step( "Starting wireshark capture for port status down" ) |
| 757 | main.ONOS1.tsharkGrep( tsharkPortStatus, |
| 758 | tsharkPortDown ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 759 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 760 | time.sleep( 5 ) |
| 761 | |
| 762 | # Disable interface that is connected to switch 2 |
| 763 | main.step( "Disable port: " + interfaceConfig ) |
| 764 | main.Mininet1.handle.sendline( "sh ifconfig " + |
| 765 | interfaceConfig + " down" ) |
| 766 | main.Mininet1.handle.expect( "mininet>" ) |
| 767 | |
| 768 | time.sleep( 3 ) |
| 769 | main.ONOS1.tsharkStop() |
| 770 | |
| 771 | # Copy tshark output file from ONOS to TestON instance |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 772 | #/tmp directory |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 773 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 774 | tsharkPortDown + " /tmp/" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 775 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 776 | fPortDown = open( tsharkPortDown, 'r' ) |
| 777 | # Get first line of port down event from tshark |
| 778 | fLine = fPortDown.readline() |
| 779 | objDown = fLine.split( " " ) |
| 780 | if len( fLine ) > 0: |
| 781 | # NOTE: objDown[ 1 ] is a very unreliable |
| 782 | # way to determine the timestamp. If |
| 783 | # results seem way off, check the object |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 784 | # itself by printing it out |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 785 | timestampBeginPtDown = int( float( objDown[ 1 ] ) * 1000 ) |
| 786 | # For some reason, wireshark decides to record the |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 787 | # timestamp at the 3rd object position instead of |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 788 | # 2nd at unpredictable times. This statement is |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 789 | # used to capture that odd behavior and use the |
| 790 | # correct epoch time |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 791 | if timestampBeginPtDown < 1400000000000: |
| 792 | timestampBeginPtDown = \ |
| 793 | int( float( objDown[ 2 ] ) * 1000 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 794 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 795 | main.log.info( "Port down begin timestamp: " + |
| 796 | str( timestampBeginPtDown ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 797 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 798 | main.log.info( "Tshark output file returned unexpected" + |
| 799 | " results: " + str( objDown ) ) |
| 800 | timestampBeginPtDown = 0 |
| 801 | fPortDown.close() |
| 802 | |
| 803 | main.step( "Obtain t1 by metrics call" ) |
| 804 | jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics() |
| 805 | jsonObj1 = json.loads( jsonStrUp1 ) |
| 806 | # Obtain graph timestamp. This timestsamp captures |
| 807 | # the epoch time at which the topology graph was updated. |
| 808 | graphTimestamp1 = \ |
| 809 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 810 | # Obtain device timestamp. This timestamp captures |
| 811 | # the epoch time at which the device event happened |
| 812 | deviceTimestamp1 = \ |
| 813 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 814 | # Get delta between graph event and OFP |
| 815 | ptDownGraphToOfp1 = int( graphTimestamp1 ) -\ |
| 816 | int( timestampBeginPtDown ) |
| 817 | # Get delta between device event and OFP |
| 818 | ptDownDeviceToOfp1 = int( deviceTimestamp1 ) -\ |
| 819 | int( timestampBeginPtDown ) |
| 820 | |
| 821 | if clusterCount >= 3: |
| 822 | jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics() |
| 823 | jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics() |
| 824 | jsonObj2 = json.loads( jsonStrUp2 ) |
| 825 | jsonObj3 = json.loads( jsonStrUp3 ) |
| 826 | graphTimestamp2 = \ |
| 827 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 828 | graphTimestamp3 = \ |
| 829 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 830 | deviceTimestamp2 = \ |
| 831 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 832 | deviceTimestamp3 = \ |
| 833 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 834 | ptDownGraphToOfp2 = int( graphTimestamp2 ) -\ |
| 835 | int( timestampBeginPtDown ) |
| 836 | ptDownGraphToOfp3 = int( graphTimestamp3 ) -\ |
| 837 | int( timestampBeginPtDown ) |
| 838 | ptDownDeviceToOfp2 = int( deviceTimestamp2 ) -\ |
| 839 | int( timestampBeginPtDown ) |
| 840 | ptDownDeviceToOfp3 = int( deviceTimestamp3 ) -\ |
| 841 | int( timestampBeginPtDown ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 842 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 843 | ptDownGraphToOfp2 = 0 |
| 844 | ptDownGraphToOfp3 = 0 |
| 845 | ptDownDeviceToOfp2 = 0 |
| 846 | ptDownDeviceToOfp3 = 0 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 847 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 848 | if clusterCount >= 5: |
| 849 | jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics() |
| 850 | jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics() |
| 851 | jsonObj4 = json.loads( jsonStrUp4 ) |
| 852 | jsonObj5 = json.loads( jsonStrUp5 ) |
| 853 | graphTimestamp4 = \ |
| 854 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 855 | graphTimestamp5 = \ |
| 856 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 857 | deviceTimestamp4 = \ |
| 858 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 859 | deviceTimestamp5 = \ |
| 860 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 861 | ptDownGraphToOfp4 = int( graphTimestamp4 ) -\ |
| 862 | int( timestampBeginPtDown ) |
| 863 | ptDownGraphToOfp5 = int( graphTimestamp5 ) -\ |
| 864 | int( timestampBeginPtDown ) |
| 865 | ptDownDeviceToOfp4 = int( deviceTimestamp4 ) -\ |
| 866 | int( timestampBeginPtDown ) |
| 867 | ptDownDeviceToOfp5 = int( deviceTimestamp5 ) -\ |
| 868 | int( timestampBeginPtDown ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 869 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 870 | ptDownGraphToOfp4 = 0 |
| 871 | ptDownGraphToOfp5 = 0 |
| 872 | ptDownDeviceToOfp4 = 0 |
| 873 | ptDownDeviceToOfp5 = 0 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 874 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 875 | if clusterCount >= 7: |
| 876 | jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics() |
| 877 | jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics() |
| 878 | jsonObj6 = json.loads( jsonStrUp6 ) |
| 879 | jsonObj7 = json.loads( jsonStrUp7 ) |
| 880 | graphTimestamp6 = \ |
| 881 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 882 | graphTimestamp7 = \ |
| 883 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 884 | deviceTimestamp6 = \ |
| 885 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 886 | deviceTimestamp7 = \ |
| 887 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 888 | ptDownGraphToOfp6 = int( graphTimestamp6 ) -\ |
| 889 | int( timestampBeginPtDown ) |
| 890 | ptDownGraphToOfp7 = int( graphTimestamp7 ) -\ |
| 891 | int( timestampBeginPtDown ) |
| 892 | ptDownDeviceToOfp6 = int( deviceTimestamp6 ) -\ |
| 893 | int( timestampBeginPtDown ) |
| 894 | ptDownDeviceToOfp7 = int( deviceTimestamp7 ) -\ |
| 895 | int( timestampBeginPtDown ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 896 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 897 | ptDownGraphToOfp6 = 0 |
| 898 | ptDownGraphToOfp7 = 0 |
| 899 | ptDownDeviceToOfp6 = 0 |
| 900 | ptDownDeviceToOfp7 = 0 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 901 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 902 | time.sleep( 3 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 903 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 904 | # Caluclate average across clusters |
| 905 | ptDownGraphToOfpAvg =\ |
| 906 | ( int( ptDownGraphToOfp1 ) + |
| 907 | int( ptDownGraphToOfp2 ) + |
| 908 | int( ptDownGraphToOfp3 ) + |
| 909 | int( ptDownGraphToOfp4 ) + |
| 910 | int( ptDownGraphToOfp5 ) + |
| 911 | int( ptDownGraphToOfp6 ) + |
| 912 | int( ptDownGraphToOfp7 ) ) / clusterCount |
| 913 | ptDownDeviceToOfpAvg = \ |
| 914 | ( int( ptDownDeviceToOfp1 ) + |
| 915 | int( ptDownDeviceToOfp2 ) + |
| 916 | int( ptDownDeviceToOfp3 ) + |
| 917 | int( ptDownDeviceToOfp4 ) + |
| 918 | int( ptDownDeviceToOfp5 ) + |
| 919 | int( ptDownDeviceToOfp6 ) + |
| 920 | int( ptDownDeviceToOfp7 ) ) / clusterCount |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 921 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 922 | if ptDownGraphToOfpAvg > downThresholdMin and \ |
| 923 | ptDownGraphToOfpAvg < downThresholdMax: |
| 924 | portDownGraphToOfpList.append( |
| 925 | ptDownGraphToOfpAvg ) |
| 926 | main.log.info( "Port down: graph to ofp avg: " + |
| 927 | str( ptDownGraphToOfpAvg ) + " ms" ) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 928 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 929 | main.log.info( "Average port down graph-to-ofp result" + |
| 930 | " exceeded the threshold: " + |
| 931 | str( ptDownGraphToOfpAvg ) ) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 932 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 933 | if ptDownDeviceToOfpAvg > 0 and \ |
| 934 | ptDownDeviceToOfpAvg < 1000: |
| 935 | portDownDeviceToOfpList.append( |
| 936 | ptDownDeviceToOfpAvg ) |
| 937 | main.log.info( "Port down: device to ofp avg: " + |
| 938 | str( ptDownDeviceToOfpAvg ) + " ms" ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 939 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 940 | main.log.info( "Average port down device-to-ofp result" + |
| 941 | " exceeded the threshold: " + |
| 942 | str( ptDownDeviceToOfpAvg ) ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 943 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 944 | # Port up events |
| 945 | main.step( "Enable port and obtain timestamp" ) |
| 946 | main.step( "Starting wireshark capture for port status up" ) |
| 947 | main.ONOS1.tsharkGrep( tsharkPortStatus, tsharkPortUp ) |
| 948 | time.sleep( 5 ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 949 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 950 | main.Mininet1.handle.sendline( "sh ifconfig " + |
| 951 | interfaceConfig + " up" ) |
| 952 | main.Mininet1.handle.expect( "mininet>" ) |
| 953 | |
| 954 | # Allow time for tshark to capture event |
| 955 | time.sleep( 5 ) |
| 956 | main.ONOS1.tsharkStop() |
| 957 | |
| 958 | time.sleep( 3 ) |
| 959 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 960 | tsharkPortUp + " /tmp/" ) |
| 961 | fPortUp = open( tsharkPortUp, 'r' ) |
| 962 | fLine = fPortUp.readline() |
| 963 | objUp = fLine.split( " " ) |
| 964 | if len( fLine ) > 0: |
| 965 | timestampBeginPtUp = int( float( objUp[ 1 ] ) * 1000 ) |
| 966 | if timestampBeginPtUp < 1400000000000: |
| 967 | timestampBeginPtUp = \ |
| 968 | int( float( objUp[ 2 ] ) * 1000 ) |
| 969 | main.log.info( "Port up begin timestamp: " + |
| 970 | str( timestampBeginPtUp ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 971 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 972 | main.log.info( "Tshark output file returned unexpected" + |
| 973 | " results." ) |
| 974 | timestampBeginPtUp = 0 |
| 975 | fPortUp.close() |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 976 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 977 | # Obtain metrics shortly afterwards |
| 978 | # This timestsamp captures |
| 979 | # the epoch time at which the topology graph was updated. |
| 980 | main.step( "Obtain t1 by REST call" ) |
| 981 | jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics() |
| 982 | jsonObj1 = json.loads( jsonStrUp1 ) |
| 983 | graphTimestamp1 = \ |
| 984 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 985 | # Obtain device timestamp. This timestamp captures |
| 986 | # the epoch time at which the device event happened |
| 987 | deviceTimestamp1 = \ |
| 988 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 989 | # Get delta between graph event and OFP |
| 990 | ptUpGraphToOfp1 = int( graphTimestamp1 ) -\ |
| 991 | int( timestampBeginPtUp ) |
| 992 | # Get delta between device event and OFP |
| 993 | ptUpDeviceToOfp1 = int( deviceTimestamp1 ) -\ |
| 994 | int( timestampBeginPtUp ) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 995 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 996 | if clusterCount >= 3: |
| 997 | jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics() |
| 998 | jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics() |
| 999 | jsonObj2 = json.loads( jsonStrUp2 ) |
| 1000 | jsonObj3 = json.loads( jsonStrUp3 ) |
| 1001 | graphTimestamp2 = \ |
| 1002 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 1003 | graphTimestamp3 = \ |
| 1004 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 1005 | deviceTimestamp2 = \ |
| 1006 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 1007 | deviceTimestamp3 = \ |
| 1008 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 1009 | ptUpGraphToOfp2 = int( graphTimestamp2 ) -\ |
| 1010 | int( timestampBeginPtUp ) |
| 1011 | ptUpGraphToOfp3 = int( graphTimestamp3 ) -\ |
| 1012 | int( timestampBeginPtUp ) |
| 1013 | ptUpDeviceToOfp2 = int( deviceTimestamp2 ) -\ |
| 1014 | int( timestampBeginPtUp ) |
| 1015 | ptUpDeviceToOfp3 = int( deviceTimestamp3 ) -\ |
| 1016 | int( timestampBeginPtUp ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1017 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1018 | ptUpGraphToOfp2 = 0 |
| 1019 | ptUpGraphToOfp3 = 0 |
| 1020 | ptUpDeviceToOfp2 = 0 |
| 1021 | ptUpDeviceToOfp3 = 0 |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 1022 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1023 | if clusterCount >= 5: |
| 1024 | jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics() |
| 1025 | jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics() |
| 1026 | jsonObj4 = json.loads( jsonStrUp4 ) |
| 1027 | jsonObj5 = json.loads( jsonStrUp5 ) |
| 1028 | graphTimestamp4 = \ |
| 1029 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 1030 | graphTimestamp5 = \ |
| 1031 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 1032 | deviceTimestamp4 = \ |
| 1033 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 1034 | deviceTimestamp5 = \ |
| 1035 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 1036 | ptUpGraphToOfp4 = int( graphTimestamp4 ) -\ |
| 1037 | int( timestampBeginPtUp ) |
| 1038 | ptUpGraphToOfp5 = int( graphTimestamp5 ) -\ |
| 1039 | int( timestampBeginPtUp ) |
| 1040 | ptUpDeviceToOfp4 = int( deviceTimestamp4 ) -\ |
| 1041 | int( timestampBeginPtUp ) |
| 1042 | ptUpDeviceToOfp5 = int( deviceTimestamp5 ) -\ |
| 1043 | int( timestampBeginPtUp ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1044 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1045 | ptUpGraphToOfp4 = 0 |
| 1046 | ptUpGraphToOfp5 = 0 |
| 1047 | ptUpDeviceToOfp4 = 0 |
| 1048 | ptUpDeviceToOfp5 = 0 |
| 1049 | |
| 1050 | if clusterCount >= 7: |
| 1051 | jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics() |
| 1052 | jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics() |
| 1053 | jsonObj6 = json.loads( jsonStrUp6 ) |
| 1054 | jsonObj7 = json.loads( jsonStrUp7 ) |
| 1055 | graphTimestamp6 = \ |
| 1056 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 1057 | graphTimestamp7 = \ |
| 1058 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 1059 | deviceTimestamp6 = \ |
| 1060 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 1061 | deviceTimestamp7 = \ |
| 1062 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 1063 | ptUpGraphToOfp6 = int( graphTimestamp6 ) -\ |
| 1064 | int( timestampBeginPtUp ) |
| 1065 | ptUpGraphToOfp7 = int( graphTimestamp7 ) -\ |
| 1066 | int( timestampBeginPtUp ) |
| 1067 | ptUpDeviceToOfp6 = int( deviceTimestamp6 ) -\ |
| 1068 | int( timestampBeginPtUp ) |
| 1069 | ptUpDeviceToOfp7 = int( deviceTimestamp7 ) -\ |
| 1070 | int( timestampBeginPtUp ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1071 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1072 | ptUpGraphToOfp6 = 0 |
| 1073 | ptUpGraphToOfp7 = 0 |
| 1074 | ptUpDeviceToOfp6 = 0 |
| 1075 | ptUpDeviceToOfp7 = 0 |
| 1076 | |
| 1077 | ptUpGraphToOfpAvg = \ |
| 1078 | ( int( ptUpGraphToOfp1 ) + |
| 1079 | int( ptUpGraphToOfp2 ) + |
| 1080 | int( ptUpGraphToOfp3 ) + |
| 1081 | int( ptUpGraphToOfp4 ) + |
| 1082 | int( ptUpGraphToOfp5 ) + |
| 1083 | int( ptUpGraphToOfp6 ) + |
| 1084 | int( ptUpGraphToOfp7 ) ) / clusterCount |
| 1085 | |
| 1086 | ptUpDeviceToOfpAvg = \ |
| 1087 | ( int( ptUpDeviceToOfp1 ) + |
| 1088 | int( ptUpDeviceToOfp2 ) + |
| 1089 | int( ptUpDeviceToOfp3 ) + |
| 1090 | int( ptUpDeviceToOfp4 ) + |
| 1091 | int( ptUpDeviceToOfp5 ) + |
| 1092 | int( ptUpDeviceToOfp6 ) + |
| 1093 | int( ptUpDeviceToOfp7 ) ) / clusterCount |
| 1094 | |
| 1095 | if ptUpGraphToOfpAvg > upThresholdMin and \ |
| 1096 | ptUpGraphToOfpAvg < upThresholdMax: |
| 1097 | portUpGraphToOfpList.append( |
| 1098 | ptUpGraphToOfpAvg ) |
| 1099 | main.log.info( "Port down: graph to ofp avg: " + |
| 1100 | str( ptUpGraphToOfpAvg ) + " ms" ) |
| 1101 | else: |
| 1102 | main.log.info( "Average port up graph-to-ofp result" + |
| 1103 | " exceeded the threshold: " + |
| 1104 | str( ptUpGraphToOfpAvg ) ) |
| 1105 | |
| 1106 | if ptUpDeviceToOfpAvg > upThresholdMin and \ |
| 1107 | ptUpDeviceToOfpAvg < upThresholdMax: |
| 1108 | portUpDeviceToOfpList.append( |
| 1109 | ptUpDeviceToOfpAvg ) |
| 1110 | main.log.info( "Port up: device to ofp avg: " + |
| 1111 | str( ptUpDeviceToOfpAvg ) + " ms" ) |
| 1112 | else: |
| 1113 | main.log.info( "Average port up device-to-ofp result" + |
| 1114 | " exceeded the threshold: " + |
| 1115 | str( ptUpDeviceToOfpAvg ) ) |
| 1116 | |
| 1117 | # END ITERATION FOR LOOP |
| 1118 | |
| 1119 | # Check all list for latency existence and set assertion |
| 1120 | if ( portDownGraphToOfpList and portDownDeviceToOfpList |
| 1121 | and portUpGraphToOfpList and portUpDeviceToOfpList ): |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1122 | assertion = main.TRUE |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1123 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1124 | main.log.report( "Cluster size: " + str( clusterCount ) + |
| 1125 | " node(s)" ) |
| 1126 | # Calculate and report latency measurements |
| 1127 | portDownGraphToOfpMin = min( portDownGraphToOfpList ) |
| 1128 | portDownGraphToOfpMax = max( portDownGraphToOfpList ) |
| 1129 | portDownGraphToOfpAvg = \ |
| 1130 | ( sum( portDownGraphToOfpList ) / |
| 1131 | len( portDownGraphToOfpList ) ) |
| 1132 | portDownGraphToOfpStdDev = \ |
| 1133 | str( round( numpy.std( portDownGraphToOfpList ), 1 ) ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1134 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1135 | main.log.report( "Port down graph-to-ofp " + |
| 1136 | "Avg: " + str( portDownGraphToOfpAvg ) + " ms " + |
| 1137 | "Std Deviation: " + portDownGraphToOfpStdDev + " ms" ) |
| 1138 | |
| 1139 | portDownDeviceToOfpMin = min( portDownDeviceToOfpList ) |
| 1140 | portDownDeviceToOfpMax = max( portDownDeviceToOfpList ) |
| 1141 | portDownDeviceToOfpAvg = \ |
| 1142 | ( sum( portDownDeviceToOfpList ) / |
| 1143 | len( portDownDeviceToOfpList ) ) |
| 1144 | portDownDeviceToOfpStdDev = \ |
| 1145 | str( round( numpy.std( portDownDeviceToOfpList ), 1 ) ) |
| 1146 | |
| 1147 | main.log.report( |
| 1148 | "Port down device-to-ofp " + |
| 1149 | "Avg: " + |
| 1150 | str( portDownDeviceToOfpAvg ) + |
| 1151 | " ms " + |
| 1152 | "Std Deviation: " + |
| 1153 | portDownDeviceToOfpStdDev + |
| 1154 | " ms" ) |
| 1155 | |
| 1156 | portUpGraphToOfpMin = min( portUpGraphToOfpList ) |
| 1157 | portUpGraphToOfpMax = max( portUpGraphToOfpList ) |
| 1158 | portUpGraphToOfpAvg = \ |
| 1159 | ( sum( portUpGraphToOfpList ) / |
| 1160 | len( portUpGraphToOfpList ) ) |
| 1161 | portUpGraphToOfpStdDev = \ |
| 1162 | str( round( numpy.std( portUpGraphToOfpList ), 1 ) ) |
| 1163 | |
| 1164 | main.log.report( "Port up graph-to-ofp " + |
| 1165 | "Avg: " + str( portUpGraphToOfpAvg ) + " ms " + |
| 1166 | "Std Deviation: " + portUpGraphToOfpStdDev + " ms" ) |
| 1167 | |
| 1168 | portUpDeviceToOfpMin = min( portUpDeviceToOfpList ) |
| 1169 | portUpDeviceToOfpMax = max( portUpDeviceToOfpList ) |
| 1170 | portUpDeviceToOfpAvg = \ |
| 1171 | ( sum( portUpDeviceToOfpList ) / |
| 1172 | len( portUpDeviceToOfpList ) ) |
| 1173 | portUpDeviceToOfpStdDev = \ |
| 1174 | str( round( numpy.std( portUpDeviceToOfpList ), 1 ) ) |
| 1175 | |
| 1176 | main.log.report( "Port up device-to-ofp " + |
| 1177 | "Avg: " + str( portUpDeviceToOfpAvg ) + " ms " + |
| 1178 | "Std Deviation: " + portUpDeviceToOfpStdDev + " ms" ) |
| 1179 | |
| 1180 | # Remove switches from controller for next test |
| 1181 | main.Mininet1.deleteSwController( "s1" ) |
| 1182 | main.Mininet1.deleteSwController( "s2" ) |
| 1183 | |
| 1184 | utilities.assert_equals( |
| 1185 | expect=main.TRUE, |
| 1186 | actual=assertion, |
| 1187 | onpass="Port discovery latency calculation successful", |
| 1188 | onfail="Port discovery test failed" ) |
| 1189 | |
| 1190 | def CASE4( self, main ): |
| 1191 | """ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1192 | Link down event using loss rate 100% |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1193 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1194 | Important: |
| 1195 | Use a simple 2 switch topology with 1 link between |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1196 | the two switches. Ensure that mac addresses of the |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1197 | switches are 1 / 2 respectively |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1198 | """ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1199 | import time |
| 1200 | import subprocess |
| 1201 | import os |
| 1202 | import requests |
| 1203 | import json |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1204 | import numpy |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1205 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1206 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1207 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1208 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1209 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1210 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1211 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1212 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1213 | # Number of iterations of case |
| 1214 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1215 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1216 | # Timestamp 'keys' for json metrics output. |
| 1217 | # These are subject to change, hence moved into params |
| 1218 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 1219 | linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ] |
| 1220 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1221 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1222 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1223 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1224 | localTime = time.strftime( '%x %X' ) |
| 1225 | localTime = localTime.replace( "/", "" ) |
| 1226 | localTime = localTime.replace( " ", "_" ) |
| 1227 | localTime = localTime.replace( ":", "" ) |
| 1228 | if debugMode == 'on': |
| 1229 | main.ONOS1.tsharkPcap( "eth0", |
| 1230 | "/tmp/link_lat_pcap_" + localTime ) |
| 1231 | |
| 1232 | # Threshold for this test case |
| 1233 | upThresholdStr = main.params[ 'TEST' ][ 'linkUpThreshold' ] |
| 1234 | downThresholdStr = main.params[ 'TEST' ][ 'linkDownThreshold' ] |
| 1235 | |
| 1236 | upThresholdObj = upThresholdStr.split( "," ) |
| 1237 | downThresholdObj = downThresholdStr.split( "," ) |
| 1238 | |
| 1239 | upThresholdMin = int( upThresholdObj[ 0 ] ) |
| 1240 | upThresholdMax = int( upThresholdObj[ 1 ] ) |
| 1241 | |
| 1242 | downThresholdMin = int( downThresholdObj[ 0 ] ) |
| 1243 | downThresholdMax = int( downThresholdObj[ 1 ] ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1244 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1245 | assertion = main.TRUE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1246 | # Link event timestamp to system time list |
| 1247 | linkDownLinkToSystemList = [] |
| 1248 | linkUpLinkToSystemList = [] |
| 1249 | # Graph event timestamp to system time list |
| 1250 | linkDownGraphToSystemList = [] |
| 1251 | linkUpGraphToSystemList = [] |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1252 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1253 | main.log.report( "Link up / down discovery latency between " + |
| 1254 | "two switches" ) |
| 1255 | main.log.report( "Simulated by setting loss-rate 100%" ) |
| 1256 | main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" ) |
| 1257 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1258 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1259 | main.step( "Assign all switches" ) |
| 1260 | main.Mininet1.assignSwController( sw="1", |
| 1261 | ip1=ONOS1Ip, port1=defaultSwPort ) |
| 1262 | main.Mininet1.assignSwController( sw="2", |
| 1263 | ip1=ONOS1Ip, port1=defaultSwPort ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1264 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1265 | main.step( "Verifying switch assignment" ) |
| 1266 | resultS1 = main.Mininet1.getSwController( sw="s1" ) |
| 1267 | resultS2 = main.Mininet1.getSwController( sw="s2" ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1268 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1269 | # Allow time for events to finish before taking measurements |
| 1270 | time.sleep( 10 ) |
| 1271 | |
| 1272 | linkDown1 = False |
| 1273 | linkDown2 = False |
| 1274 | linkDown3 = False |
| 1275 | # Start iteration of link event test |
| 1276 | for i in range( 0, int( numIter ) ): |
| 1277 | main.step( "Getting initial system time as t0" ) |
| 1278 | |
| 1279 | # System time in epoch ms |
| 1280 | timestampLinkDownT0 = time.time() * 1000 |
| 1281 | # Link down is simulated by 100% loss rate using traffic |
| 1282 | # control command |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1283 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1284 | "sh tc qdisc add dev s1-eth1 root netem loss 100%" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1285 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1286 | # TODO: Iterate through 'links' command to verify that |
| 1287 | # link s1 -> s2 went down ( loop timeout 30 seconds ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1288 | # on all 3 ONOS instances |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1289 | main.log.info( "Checking ONOS for link update" ) |
| 1290 | loopCount = 0 |
| 1291 | while( not ( linkDown1 and linkDown2 and linkDown3 ) |
| 1292 | and loopCount < 30 ): |
| 1293 | jsonStr1 = main.ONOS1cli.links() |
| 1294 | jsonStr2 = main.ONOS2cli.links() |
| 1295 | jsonStr3 = main.ONOS3cli.links() |
| 1296 | |
| 1297 | if not ( jsonStr1 and jsonStr2 and jsonStr3 ): |
| 1298 | main.log.error( "CLI command returned error " ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1299 | break |
| 1300 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1301 | jsonObj1 = json.loads( jsonStr1 ) |
| 1302 | jsonObj2 = json.loads( jsonStr2 ) |
| 1303 | jsonObj3 = json.loads( jsonStr3 ) |
| 1304 | for obj1 in jsonObj1: |
| 1305 | if '01' not in obj1[ 'src' ][ 'device' ]: |
| 1306 | linkDown1 = True |
| 1307 | main.log.info( "Link down from " + |
| 1308 | "s1 -> s2 on ONOS1 detected" ) |
| 1309 | for obj2 in jsonObj2: |
| 1310 | if '01' not in obj2[ 'src' ][ 'device' ]: |
| 1311 | linkDown2 = True |
| 1312 | main.log.info( "Link down from " + |
| 1313 | "s1 -> s2 on ONOS2 detected" ) |
| 1314 | for obj3 in jsonObj3: |
| 1315 | if '01' not in obj3[ 'src' ][ 'device' ]: |
| 1316 | linkDown3 = True |
| 1317 | main.log.info( "Link down from " + |
| 1318 | "s1 -> s2 on ONOS3 detected" ) |
| 1319 | |
| 1320 | loopCount += 1 |
| 1321 | # If CLI doesn't like the continuous requests |
| 1322 | # and exits in this loop, increase the sleep here. |
| 1323 | # Consequently, while loop timeout will increase |
| 1324 | time.sleep( 1 ) |
| 1325 | |
| 1326 | # Give time for metrics measurement to catch up |
| 1327 | # NOTE: May need to be configured more accurately |
| 1328 | time.sleep( 10 ) |
| 1329 | # If we exited the while loop and link down 1,2,3 are still |
| 1330 | # false, then ONOS has failed to discover link down event |
| 1331 | if not ( linkDown1 and linkDown2 and linkDown3 ): |
| 1332 | main.log.info( "Link down discovery failed" ) |
| 1333 | |
| 1334 | linkDownLatGraph1 = 0 |
| 1335 | linkDownLatGraph2 = 0 |
| 1336 | linkDownLatGraph3 = 0 |
| 1337 | linkDownLatDevice1 = 0 |
| 1338 | linkDownLatDevice2 = 0 |
| 1339 | linkDownLatDevice3 = 0 |
| 1340 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1341 | assertion = main.FALSE |
| 1342 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1343 | jsonTopoMetrics1 =\ |
| 1344 | main.ONOS1cli.topologyEventsMetrics() |
| 1345 | jsonTopoMetrics2 =\ |
| 1346 | main.ONOS2cli.topologyEventsMetrics() |
| 1347 | jsonTopoMetrics3 =\ |
| 1348 | main.ONOS3cli.topologyEventsMetrics() |
| 1349 | jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 ) |
| 1350 | jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 ) |
| 1351 | jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1352 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1353 | main.log.info( "Obtaining graph and device timestamp" ) |
| 1354 | graphTimestamp1 = \ |
| 1355 | jsonTopoMetrics1[ graphTimestamp ][ 'value' ] |
| 1356 | graphTimestamp2 = \ |
| 1357 | jsonTopoMetrics2[ graphTimestamp ][ 'value' ] |
| 1358 | graphTimestamp3 = \ |
| 1359 | jsonTopoMetrics3[ graphTimestamp ][ 'value' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1360 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1361 | linkTimestamp1 = \ |
| 1362 | jsonTopoMetrics1[ linkTimestamp ][ 'value' ] |
| 1363 | linkTimestamp2 = \ |
| 1364 | jsonTopoMetrics2[ linkTimestamp ][ 'value' ] |
| 1365 | linkTimestamp3 = \ |
| 1366 | jsonTopoMetrics3[ linkTimestamp ][ 'value' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1367 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1368 | if graphTimestamp1 and graphTimestamp2 and\ |
| 1369 | graphTimestamp3 and linkTimestamp1 and\ |
| 1370 | linkTimestamp2 and linkTimestamp3: |
| 1371 | linkDownLatGraph1 = int( graphTimestamp1 ) -\ |
| 1372 | int( timestampLinkDownT0 ) |
| 1373 | linkDownLatGraph2 = int( graphTimestamp2 ) -\ |
| 1374 | int( timestampLinkDownT0 ) |
| 1375 | linkDownLatGraph3 = int( graphTimestamp3 ) -\ |
| 1376 | int( timestampLinkDownT0 ) |
| 1377 | |
| 1378 | linkDownLatLink1 = int( linkTimestamp1 ) -\ |
| 1379 | int( timestampLinkDownT0 ) |
| 1380 | linkDownLatLink2 = int( linkTimestamp2 ) -\ |
| 1381 | int( timestampLinkDownT0 ) |
| 1382 | linkDownLatLink3 = int( linkTimestamp3 ) -\ |
| 1383 | int( timestampLinkDownT0 ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1384 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1385 | main.log.error( "There was an error calculating" + |
| 1386 | " the delta for link down event" ) |
| 1387 | linkDownLatGraph1 = 0 |
| 1388 | linkDownLatGraph2 = 0 |
| 1389 | linkDownLatGraph3 = 0 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1390 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1391 | linkDownLatDevice1 = 0 |
| 1392 | linkDownLatDevice2 = 0 |
| 1393 | linkDownLatDevice3 = 0 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1394 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1395 | main.log.info( "Link down latency ONOS1 iteration " + |
| 1396 | str( i ) + " (end-to-end): " + |
| 1397 | str( linkDownLatGraph1 ) + " ms" ) |
| 1398 | main.log.info( "Link down latency ONOS2 iteration " + |
| 1399 | str( i ) + " (end-to-end): " + |
| 1400 | str( linkDownLatGraph2 ) + " ms" ) |
| 1401 | main.log.info( "Link down latency ONOS3 iteration " + |
| 1402 | str( i ) + " (end-to-end): " + |
| 1403 | str( linkDownLatGraph3 ) + " ms" ) |
| 1404 | |
| 1405 | main.log.info( "Link down latency ONOS1 iteration " + |
| 1406 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1407 | str( linkDownLatLink1 ) + " ms" ) |
| 1408 | main.log.info( "Link down latency ONOS2 iteration " + |
| 1409 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1410 | str( linkDownLatLink2 ) + " ms" ) |
| 1411 | main.log.info( "Link down latency ONOS3 iteration " + |
| 1412 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1413 | str( linkDownLatLink3 ) ) |
| 1414 | |
| 1415 | # Calculate avg of node calculations |
| 1416 | linkDownLatGraphAvg =\ |
| 1417 | ( linkDownLatGraph1 + |
| 1418 | linkDownLatGraph2 + |
| 1419 | linkDownLatGraph3 ) / 3 |
| 1420 | linkDownLatLinkAvg =\ |
| 1421 | ( linkDownLatLink1 + |
| 1422 | linkDownLatLink2 + |
| 1423 | linkDownLatLink3 ) / 3 |
| 1424 | |
| 1425 | # Set threshold and append latency to list |
| 1426 | if linkDownLatGraphAvg > downThresholdMin and\ |
| 1427 | linkDownLatGraphAvg < downThresholdMax: |
| 1428 | linkDownGraphToSystemList.append( |
| 1429 | linkDownLatGraphAvg ) |
| 1430 | else: |
| 1431 | main.log.info( "Link down latency exceeded threshold" ) |
| 1432 | main.log.info( "Results for iteration " + str( i ) + |
| 1433 | "have been omitted" ) |
| 1434 | if linkDownLatLinkAvg > downThresholdMin and\ |
| 1435 | linkDownLatLinkAvg < downThresholdMax: |
| 1436 | linkDownLinkToSystemList.append( |
| 1437 | linkDownLatLinkAvg ) |
| 1438 | else: |
| 1439 | main.log.info( "Link down latency exceeded threshold" ) |
| 1440 | main.log.info( "Results for iteration " + str( i ) + |
| 1441 | "have been omitted" ) |
| 1442 | |
| 1443 | # NOTE: To remove loss rate and measure latency: |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1444 | # 'sh tc qdisc del dev s1-eth1 root' |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1445 | timestampLinkUpT0 = time.time() * 1000 |
| 1446 | main.Mininet1.handle.sendline( "sh tc qdisc del dev " + |
| 1447 | "s1-eth1 root" ) |
| 1448 | main.Mininet1.handle.expect( "mininet>" ) |
| 1449 | |
| 1450 | main.log.info( "Checking ONOS for link update" ) |
| 1451 | |
| 1452 | linkDown1 = True |
| 1453 | linkDown2 = True |
| 1454 | linkDown3 = True |
| 1455 | loopCount = 0 |
| 1456 | while( ( linkDown1 and linkDown2 and linkDown3 ) |
| 1457 | and loopCount < 30 ): |
| 1458 | jsonStr1 = main.ONOS1cli.links() |
| 1459 | jsonStr2 = main.ONOS2cli.links() |
| 1460 | jsonStr3 = main.ONOS3cli.links() |
| 1461 | if not ( jsonStr1 and jsonStr2 and jsonStr3 ): |
| 1462 | main.log.error( "CLI command returned error " ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1463 | break |
| 1464 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1465 | jsonObj1 = json.loads( jsonStr1 ) |
| 1466 | jsonObj2 = json.loads( jsonStr2 ) |
| 1467 | jsonObj3 = json.loads( jsonStr3 ) |
| 1468 | |
| 1469 | for obj1 in jsonObj1: |
| 1470 | if '01' in obj1[ 'src' ][ 'device' ]: |
| 1471 | linkDown1 = False |
| 1472 | main.log.info( "Link up from " + |
| 1473 | "s1 -> s2 on ONOS1 detected" ) |
| 1474 | for obj2 in jsonObj2: |
| 1475 | if '01' in obj2[ 'src' ][ 'device' ]: |
| 1476 | linkDown2 = False |
| 1477 | main.log.info( "Link up from " + |
| 1478 | "s1 -> s2 on ONOS2 detected" ) |
| 1479 | for obj3 in jsonObj3: |
| 1480 | if '01' in obj3[ 'src' ][ 'device' ]: |
| 1481 | linkDown3 = False |
| 1482 | main.log.info( "Link up from " + |
| 1483 | "s1 -> s2 on ONOS3 detected" ) |
| 1484 | |
| 1485 | loopCount += 1 |
| 1486 | time.sleep( 1 ) |
| 1487 | |
| 1488 | if ( linkDown1 and linkDown2 and linkDown3 ): |
| 1489 | main.log.info( "Link up discovery failed" ) |
| 1490 | |
| 1491 | linkUpLatGraph1 = 0 |
| 1492 | linkUpLatGraph2 = 0 |
| 1493 | linkUpLatGraph3 = 0 |
| 1494 | linkUpLatDevice1 = 0 |
| 1495 | linkUpLatDevice2 = 0 |
| 1496 | linkUpLatDevice3 = 0 |
| 1497 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1498 | assertion = main.FALSE |
| 1499 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1500 | jsonTopoMetrics1 =\ |
| 1501 | main.ONOS1cli.topologyEventsMetrics() |
| 1502 | jsonTopoMetrics2 =\ |
| 1503 | main.ONOS2cli.topologyEventsMetrics() |
| 1504 | jsonTopoMetrics3 =\ |
| 1505 | main.ONOS3cli.topologyEventsMetrics() |
| 1506 | jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 ) |
| 1507 | jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 ) |
| 1508 | jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1509 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1510 | main.log.info( "Obtaining graph and device timestamp" ) |
| 1511 | graphTimestamp1 = \ |
| 1512 | jsonTopoMetrics1[ graphTimestamp ][ 'value' ] |
| 1513 | graphTimestamp2 = \ |
| 1514 | jsonTopoMetrics2[ graphTimestamp ][ 'value' ] |
| 1515 | graphTimestamp3 = \ |
| 1516 | jsonTopoMetrics3[ graphTimestamp ][ 'value' ] |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1517 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1518 | linkTimestamp1 = \ |
| 1519 | jsonTopoMetrics1[ linkTimestamp ][ 'value' ] |
| 1520 | linkTimestamp2 = \ |
| 1521 | jsonTopoMetrics2[ linkTimestamp ][ 'value' ] |
| 1522 | linkTimestamp3 = \ |
| 1523 | jsonTopoMetrics3[ linkTimestamp ][ 'value' ] |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1524 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1525 | if graphTimestamp1 and graphTimestamp2 and\ |
| 1526 | graphTimestamp3 and linkTimestamp1 and\ |
| 1527 | linkTimestamp2 and linkTimestamp3: |
| 1528 | linkUpLatGraph1 = int( graphTimestamp1 ) -\ |
| 1529 | int( timestampLinkUpT0 ) |
| 1530 | linkUpLatGraph2 = int( graphTimestamp2 ) -\ |
| 1531 | int( timestampLinkUpT0 ) |
| 1532 | linkUpLatGraph3 = int( graphTimestamp3 ) -\ |
| 1533 | int( timestampLinkUpT0 ) |
| 1534 | |
| 1535 | linkUpLatLink1 = int( linkTimestamp1 ) -\ |
| 1536 | int( timestampLinkUpT0 ) |
| 1537 | linkUpLatLink2 = int( linkTimestamp2 ) -\ |
| 1538 | int( timestampLinkUpT0 ) |
| 1539 | linkUpLatLink3 = int( linkTimestamp3 ) -\ |
| 1540 | int( timestampLinkUpT0 ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1541 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1542 | main.log.error( "There was an error calculating" + |
| 1543 | " the delta for link down event" ) |
| 1544 | linkUpLatGraph1 = 0 |
| 1545 | linkUpLatGraph2 = 0 |
| 1546 | linkUpLatGraph3 = 0 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1547 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1548 | linkUpLatDevice1 = 0 |
| 1549 | linkUpLatDevice2 = 0 |
| 1550 | linkUpLatDevice3 = 0 |
| 1551 | |
| 1552 | if debugMode == 'on': |
| 1553 | main.log.info( "Link up latency ONOS1 iteration " + |
| 1554 | str( i ) + " (end-to-end): " + |
| 1555 | str( linkUpLatGraph1 ) + " ms" ) |
| 1556 | main.log.info( "Link up latency ONOS2 iteration " + |
| 1557 | str( i ) + " (end-to-end): " + |
| 1558 | str( linkUpLatGraph2 ) + " ms" ) |
| 1559 | main.log.info( "Link up latency ONOS3 iteration " + |
| 1560 | str( i ) + " (end-to-end): " + |
| 1561 | str( linkUpLatGraph3 ) + " ms" ) |
| 1562 | |
| 1563 | main.log.info( |
| 1564 | "Link up latency ONOS1 iteration " + |
| 1565 | str( i ) + |
| 1566 | " (link-event-to-system-timestamp): " + |
| 1567 | str( linkUpLatLink1 ) + |
| 1568 | " ms" ) |
| 1569 | main.log.info( |
| 1570 | "Link up latency ONOS2 iteration " + |
| 1571 | str( i ) + |
| 1572 | " (link-event-to-system-timestamp): " + |
| 1573 | str( linkUpLatLink2 ) + |
| 1574 | " ms" ) |
| 1575 | main.log.info( |
| 1576 | "Link up latency ONOS3 iteration " + |
| 1577 | str( i ) + |
| 1578 | " (link-event-to-system-timestamp): " + |
| 1579 | str( linkUpLatLink3 ) ) |
| 1580 | |
| 1581 | # Calculate avg of node calculations |
| 1582 | linkUpLatGraphAvg =\ |
| 1583 | ( linkUpLatGraph1 + |
| 1584 | linkUpLatGraph2 + |
| 1585 | linkUpLatGraph3 ) / 3 |
| 1586 | linkUpLatLinkAvg =\ |
| 1587 | ( linkUpLatLink1 + |
| 1588 | linkUpLatLink2 + |
| 1589 | linkUpLatLink3 ) / 3 |
| 1590 | |
| 1591 | # Set threshold and append latency to list |
| 1592 | if linkUpLatGraphAvg > upThresholdMin and\ |
| 1593 | linkUpLatGraphAvg < upThresholdMax: |
| 1594 | linkUpGraphToSystemList.append( |
| 1595 | linkUpLatGraphAvg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1596 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1597 | main.log.info( "Link up latency exceeded threshold" ) |
| 1598 | main.log.info( "Results for iteration " + str( i ) + |
| 1599 | "have been omitted" ) |
| 1600 | if linkUpLatLinkAvg > upThresholdMin and\ |
| 1601 | linkUpLatLinkAvg < upThresholdMax: |
| 1602 | linkUpLinkToSystemList.append( |
| 1603 | linkUpLatLinkAvg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1604 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1605 | main.log.info( "Link up latency exceeded threshold" ) |
| 1606 | main.log.info( "Results for iteration " + str( i ) + |
| 1607 | "have been omitted" ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1608 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1609 | # Calculate min, max, avg of list and report |
| 1610 | linkDownMin = min( linkDownGraphToSystemList ) |
| 1611 | linkDownMax = max( linkDownGraphToSystemList ) |
| 1612 | linkDownAvg = sum( linkDownGraphToSystemList ) / \ |
| 1613 | len( linkDownGraphToSystemList ) |
| 1614 | linkUpMin = min( linkUpGraphToSystemList ) |
| 1615 | linkUpMax = max( linkUpGraphToSystemList ) |
| 1616 | linkUpAvg = sum( linkUpGraphToSystemList ) / \ |
| 1617 | len( linkUpGraphToSystemList ) |
| 1618 | linkDownStdDev = \ |
| 1619 | str( round( numpy.std( linkDownGraphToSystemList ), 1 ) ) |
| 1620 | linkUpStdDev = \ |
| 1621 | str( round( numpy.std( linkUpGraphToSystemList ), 1 ) ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1622 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1623 | main.log.report( "Link down latency " + |
| 1624 | "Avg: " + str( linkDownAvg ) + " ms " + |
| 1625 | "Std Deviation: " + linkDownStdDev + " ms" ) |
| 1626 | main.log.report( "Link up latency " + |
| 1627 | "Avg: " + str( linkUpAvg ) + " ms " + |
| 1628 | "Std Deviation: " + linkUpStdDev + " ms" ) |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1629 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1630 | utilities.assert_equals( |
| 1631 | expect=main.TRUE, |
| 1632 | actual=assertion, |
| 1633 | onpass="Link discovery latency calculation successful", |
| 1634 | onfail="Link discovery latency case failed" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1635 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1636 | def CASE5( self, main ): |
| 1637 | """ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1638 | 100 Switch discovery latency |
| 1639 | |
| 1640 | Important: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1641 | This test case can be potentially dangerous if |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1642 | your machine has previously set iptables rules. |
| 1643 | One of the steps of the test case will flush |
| 1644 | all existing iptables rules. |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1645 | Note: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1646 | You can specify the number of switches in the |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1647 | params file to adjust the switch discovery size |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1648 | ( and specify the corresponding topology in Mininet1 |
| 1649 | .topo file ) |
| 1650 | """ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1651 | import time |
| 1652 | import subprocess |
| 1653 | import os |
| 1654 | import requests |
| 1655 | import json |
| 1656 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1657 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1658 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1659 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1660 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 1661 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1662 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1663 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1664 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1665 | # Number of iterations of case |
| 1666 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 1667 | numSw = main.params[ 'TEST' ][ 'numSwitch' ] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1668 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1669 | # Timestamp 'keys' for json metrics output. |
| 1670 | # These are subject to change, hence moved into params |
| 1671 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 1672 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1673 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1674 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1675 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1676 | localTime = time.strftime( '%X' ) |
| 1677 | localTime = localTime.replace( "/", "" ) |
| 1678 | localTime = localTime.replace( " ", "_" ) |
| 1679 | localTime = localTime.replace( ":", "" ) |
| 1680 | if debugMode == 'on': |
| 1681 | main.ONOS1.tsharkPcap( "eth0", |
| 1682 | "/tmp/100_sw_lat_pcap_" + localTime ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1683 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1684 | # Threshold for this test case |
| 1685 | swDiscThresholdStr = main.params[ 'TEST' ][ 'swDisc100Threshold' ] |
| 1686 | swDiscThresholdObj = swDiscThresholdStr.split( "," ) |
| 1687 | swDiscThresholdMin = int( swDiscThresholdObj[ 0 ] ) |
| 1688 | swDiscThresholdMax = int( swDiscThresholdObj[ 1 ] ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1689 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1690 | tsharkOfpOutput = "/tmp/tshark_ofp_" + numSw + "sw.txt" |
| 1691 | tsharkTcpOutput = "/tmp/tshark_tcp_" + numSw + "sw.txt" |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1692 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1693 | tsharkOfpResultList = [] |
| 1694 | tsharkTcpResultList = [] |
| 1695 | |
| 1696 | swDiscoveryLatList = [] |
| 1697 | |
| 1698 | main.case( numSw + " Switch discovery latency" ) |
| 1699 | main.step( "Assigning all switches to ONOS1" ) |
| 1700 | for i in range( 1, int( numSw ) + 1 ): |
| 1701 | main.Mininet1.assignSwController( |
| 1702 | sw=str( i ), |
| 1703 | ip1=ONOS1Ip, |
| 1704 | port1=defaultSwPort ) |
| 1705 | |
| 1706 | # Ensure that nodes are configured with ptpd |
| 1707 | # Just a warning message |
| 1708 | main.log.info( "Please check ptpd configuration to ensure" + |
| 1709 | " All nodes' system times are in sync" ) |
| 1710 | time.sleep( 5 ) |
| 1711 | |
| 1712 | for i in range( 0, int( numIter ) ): |
| 1713 | |
| 1714 | main.step( "Set iptables rule to block incoming sw connections" ) |
| 1715 | # Set iptables rule to block incoming switch connections |
| 1716 | # The rule description is as follows: |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1717 | # Append to INPUT rule, |
| 1718 | # behavior DROP that matches following: |
| 1719 | # * packet type: tcp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1720 | # * source IP: MN1Ip |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1721 | # * destination PORT: 6633 |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1722 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1723 | "sudo iptables -A INPUT -p tcp -s " + MN1Ip + |
| 1724 | " --dport " + defaultSwPort + " -j DROP" ) |
| 1725 | main.ONOS1.handle.expect( "\$" ) |
| 1726 | # Append to OUTPUT rule, |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1727 | # behavior DROP that matches following: |
| 1728 | # * packet type: tcp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1729 | # * source IP: MN1Ip |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1730 | # * destination PORT: 6633 |
| 1731 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1732 | "sudo iptables -A OUTPUT -p tcp -s " + MN1Ip + |
| 1733 | " --dport " + defaultSwPort + " -j DROP" ) |
| 1734 | main.ONOS1.handle.expect( "\$" ) |
| 1735 | # Give time to allow rule to take effect |
| 1736 | # NOTE: Sleep period may need to be configured |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1737 | # based on the number of switches in the topology |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1738 | main.log.info( "Please wait for switch connection to " + |
| 1739 | "time out" ) |
| 1740 | time.sleep( 60 ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1741 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1742 | # Gather vendor OFP with tshark |
| 1743 | main.ONOS1.tsharkGrep( "OFP 86 Vendor", |
| 1744 | tsharkOfpOutput ) |
| 1745 | main.ONOS1.tsharkGrep( "TCP 74 ", |
| 1746 | tsharkTcpOutput ) |
| 1747 | |
| 1748 | # NOTE: Remove all iptables rule quickly ( flush ) |
| 1749 | # Before removal, obtain TestON timestamp at which |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1750 | # removal took place |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1751 | # ( ensuring nodes are configured via ptp ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1752 | # sudo iptables -F |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1753 | |
| 1754 | t0System = time.time() * 1000 |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1755 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1756 | "sudo iptables -F" ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1757 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1758 | # Counter to track loop count |
| 1759 | counterLoop = 0 |
| 1760 | counterAvail1 = 0 |
| 1761 | counterAvail2 = 0 |
| 1762 | counterAvail3 = 0 |
| 1763 | onos1Dev = False |
| 1764 | onos2Dev = False |
| 1765 | onos3Dev = False |
| 1766 | while counterLoop < 60: |
| 1767 | # Continue to check devices for all device |
| 1768 | # availability. When all devices in all 3 |
| 1769 | # ONOS instances indicate that devices are available |
| 1770 | # obtain graph event timestamp for t1. |
| 1771 | deviceStrObj1 = main.ONOS1cli.devices() |
| 1772 | deviceStrObj2 = main.ONOS2cli.devices() |
| 1773 | deviceStrObj3 = main.ONOS3cli.devices() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1774 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1775 | deviceJson1 = json.loads( deviceStrObj1 ) |
| 1776 | deviceJson2 = json.loads( deviceStrObj2 ) |
| 1777 | deviceJson3 = json.loads( deviceStrObj3 ) |
| 1778 | |
| 1779 | for device1 in deviceJson1: |
| 1780 | if device1[ 'available' ]: |
| 1781 | counterAvail1 += 1 |
| 1782 | if counterAvail1 == int( numSw ): |
| 1783 | onos1Dev = True |
| 1784 | main.log.info( "All devices have been " + |
| 1785 | "discovered on ONOS1" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1786 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1787 | counterAvail1 = 0 |
| 1788 | for device2 in deviceJson2: |
| 1789 | if device2[ 'available' ]: |
| 1790 | counterAvail2 += 1 |
| 1791 | if counterAvail2 == int( numSw ): |
| 1792 | onos2Dev = True |
| 1793 | main.log.info( "All devices have been " + |
| 1794 | "discovered on ONOS2" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1795 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1796 | counterAvail2 = 0 |
| 1797 | for device3 in deviceJson3: |
| 1798 | if device3[ 'available' ]: |
| 1799 | counterAvail3 += 1 |
| 1800 | if counterAvail3 == int( numSw ): |
| 1801 | onos3Dev = True |
| 1802 | main.log.info( "All devices have been " + |
| 1803 | "discovered on ONOS3" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1804 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1805 | counterAvail3 = 0 |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1806 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1807 | if onos1Dev and onos2Dev and onos3Dev: |
| 1808 | main.log.info( "All devices have been discovered " + |
| 1809 | "on all ONOS instances" ) |
| 1810 | jsonStrTopologyMetrics1 =\ |
| 1811 | main.ONOS1cli.topologyEventsMetrics() |
| 1812 | jsonStrTopologyMetrics2 =\ |
| 1813 | main.ONOS2cli.topologyEventsMetrics() |
| 1814 | jsonStrTopologyMetrics3 =\ |
| 1815 | main.ONOS3cli.topologyEventsMetrics() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1816 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1817 | # Exit while loop if all devices discovered |
| 1818 | break |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1819 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1820 | counterLoop += 1 |
| 1821 | # Give some time in between CLI calls |
| 1822 | #( will not affect measurement ) |
| 1823 | time.sleep( 3 ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1824 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1825 | main.ONOS1.tsharkStop() |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1826 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1827 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 1828 | tsharkOfpOutput + " /tmp/" ) |
| 1829 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 1830 | tsharkTcpOutput + " /tmp/" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1831 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1832 | # TODO: Automate OFP output analysis |
| 1833 | # Debug mode - print out packets captured at runtime |
| 1834 | if debugMode == 'on': |
| 1835 | ofpFile = open( tsharkOfpOutput, 'r' ) |
| 1836 | main.log.info( "Tshark OFP Vendor output: " ) |
| 1837 | for line in ofpFile: |
| 1838 | tsharkOfpResultList.append( line ) |
| 1839 | main.log.info( line ) |
| 1840 | ofpFile.close() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1841 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1842 | tcpFile = open( tsharkTcpOutput, 'r' ) |
| 1843 | main.log.info( "Tshark TCP 74 output: " ) |
| 1844 | for line in tcpFile: |
| 1845 | tsharkTcpResultList.append( line ) |
| 1846 | main.log.info( line ) |
| 1847 | tcpFile.close() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1848 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1849 | jsonObj1 = json.loads( jsonStrTopologyMetrics1 ) |
| 1850 | jsonObj2 = json.loads( jsonStrTopologyMetrics2 ) |
| 1851 | jsonObj3 = json.loads( jsonStrTopologyMetrics3 ) |
| 1852 | |
| 1853 | graphTimestamp1 = \ |
| 1854 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 1855 | graphTimestamp2 = \ |
| 1856 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 1857 | graphTimestamp3 = \ |
| 1858 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 1859 | |
| 1860 | graphLat1 = int( graphTimestamp1 ) - int( t0System ) |
| 1861 | graphLat2 = int( graphTimestamp2 ) - int( t0System ) |
| 1862 | graphLat3 = int( graphTimestamp3 ) - int( t0System ) |
| 1863 | |
| 1864 | avgGraphLat = \ |
| 1865 | ( int( graphLat1 ) + |
| 1866 | int( graphLat2 ) + |
| 1867 | int( graphLat3 ) ) / 3 |
| 1868 | |
| 1869 | if avgGraphLat > swDiscThresholdMin \ |
| 1870 | and avgGraphLat < swDiscThresholdMax: |
| 1871 | swDiscoveryLatList.append( |
| 1872 | avgGraphLat ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1873 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1874 | main.log.info( "100 Switch discovery latency " + |
| 1875 | "exceeded the threshold." ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1876 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1877 | # END ITERATION FOR LOOP |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1878 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1879 | swLatMin = min( swDiscoveryLatList ) |
| 1880 | swLatMax = max( swDiscoveryLatList ) |
| 1881 | swLatAvg = sum( swDiscoveryLatList ) /\ |
| 1882 | len( swDiscoveryLatList ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1883 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1884 | main.log.report( "100 Switch discovery lat " + |
| 1885 | "Min: " + str( swLatMin ) + " ms" + |
| 1886 | "Max: " + str( swLatMax ) + " ms" + |
| 1887 | "Avg: " + str( swLatAvg ) + " ms" ) |
| 1888 | |
| 1889 | def CASE6( self, main ): |
| 1890 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1891 | Increase number of nodes and initiate CLI |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1892 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1893 | import time |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1894 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1895 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1896 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1897 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1898 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 1899 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 1900 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 1901 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1902 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1903 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1904 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1905 | global clusterCount |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1906 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1907 | # Cluster size increased everytime the case is defined |
| 1908 | clusterCount += 2 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1909 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1910 | main.log.report( "Increasing cluster size to " + |
| 1911 | str( clusterCount ) ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1912 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1913 | installResult = main.FALSE |
| 1914 | if clusterCount == 3: |
| 1915 | main.log.info( "Installing nodes 2 and 3" ) |
| 1916 | node2Result = \ |
| 1917 | main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 1918 | node3Result = \ |
| 1919 | main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 1920 | installResult = node2Result and node3Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1921 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1922 | time.sleep( 5 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1923 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1924 | main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 1925 | main.ONOS3cli.startOnosCli( ONOS3Ip ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1926 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1927 | elif clusterCount == 5: |
| 1928 | main.log.info( "Installing nodes 4 and 5" ) |
| 1929 | node4Result = \ |
| 1930 | main.ONOSbench.onosInstall( node=ONOS4Ip ) |
| 1931 | node5Result = \ |
| 1932 | main.ONOSbench.onosInstall( node=ONOS5Ip ) |
| 1933 | installResult = node4Result and node5Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1934 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1935 | time.sleep( 5 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1936 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1937 | main.ONOS4cli.startOnosCli( ONOS4Ip ) |
| 1938 | main.ONOS5cli.startOnosCli( ONOS5Ip ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1939 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1940 | elif clusterCount == 7: |
| 1941 | main.log.info( "Installing nodes 4 and 5" ) |
| 1942 | node6Result = \ |
| 1943 | main.ONOSbench.onosInstall( node=ONOS6Ip ) |
| 1944 | node7Result = \ |
| 1945 | main.ONOSbench.onosInstall( node=ONOS7Ip ) |
| 1946 | installResult = node6Result and node7Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1947 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1948 | time.sleep( 5 ) |
| 1949 | |
| 1950 | main.ONOS6cli.startOnosCli( ONOS6Ip ) |
| 1951 | main.ONOS7cli.startOnosCli( ONOS7Ip ) |