jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1 | # 2015.03.12 10:22:05 PDT |
| 2 | #Embedded file name: ../tests/TopoPerfNextBM/TopoPerfNextBM.py |
| 3 | import time |
| 4 | import sys |
| 5 | import os |
| 6 | import re |
| 7 | |
| 8 | class TopoPerfNextBM: |
| 9 | |
| 10 | def __init__(self): |
| 11 | self.default = '' |
| 12 | |
| 13 | def CASE1(self, main): |
| 14 | """ |
| 15 | ONOS startup sequence |
| 16 | """ |
| 17 | global clusterCount |
| 18 | global timeToPost |
| 19 | global runNum |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 20 | global jenkinsBuildNumber |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 21 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 22 | import time |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 23 | import os |
| 24 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 25 | clusterCount = 1 |
| 26 | timeToPost = time.strftime('%Y-%m-%d %H:%M:%S') |
| 27 | runNum = time.strftime('%d%H%M%S') |
| 28 | cellName = main.params['ENV']['cellName'] |
| 29 | gitPull = main.params['GIT']['autoPull'] |
| 30 | checkoutBranch = main.params['GIT']['checkout'] |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 31 | |
| 32 | # Get jenkins build number from environment. |
| 33 | # This environment variable will only exist when |
| 34 | # triggered by a jenkins job |
| 35 | try: |
| 36 | jenkinsBuildNumber = str(os.environ['BUILD_NUMBER']) |
| 37 | main.log.report( 'Jenkins build number: ' + |
| 38 | jenkinsBuildNumber ) |
| 39 | except KeyError: |
| 40 | # Jenkins build number is also used in posting to DB |
| 41 | # If this test is not triggered by jenkins, give |
| 42 | # it the runNum variable instead, ensuring that |
| 43 | # the DB post will recognize it as a non-jenkins run |
| 44 | jenkinsBuildNumber = str(runNum) |
| 45 | main.log.info( 'Job is not run by jenkins. '+ |
| 46 | 'Build number set to: ' + jenkinsBuildNumber) |
| 47 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 48 | global CLIs |
| 49 | CLIs = [] |
| 50 | global nodes |
| 51 | nodes = [] |
| 52 | global nodeIpList |
| 53 | nodeIpList = [] |
| 54 | for i in range( 1, 8 ): |
| 55 | CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) ) |
| 56 | nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 57 | nodeIpList.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] ) |
| 58 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 59 | MN1Ip = main.params['MN']['ip1'] |
| 60 | BENCHIp = main.params['BENCH']['ip'] |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 61 | cellFeatures = main.params['ENV']['cellFeatures'] |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 62 | topoCfgFile = main.params['TEST']['topoConfigFile'] |
| 63 | topoCfgName = main.params['TEST']['topoConfigName'] |
| 64 | portEventResultPath = main.params['DB']['portEventResultPath'] |
| 65 | switchEventResultPath = main.params['DB']['switchEventResultPath'] |
| 66 | mvnCleanInstall = main.params['TEST']['mci'] |
| 67 | |
| 68 | main.case('Setting up test environment') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 69 | |
| 70 | # NOTE: Below is deprecated after new way to install features |
| 71 | #main.log.info('Copying topology event accumulator config' + |
| 72 | # ' to ONOS /package/etc') |
| 73 | #main.ONOSbench.handle.sendline('cp ~/' + |
| 74 | # topoCfgFile + ' ~/ONOS/tools/package/etc/' + |
| 75 | # topoCfgName) |
| 76 | #main.ONOSbench.handle.expect('\\$') |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 77 | |
| 78 | main.log.report('Setting up test environment') |
| 79 | |
| 80 | main.step('Starting mininet topology ') |
| 81 | main.Mininet1.startNet() |
| 82 | |
| 83 | main.step('Cleaning previously installed ONOS if any') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 84 | # Nodes 2 ~ 7 |
| 85 | for i in range( 1, 7 ): |
| 86 | main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i]) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 87 | |
| 88 | main.step('Clearing previous DB log file') |
| 89 | |
| 90 | fPortLog = open(portEventResultPath, 'w') |
| 91 | fPortLog.write('') |
| 92 | fPortLog.close() |
| 93 | fSwitchLog = open(switchEventResultPath, 'w') |
| 94 | fSwitchLog.write('') |
| 95 | fSwitchLog.close() |
| 96 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 97 | main.step('Creating cell file') |
| 98 | cellFileResult = main.ONOSbench.createCellFile( |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 99 | BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0]) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 100 | |
| 101 | main.step('Applying cell file to environment') |
| 102 | cellApplyResult = main.ONOSbench.setCell(cellName) |
| 103 | verifyCellResult = main.ONOSbench.verifyCell() |
| 104 | |
| 105 | main.step('Git checkout and pull ' + checkoutBranch) |
| 106 | if gitPull == 'on': |
| 107 | checkoutResult = main.TRUE |
| 108 | pullResult = main.ONOSbench.gitPull() |
| 109 | else: |
| 110 | checkoutResult = main.TRUE |
| 111 | pullResult = main.TRUE |
| 112 | main.log.info('Skipped git checkout and pull') |
| 113 | |
| 114 | main.log.report('Commit information - ') |
| 115 | main.ONOSbench.getVersion(report=True) |
| 116 | main.step('Using mvn clean & install') |
| 117 | if mvnCleanInstall == 'on': |
| 118 | mvnResult = main.ONOSbench.cleanInstall() |
| 119 | elif mvnCleanInstall == 'off': |
| 120 | main.log.info('mci turned off by settings') |
| 121 | mvnResult = main.TRUE |
| 122 | main.step('Set cell for ONOS cli env') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 123 | CLIs[0].setCell(cellName) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 124 | |
| 125 | main.step('Creating ONOS package') |
| 126 | packageResult = main.ONOSbench.onosPackage() |
| 127 | |
| 128 | main.step('Installing ONOS package') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 129 | install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0]) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 130 | |
| 131 | time.sleep(10) |
| 132 | |
| 133 | main.step('Start onos cli') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 134 | cli1 = CLIs[0].startOnosCli(nodeIpList[0]) |
| 135 | |
| 136 | main.step( 'activating essential applications' ) |
| 137 | CLIs[0].activateApp( 'org.onosproject.metrics' ) |
| 138 | CLIs[0].activateApp( 'org.onosproject.openflow' ) |
| 139 | |
| 140 | main.step( 'Configuring application parameters' ) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 141 | |
| 142 | configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider' |
| 143 | configParam = 'maxEvents 1' |
| 144 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 145 | configParam = 'maxBatchMs 0' |
| 146 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 147 | configParam = 'maxIdleMs 0' |
| 148 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 149 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 150 | utilities.assert_equals(expect=main.TRUE, |
| 151 | actual=cellFileResult and cellApplyResult and\ |
| 152 | verifyCellResult and checkoutResult and\ |
| 153 | pullResult and mvnResult and\ |
| 154 | install1Result, |
| 155 | onpass='Test Environment setup successful', |
| 156 | onfail='Failed to setup test environment') |
| 157 | |
| 158 | def CASE2(self, main): |
| 159 | """ |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 160 | Assign s3 to ONOS1 and measure latency |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 161 | |
| 162 | There are 4 levels of latency measurements to this test: |
| 163 | 1 ) End-to-end measurement: Complete end-to-end measurement |
| 164 | from TCP ( SYN/ACK ) handshake to Graph change |
| 165 | 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of |
| 166 | measurement from OFP Vendor message to Graph change |
| 167 | 3 ) OFP-to-device measurement: 'ONOS processing without |
| 168 | graph change' snippet of measurement from OFP vendor |
| 169 | message to Device change timestamp |
| 170 | 4 ) T0-to-device measurement: Measurement that includes |
| 171 | the switch handshake to devices timestamp without |
| 172 | the graph view change. ( TCP handshake -> Device |
| 173 | change ) |
| 174 | """ |
| 175 | import time |
| 176 | import subprocess |
| 177 | import json |
| 178 | import requests |
| 179 | import os |
| 180 | import numpy |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 181 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 182 | ONOSUser = main.params['CTRL']['user'] |
| 183 | defaultSwPort = main.params['CTRL']['port1'] |
| 184 | numIter = main.params['TEST']['numIter'] |
| 185 | iterIgnore = int(main.params['TEST']['iterIgnore']) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 186 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 187 | deviceTimestampKey = main.params['JSON']['deviceTimestamp'] |
| 188 | graphTimestampKey = main.params['JSON']['graphTimestamp'] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 189 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 190 | debugMode = main.params['TEST']['debugMode'] |
| 191 | onosLog = main.params['TEST']['onosLogFile'] |
| 192 | resultPath = main.params['DB']['switchEventResultPath'] |
| 193 | thresholdStr = main.params['TEST']['singleSwThreshold'] |
| 194 | thresholdObj = thresholdStr.split(',') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 195 | thresholdMin = float(thresholdObj[0]) |
| 196 | thresholdMax = float(thresholdObj[1]) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 197 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 198 | # Look for 'role-request' messages, |
| 199 | # which replaces the 'vendor' messages previously seen |
| 200 | # on OVS 2.0.1 |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 201 | tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 202 | tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ] |
| 203 | tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ] |
| 204 | tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ] |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 205 | tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 206 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 207 | tsharkOfOutput = '/tmp/tshark_of_topo.txt' |
| 208 | tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt' |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 209 | tsharkRoleOutput = '/tmp/tshark_role_request.txt' |
| 210 | tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt' |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 211 | tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt' |
| 212 | |
| 213 | # Switch connect measurement list |
| 214 | # TCP Syn/Ack -> Feature Reply latency collection for each node |
| 215 | tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 216 | # Feature Reply -> Role Request latency collection for each node |
| 217 | featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount, |
| 218 | int(numIter))) |
| 219 | # Role Request -> Role Reply latency collection for each node |
| 220 | roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount, |
| 221 | int(numIter))) |
| 222 | # Role Reply -> Device Update latency collection for each node |
| 223 | roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount, |
| 224 | int(numIter))) |
| 225 | # Device Update -> Graph Update latency collection for each node |
| 226 | deviceToGraphLatNodeIter = numpy.zeros((clusterCount, |
| 227 | int(numIter))) |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 228 | endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 229 | |
| 230 | # Switch disconnect measurement lists |
| 231 | # Mininet Fin / Ack -> Mininet Ack |
| 232 | finAckTransactionLatNodeIter = numpy.zeros((clusterCount, |
| 233 | int(numIter))) |
| 234 | # Mininet Ack -> Device Event |
| 235 | ackToDeviceLatNodeIter = numpy.zeros((clusterCount, |
| 236 | int(numIter))) |
| 237 | # Device event -> Graph event |
| 238 | deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount, |
| 239 | int(numIter))) |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 240 | endToEndDiscLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 241 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 242 | assertion = main.TRUE |
| 243 | localTime = time.strftime('%x %X') |
| 244 | localTime = localTime.replace('/', '') |
| 245 | localTime = localTime.replace(' ', '_') |
| 246 | localTime = localTime.replace(':', '') |
| 247 | |
| 248 | if debugMode == 'on': |
| 249 | main.ONOS1.tsharkPcap('eth0', |
| 250 | '/tmp/single_sw_lat_pcap_' + localTime) |
| 251 | main.log.info('Debug mode is on') |
| 252 | main.log.report('Latency of adding one switch to controller') |
| 253 | main.log.report('First ' + str(iterIgnore) + |
| 254 | ' iterations ignored' + ' for jvm warmup time') |
| 255 | main.log.report('Total iterations of test: ' + str(numIter)) |
| 256 | |
| 257 | for i in range(0, int(numIter)): |
| 258 | main.log.info('Starting tshark capture') |
| 259 | main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput) |
| 260 | main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 261 | main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput) |
| 262 | main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput) |
| 263 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 264 | time.sleep(10) |
| 265 | |
| 266 | main.log.info('Assigning s3 to controller') |
| 267 | main.Mininet1.assignSwController(sw='3', |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 268 | ip1=nodeIpList[0], port1=defaultSwPort) |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 269 | |
| 270 | time.sleep(10) |
| 271 | |
| 272 | main.log.info('Stopping all Tshark processes') |
| 273 | main.ONOS1.tsharkStop() |
| 274 | |
| 275 | main.log.info('Copying over tshark files') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 276 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 277 | ':' + tsharkTcpOutput + ' /tmp/') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 278 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 279 | ':' + tsharkRoleOutput + ' /tmp/') |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 280 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 281 | ':' + tsharkFeatureOutput + ' /tmp/') |
| 282 | os.system('scp ' + ONOSUser + '@' + |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 283 | nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/') |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 284 | |
| 285 | # Get tcp syn / ack output |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 286 | time.sleep(5) |
| 287 | tcpFile = open(tsharkTcpOutput, 'r') |
| 288 | tempText = tcpFile.readline() |
| 289 | tempText = tempText.split(' ') |
| 290 | main.log.info('Object read in from TCP capture: ' + |
| 291 | str(tempText)) |
| 292 | |
| 293 | if len(tempText) > 1: |
| 294 | t0Tcp = float(tempText[1]) * 1000.0 |
| 295 | else: |
| 296 | main.log.error('Tshark output file for TCP' + |
| 297 | ' returned unexpected results') |
| 298 | t0Tcp = 0 |
| 299 | assertion = main.FALSE |
| 300 | tcpFile.close() |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 301 | |
| 302 | # Get Role reply output |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 303 | time.sleep(5) |
| 304 | ofFile = open(tsharkOfOutput, 'r') |
| 305 | lineOfp = '' |
| 306 | while True: |
| 307 | tempText = ofFile.readline() |
| 308 | if tempText != '': |
| 309 | lineOfp = tempText |
| 310 | else: |
| 311 | break |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 312 | obj = lineOfp.split(' ') |
| 313 | main.log.info('Object read in from OFP capture: ' + |
| 314 | str(lineOfp)) |
| 315 | if len(obj) > 1: |
| 316 | t0Ofp = float(obj[1]) * 1000.0 |
| 317 | else: |
| 318 | main.log.error('Tshark output file for OFP' + |
| 319 | ' returned unexpected results') |
| 320 | t0Ofp = 0 |
| 321 | assertion = main.FALSE |
| 322 | ofFile.close() |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 323 | |
| 324 | # Get role request output |
| 325 | roleFile = open(tsharkRoleOutput, 'r') |
| 326 | tempText = roleFile.readline() |
| 327 | tempText = tempText.split(' ') |
| 328 | if len(tempText) > 1: |
| 329 | main.log.info('Object read in from role request capture:' + |
| 330 | str(tempText)) |
| 331 | roleTimestamp = float(tempText[1]) * 1000.0 |
| 332 | else: |
| 333 | main.log.error('Tshark output file for role request' + |
| 334 | ' returned unexpected results') |
| 335 | timeRoleRequest = 0 |
| 336 | assertion = main.FALSE |
| 337 | roleFile.close() |
| 338 | |
| 339 | # Get feature reply output |
| 340 | featureFile = open(tsharkFeatureOutput, 'r') |
| 341 | tempText = featureFile.readline() |
| 342 | tempText = tempText.split(' ') |
| 343 | if len(tempText) > 1: |
| 344 | main.log.info('Object read in from feature reply capture: '+ |
| 345 | str(tempText)) |
| 346 | featureTimestamp = float(tempText[1]) * 1000.0 |
| 347 | else: |
| 348 | main.log.error('Tshark output file for feature reply' + |
| 349 | ' returned unexpected results') |
| 350 | timeFeatureReply = 0 |
| 351 | assertion = main.FALSE |
| 352 | featureFile.close() |
| 353 | |
| 354 | # TODO: calculate feature reply, role request times |
| 355 | # stack measurements correctly and report |
| 356 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 357 | #TODO: Refactor in progress |
| 358 | |
| 359 | for node in range(0, clusterCount): |
| 360 | nodeNum = node+1 |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 361 | metricsSwUp = CLIs[node].topologyEventsMetrics |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 362 | jsonStr = metricsSwUp() |
| 363 | jsonObj = json.loads(jsonStr) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 364 | if jsonObj: |
| 365 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 366 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 367 | else: |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 368 | main.log.error( "Unexpected JSON object" ) |
| 369 | # If we could not obtain the JSON object, |
| 370 | # set the timestamps to 0, which will be |
| 371 | # excluded from the measurement later on |
| 372 | # (realized as invalid) |
| 373 | graphTimestamp = 0 |
| 374 | deviceTimestamp = 0 |
| 375 | |
| 376 | endToEnd = int(graphTimestamp) - int(t0Tcp) |
| 377 | |
| 378 | # Below are measurement breakdowns of the end-to-end |
| 379 | # measurement. |
| 380 | tcpToFeature = int(featureTimestamp) - int(t0Tcp) |
| 381 | featureToRole = int(roleTimestamp) - int(featureTimestamp) |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 382 | roleToOfp = float(t0Ofp) - float(roleTimestamp) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 383 | ofpToDevice = int(deviceTimestamp) - int(t0Ofp) |
| 384 | deviceToGraph = float(graphTimestamp) - float(deviceTimestamp) |
| 385 | |
| 386 | if endToEnd > thresholdMin and\ |
| 387 | endToEnd < thresholdMax and i >= iterIgnore: |
| 388 | endToEndLatNodeIter[node][i] = endToEnd |
| 389 | main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+ |
| 390 | str(endToEnd) + " ms") |
| 391 | else: |
| 392 | main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+ |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 393 | "measurement ignored due to excess in "+ |
| 394 | "threshold or premature iteration") |
| 395 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 396 | if tcpToFeature > thresholdMin and\ |
| 397 | tcpToFeature < thresholdMax and i >= iterIgnore: |
| 398 | tcpToFeatureLatNodeIter[node][i] = tcpToFeature |
| 399 | main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+ |
| 400 | str(tcpToFeature) + " ms") |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 401 | else: |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 402 | main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+ |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 403 | "measurement ignored due to excess in "+ |
| 404 | "threshold or premature iteration") |
| 405 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 406 | if featureToRole > thresholdMin and\ |
| 407 | featureToRole < thresholdMax and i >= iterIgnore: |
| 408 | featureToRoleRequestLatNodeIter[node][i] = featureToRole |
| 409 | main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+ |
| 410 | str(featureToRole) + " ms") |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 411 | else: |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 412 | main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+ |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 413 | "measurement ignored due to excess in "+ |
| 414 | "threshold or premature iteration") |
| 415 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 416 | if roleToOfp > thresholdMin and\ |
| 417 | roleToOfp < thresholdMax and i >= iterIgnore: |
| 418 | roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp |
| 419 | main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+ |
| 420 | str(roleToOfp) + " ms") |
| 421 | else: |
| 422 | main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+ |
| 423 | "measurement ignored due to excess in "+ |
| 424 | "threshold or premature iteration") |
| 425 | |
| 426 | if ofpToDevice > thresholdMin and\ |
| 427 | ofpToDevice < thresholdMax and i >= iterIgnore: |
| 428 | roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice |
| 429 | main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+ |
| 430 | str(ofpToDevice) + " ms") |
| 431 | else: |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 432 | main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+ |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 433 | "measurement ignored due to excess in "+ |
| 434 | "threshold or premature iteration") |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 435 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 436 | if deviceToGraph > thresholdMin and\ |
| 437 | deviceToGraph < thresholdMax and i >= iterIgnore: |
| 438 | deviceToGraphLatNodeIter[node][i] = deviceToGraph |
| 439 | main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+ |
| 440 | str(deviceToGraph) + " ms") |
| 441 | else: |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 442 | main.log.info("ONOS "+str(nodeNum)+ " device-to-graph "+ |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 443 | "measurement ignored due to excess in "+ |
| 444 | "threshold or premature iteration") |
| 445 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 446 | # ******************** |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 447 | time.sleep(5) |
| 448 | |
| 449 | # Get device id to remove |
| 450 | deviceIdJsonStr = main.ONOS1cli.devices() |
| 451 | |
| 452 | main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) ) |
| 453 | deviceId = json.loads(deviceIdJsonStr) |
| 454 | |
| 455 | deviceList = [] |
| 456 | for device in deviceId: |
| 457 | deviceList.append(device['id']) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 458 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 459 | # Measure switch down metrics |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 460 | # TCP FIN/ACK -> TCP FIN |
| 461 | # TCP FIN -> Device Event |
| 462 | # Device Event -> Graph Event |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 463 | # Capture switch down FIN / ACK packets |
| 464 | |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 465 | # The -A 1 grep option allows us to grab 1 extra line after the |
| 466 | # last tshark output grepped originally |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 467 | main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput, |
| 468 | grepOptions = '-A 1' ) |
| 469 | |
| 470 | time.sleep( 5 ) |
| 471 | |
| 472 | removeJsonList = [] |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 473 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 474 | main.step('Remove switch from controller') |
| 475 | main.Mininet1.deleteSwController('s3') |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 476 | firstDevice = deviceList[0] |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 477 | main.log.info( "Removing device " +str(firstDevice)+ |
| 478 | " from ONOS" ) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 479 | |
| 480 | time.sleep( 5 ) |
| 481 | |
| 482 | # We need to get metrics before removing |
| 483 | # device from the store below. |
| 484 | for node in range(0, clusterCount): |
| 485 | metricsSwDown = CLIs[node].topologyEventsMetrics |
| 486 | jsonStr = metricsSwDown() |
| 487 | removeJsonList.append( json.loads(jsonStr) ) |
| 488 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 489 | #if deviceId: |
| 490 | main.ONOS1cli.deviceRemove(firstDevice) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 491 | |
| 492 | main.ONOS1.tsharkStop() |
| 493 | |
| 494 | main.log.info('Copying over tshark files') |
| 495 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
| 496 | ':' + tsharkFinAckOutput + ' /tmp/') |
| 497 | |
| 498 | time.sleep( 10 ) |
| 499 | finAckOutputList = [] |
| 500 | with open(tsharkFinAckOutput, 'r') as f: |
| 501 | tempLine = f.readlines() |
| 502 | main.log.info('Object read in from FinAck capture: ' + |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 503 | "\n".join(tempLine)) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 504 | |
| 505 | index = 1 |
| 506 | for line in tempLine: |
| 507 | obj = line.split(' ') |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 508 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 509 | if len(obj) > 1: |
| 510 | if index == 1: |
| 511 | tFinAck = float(obj[1]) * 1000.0 |
| 512 | elif index == 3: |
| 513 | tAck = float(obj[1]) * 1000.0 |
| 514 | else: |
| 515 | main.log.error('Tshark output file for OFP' + |
| 516 | ' returned unexpected results') |
| 517 | tFinAck = 0 |
| 518 | tAck = 0 |
| 519 | assertion = main.FALSE |
| 520 | |
| 521 | index = index+1 |
| 522 | |
| 523 | # with open() as f takes care of closing file |
| 524 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 525 | time.sleep(5) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 526 | |
| 527 | for node in range(0, clusterCount): |
| 528 | nodeNum = node+1 |
| 529 | jsonObj = removeJsonList[node] |
| 530 | if jsonObj: |
| 531 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 532 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 533 | main.log.info("Graph timestamp: "+str(graphTimestamp)) |
| 534 | main.log.info("Device timestamp: "+str(deviceTimestamp)) |
| 535 | else: |
| 536 | main.log.error( "Unexpected JSON object" ) |
| 537 | # If we could not obtain the JSON object, |
| 538 | # set the timestamps to 0, which will be |
| 539 | # excluded from the measurement later on |
| 540 | # (realized as invalid) |
| 541 | graphTimestamp = 0 |
| 542 | deviceTimestamp = 0 |
| 543 | |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 544 | finAckTransaction = float(tAck) - float(tFinAck) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 545 | ackToDevice = int(deviceTimestamp) - int(tAck) |
| 546 | deviceToGraph = int(graphTimestamp) - int(deviceTimestamp) |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 547 | endToEndDisc = int(graphTimestamp) - int(tFinAck) |
| 548 | |
| 549 | if endToEndDisc > thresholdMin and\ |
| 550 | endToEndDisc < thresholdMax and i >= iterIgnore: |
| 551 | endToEndDiscLatNodeIter[node][i] = endToEndDisc |
| 552 | main.log.info("ONOS "+str(nodeNum) + |
| 553 | "end-to-end disconnection: "+ |
| 554 | str(endToEndDisc) + " ms" ) |
| 555 | else: |
| 556 | main.log.info("ONOS " + str(nodeNum) + |
| 557 | " end-to-end disconnection "+ |
| 558 | "measurement ignored due to excess in "+ |
| 559 | "threshold or premature iteration") |
| 560 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 561 | if finAckTransaction > thresholdMin and\ |
| 562 | finAckTransaction < thresholdMax and i >= iterIgnore: |
| 563 | finAckTransactionLatNodeIter[node][i] = finAckTransaction |
| 564 | main.log.info("ONOS "+str(nodeNum)+ |
| 565 | " fin/ack transaction: "+ |
| 566 | str(finAckTransaction) + " ms") |
| 567 | else: |
| 568 | main.log.info("ONOS "+str(nodeNum)+ |
| 569 | " fin/ack transaction "+ |
| 570 | "measurement ignored due to excess in "+ |
| 571 | "threshold or premature iteration") |
| 572 | |
| 573 | if ackToDevice > thresholdMin and\ |
| 574 | ackToDevice < thresholdMax and i >= iterIgnore: |
| 575 | ackToDeviceLatNodeIter[node][i] = ackToDevice |
| 576 | main.log.info("ONOS "+str(nodeNum)+ |
| 577 | " ack-to-device: "+ |
| 578 | str(ackToDevice) + " ms") |
| 579 | else: |
| 580 | main.log.info("ONOS "+str(nodeNum)+ |
| 581 | " ack-to-device "+ |
| 582 | "measurement ignored due to excess in "+ |
| 583 | "threshold or premature iteration") |
| 584 | |
| 585 | if deviceToGraph > thresholdMin and\ |
| 586 | deviceToGraph < thresholdMax and i >= iterIgnore: |
| 587 | deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph |
| 588 | main.log.info("ONOS "+str(nodeNum)+ |
| 589 | " device-to-graph disconnect: "+ |
| 590 | str(deviceToGraph) + " ms") |
| 591 | else: |
| 592 | main.log.info("ONOS "+str(nodeNum)+ |
| 593 | " device-to-graph disconnect "+ |
| 594 | "measurement ignored due to excess in "+ |
| 595 | "threshold or premature iteration") |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 596 | |
| 597 | endToEndAvg = 0 |
| 598 | ofpToGraphAvg = 0 |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 599 | dbCmdList = [] |
| 600 | for node in range(0, clusterCount): |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 601 | # List of latency for each node |
| 602 | endToEndList = [] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 603 | tcpToFeatureList = [] |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 604 | featureToRoleList = [] |
| 605 | roleToOfpList = [] |
| 606 | ofpToDeviceList = [] |
| 607 | deviceToGraphList = [] |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 608 | |
| 609 | finAckTransactionList = [] |
| 610 | ackToDeviceList = [] |
| 611 | deviceToGraphDiscList = [] |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 612 | endToEndDiscList = [] |
| 613 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 614 | # LatNodeIter 2d arrays contain all iteration latency |
| 615 | # for each node of the current scale cluster size |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 616 | # Switch connection measurements |
| 617 | # Set further acceptance criteria for measurements |
| 618 | # here if you would like to filter reporting results |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 619 | for item in endToEndLatNodeIter[node]: |
| 620 | if item > 0.0: |
| 621 | endToEndList.append(item) |
| 622 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 623 | for item in tcpToFeatureLatNodeIter[node]: |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 624 | if item > 0.0: |
| 625 | tcpToFeatureList.append(item) |
| 626 | |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 627 | for item in featureToRoleRequestLatNodeIter[node]: |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 628 | if item > 0.0: |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 629 | featureToRoleList.append(item) |
| 630 | |
| 631 | for item in roleRequestToRoleReplyLatNodeIter[node]: |
| 632 | if item > 0.0: |
| 633 | roleToOfpList.append(item) |
| 634 | |
| 635 | for item in roleReplyToDeviceLatNodeIter[node]: |
| 636 | if item > 0.0: |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 637 | tcpToFeatureList.append(item) |
| 638 | |
| 639 | for item in featureToRoleRequestLatNodeIter[node]: |
| 640 | if item > 0.0: |
| 641 | featureToRoleList.append(item) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 642 | |
| 643 | for item in deviceToGraphLatNodeIter[node]: |
| 644 | if item > 0.0: |
| 645 | deviceToGraphList.append(item) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 646 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 647 | # Switch disconnect measurements |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 648 | for item in endToEndDiscLatNodeIter[node]: |
| 649 | if item > 0.0: |
| 650 | endToEndDiscList.append(item) |
| 651 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 652 | for item in finAckTransactionLatNodeIter[node]: |
| 653 | if item > 0.0: |
| 654 | finAckTransactionList.append(item) |
| 655 | |
| 656 | for item in ackToDeviceLatNodeIter[node]: |
| 657 | if item > 0.0: |
| 658 | ackToDeviceList.append(item) |
| 659 | |
| 660 | for item in deviceToGraphDiscLatNodeIter[node]: |
| 661 | if item > 0.0: |
| 662 | deviceToGraphDiscList.append(item) |
| 663 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 664 | endToEndAvg = round(numpy.mean(endToEndList), 2) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 665 | endToEndStdDev = round(numpy.std(endToEndList), 2) |
| 666 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 667 | tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 668 | tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2) |
| 669 | |
| 670 | featureToRoleAvg = round(numpy.mean(featureToRoleList), 2) |
| 671 | featureToRoleStdDev = round(numpy.std(featureToRoleList), 2) |
| 672 | |
| 673 | roleToOfpAvg = round(numpy.mean(roleToOfpList), 2) |
| 674 | roleToOfpStdDev = round(numpy.std(roleToOfpList), 2) |
| 675 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 676 | ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2) |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 677 | ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2) |
| 678 | |
| 679 | deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2) |
| 680 | deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2) |
| 681 | |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 682 | endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2) |
| 683 | endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2) |
| 684 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 685 | finAckAvg = round(numpy.mean(finAckTransactionList), 2) |
| 686 | finAckStdDev = round(numpy.std(finAckTransactionList), 2) |
| 687 | |
| 688 | ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2) |
| 689 | ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2) |
| 690 | |
| 691 | deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2) |
| 692 | deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2) |
| 693 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 694 | main.log.report(' - Node ' + str(node + 1) + ' Summary - ') |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 695 | main.log.report(' - Switch Connection Statistics - ') |
| 696 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 697 | main.log.report(' End-to-end Avg: ' + str(endToEndAvg) + |
| 698 | ' ms' + ' End-to-end Std dev: ' + |
andrew@onlab.us | 0f468c4 | 2015-04-02 17:05:47 -0400 | [diff] [blame] | 699 | str(endToEndStdDev) + ' ms') |
| 700 | |
| 701 | main.log.report(' Tcp-to-feature-reply Avg: ' + |
| 702 | str(tcpToFeatureAvg) + ' ms') |
| 703 | main.log.report(' Tcp-to-feature-reply Std dev: '+ |
| 704 | str(tcpToFeatureStdDev) + ' ms') |
| 705 | |
| 706 | main.log.report(' Feature-reply-to-role-request Avg: ' + |
| 707 | str(featureToRoleAvg) + ' ms') |
| 708 | main.log.report(' Feature-reply-to-role-request Std Dev: ' + |
| 709 | str(featureToRoleStdDev) + ' ms') |
| 710 | |
| 711 | main.log.report(' Role-request-to-role-reply Avg: ' + |
| 712 | str(roleToOfpAvg) +' ms') |
| 713 | main.log.report(' Role-request-to-role-reply Std dev: ' + |
| 714 | str(roleToOfpStdDev) + ' ms') |
| 715 | |
| 716 | main.log.report(' Role-reply-to-device Avg: ' + |
| 717 | str(ofpToDeviceAvg) +' ms') |
| 718 | main.log.report(' Role-reply-to-device Std dev: ' + |
| 719 | str(ofpToDeviceStdDev) + ' ms') |
| 720 | |
| 721 | main.log.report(' Device-to-graph Avg: ' + |
| 722 | str(deviceToGraphAvg) + ' ms') |
| 723 | main.log.report( 'Device-to-graph Std dev: ' + |
| 724 | str(deviceToGraphStdDev) + ' ms') |
| 725 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 726 | main.log.report(' - Switch Disconnection Statistics - ') |
andrew@onlab.us | 9210ba1 | 2015-04-09 14:11:27 -0400 | [diff] [blame] | 727 | main.log.report(' End-to-end switch disconnect Avg: ' + |
| 728 | str(endToEndDiscAvg) + ' ms') |
| 729 | main.log.report(' End-to-end switch disconnect Std dev: ' + |
| 730 | str(endToEndDiscStdDev) + ' ms') |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 731 | main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms') |
| 732 | main.log.report(' Fin/Ack-to-Ack Std dev: ' + |
| 733 | str(finAckStdDev) + ' ms') |
| 734 | |
| 735 | main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) + |
| 736 | ' ms') |
| 737 | main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) + |
| 738 | ' ms') |
| 739 | |
| 740 | main.log.report(' Device-to-graph (disconnect) Avg: ' + |
| 741 | str(deviceToGraphDiscAvg) + ' ms') |
| 742 | main.log.report(' Device-to-graph (disconnect) Std dev: ' + |
| 743 | str(deviceToGraphDiscStdDev) + ' ms') |
| 744 | |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 745 | # For database schema, refer to Amazon web services |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 746 | dbCmdList.append( |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 747 | "INSERT INTO switch_latency_details VALUES('" + |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 748 | timeToPost + "','switch_latency_results'," + |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 749 | jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" + |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 750 | str(node + 1) + "'," + |
| 751 | str(endToEndAvg) + ',' + |
| 752 | str(tcpToFeatureAvg) + ',' + |
| 753 | str(featureToRoleAvg) + ',' + |
| 754 | str(roleToOfpAvg) + ',' + |
| 755 | str(ofpToDeviceAvg) + ',' + |
| 756 | str(deviceToGraphAvg) + ',' + |
| 757 | str(endToEndDiscAvg) + ',' + |
| 758 | str(finAckAvg) + ',' + |
| 759 | str(ackToDeviceAvg) + ',' + |
| 760 | str(deviceToGraphDiscAvg) + |
| 761 | ');') |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 762 | |
| 763 | if debugMode == 'on': |
| 764 | main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log', |
| 765 | '/tmp/', copyFileName='sw_lat_karaf') |
| 766 | fResult = open(resultPath, 'a') |
| 767 | for line in dbCmdList: |
| 768 | if line: |
| 769 | fResult.write(line + '\n') |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 770 | fResult.close() |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 771 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 772 | assertion = main.TRUE |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 773 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 774 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 775 | onpass='Switch latency test successful', |
| 776 | onfail='Switch latency test failed') |
| 777 | |
| 778 | def CASE3(self, main): |
| 779 | """ |
| 780 | Bring port up / down and measure latency. |
| 781 | Port enable / disable is simulated by ifconfig up / down |
| 782 | |
| 783 | In ONOS-next, we must ensure that the port we are |
| 784 | manipulating is connected to another switch with a valid |
| 785 | connection. Otherwise, graph view will not be updated. |
| 786 | """ |
| 787 | global timeToPost |
| 788 | import time |
| 789 | import subprocess |
| 790 | import os |
| 791 | import requests |
| 792 | import json |
| 793 | import numpy |
| 794 | ONOS1Ip = main.params['CTRL']['ip1'] |
| 795 | ONOS2Ip = main.params['CTRL']['ip2'] |
| 796 | ONOS3Ip = main.params['CTRL']['ip3'] |
| 797 | ONOSUser = main.params['CTRL']['user'] |
| 798 | defaultSwPort = main.params['CTRL']['port1'] |
| 799 | assertion = main.TRUE |
| 800 | numIter = main.params['TEST']['numIter'] |
| 801 | iterIgnore = int(main.params['TEST']['iterIgnore']) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 802 | |
| 803 | deviceTimestampKey = main.params['JSON']['deviceTimestamp'] |
| 804 | graphTimestampKey = main.params['JSON']['graphTimestamp'] |
| 805 | linkTimestampKey = main.params['JSON']['linkTimestamp'] |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 806 | |
| 807 | tsharkPortUp = '/tmp/tshark_port_up.txt' |
| 808 | tsharkPortDown = '/tmp/tshark_port_down.txt' |
| 809 | tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ] |
| 810 | |
| 811 | debugMode = main.params['TEST']['debugMode'] |
| 812 | postToDB = main.params['DB']['postToDB'] |
| 813 | resultPath = main.params['DB']['portEventResultPath'] |
| 814 | timeToPost = time.strftime('%Y-%m-%d %H:%M:%S') |
| 815 | localTime = time.strftime('%x %X') |
| 816 | localTime = localTime.replace('/', '') |
| 817 | localTime = localTime.replace(' ', '_') |
| 818 | localTime = localTime.replace(':', '') |
| 819 | |
| 820 | if debugMode == 'on': |
| 821 | main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime) |
| 822 | |
| 823 | upThresholdStr = main.params['TEST']['portUpThreshold'] |
| 824 | downThresholdStr = main.params['TEST']['portDownThreshold'] |
| 825 | upThresholdObj = upThresholdStr.split(',') |
| 826 | downThresholdObj = downThresholdStr.split(',') |
| 827 | upThresholdMin = int(upThresholdObj[0]) |
| 828 | upThresholdMax = int(upThresholdObj[1]) |
| 829 | downThresholdMin = int(downThresholdObj[0]) |
| 830 | downThresholdMax = int(downThresholdObj[1]) |
| 831 | |
| 832 | interfaceConfig = 's1-eth1' |
| 833 | main.log.report('Port enable / disable latency') |
| 834 | main.log.report('Simulated by ifconfig up / down') |
| 835 | main.log.report('Total iterations of test: ' + str(numIter)) |
| 836 | main.step('Assign switches s1 and s2 to controller 1') |
| 837 | |
| 838 | main.Mininet1.assignSwController(sw='1', |
| 839 | ip1=ONOS1Ip, port1=defaultSwPort) |
| 840 | main.Mininet1.assignSwController(sw='2', |
| 841 | ip1=ONOS1Ip, port1=defaultSwPort) |
| 842 | |
| 843 | time.sleep(15) |
| 844 | |
| 845 | portUpDeviceToOfpList = [] |
| 846 | portUpGraphToOfpList = [] |
| 847 | portDownDeviceToOfpList = [] |
| 848 | portDownGraphToOfpList = [] |
| 849 | |
| 850 | portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 851 | portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 852 | portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 853 | portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 854 | portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 855 | portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 856 | portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 857 | |
| 858 | for i in range(0, int(numIter)): |
| 859 | main.step('Starting wireshark capture for port status down') |
| 860 | main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 861 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 862 | time.sleep(5) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 863 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 864 | main.step('Disable port: ' + interfaceConfig) |
| 865 | main.Mininet1.handle.sendline('sh ifconfig ' + |
| 866 | interfaceConfig + ' down') |
| 867 | main.Mininet1.handle.expect('mininet>') |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 868 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 869 | time.sleep(3) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 870 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 871 | main.ONOS1.tsharkStop() |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 872 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 873 | os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' + |
| 874 | tsharkPortDown + ' /tmp/') |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 875 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 876 | fPortDown = open(tsharkPortDown, 'r') |
| 877 | fLine = fPortDown.readline() |
| 878 | objDown = fLine.split(' ') |
| 879 | if len(fLine) > 0: |
| 880 | timestampBeginPtDown = int(float(objDown[1]) * 1000) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 881 | # At times, tshark reports timestamp at the 3rd |
| 882 | # index of the array. If initial readings were |
| 883 | # unlike the epoch timestamp, then check the 3rd |
| 884 | # index and set that as a timestamp |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 885 | if timestampBeginPtDown < 1400000000000: |
| 886 | timestampBeginPtDown = int(float(objDown[2]) * 1000) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 887 | # If there are any suspicion of invalid results |
| 888 | # check this reported value |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 889 | main.log.info('Port down begin timestamp: ' + |
| 890 | str(timestampBeginPtDown)) |
| 891 | else: |
| 892 | main.log.info('Tshark output file returned unexpected' + |
| 893 | ' results: ' + str(objDown)) |
| 894 | timestampBeginPtDown = 0 |
| 895 | fPortDown.close() |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 896 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 897 | for node in range(0, clusterCount): |
| 898 | nodeNum = node+1 |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 899 | metricsDown = CLIs[node].topologyEventsMetrics |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 900 | jsonStrDown = metricsDown() |
| 901 | jsonObj = json.loads(jsonStrDown) |
| 902 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 903 | if jsonObj: |
| 904 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 905 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 906 | linkTimestamp = jsonObj[linkTimestampKey]['value'] |
| 907 | else: |
| 908 | main.log.error( "Unexpected json object" ) |
| 909 | graphTimestamp = 0 |
| 910 | deviceTimestamp = 0 |
| 911 | linkTimestamp = 0 |
| 912 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 913 | ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown) |
| 914 | ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown) |
| 915 | ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown) |
| 916 | |
| 917 | if ptDownGraphToOfp > downThresholdMin and\ |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 918 | ptDownGraphToOfp < downThresholdMax and i >= iterIgnore: |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 919 | portDownGraphNodeIter[node][i] = ptDownGraphToOfp |
| 920 | main.log.info("ONOS "+str(nodeNum)+ |
| 921 | " port down graph-to-ofp: "+ |
| 922 | str(ptDownGraphToOfp) + " ms") |
| 923 | else: |
| 924 | main.log.info("ONOS "+str(nodeNum)+ |
| 925 | " port down graph-to-ofp ignored"+ |
| 926 | " due to excess in threshold or premature iteration") |
| 927 | |
| 928 | if ptDownDeviceToOfp > downThresholdMin and\ |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 929 | ptDownDeviceToOfp < downThresholdMax and i >= iterIgnore: |
| 930 | portDownDevNodeIter[node][i] = ptDownDeviceToOfp |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 931 | main.log.info("ONOS "+str(nodeNum)+ |
| 932 | " port down device-to-ofp: "+ |
| 933 | str(ptDownDeviceToOfp) + " ms") |
| 934 | else: |
| 935 | main.log.info("ONOS "+str(nodeNum)+ |
| 936 | " port down device-to-ofp ignored"+ |
| 937 | " due to excess in threshold or premature iteration") |
| 938 | |
| 939 | if ptDownLinkToOfp > downThresholdMin and\ |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 940 | ptDownLinkToOfp < downThresholdMax and i >= iterIgnore: |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 941 | portDownLinkNodeIter[node][i] = ptDownLinkToOfp |
| 942 | main.log.info("ONOS "+str(nodeNum)+ |
| 943 | " port down link-to-ofp: "+ |
| 944 | str(ptDownLinkToOfp) + " ms") |
| 945 | else: |
| 946 | main.log.info("ONOS "+str(nodeNum)+ |
| 947 | " port down link-to-ofp ignored"+ |
| 948 | " due to excess in threshold or premature iteration") |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 949 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 950 | time.sleep(3) |
| 951 | |
| 952 | main.step('Starting wireshark capture for port status up') |
| 953 | main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp) |
| 954 | |
| 955 | time.sleep(5) |
| 956 | main.step('Enable port and obtain timestamp') |
| 957 | main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up') |
| 958 | main.Mininet1.handle.expect('mininet>') |
| 959 | |
| 960 | time.sleep(5) |
| 961 | main.ONOS1.tsharkStop() |
| 962 | |
| 963 | time.sleep(3) |
| 964 | os.system('scp ' + ONOSUser + '@' + |
| 965 | ONOS1Ip + ':' + tsharkPortUp + ' /tmp/') |
| 966 | |
| 967 | fPortUp = open(tsharkPortUp, 'r') |
| 968 | fLine = fPortUp.readline() |
| 969 | objUp = fLine.split(' ') |
| 970 | if len(fLine) > 0: |
| 971 | timestampBeginPtUp = int(float(objUp[1]) * 1000) |
| 972 | if timestampBeginPtUp < 1400000000000: |
| 973 | timestampBeginPtUp = int(float(objUp[2]) * 1000) |
| 974 | main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp)) |
| 975 | else: |
| 976 | main.log.info('Tshark output file returned unexpected' + ' results.') |
| 977 | timestampBeginPtUp = 0 |
| 978 | fPortUp.close() |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 979 | |
| 980 | for node in range(0, clusterCount): |
| 981 | nodeNum = node+1 |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 982 | metricsUp = CLIs[node].topologyEventsMetrics |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 983 | jsonStrUp = metricsUp() |
| 984 | jsonObj = json.loads(jsonStrUp) |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 985 | |
| 986 | if jsonObj: |
| 987 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 988 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 989 | linkTimestamp = jsonObj[linkTimestampKey]['value'] |
| 990 | else: |
| 991 | main.log.error( "Unexpected json object" ) |
| 992 | graphTimestamp = 0 |
| 993 | deviceTimestamp = 0 |
| 994 | linkTimestamp = 0 |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 995 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 996 | ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp) |
| 997 | ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp) |
| 998 | ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp) |
| 999 | |
| 1000 | if ptUpGraphToOfp > upThresholdMin and\ |
| 1001 | ptUpGraphToOfp < upThresholdMax and i > iterIgnore: |
| 1002 | portUpGraphNodeIter[node][i] = ptUpGraphToOfp |
| 1003 | main.log.info("ONOS "+str(nodeNum)+ |
| 1004 | " port up graph-to-ofp: "+ |
| 1005 | str(ptUpGraphToOfp) + " ms") |
| 1006 | else: |
| 1007 | main.log.info("ONOS "+str(nodeNum)+ |
| 1008 | " port up graph-to-ofp ignored"+ |
| 1009 | " due to excess in threshold or premature iteration") |
| 1010 | |
| 1011 | if ptUpDeviceToOfp > upThresholdMin and\ |
| 1012 | ptUpDeviceToOfp < upThresholdMax and i > iterIgnore: |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 1013 | portUpDevNodeIter[node][i] = ptUpDeviceToOfp |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1014 | main.log.info("ONOS "+str(nodeNum)+ |
| 1015 | " port up device-to-ofp: "+ |
| 1016 | str(ptUpDeviceToOfp) + " ms") |
| 1017 | else: |
| 1018 | main.log.info("ONOS "+str(nodeNum)+ |
| 1019 | " port up device-to-ofp ignored"+ |
| 1020 | " due to excess in threshold or premature iteration") |
| 1021 | |
| 1022 | if ptUpLinkToOfp > upThresholdMin and\ |
| 1023 | ptUpLinkToOfp < upThresholdMax and i > iterIgnore: |
| 1024 | portUpLinkNodeIter[node][i] = ptUpLinkToOfp |
| 1025 | main.log.info("ONOS "+str(nodeNum)+ |
| 1026 | " port up link-to-ofp: "+ |
| 1027 | str(ptUpLinkToOfp) + " ms") |
| 1028 | else: |
| 1029 | main.log.info("ONOS "+str(nodeNum)+ |
| 1030 | " port up link-to-ofp ignored"+ |
| 1031 | " due to excess in threshold or premature iteration") |
| 1032 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1033 | dbCmdList = [] |
| 1034 | for node in range(0, clusterCount): |
| 1035 | portUpDevList = [] |
| 1036 | portUpGraphList = [] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1037 | portUpLinkList = [] |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1038 | portDownDevList = [] |
| 1039 | portDownGraphList = [] |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1040 | portDownLinkList = [] |
| 1041 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1042 | portUpDevAvg = 0 |
| 1043 | portUpGraphAvg = 0 |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1044 | portUpLinkAvg = 0 |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1045 | portDownDevAvg = 0 |
| 1046 | portDownGraphAvg = 0 |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1047 | portDownLinkAvg = 0 |
| 1048 | |
andrew@onlab.us | aa1f0dc | 2015-04-10 12:18:01 -0400 | [diff] [blame^] | 1049 | # TODO: Update for more pythonic way to get list |
| 1050 | # portUpDevList = [item for item in portUpDevNodeIter[node] |
| 1051 | # if item > 0.0] |
| 1052 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1053 | for item in portUpDevNodeIter[node]: |
| 1054 | if item > 0.0: |
| 1055 | portUpDevList.append(item) |
| 1056 | |
| 1057 | for item in portUpGraphNodeIter[node]: |
| 1058 | if item > 0.0: |
| 1059 | portUpGraphList.append(item) |
| 1060 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1061 | for item in portUpLinkNodeIter[node]: |
| 1062 | if item > 0.0: |
| 1063 | portUpLinkList.append(item) |
| 1064 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1065 | for item in portDownDevNodeIter[node]: |
| 1066 | if item > 0.0: |
| 1067 | portDownDevList.append(item) |
| 1068 | |
| 1069 | for item in portDownGraphNodeIter[node]: |
| 1070 | if item > 0.0: |
| 1071 | portDownGraphList.append(item) |
| 1072 | |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1073 | for item in portDownLinkNodeIter[node]: |
| 1074 | if item > 0.0: |
| 1075 | portDownLinkList.append(item) |
| 1076 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1077 | portUpDevAvg = round(numpy.mean(portUpDevList), 2) |
| 1078 | portUpGraphAvg = round(numpy.mean(portUpGraphList), 2) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1079 | portUpLinkAvg = round(numpy.mean(portUpLinkList), 2) |
| 1080 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1081 | portDownDevAvg = round(numpy.mean(portDownDevList), 2) |
| 1082 | portDownGraphAvg = round(numpy.mean(portDownGraphList), 2) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1083 | portDownLinkAvg = round(numpy.mean(portDownLinkList), 2) |
| 1084 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1085 | portUpStdDev = round(numpy.std(portUpGraphList), 2) |
| 1086 | portDownStdDev = round(numpy.std(portDownGraphList), 2) |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1087 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1088 | main.log.report(' - Node ' + str(node + 1) + ' Summary - ') |
| 1089 | main.log.report(' Port up ofp-to-device ' + |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1090 | str(portUpDevAvg) + ' ms') |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1091 | main.log.report(' Port up ofp-to-graph ' + |
| 1092 | str(portUpGraphAvg) + ' ms') |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1093 | main.log.report(' Port up ofp-to-link ' + |
| 1094 | str(portUpLinkAvg) + ' ms') |
| 1095 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1096 | main.log.report(' Port down ofp-to-device ' + |
| 1097 | str(round(portDownDevAvg, 2)) + ' ms') |
| 1098 | main.log.report(' Port down ofp-to-graph ' + |
| 1099 | str(portDownGraphAvg) + ' ms') |
jenkins | 8ba10ab | 2015-03-24 10:31:31 -0700 | [diff] [blame] | 1100 | main.log.report(' Port down ofp-to-link ' + |
| 1101 | str(portDownLinkAvg) + ' ms') |
| 1102 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1103 | dbCmdList.append("INSERT INTO port_latency_tests VALUES('" + |
andrew@onlab.us | 09a4a0c | 2015-04-09 13:38:13 -0400 | [diff] [blame] | 1104 | timeToPost + "','port_latency_results'," + jenkinsBuildNumber + |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1105 | ',' + str(clusterCount) + ",'baremetal" + str(node + 1) + |
| 1106 | "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) + |
| 1107 | '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');') |
| 1108 | |
| 1109 | fResult = open(resultPath, 'a') |
| 1110 | for line in dbCmdList: |
| 1111 | if line: |
| 1112 | fResult.write(line + '\n') |
| 1113 | |
| 1114 | fResult.close() |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 1115 | |
| 1116 | # Delete switches from controller to prepare for next |
| 1117 | # set of tests |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1118 | main.Mininet1.deleteSwController('s1') |
| 1119 | main.Mininet1.deleteSwController('s2') |
| 1120 | utilities.assert_equals(expect=main.TRUE, |
| 1121 | actual=assertion, |
| 1122 | onpass='Port discovery latency calculation successful', |
| 1123 | onfail='Port discovery test failed') |
| 1124 | |
| 1125 | def CASE4(self, main): |
| 1126 | """ |
| 1127 | Increase number of nodes and initiate CLI |
| 1128 | |
| 1129 | With the most recent implementation, we need a method to |
| 1130 | ensure all ONOS nodes are killed, as well as redefine |
| 1131 | the cell files to ensure all nodes that will be used |
| 1132 | is in the cell file. Otherwise, exceptions will |
| 1133 | prohibit test from running successfully. |
| 1134 | |
| 1135 | 3/12/15 |
| 1136 | |
| 1137 | """ |
| 1138 | global clusterCount |
| 1139 | import time |
| 1140 | import os |
| 1141 | |
| 1142 | clusterCount += 2 |
| 1143 | |
| 1144 | benchIp = main.params[ 'BENCH' ][ 'ip' ] |
| 1145 | features = main.params[ 'ENV' ][ 'cellFeatures' ] |
| 1146 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1147 | mininetIp = main.params[ 'MN' ][ 'ip1' ] |
| 1148 | |
| 1149 | main.log.report('Increasing cluster size to ' + str(clusterCount)) |
| 1150 | |
| 1151 | main.log.step( "Killing all ONOS processes before scale-out" ) |
| 1152 | |
| 1153 | for i in range( 1, 8 ): |
| 1154 | main.ONOSbench.onosDie( |
| 1155 | main.params[ 'CTRL' ][ 'ip'+str(i) ] ) |
| 1156 | main.ONOSbench.onosUninstall( |
| 1157 | main.params[ 'CTRL' ][ 'ip'+str(i) ] ) |
| 1158 | |
| 1159 | main.step( "Creating scale-out cell file" ) |
| 1160 | cellIp = [] |
| 1161 | for node in range( 1, clusterCount + 1 ): |
| 1162 | cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] ) |
| 1163 | |
| 1164 | main.log.info( "Cell Ip list: " + str(cellIp) ) |
| 1165 | main.ONOSbench.createCellFile( benchIp, cellName, mininetIp, |
| 1166 | str(features), *cellIp ) |
| 1167 | |
| 1168 | main.step( "Setting cell definition" ) |
| 1169 | main.ONOSbench.setCell(cellName) |
| 1170 | |
| 1171 | main.step( "Packaging cell definition" ) |
| 1172 | main.ONOSbench.onosPackage() |
| 1173 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1174 | for node in range( 1, clusterCount + 1 ): |
jenkins | ac38ab7 | 2015-03-13 11:24:10 -0700 | [diff] [blame] | 1175 | main.ONOSbench.onosInstall( |
| 1176 | node = main.params[ 'CTRL' ][ 'ip'+str(node) ]) |
| 1177 | |
| 1178 | time.sleep( 20 ) |
| 1179 | |
jenkins | 7ead5a8 | 2015-03-13 10:28:21 -0700 | [diff] [blame] | 1180 | for node in range( 1, clusterCount + 1): |
| 1181 | for i in range( 2 ): |
| 1182 | isup = main.ONOSbench.isup( |
| 1183 | main.params[ 'CTRL' ][ 'ip'+str(node) ] ) |
| 1184 | if isup: |
| 1185 | main.log.info( "ONOS "+str(node) + " is up\n") |
| 1186 | break |
| 1187 | if not isup: |
| 1188 | main.log.error( "ONOS "+str(node) + " did not start" ) |
jenkins | ac38ab7 | 2015-03-13 11:24:10 -0700 | [diff] [blame] | 1189 | |
andrew@onlab.us | b4cb2b8 | 2015-04-03 14:06:09 -0400 | [diff] [blame] | 1190 | for node in range( 0, clusterCount ): |
| 1191 | CLIs[node].startOnosCli( cellIp[node] ) |
| 1192 | |
| 1193 | main.step( 'Setting configurations for metrics' ) |
| 1194 | configParam = 'maxEvents 1' |
| 1195 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1196 | configParam = 'maxBatchMs 0' |
| 1197 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1198 | configParam = 'maxIdleMs 0' |
| 1199 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1200 | |
| 1201 | main.step( 'Activating essential applications' ) |
| 1202 | CLIs[0].activateApp( 'org.onosproject.metrics' ) |
| 1203 | CLIs[0].activateApp( 'org.onosproject.openflow' ) |
jenkins | ac38ab7 | 2015-03-13 11:24:10 -0700 | [diff] [blame] | 1204 | |