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