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