jenkins | ef9115b | 2015-05-15 09:52:22 -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 |
| 20 | global jenkinsBuildNumber |
| 21 | |
| 22 | import time |
| 23 | import os |
| 24 | |
| 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'] |
| 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 0 instead, ensuring that |
| 43 | # the DB post will recognize it as a non-jenkins run |
| 44 | jenkinsBuildNumber = str(0) |
| 45 | main.log.info( 'Job is not run by jenkins. '+ |
| 46 | 'Build number set to: ' + jenkinsBuildNumber) |
| 47 | |
| 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 | |
| 59 | MN1Ip = main.params['MN']['ip1'] |
| 60 | BENCHIp = main.params['BENCH']['ip'] |
| 61 | cellFeatures = main.params['ENV']['cellFeatures'] |
| 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') |
| 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('\\$') |
| 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') |
| 84 | # Nodes 2 ~ 7 |
| 85 | for i in range( 1, 7 ): |
| 86 | main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i]) |
| 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 | |
| 97 | main.step('Creating cell file') |
| 98 | cellFileResult = main.ONOSbench.createCellFile( |
| 99 | BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0]) |
| 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') |
| 123 | CLIs[0].setCell(cellName) |
| 124 | |
| 125 | main.step('Creating ONOS package') |
| 126 | packageResult = main.ONOSbench.onosPackage() |
| 127 | |
| 128 | main.step('Installing ONOS package') |
| 129 | install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0]) |
| 130 | |
| 131 | time.sleep(10) |
| 132 | |
| 133 | main.step('Start onos cli') |
| 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' ) |
| 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 | |
| 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 | """ |
| 160 | Assign s3 to ONOS1 and measure latency |
| 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 |
| 181 | |
| 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']) |
| 186 | |
| 187 | deviceTimestampKey = main.params['JSON']['deviceTimestamp'] |
| 188 | graphTimestampKey = main.params['JSON']['graphTimestamp'] |
| 189 | |
| 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(',') |
| 195 | thresholdMin = int(thresholdObj[0]) |
| 196 | thresholdMax = int(thresholdObj[1]) |
| 197 | |
| 198 | # Look for 'role-request' messages, |
| 199 | # which replaces the 'vendor' messages previously seen |
| 200 | # on OVS 2.0.1 |
| 201 | tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ] |
| 202 | tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ] |
| 203 | tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ] |
| 204 | tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ] |
| 205 | tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ] |
| 206 | |
| 207 | tsharkOfOutput = '/tmp/tshark_of_topo.txt' |
| 208 | tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt' |
| 209 | tsharkRoleOutput = '/tmp/tshark_role_request.txt' |
| 210 | tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt' |
| 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))) |
| 228 | endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 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))) |
| 240 | endToEndDiscLatNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 241 | |
| 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) |
| 261 | main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput) |
| 262 | main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput) |
| 263 | |
| 264 | time.sleep(10) |
| 265 | |
| 266 | main.log.info('Assigning s3 to controller') |
| 267 | main.Mininet1.assignSwController(sw='3', |
| 268 | ip1=nodeIpList[0], port1=defaultSwPort) |
| 269 | |
| 270 | jsonStr = [] |
| 271 | for node in range (0, clusterCount): |
| 272 | metricsSwUp = CLIs[node].topologyEventsMetrics() |
| 273 | jsonStr.append(metricsSwUp) |
| 274 | |
| 275 | main.log.info('Stopping all Tshark processes') |
| 276 | main.ONOS1.tsharkStop() |
| 277 | |
| 278 | time.sleep(5) |
| 279 | |
| 280 | main.log.info('Copying over tshark files') |
| 281 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
| 282 | ':' + tsharkTcpOutput + ' /tmp/') |
| 283 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
| 284 | ':' + tsharkRoleOutput + ' /tmp/') |
| 285 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
| 286 | ':' + tsharkFeatureOutput + ' /tmp/') |
| 287 | os.system('scp ' + ONOSUser + '@' + |
| 288 | nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/') |
| 289 | |
| 290 | # Get tcp syn / ack output |
| 291 | time.sleep(1) |
| 292 | |
| 293 | tcpFile = open(tsharkTcpOutput, 'r') |
| 294 | tempText = tcpFile.readline() |
| 295 | tempText = tempText.split(' ') |
| 296 | main.log.info('Object read in from TCP capture: ' + |
| 297 | str(tempText)) |
| 298 | |
| 299 | if len(tempText) > 1: |
| 300 | t0Tcp = float(tempText[1]) * 1000.0 |
| 301 | else: |
| 302 | main.log.error('Tshark output file for TCP' + |
| 303 | ' returned unexpected results') |
| 304 | t0Tcp = 0 |
| 305 | assertion = main.FALSE |
| 306 | tcpFile.close() |
| 307 | |
| 308 | # Get Role reply output |
| 309 | ofFile = open(tsharkOfOutput, 'r') |
| 310 | lineOfp = '' |
| 311 | while True: |
| 312 | tempText = ofFile.readline() |
| 313 | if tempText != '': |
| 314 | lineOfp = tempText |
| 315 | else: |
| 316 | break |
| 317 | obj = lineOfp.split(' ') |
| 318 | main.log.info('Object read in from OFP capture: ' + |
| 319 | str(lineOfp)) |
| 320 | if len(obj) > 1: |
| 321 | t0Ofp = float(obj[1]) * 1000.0 |
| 322 | else: |
| 323 | main.log.error('Tshark output file for OFP' + |
| 324 | ' returned unexpected results') |
| 325 | t0Ofp = 0 |
| 326 | assertion = main.FALSE |
| 327 | ofFile.close() |
| 328 | |
| 329 | # Get role request output |
| 330 | roleFile = open(tsharkRoleOutput, 'r') |
| 331 | tempText = roleFile.readline() |
| 332 | tempText = tempText.split(' ') |
| 333 | if len(tempText) > 1: |
| 334 | main.log.info('Object read in from role request capture:' + |
| 335 | str(tempText)) |
| 336 | roleTimestamp = float(tempText[1]) * 1000.0 |
| 337 | else: |
| 338 | main.log.error('Tshark output file for role request' + |
| 339 | ' returned unexpected results') |
| 340 | timeRoleRequest = 0 |
| 341 | assertion = main.FALSE |
| 342 | roleFile.close() |
| 343 | |
| 344 | # Get feature reply output |
| 345 | featureFile = open(tsharkFeatureOutput, 'r') |
| 346 | tempText = featureFile.readline() |
| 347 | tempText = tempText.split(' ') |
| 348 | if len(tempText) > 1: |
| 349 | main.log.info('Object read in from feature reply capture: '+ |
| 350 | str(tempText)) |
| 351 | if tempText[1] != ' ' and float(tempText[1]) > 1400000000.0: |
| 352 | temp = tempText[1] |
| 353 | elif tempText[2] != ' ' and float(tempText[2]) > 1400000000.0: |
| 354 | temp = tempText[2] |
| 355 | else: |
| 356 | temp = 0 |
| 357 | featureTimestamp = float(temp) * 1000.0 |
| 358 | else: |
| 359 | main.log.error('Tshark output file for feature reply' + |
| 360 | ' returned unexpected results') |
| 361 | timeFeatureReply = 0 |
| 362 | assertion = main.FALSE |
| 363 | featureFile.close() |
| 364 | |
| 365 | for node in range(0, clusterCount): |
| 366 | nodeNum = node+1 |
| 367 | #metricsSwUp = CLIs[node].topologyEventsMetrics |
| 368 | #jsonStr = metricsSwUp() |
| 369 | jsonObj = json.loads(jsonStr[node]) |
| 370 | if jsonObj: |
| 371 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 372 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 373 | else: |
| 374 | main.log.error( "Unexpected JSON object" ) |
| 375 | # If we could not obtain the JSON object, |
| 376 | # set the timestamps to 0, which will be |
| 377 | # excluded from the measurement later on |
| 378 | # (realized as invalid) |
| 379 | graphTimestamp = 0 |
| 380 | deviceTimestamp = 0 |
| 381 | |
| 382 | endToEnd = int(graphTimestamp) - int(t0Tcp) |
| 383 | |
| 384 | # Below are measurement breakdowns of the end-to-end |
| 385 | # measurement. |
| 386 | tcpToFeature = int(featureTimestamp) - int(t0Tcp) |
| 387 | featureToRole = int(roleTimestamp) - int(featureTimestamp) |
| 388 | roleToOfp = float(t0Ofp) - float(roleTimestamp) |
| 389 | ofpToDevice = float(deviceTimestamp) - float(t0Ofp) |
| 390 | # Timestamps gathered from ONOS are millisecond |
| 391 | # precision. They are returned as integers, thus no |
| 392 | # need to be more precise than 'int'. However, |
| 393 | # the processing seems to be mostly under 1 ms, |
| 394 | # thus this may be a problem point to handle any |
| 395 | # submillisecond output that we are unsure of. |
| 396 | # For now, this will be treated as 0 ms if less than 1 ms |
| 397 | deviceToGraph = int(graphTimestamp) - int(deviceTimestamp) |
| 398 | |
| 399 | if endToEnd >= thresholdMin and\ |
| 400 | endToEnd < thresholdMax and i >= iterIgnore: |
| 401 | endToEndLatNodeIter[node][i] = endToEnd |
| 402 | main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+ |
| 403 | str(endToEnd) + " ms") |
| 404 | else: |
| 405 | main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+ |
| 406 | "measurement ignored due to excess in "+ |
| 407 | "threshold or premature iteration: ") |
| 408 | main.log.info(str(endToEnd)) |
| 409 | |
| 410 | if tcpToFeature >= thresholdMin and\ |
| 411 | tcpToFeature < thresholdMax and i >= iterIgnore: |
| 412 | tcpToFeatureLatNodeIter[node][i] = tcpToFeature |
| 413 | main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+ |
| 414 | str(tcpToFeature) + " ms") |
| 415 | else: |
| 416 | main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+ |
| 417 | "measurement ignored due to excess in "+ |
| 418 | "threshold or premature iteration: ") |
| 419 | main.log.info(str(tcpToFeature)) |
| 420 | |
| 421 | if featureToRole >= thresholdMin and\ |
| 422 | featureToRole < thresholdMax and i >= iterIgnore: |
| 423 | featureToRoleRequestLatNodeIter[node][i] = featureToRole |
| 424 | main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+ |
| 425 | str(featureToRole) + " ms") |
| 426 | else: |
| 427 | main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+ |
| 428 | "measurement ignored due to excess in "+ |
| 429 | "threshold or premature iteration: ") |
| 430 | main.log.info(str(featureToRole)) |
| 431 | |
| 432 | if roleToOfp >= thresholdMin and\ |
| 433 | roleToOfp < thresholdMax and i >= iterIgnore: |
| 434 | roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp |
| 435 | main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+ |
| 436 | str(roleToOfp) + " ms") |
| 437 | else: |
| 438 | main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+ |
| 439 | "measurement ignored due to excess in "+ |
| 440 | "threshold or premature iteration: ") |
| 441 | main.log.info(str(roleToOfp)) |
| 442 | |
| 443 | if ofpToDevice >= thresholdMin and\ |
| 444 | ofpToDevice < thresholdMax and i >= iterIgnore: |
| 445 | roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice |
| 446 | main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+ |
| 447 | str(ofpToDevice) + " ms") |
| 448 | else: |
| 449 | main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+ |
| 450 | "measurement ignored due to excess in "+ |
| 451 | "threshold or premature iteration: ") |
| 452 | main.log.info(str(ofpToDevice)) |
| 453 | |
| 454 | if deviceToGraph >= thresholdMin and\ |
| 455 | deviceToGraph < thresholdMax and i >= iterIgnore: |
| 456 | deviceToGraphLatNodeIter[node][i] = deviceToGraph |
| 457 | main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+ |
| 458 | str(deviceToGraph) + " ms") |
| 459 | else: |
| 460 | if deviceToGraph == 0: |
| 461 | deviceToGraphLatNodeIter[node][i] = 0 |
| 462 | main.log.info("ONOS "+str(nodeNum) + |
| 463 | " device-to-graph measurement "+ |
| 464 | "was set to 0 ms because of precision "+ |
| 465 | "uncertainty. ") |
| 466 | else: |
| 467 | main.log.info("ONOS "+str(nodeNum)+ |
| 468 | " device-to-graph "+ |
| 469 | "measurement ignored due to excess in "+ |
| 470 | "threshold or premature iteration: ") |
| 471 | main.log.info(str(deviceToGraph)) |
| 472 | |
| 473 | # ******************** |
| 474 | time.sleep(5) |
| 475 | |
| 476 | # Get device id to remove |
| 477 | deviceIdJsonStr = main.ONOS1cli.devices() |
| 478 | |
| 479 | main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) ) |
| 480 | deviceId = json.loads(deviceIdJsonStr) |
| 481 | |
| 482 | deviceList = [] |
| 483 | for device in deviceId: |
| 484 | deviceList.append(device['id']) |
| 485 | |
| 486 | # Measure switch down metrics |
| 487 | # TCP FIN/ACK -> TCP FIN |
| 488 | # TCP FIN -> Device Event |
| 489 | # Device Event -> Graph Event |
| 490 | # Capture switch down FIN / ACK packets |
| 491 | |
| 492 | # The -A 1 grep option allows us to grab 1 extra line after the |
| 493 | # last tshark output grepped originally |
| 494 | main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput, |
| 495 | grepOptions = '-A 1' ) |
| 496 | |
| 497 | time.sleep( 5 ) |
| 498 | |
| 499 | removeJsonList = [] |
| 500 | |
| 501 | main.step('Remove switch from controller') |
| 502 | main.Mininet1.deleteSwController('s3') |
| 503 | firstDevice = deviceList[0] |
| 504 | |
| 505 | # We need to get metrics before removing |
| 506 | # device from the store below. |
| 507 | for node in range(0, clusterCount): |
| 508 | metricsSwDown = CLIs[node].topologyEventsMetrics |
| 509 | jsonStr = metricsSwDown() |
| 510 | removeJsonList.append( json.loads(jsonStr) ) |
| 511 | |
| 512 | main.ONOS1.tsharkStop() |
| 513 | |
| 514 | main.log.info( "Removing device " +str(firstDevice)+ |
| 515 | " from ONOS" ) |
| 516 | |
| 517 | #if deviceId: |
| 518 | main.ONOS1cli.deviceRemove(firstDevice) |
| 519 | |
| 520 | main.log.info('Copying over tshark files') |
| 521 | os.system('scp ' + ONOSUser + '@' + nodeIpList[0] + |
| 522 | ':' + tsharkFinAckOutput + ' /tmp/') |
| 523 | |
| 524 | time.sleep( 10 ) |
| 525 | finAckOutputList = [] |
| 526 | with open(tsharkFinAckOutput, 'r') as f: |
| 527 | tempLine = f.readlines() |
| 528 | main.log.info('Object read in from FinAck capture: ' + |
| 529 | "\n".join(tempLine)) |
| 530 | |
| 531 | index = 1 |
| 532 | for line in tempLine: |
| 533 | obj = line.split(' ') |
| 534 | |
| 535 | # There are at least 3 objects in field (valid |
| 536 | # tshark output is lengthy) |
| 537 | if len(obj) > 2: |
| 538 | # If first index of object is like an epoch time |
| 539 | if obj[1] != ' ' and float(obj[1]) > 1400000000.0: |
| 540 | temp = obj[1] |
| 541 | elif obj[2] != ' 'and float(obj[2]) > 1400000000.0: |
| 542 | temp = obj[2] |
| 543 | elif obj[3] != ' 'and float(obj[3]) > 1400000000.0: |
| 544 | temp = obj[3] |
| 545 | else: |
| 546 | temp = 0 |
| 547 | if index == 1: |
| 548 | tFinAck = float(temp) * 1000.0 |
| 549 | elif index == 2: |
| 550 | continue |
| 551 | elif index == 3: |
| 552 | tAck = float(temp) * 1000.0 |
| 553 | else: |
| 554 | tFinAck = 0 |
| 555 | tAck = 0 |
| 556 | else: |
| 557 | main.log.error('Tshark output file for OFP' + |
| 558 | ' returned unexpected results') |
| 559 | tFinAck = 0 |
| 560 | tAck = 0 |
| 561 | assertion = main.FALSE |
| 562 | |
| 563 | index = index+1 |
| 564 | |
| 565 | # with open() as f takes care of closing file |
| 566 | |
| 567 | time.sleep(5) |
| 568 | |
| 569 | for node in range(0, clusterCount): |
| 570 | nodeNum = node+1 |
| 571 | jsonObj = removeJsonList[node] |
| 572 | if jsonObj: |
| 573 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 574 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 575 | main.log.info("Graph timestamp: "+str(graphTimestamp)) |
| 576 | main.log.info("Device timestamp: "+str(deviceTimestamp)) |
| 577 | else: |
| 578 | main.log.error( "Unexpected JSON object" ) |
| 579 | # If we could not obtain the JSON object, |
| 580 | # set the timestamps to 0, which will be |
| 581 | # excluded from the measurement later on |
| 582 | # (realized as invalid) |
| 583 | graphTimestamp = 0 |
| 584 | deviceTimestamp = 0 |
| 585 | |
| 586 | finAckTransaction = float(tAck) - float(tFinAck) |
| 587 | ackToDevice = float(deviceTimestamp) - float(tAck) |
| 588 | deviceToGraph = float(graphTimestamp) - float(deviceTimestamp) |
| 589 | endToEndDisc = int(graphTimestamp) - int(tFinAck) |
| 590 | |
| 591 | if endToEndDisc >= thresholdMin and\ |
| 592 | endToEndDisc < thresholdMax and i >= iterIgnore: |
| 593 | endToEndDiscLatNodeIter[node][i] = endToEndDisc |
| 594 | main.log.info("ONOS "+str(nodeNum) + |
| 595 | "end-to-end disconnection: "+ |
| 596 | str(endToEndDisc) + " ms" ) |
| 597 | else: |
| 598 | main.log.info("ONOS " + str(nodeNum) + |
| 599 | " end-to-end disconnection "+ |
| 600 | "measurement ignored due to excess in "+ |
| 601 | "threshold or premature iteration: ") |
| 602 | main.log.info(str(endToEndDisc)) |
| 603 | |
| 604 | if finAckTransaction >= thresholdMin and\ |
| 605 | finAckTransaction < thresholdMax and i >= iterIgnore: |
| 606 | finAckTransactionLatNodeIter[node][i] = finAckTransaction |
| 607 | main.log.info("ONOS "+str(nodeNum)+ |
| 608 | " fin/ack transaction: "+ |
| 609 | str(finAckTransaction) + " ms") |
| 610 | else: |
| 611 | main.log.info("ONOS "+str(nodeNum)+ |
| 612 | " fin/ack transaction "+ |
| 613 | "measurement ignored due to excess in "+ |
| 614 | "threshold or premature iteration: ") |
| 615 | main.log.info(str(finAckTransaction)) |
| 616 | |
| 617 | if ackToDevice >= thresholdMin and\ |
| 618 | ackToDevice < thresholdMax and i >= iterIgnore: |
| 619 | ackToDeviceLatNodeIter[node][i] = ackToDevice |
| 620 | main.log.info("ONOS "+str(nodeNum)+ |
| 621 | " ack-to-device: "+ |
| 622 | str(ackToDevice) + " ms") |
| 623 | else: |
| 624 | main.log.info("ONOS "+str(nodeNum)+ |
| 625 | " ack-to-device "+ |
| 626 | "measurement ignored due to excess in "+ |
| 627 | "threshold or premature iteration: ") |
| 628 | main.log.info(str(ackToDevice)) |
| 629 | |
| 630 | if deviceToGraph >= thresholdMin and\ |
| 631 | deviceToGraph < thresholdMax and i >= iterIgnore: |
| 632 | deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph |
| 633 | main.log.info("ONOS "+str(nodeNum)+ |
| 634 | " device-to-graph disconnect: "+ |
| 635 | str(deviceToGraph) + " ms") |
| 636 | else: |
| 637 | main.log.info("ONOS "+str(nodeNum)+ |
| 638 | " device-to-graph disconnect "+ |
| 639 | "measurement ignored due to excess in "+ |
| 640 | "threshold or premature iteration: ") |
| 641 | main.log.info(str(deviceToGraph)) |
| 642 | |
| 643 | endToEndAvg = 0 |
| 644 | ofpToGraphAvg = 0 |
| 645 | dbCmdList = [] |
| 646 | for node in range(0, clusterCount): |
| 647 | # List of latency for each node |
| 648 | endToEndList = [] |
| 649 | tcpToFeatureList = [] |
| 650 | featureToRoleList = [] |
| 651 | roleToOfpList = [] |
| 652 | ofpToDeviceList = [] |
| 653 | deviceToGraphList = [] |
| 654 | |
| 655 | finAckTransactionList = [] |
| 656 | ackToDeviceList = [] |
| 657 | deviceToGraphDiscList = [] |
| 658 | endToEndDiscList = [] |
| 659 | |
| 660 | # LatNodeIter 2d arrays contain all iteration latency |
| 661 | # for each node of the current scale cluster size |
| 662 | # Switch connection measurements |
| 663 | # Set further acceptance criteria for measurements |
| 664 | # here if you would like to filter reporting results |
| 665 | for item in endToEndLatNodeIter[node]: |
| 666 | if item > 0.0: |
| 667 | endToEndList.append(item) |
| 668 | |
| 669 | for item in tcpToFeatureLatNodeIter[node]: |
| 670 | if item > 0.0: |
| 671 | tcpToFeatureList.append(item) |
| 672 | |
| 673 | for item in featureToRoleRequestLatNodeIter[node]: |
| 674 | if item > 0.0: |
| 675 | featureToRoleList.append(item) |
| 676 | |
| 677 | for item in roleRequestToRoleReplyLatNodeIter[node]: |
| 678 | if item > 0.0: |
| 679 | roleToOfpList.append(item) |
| 680 | |
| 681 | for item in roleReplyToDeviceLatNodeIter[node]: |
| 682 | if item >= 0.0: |
| 683 | ofpToDeviceList.append(item) |
| 684 | |
| 685 | for item in featureToRoleRequestLatNodeIter[node]: |
| 686 | if item > 0.0: |
| 687 | featureToRoleList.append(item) |
| 688 | |
| 689 | for item in deviceToGraphLatNodeIter[node]: |
| 690 | if item >= 0.0: |
| 691 | deviceToGraphList.append(item) |
| 692 | |
| 693 | # Switch disconnect measurements |
| 694 | for item in endToEndDiscLatNodeIter[node]: |
| 695 | if item > 0.0: |
| 696 | endToEndDiscList.append(item) |
| 697 | |
| 698 | for item in finAckTransactionLatNodeIter[node]: |
| 699 | if item > 0.0: |
| 700 | finAckTransactionList.append(item) |
| 701 | |
| 702 | for item in ackToDeviceLatNodeIter[node]: |
| 703 | if item > 0.0: |
| 704 | ackToDeviceList.append(item) |
| 705 | |
| 706 | for item in deviceToGraphDiscLatNodeIter[node]: |
| 707 | if item >= 0.0: |
| 708 | deviceToGraphDiscList.append(item) |
| 709 | |
| 710 | endToEndAvg = round(numpy.mean(endToEndList), 2) |
| 711 | endToEndStdDev = round(numpy.std(endToEndList), 2) |
| 712 | |
| 713 | tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2) |
| 714 | tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2) |
| 715 | |
| 716 | featureToRoleAvg = round(numpy.mean(featureToRoleList), 2) |
| 717 | featureToRoleStdDev = round(numpy.std(featureToRoleList), 2) |
| 718 | |
| 719 | roleToOfpAvg = round(numpy.mean(roleToOfpList), 2) |
| 720 | roleToOfpStdDev = round(numpy.std(roleToOfpList), 2) |
| 721 | |
| 722 | ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2) |
| 723 | ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2) |
| 724 | |
| 725 | deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2) |
| 726 | deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2) |
| 727 | |
| 728 | endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2) |
| 729 | endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2) |
| 730 | |
| 731 | finAckAvg = round(numpy.mean(finAckTransactionList), 2) |
| 732 | finAckStdDev = round(numpy.std(finAckTransactionList), 2) |
| 733 | |
| 734 | ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2) |
| 735 | ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2) |
| 736 | |
| 737 | deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2) |
| 738 | deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2) |
| 739 | |
| 740 | main.log.report(' - Node ' + str(node + 1) + ' Summary - ') |
| 741 | main.log.report(' - Switch Connection Statistics - ') |
| 742 | |
| 743 | main.log.report(' End-to-end Avg: ' + str(endToEndAvg) + |
| 744 | ' ms' + ' End-to-end Std dev: ' + |
| 745 | str(endToEndStdDev) + ' ms') |
| 746 | |
| 747 | main.log.report(' Tcp-to-feature-reply Avg: ' + |
| 748 | str(tcpToFeatureAvg) + ' ms') |
| 749 | main.log.report(' Tcp-to-feature-reply Std dev: '+ |
| 750 | str(tcpToFeatureStdDev) + ' ms') |
| 751 | |
| 752 | main.log.report(' Feature-reply-to-role-request Avg: ' + |
| 753 | str(featureToRoleAvg) + ' ms') |
| 754 | main.log.report(' Feature-reply-to-role-request Std Dev: ' + |
| 755 | str(featureToRoleStdDev) + ' ms') |
| 756 | |
| 757 | main.log.report(' Role-request-to-role-reply Avg: ' + |
| 758 | str(roleToOfpAvg) +' ms') |
| 759 | main.log.report(' Role-request-to-role-reply Std dev: ' + |
| 760 | str(roleToOfpStdDev) + ' ms') |
| 761 | |
| 762 | main.log.report(' Role-reply-to-device Avg: ' + |
| 763 | str(ofpToDeviceAvg) +' ms') |
| 764 | main.log.report(' Role-reply-to-device Std dev: ' + |
| 765 | str(ofpToDeviceStdDev) + ' ms') |
| 766 | |
| 767 | main.log.report(' Device-to-graph Avg: ' + |
| 768 | str(deviceToGraphAvg) + ' ms') |
| 769 | main.log.report( 'Device-to-graph Std dev: ' + |
| 770 | str(deviceToGraphStdDev) + ' ms') |
| 771 | |
| 772 | main.log.report(' - Switch Disconnection Statistics - ') |
| 773 | main.log.report(' End-to-end switch disconnect Avg: ' + |
| 774 | str(endToEndDiscAvg) + ' ms') |
| 775 | main.log.report(' End-to-end switch disconnect Std dev: ' + |
| 776 | str(endToEndDiscStdDev) + ' ms') |
| 777 | main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms') |
| 778 | main.log.report(' Fin/Ack-to-Ack Std dev: ' + |
| 779 | str(finAckStdDev) + ' ms') |
| 780 | |
| 781 | main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) + |
| 782 | ' ms') |
| 783 | main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) + |
| 784 | ' ms') |
| 785 | |
| 786 | main.log.report(' Device-to-graph (disconnect) Avg: ' + |
| 787 | str(deviceToGraphDiscAvg) + ' ms') |
| 788 | main.log.report(' Device-to-graph (disconnect) Std dev: ' + |
| 789 | str(deviceToGraphDiscStdDev) + ' ms') |
| 790 | |
| 791 | # For database schema, refer to Amazon web services |
| 792 | dbCmdList.append( |
| 793 | "INSERT INTO switch_latency_details VALUES('" + |
| 794 | timeToPost + "','switch_latency_results'," + |
| 795 | jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" + |
| 796 | str(node + 1) + "'," + |
| 797 | str(endToEndAvg) + ',' + |
| 798 | str(tcpToFeatureAvg) + ',' + |
| 799 | str(featureToRoleAvg) + ',' + |
| 800 | str(roleToOfpAvg) + ',' + |
| 801 | str(ofpToDeviceAvg) + ',' + |
| 802 | str(deviceToGraphAvg) + ',' + |
| 803 | str(endToEndDiscAvg) + ',' + |
| 804 | str(finAckAvg) + ',' + |
| 805 | str(ackToDeviceAvg) + ',' + |
| 806 | str(deviceToGraphDiscAvg) + |
| 807 | ');') |
| 808 | |
| 809 | if debugMode == 'on': |
| 810 | main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log', |
| 811 | '/tmp/', copyFileName='sw_lat_karaf') |
| 812 | fResult = open(resultPath, 'a') |
| 813 | for line in dbCmdList: |
| 814 | if line: |
| 815 | fResult.write(line + '\n') |
| 816 | fResult.close() |
| 817 | |
| 818 | assertion = main.TRUE |
| 819 | |
| 820 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 821 | onpass='Switch latency test successful', |
| 822 | onfail='Switch latency test failed') |
| 823 | |
| 824 | def CASE3(self, main): |
| 825 | """ |
| 826 | Bring port up / down and measure latency. |
| 827 | Port enable / disable is simulated by ifconfig up / down |
| 828 | |
| 829 | In ONOS-next, we must ensure that the port we are |
| 830 | manipulating is connected to another switch with a valid |
| 831 | connection. Otherwise, graph view will not be updated. |
| 832 | """ |
| 833 | import time |
| 834 | import subprocess |
| 835 | import os |
| 836 | import requests |
| 837 | import json |
| 838 | import numpy |
| 839 | ONOS1Ip = main.params['CTRL']['ip1'] |
| 840 | ONOS2Ip = main.params['CTRL']['ip2'] |
| 841 | ONOS3Ip = main.params['CTRL']['ip3'] |
| 842 | ONOSUser = main.params['CTRL']['user'] |
| 843 | defaultSwPort = main.params['CTRL']['port1'] |
| 844 | assertion = main.TRUE |
| 845 | numIter = main.params['TEST']['numIter'] |
| 846 | iterIgnore = int(main.params['TEST']['iterIgnore']) |
| 847 | |
| 848 | deviceTimestampKey = main.params['JSON']['deviceTimestamp'] |
| 849 | graphTimestampKey = main.params['JSON']['graphTimestamp'] |
| 850 | linkTimestampKey = main.params['JSON']['linkTimestamp'] |
| 851 | |
| 852 | tsharkPortUp = '/tmp/tshark_port_up.txt' |
| 853 | tsharkPortDown = '/tmp/tshark_port_down.txt' |
| 854 | tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ] |
| 855 | |
| 856 | debugMode = main.params['TEST']['debugMode'] |
| 857 | postToDB = main.params['DB']['postToDB'] |
| 858 | resultPath = main.params['DB']['portEventResultPath'] |
| 859 | localTime = time.strftime('%x %X') |
| 860 | localTime = localTime.replace('/', '') |
| 861 | localTime = localTime.replace(' ', '_') |
| 862 | localTime = localTime.replace(':', '') |
| 863 | |
| 864 | if debugMode == 'on': |
| 865 | main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime) |
| 866 | |
| 867 | upThresholdStr = main.params['TEST']['portUpThreshold'] |
| 868 | downThresholdStr = main.params['TEST']['portDownThreshold'] |
| 869 | upThresholdObj = upThresholdStr.split(',') |
| 870 | downThresholdObj = downThresholdStr.split(',') |
| 871 | upThresholdMin = int(upThresholdObj[0]) |
| 872 | upThresholdMax = int(upThresholdObj[1]) |
| 873 | downThresholdMin = int(downThresholdObj[0]) |
| 874 | downThresholdMax = int(downThresholdObj[1]) |
| 875 | |
| 876 | interfaceConfig = 's1-eth1' |
| 877 | main.log.report('Port enable / disable latency') |
| 878 | main.log.report('Simulated by ifconfig up / down') |
| 879 | main.log.report('Total iterations of test: ' + str(numIter)) |
| 880 | main.step('Assign switches s1 and s2 to controller 1') |
| 881 | |
| 882 | main.Mininet1.assignSwController(sw='1', |
| 883 | ip1=ONOS1Ip, port1=defaultSwPort) |
| 884 | main.Mininet1.assignSwController(sw='2', |
| 885 | ip1=ONOS1Ip, port1=defaultSwPort) |
| 886 | |
| 887 | time.sleep(15) |
| 888 | |
| 889 | portUpEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 890 | portUpOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 891 | portUpDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 892 | portUpLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 893 | |
| 894 | portDownEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 895 | portDownOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 896 | portDownDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 897 | portDownLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter))) |
| 898 | |
| 899 | for i in range(0, int(numIter)): |
| 900 | main.step('Starting wireshark capture for port status down') |
| 901 | main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown) |
| 902 | |
| 903 | time.sleep(5) |
| 904 | |
| 905 | main.step('Disable port: ' + interfaceConfig) |
| 906 | main.Mininet1.handle.sendline('sh ifconfig ' + |
| 907 | interfaceConfig + ' down') |
| 908 | main.Mininet1.handle.expect('mininet>') |
| 909 | |
| 910 | jsonStrPtDown = [] |
| 911 | for node in range (0, clusterCount): |
| 912 | metricsPortDown = CLIs[node].topologyEventsMetrics() |
| 913 | jsonStrPtDown.append(metricsPortDown) |
| 914 | |
| 915 | time.sleep(3) |
| 916 | |
| 917 | main.ONOS1.tsharkStop() |
| 918 | |
| 919 | os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' + |
| 920 | tsharkPortDown + ' /tmp/') |
| 921 | |
| 922 | fPortDown = open(tsharkPortDown, 'r') |
| 923 | fLine = fPortDown.readline() |
| 924 | objDown = fLine.split(' ') |
| 925 | if len(fLine) > 0: |
| 926 | timestampBeginPtDown = int(float(objDown[1]) * 1000) |
| 927 | # At times, tshark reports timestamp at the 3rd |
| 928 | # index of the array. If initial readings were |
| 929 | # unlike the epoch timestamp, then check the 3rd |
| 930 | # index and set that as a timestamp |
| 931 | if timestampBeginPtDown < 1400000000000: |
| 932 | timestampBeginPtDown = int(float(objDown[2]) * 1000) |
| 933 | # If there are any suspicion of invalid results |
| 934 | # check this reported value |
| 935 | main.log.info('Port down begin timestamp: ' + |
| 936 | str(timestampBeginPtDown)) |
| 937 | else: |
| 938 | main.log.info('Tshark output file returned unexpected' + |
| 939 | ' results: ' + str(objDown)) |
| 940 | timestampBeginPtDown = 0 |
| 941 | fPortDown.close() |
| 942 | |
| 943 | for node in range(0, clusterCount): |
| 944 | nodeNum = node+1 |
| 945 | # metricsDown = CLIs[node].topologyEventsMetrics |
| 946 | #jsonStrPtDown[node] = metricsDown() |
| 947 | jsonObj = json.loads(jsonStrPtDown[node]) |
| 948 | |
| 949 | if jsonObj: |
| 950 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 951 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 952 | linkTimestamp = jsonObj[linkTimestampKey]['value'] |
| 953 | else: |
| 954 | main.log.error( "Unexpected json object" ) |
| 955 | graphTimestamp = 0 |
| 956 | deviceTimestamp = 0 |
| 957 | linkTimestamp = 0 |
| 958 | |
| 959 | ptDownEndToEnd = int(graphTimestamp) - int(timestampBeginPtDown) |
| 960 | ptDownOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtDown) |
| 961 | ptDownDeviceToLink = float(linkTimestamp) - float(deviceTimestamp) |
| 962 | ptDownLinkToGraph = float(graphTimestamp) - float(linkTimestamp) |
| 963 | |
| 964 | if ptDownEndToEnd >= downThresholdMin and\ |
| 965 | ptDownEndToEnd < downThresholdMax and i >= iterIgnore: |
| 966 | portDownEndToEndNodeIter[node][i] = ptDownEndToEnd |
| 967 | main.log.info("ONOS "+str(nodeNum)+ |
| 968 | " port down End-to-end: "+ |
| 969 | str(ptDownEndToEnd) + " ms") |
| 970 | else: |
| 971 | main.log.info("ONOS "+str(nodeNum)+ |
| 972 | " port down End-to-end ignored"+ |
| 973 | " due to excess in threshold or premature iteration") |
| 974 | |
| 975 | if ptDownOfpToDevice >= downThresholdMin and\ |
| 976 | ptDownOfpToDevice < downThresholdMax and i >= iterIgnore: |
| 977 | portDownOfpToDevNodeIter[node][i] = ptDownOfpToDevice |
| 978 | main.log.info("ONOS "+str(nodeNum)+ |
| 979 | " port down Ofp-to-device: "+ |
| 980 | str(ptDownOfpToDevice) + " ms") |
| 981 | else: |
| 982 | main.log.info("ONOS "+str(nodeNum)+ |
| 983 | " port down Ofp-to-device ignored"+ |
| 984 | " due to excess in threshold or premature iteration") |
| 985 | |
| 986 | if ptDownDeviceToLink >= downThresholdMin and\ |
| 987 | ptDownDeviceToLink < downThresholdMax and i >= iterIgnore: |
| 988 | portDownDevToLinkNodeIter[node][i] = ptDownDeviceToLink |
| 989 | main.log.info("ONOS "+str(nodeNum)+ |
| 990 | " port down Device-to-link "+ |
| 991 | str(ptDownDeviceToLink) + " ms") |
| 992 | else: |
| 993 | main.log.info("ONOS "+str(nodeNum)+ |
| 994 | " port down Device-to-link ignored"+ |
| 995 | " due to excess in threshold or premature iteration") |
| 996 | |
| 997 | if ptDownLinkToGraph >= downThresholdMin and\ |
| 998 | ptDownLinkToGraph < downThresholdMax and i >= iterIgnore: |
| 999 | portDownLinkToGraphNodeIter[node][i] = ptDownLinkToGraph |
| 1000 | main.log.info("ONOS "+str(nodeNum)+ |
| 1001 | " port down Link-to-graph "+ |
| 1002 | str(ptDownLinkToGraph) + " ms") |
| 1003 | else: |
| 1004 | main.log.info("ONOS "+str(nodeNum)+ |
| 1005 | " port down Link-to-graph ignored"+ |
| 1006 | " due to excess in threshold or premature iteration") |
| 1007 | |
| 1008 | time.sleep(3) |
| 1009 | |
| 1010 | main.step('Starting wireshark capture for port status up') |
| 1011 | main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp) |
| 1012 | |
| 1013 | time.sleep(5) |
| 1014 | main.step('Enable port and obtain timestamp') |
| 1015 | main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up') |
| 1016 | main.Mininet1.handle.expect('mininet>') |
| 1017 | |
| 1018 | jsonStrPtUp = [] |
| 1019 | for node in range (0, clusterCount): |
| 1020 | metricsPortUp = CLIs[node].topologyEventsMetrics() |
| 1021 | jsonStrPtUp.append(metricsPortUp) |
| 1022 | |
| 1023 | time.sleep(5) |
| 1024 | main.ONOS1.tsharkStop() |
| 1025 | |
| 1026 | time.sleep(3) |
| 1027 | os.system('scp ' + ONOSUser + '@' + |
| 1028 | ONOS1Ip + ':' + tsharkPortUp + ' /tmp/') |
| 1029 | |
| 1030 | fPortUp = open(tsharkPortUp, 'r') |
| 1031 | fLine = fPortUp.readline() |
| 1032 | objUp = fLine.split(' ') |
| 1033 | if len(fLine) > 0: |
| 1034 | timestampBeginPtUp = int(float(objUp[1]) * 1000) |
| 1035 | if timestampBeginPtUp < 1400000000000: |
| 1036 | timestampBeginPtUp = int(float(objUp[2]) * 1000) |
| 1037 | main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp)) |
| 1038 | else: |
| 1039 | main.log.info('Tshark output file returned unexpected' + ' results.') |
| 1040 | timestampBeginPtUp = 0 |
| 1041 | fPortUp.close() |
| 1042 | |
| 1043 | for node in range(0, clusterCount): |
| 1044 | nodeNum = node+1 |
| 1045 | #metricsUp = CLIs[node].topologyEventsMetrics |
| 1046 | #jsonStrUp = metricsUp() |
| 1047 | jsonObj = json.loads(jsonStrPtUp[node]) |
| 1048 | |
| 1049 | if jsonObj: |
| 1050 | graphTimestamp = jsonObj[graphTimestampKey]['value'] |
| 1051 | deviceTimestamp = jsonObj[deviceTimestampKey]['value'] |
| 1052 | linkTimestamp = jsonObj[linkTimestampKey]['value'] |
| 1053 | else: |
| 1054 | main.log.error( "Unexpected json object" ) |
| 1055 | graphTimestamp = 0 |
| 1056 | deviceTimestamp = 0 |
| 1057 | linkTimestamp = 0 |
| 1058 | |
| 1059 | ptUpEndToEnd = int(graphTimestamp) - int(timestampBeginPtUp) |
| 1060 | ptUpOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtUp) |
| 1061 | ptUpDeviceToLink = float(linkTimestamp) - float(deviceTimestamp) |
| 1062 | ptUpLinkToGraph = float(graphTimestamp) - float(linkTimestamp) |
| 1063 | |
| 1064 | if ptUpEndToEnd >= upThresholdMin and\ |
| 1065 | ptUpEndToEnd < upThresholdMax and i > iterIgnore: |
| 1066 | portUpEndToEndNodeIter[node][i] = ptUpEndToEnd |
| 1067 | main.log.info("ONOS "+str(nodeNum)+ |
| 1068 | " port up End-to-end: "+ |
| 1069 | str(ptUpEndToEnd) + " ms") |
| 1070 | else: |
| 1071 | main.log.info("ONOS "+str(nodeNum)+ |
| 1072 | " port up End-to-end ignored"+ |
| 1073 | " due to excess in threshold or premature iteration") |
| 1074 | |
| 1075 | if ptUpOfpToDevice >= upThresholdMin and\ |
| 1076 | ptUpOfpToDevice < upThresholdMax and i > iterIgnore: |
| 1077 | portUpOfpToDevNodeIter[node][i] = ptUpOfpToDevice |
| 1078 | main.log.info("ONOS "+str(nodeNum)+ |
| 1079 | " port up Ofp-to-device: "+ |
| 1080 | str(ptUpOfpToDevice) + " ms") |
| 1081 | else: |
| 1082 | main.log.info("ONOS "+str(nodeNum)+ |
| 1083 | " port up Ofp-to-device ignored"+ |
| 1084 | " due to excess in threshold or premature iteration") |
| 1085 | |
| 1086 | if ptUpDeviceToLink >= upThresholdMin and\ |
| 1087 | ptUpDeviceToLink < upThresholdMax and i > iterIgnore: |
| 1088 | portUpDevToLinkNodeIter[node][i] = ptUpDeviceToLink |
| 1089 | main.log.info("ONOS "+str(nodeNum)+ |
| 1090 | " port up Device-to-link: "+ |
| 1091 | str(ptUpDeviceToLink) + " ms") |
| 1092 | else: |
| 1093 | main.log.info("ONOS "+str(nodeNum)+ |
| 1094 | " port up Device-to-link ignored"+ |
| 1095 | " due to excess in threshold or premature iteration") |
| 1096 | |
| 1097 | if ptUpLinkToGraph >= upThresholdMin and\ |
| 1098 | ptUpLinkToGraph < upThresholdMax and i > iterIgnore: |
| 1099 | portUpLinkToGraphNodeIter[node][i] = ptUpLinkToGraph |
| 1100 | main.log.info("ONOS "+str(nodeNum)+ |
| 1101 | " port up Link-to-graph: "+ |
| 1102 | str(ptUpLinkToGraph) + " ms") |
| 1103 | else: |
| 1104 | main.log.info("ONOS "+str(nodeNum)+ |
| 1105 | " port up Link-to-graph ignored"+ |
| 1106 | " due to excess in threshold or premature iteration") |
| 1107 | |
| 1108 | dbCmdList = [] |
| 1109 | for node in range(0, clusterCount): |
| 1110 | portUpEndToEndList = [] |
| 1111 | portUpOfpToDevList = [] |
| 1112 | portUpDevToLinkList = [] |
| 1113 | portUpLinkToGraphList = [] |
| 1114 | |
| 1115 | portDownEndToEndList = [] |
| 1116 | portDownOfpToDevList = [] |
| 1117 | portDownDevToLinkList = [] |
| 1118 | portDownLinkToGraphList = [] |
| 1119 | |
| 1120 | portUpEndToEndAvg = 0 |
| 1121 | portUpOfpToDevAvg = 0 |
| 1122 | portUpDevToLinkAvg = 0 |
| 1123 | portUpLinkToGraphAvg = 0 |
| 1124 | |
| 1125 | portDownEndToEndAvg = 0 |
| 1126 | portDownOfpToDevAvg = 0 |
| 1127 | portDownDevToLinkAvg = 0 |
| 1128 | portDownLinkToGraphAvg = 0 |
| 1129 | |
| 1130 | # TODO: Update for more pythonic way to get list |
| 1131 | # portUpDevList = [item for item in portUpDevNodeIter[node] |
| 1132 | # if item > 0.0] |
| 1133 | for item in portUpEndToEndNodeIter[node]: |
| 1134 | if item > 0.0: |
| 1135 | portUpEndToEndList.append(item) |
| 1136 | |
| 1137 | for item in portUpOfpToDevNodeIter[node]: |
| 1138 | if item > 0.0: |
| 1139 | portUpOfpToDevList.append(item) |
| 1140 | |
| 1141 | for item in portUpDevToLinkNodeIter[node]: |
| 1142 | if item > 0.0: |
| 1143 | portUpDevToLinkList.append(item) |
| 1144 | |
| 1145 | for item in portUpLinkToGraphNodeIter[node]: |
| 1146 | if item >= 0.0: |
| 1147 | portUpLinkToGraphList.append(item) |
| 1148 | |
| 1149 | for item in portDownEndToEndNodeIter[node]: |
| 1150 | if item > 0.0: |
| 1151 | portDownEndToEndList.append(item) |
| 1152 | |
| 1153 | for item in portDownOfpToDevNodeIter[node]: |
| 1154 | if item > 0.0: |
| 1155 | portDownOfpToDevList.append(item) |
| 1156 | |
| 1157 | for item in portDownDevToLinkNodeIter[node]: |
| 1158 | if item >= 0.0: |
| 1159 | portDownDevToLinkList.append(item) |
| 1160 | |
| 1161 | for item in portDownLinkToGraphNodeIter[node]: |
| 1162 | if item >= 0.0: |
| 1163 | portDownLinkToGraphList.append(item) |
| 1164 | |
| 1165 | portUpEndToEndAvg = round(numpy.mean(portUpEndToEndList), 2) |
| 1166 | portUpOfpToDevAvg = round(numpy.mean(portUpOfpToDevList), 2) |
| 1167 | portUpDevToLinkAvg = round(numpy.mean(portUpDevToLinkList), 2) |
| 1168 | portUpLinkToGraphAvg = round(numpy.mean(portUpLinkToGraphList), 2) |
| 1169 | |
| 1170 | portDownEndToEndAvg = round(numpy.mean(portDownEndToEndList), 2) |
| 1171 | portDownOfpToDevAvg = round(numpy.mean(portDownOfpToDevList), 2) |
| 1172 | portDownDevToLinkAvg = round(numpy.mean(portDownDevToLinkList), 2) |
| 1173 | portDownLinkToGraphAvg = round(numpy.mean(portDownLinkToGraphList), 2) |
| 1174 | |
| 1175 | portUpStdDev = round(numpy.std(portUpEndToEndList), 2) |
| 1176 | portDownStdDev = round(numpy.std(portDownEndToEndList), 2) |
| 1177 | |
| 1178 | main.log.report(' - Node ' + str(node + 1) + ' Summary - ') |
| 1179 | main.log.report(' Port up End-to-end ' + |
| 1180 | str(portUpEndToEndAvg) + ' ms') |
| 1181 | main.log.report(' Port up Ofp-to-device ' + |
| 1182 | str(portUpOfpToDevAvg) + ' ms') |
| 1183 | main.log.report(' Port up Device-to-link ' + |
| 1184 | str(portUpDevToLinkAvg) + ' ms') |
| 1185 | main.log.report(' Port up Link-to-graph ' + |
| 1186 | str(portUpLinkToGraphAvg) + ' ms') |
| 1187 | |
| 1188 | main.log.report(' Port down End-to-end ' + |
| 1189 | str(round(portDownEndToEndAvg, 2)) + ' ms') |
| 1190 | main.log.report(' Port down Ofp-to-device ' + |
| 1191 | str(portDownOfpToDevAvg) + ' ms') |
| 1192 | main.log.report(' Port down Device-to-link ' + |
| 1193 | str(portDownDevToLinkAvg) + ' ms') |
| 1194 | main.log.report(' Port down Link-to-graph' + |
| 1195 | str(portDownLinkToGraphAvg) + ' ms') |
| 1196 | |
| 1197 | dbCmdList.append("INSERT INTO port_latency_details VALUES('" + |
| 1198 | timeToPost + "','port_latency_results'," + jenkinsBuildNumber + |
| 1199 | ',' + str(clusterCount) + ",'baremetal" + str(node + 1) + |
| 1200 | "'," + |
| 1201 | str(portUpEndToEndAvg) +',' + |
| 1202 | str(portUpOfpToDevAvg) + ',' + |
| 1203 | str(portUpDevToLinkAvg) + ',' + |
| 1204 | str(portUpLinkToGraphAvg) + ',' + |
| 1205 | str(portDownEndToEndAvg) + ',' + |
| 1206 | str(portDownOfpToDevAvg) + ',' + |
| 1207 | str(portDownDevToLinkAvg) + ',' + |
| 1208 | str(portDownLinkToGraphAvg) + |
| 1209 | ');') |
| 1210 | |
| 1211 | fResult = open(resultPath, 'a') |
| 1212 | for line in dbCmdList: |
| 1213 | if line: |
| 1214 | fResult.write(line + '\n') |
| 1215 | |
| 1216 | fResult.close() |
| 1217 | |
| 1218 | # Delete switches from controller to prepare for next |
| 1219 | # set of tests |
| 1220 | main.Mininet1.deleteSwController('s1') |
| 1221 | main.Mininet1.deleteSwController('s2') |
| 1222 | utilities.assert_equals(expect=main.TRUE, |
| 1223 | actual=assertion, |
| 1224 | onpass='Port discovery latency calculation successful', |
| 1225 | onfail='Port discovery test failed') |
| 1226 | |
| 1227 | def CASE4(self, main): |
| 1228 | """ |
| 1229 | Increase number of nodes and initiate CLI |
| 1230 | |
| 1231 | With the most recent implementation, we need a method to |
| 1232 | ensure all ONOS nodes are killed, as well as redefine |
| 1233 | the cell files to ensure all nodes that will be used |
| 1234 | is in the cell file. Otherwise, exceptions will |
| 1235 | prohibit test from running successfully. |
| 1236 | |
| 1237 | 3/12/15 |
| 1238 | |
| 1239 | """ |
| 1240 | global clusterCount |
| 1241 | import time |
| 1242 | import os |
| 1243 | |
| 1244 | clusterCount += 2 |
| 1245 | |
| 1246 | benchIp = main.params[ 'BENCH' ][ 'ip' ] |
| 1247 | features = main.params[ 'ENV' ][ 'cellFeatures' ] |
| 1248 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1249 | mininetIp = main.params[ 'MN' ][ 'ip1' ] |
| 1250 | |
| 1251 | main.log.report('Increasing cluster size to ' + str(clusterCount)) |
| 1252 | |
| 1253 | main.log.step( "Killing all ONOS processes before scale-out" ) |
| 1254 | |
| 1255 | for i in range( 1, 8 ): |
| 1256 | main.ONOSbench.onosDie( |
| 1257 | main.params[ 'CTRL' ][ 'ip'+str(i) ] ) |
| 1258 | main.ONOSbench.onosUninstall( |
| 1259 | main.params[ 'CTRL' ][ 'ip'+str(i) ] ) |
| 1260 | |
| 1261 | main.step( "Creating scale-out cell file" ) |
| 1262 | cellIp = [] |
| 1263 | for node in range( 1, clusterCount + 1 ): |
| 1264 | cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] ) |
| 1265 | |
| 1266 | main.log.info( "Cell Ip list: " + str(cellIp) ) |
| 1267 | main.ONOSbench.createCellFile( benchIp, cellName, mininetIp, |
| 1268 | str(features), *cellIp ) |
| 1269 | |
| 1270 | main.step( "Setting cell definition" ) |
| 1271 | main.ONOSbench.setCell(cellName) |
| 1272 | |
| 1273 | main.step( "Packaging cell definition" ) |
| 1274 | main.ONOSbench.onosPackage() |
| 1275 | |
| 1276 | for node in range( 1, clusterCount + 1 ): |
| 1277 | main.ONOSbench.onosInstall( |
| 1278 | node = main.params[ 'CTRL' ][ 'ip'+str(node) ]) |
| 1279 | |
| 1280 | time.sleep( 20 ) |
| 1281 | |
| 1282 | for node in range( 1, clusterCount + 1): |
| 1283 | for i in range( 2 ): |
| 1284 | isup = main.ONOSbench.isup( |
| 1285 | main.params[ 'CTRL' ][ 'ip'+str(node) ] ) |
| 1286 | if isup: |
| 1287 | main.log.info( "ONOS "+str(node) + " is up\n") |
| 1288 | break |
| 1289 | if not isup: |
| 1290 | main.log.error( "ONOS "+str(node) + " did not start" ) |
| 1291 | |
| 1292 | for node in range( 0, clusterCount ): |
| 1293 | CLIs[node].startOnosCli( cellIp[node] ) |
| 1294 | |
| 1295 | main.step( 'Setting configurations for metrics' ) |
| 1296 | configParam = 'maxEvents 1' |
| 1297 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1298 | configParam = 'maxBatchMs 0' |
| 1299 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1300 | configParam = 'maxIdleMs 0' |
| 1301 | main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam ) |
| 1302 | |
| 1303 | main.step( 'Activating essential applications' ) |
| 1304 | CLIs[0].activateApp( 'org.onosproject.metrics' ) |
| 1305 | CLIs[0].activateApp( 'org.onosproject.openflow' ) |
| 1306 | |