blob: 6c07d6befb922a0e606cffaf9a54771f603011c9 [file] [log] [blame]
jenkins7ead5a82015-03-13 10:28:21 -07001# 2015.03.12 10:22:05 PDT
2#Embedded file name: ../tests/TopoPerfNextBM/TopoPerfNextBM.py
3import time
4import sys
5import os
6import re
7
8class 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
jenkins3e5a3912015-04-02 18:14:16 -070020
jenkins7ead5a82015-03-13 10:28:21 -070021 import time
22 clusterCount = 1
23 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
24 runNum = time.strftime('%d%H%M%S')
25 cellName = main.params['ENV']['cellName']
26 gitPull = main.params['GIT']['autoPull']
27 checkoutBranch = main.params['GIT']['checkout']
jenkins3e5a3912015-04-02 18:14:16 -070028
29 global CLIs
30 CLIs = []
31 global nodes
32 nodes = []
33 global nodeIpList
34 nodeIpList = []
35 for i in range( 1, 8 ):
36 CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) )
37 nodes.append( getattr( main, 'ONOS' + str( i ) ) )
38 nodeIpList.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] )
39
jenkins7ead5a82015-03-13 10:28:21 -070040 MN1Ip = main.params['MN']['ip1']
41 BENCHIp = main.params['BENCH']['ip']
jenkins3e5a3912015-04-02 18:14:16 -070042 cellFeatures = main.params['ENV']['cellFeatures']
jenkins7ead5a82015-03-13 10:28:21 -070043 topoCfgFile = main.params['TEST']['topoConfigFile']
44 topoCfgName = main.params['TEST']['topoConfigName']
45 portEventResultPath = main.params['DB']['portEventResultPath']
46 switchEventResultPath = main.params['DB']['switchEventResultPath']
47 mvnCleanInstall = main.params['TEST']['mci']
48
49 main.case('Setting up test environment')
jenkins3e5a3912015-04-02 18:14:16 -070050
51 # NOTE: Below is deprecated after new way to install features
52 #main.log.info('Copying topology event accumulator config' +
53 # ' to ONOS /package/etc')
54 #main.ONOSbench.handle.sendline('cp ~/' +
55 # topoCfgFile + ' ~/ONOS/tools/package/etc/' +
56 # topoCfgName)
57 #main.ONOSbench.handle.expect('\\$')
jenkins7ead5a82015-03-13 10:28:21 -070058
59 main.log.report('Setting up test environment')
60
61 main.step('Starting mininet topology ')
62 main.Mininet1.startNet()
63
64 main.step('Cleaning previously installed ONOS if any')
jenkins3e5a3912015-04-02 18:14:16 -070065 # Nodes 2 ~ 7
66 for i in range( 1, 7 ):
67 main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i])
jenkins7ead5a82015-03-13 10:28:21 -070068
69 main.step('Clearing previous DB log file')
70
71 fPortLog = open(portEventResultPath, 'w')
72 fPortLog.write('')
73 fPortLog.close()
74 fSwitchLog = open(switchEventResultPath, 'w')
75 fSwitchLog.write('')
76 fSwitchLog.close()
77
jenkins7ead5a82015-03-13 10:28:21 -070078 main.step('Creating cell file')
79 cellFileResult = main.ONOSbench.createCellFile(
jenkins3e5a3912015-04-02 18:14:16 -070080 BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -070081
82 main.step('Applying cell file to environment')
83 cellApplyResult = main.ONOSbench.setCell(cellName)
84 verifyCellResult = main.ONOSbench.verifyCell()
85
86 main.step('Git checkout and pull ' + checkoutBranch)
87 if gitPull == 'on':
88 checkoutResult = main.TRUE
89 pullResult = main.ONOSbench.gitPull()
90 else:
91 checkoutResult = main.TRUE
92 pullResult = main.TRUE
93 main.log.info('Skipped git checkout and pull')
94
95 main.log.report('Commit information - ')
96 main.ONOSbench.getVersion(report=True)
97 main.step('Using mvn clean & install')
98 if mvnCleanInstall == 'on':
99 mvnResult = main.ONOSbench.cleanInstall()
100 elif mvnCleanInstall == 'off':
101 main.log.info('mci turned off by settings')
102 mvnResult = main.TRUE
103 main.step('Set cell for ONOS cli env')
jenkins3e5a3912015-04-02 18:14:16 -0700104 CLIs[0].setCell(cellName)
jenkins7ead5a82015-03-13 10:28:21 -0700105
106 main.step('Creating ONOS package')
107 packageResult = main.ONOSbench.onosPackage()
108
109 main.step('Installing ONOS package')
jenkins3e5a3912015-04-02 18:14:16 -0700110 install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700111
112 time.sleep(10)
113
114 main.step('Start onos cli')
jenkins3e5a3912015-04-02 18:14:16 -0700115 cli1 = CLIs[0].startOnosCli(nodeIpList[0])
116
117 main.step( 'activating essential applications' )
118 CLIs[0].activateApp( 'org.onosproject.metrics' )
119 CLIs[0].activateApp( 'org.onosproject.openflow' )
120
121 main.step( 'Configuring application parameters' )
122 configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider'
123 configParam = 'maxEvents 1'
124 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
125 configParam = 'maxBatchMs 0'
126 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
127 configParam = 'maxIdleMs 0'
128 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
129
jenkins7ead5a82015-03-13 10:28:21 -0700130 utilities.assert_equals(expect=main.TRUE,
131 actual=cellFileResult and cellApplyResult and\
132 verifyCellResult and checkoutResult and\
133 pullResult and mvnResult and\
134 install1Result,
135 onpass='Test Environment setup successful',
136 onfail='Failed to setup test environment')
137
138 def CASE2(self, main):
139 """
140 Assign s1 to ONOS1 and measure latency
141
142 There are 4 levels of latency measurements to this test:
143 1 ) End-to-end measurement: Complete end-to-end measurement
144 from TCP ( SYN/ACK ) handshake to Graph change
145 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
146 measurement from OFP Vendor message to Graph change
147 3 ) OFP-to-device measurement: 'ONOS processing without
148 graph change' snippet of measurement from OFP vendor
149 message to Device change timestamp
150 4 ) T0-to-device measurement: Measurement that includes
151 the switch handshake to devices timestamp without
152 the graph view change. ( TCP handshake -> Device
153 change )
154 """
155 import time
156 import subprocess
157 import json
158 import requests
159 import os
160 import numpy
161
jenkins7ead5a82015-03-13 10:28:21 -0700162 ONOSUser = main.params['CTRL']['user']
163 defaultSwPort = main.params['CTRL']['port1']
164 numIter = main.params['TEST']['numIter']
165 iterIgnore = int(main.params['TEST']['iterIgnore'])
jenkins8ba10ab2015-03-24 10:31:31 -0700166
jenkins3e5a3912015-04-02 18:14:16 -0700167 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
168 graphTimestampKey = main.params['JSON']['graphTimestamp']
jenkins8ba10ab2015-03-24 10:31:31 -0700169
jenkins7ead5a82015-03-13 10:28:21 -0700170 debugMode = main.params['TEST']['debugMode']
171 onosLog = main.params['TEST']['onosLogFile']
172 resultPath = main.params['DB']['switchEventResultPath']
173 thresholdStr = main.params['TEST']['singleSwThreshold']
174 thresholdObj = thresholdStr.split(',')
jenkins3e5a3912015-04-02 18:14:16 -0700175 thresholdMin = float(thresholdObj[0])
176 thresholdMax = float(thresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700177
jenkins8ba10ab2015-03-24 10:31:31 -0700178 # Look for 'role-request' messages,
179 # which replaces the 'vendor' messages previously seen
180 # on OVS 2.0.1
jenkins7ead5a82015-03-13 10:28:21 -0700181 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700182 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
183 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
184 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
jenkins3e5a3912015-04-02 18:14:16 -0700185 tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700186
jenkins7ead5a82015-03-13 10:28:21 -0700187 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
188 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
jenkins8ba10ab2015-03-24 10:31:31 -0700189 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
190 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
jenkins3e5a3912015-04-02 18:14:16 -0700191 tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
192
193 # Switch connect measurement list
194 # TCP Syn/Ack -> Feature Reply latency collection for each node
195 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
196 # Feature Reply -> Role Request latency collection for each node
197 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
198 int(numIter)))
199 # Role Request -> Role Reply latency collection for each node
200 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
201 int(numIter)))
202 # Role Reply -> Device Update latency collection for each node
203 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
204 int(numIter)))
205 # Device Update -> Graph Update latency collection for each node
206 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
207 int(numIter)))
208
209 # Switch disconnect measurement lists
210 # Mininet Fin / Ack -> Mininet Ack
211 finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
212 int(numIter)))
213 # Mininet Ack -> Device Event
214 ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
215 int(numIter)))
216 # Device event -> Graph event
217 deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
218 int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700219
jenkins7ead5a82015-03-13 10:28:21 -0700220 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
221 ofpToGraphLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
222 ofpToDeviceLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
223
224 tcpToOfpLatIter = []
jenkins8ba10ab2015-03-24 10:31:31 -0700225 tcpToFeatureLatIter = []
226 tcpToRoleLatIter = []
jenkins7ead5a82015-03-13 10:28:21 -0700227 assertion = main.TRUE
228 localTime = time.strftime('%x %X')
229 localTime = localTime.replace('/', '')
230 localTime = localTime.replace(' ', '_')
231 localTime = localTime.replace(':', '')
232
233 if debugMode == 'on':
234 main.ONOS1.tsharkPcap('eth0',
235 '/tmp/single_sw_lat_pcap_' + localTime)
236 main.log.info('Debug mode is on')
237 main.log.report('Latency of adding one switch to controller')
238 main.log.report('First ' + str(iterIgnore) +
239 ' iterations ignored' + ' for jvm warmup time')
240 main.log.report('Total iterations of test: ' + str(numIter))
241
242 for i in range(0, int(numIter)):
243 main.log.info('Starting tshark capture')
244 main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
245 main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput)
jenkins8ba10ab2015-03-24 10:31:31 -0700246 main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
247 main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
248
jenkins7ead5a82015-03-13 10:28:21 -0700249 time.sleep(10)
250
251 main.log.info('Assigning s3 to controller')
252 main.Mininet1.assignSwController(sw='3',
jenkins3e5a3912015-04-02 18:14:16 -0700253 ip1=nodeIpList[0], port1=defaultSwPort)
jenkins7ead5a82015-03-13 10:28:21 -0700254
255 time.sleep(10)
256
257 main.log.info('Stopping all Tshark processes')
258 main.ONOS1.tsharkStop()
259
260 main.log.info('Copying over tshark files')
jenkins3e5a3912015-04-02 18:14:16 -0700261 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins7ead5a82015-03-13 10:28:21 -0700262 ':' + tsharkTcpOutput + ' /tmp/')
jenkins3e5a3912015-04-02 18:14:16 -0700263 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700264 ':' + tsharkRoleOutput + ' /tmp/')
jenkins3e5a3912015-04-02 18:14:16 -0700265 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700266 ':' + tsharkFeatureOutput + ' /tmp/')
267 os.system('scp ' + ONOSUser + '@' +
jenkins3e5a3912015-04-02 18:14:16 -0700268 nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700269
270 # Get tcp syn / ack output
jenkins7ead5a82015-03-13 10:28:21 -0700271 time.sleep(5)
272 tcpFile = open(tsharkTcpOutput, 'r')
273 tempText = tcpFile.readline()
274 tempText = tempText.split(' ')
275 main.log.info('Object read in from TCP capture: ' +
276 str(tempText))
277
278 if len(tempText) > 1:
279 t0Tcp = float(tempText[1]) * 1000.0
280 else:
281 main.log.error('Tshark output file for TCP' +
282 ' returned unexpected results')
283 t0Tcp = 0
284 assertion = main.FALSE
285 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700286
287 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700288 time.sleep(5)
289 ofFile = open(tsharkOfOutput, 'r')
290 lineOfp = ''
291 while True:
292 tempText = ofFile.readline()
293 if tempText != '':
294 lineOfp = tempText
295 else:
296 break
jenkins7ead5a82015-03-13 10:28:21 -0700297 obj = lineOfp.split(' ')
298 main.log.info('Object read in from OFP capture: ' +
299 str(lineOfp))
300 if len(obj) > 1:
301 t0Ofp = float(obj[1]) * 1000.0
302 else:
303 main.log.error('Tshark output file for OFP' +
304 ' returned unexpected results')
305 t0Ofp = 0
306 assertion = main.FALSE
307 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700308
309 # Get role request output
310 roleFile = open(tsharkRoleOutput, 'r')
311 tempText = roleFile.readline()
312 tempText = tempText.split(' ')
313 if len(tempText) > 1:
314 main.log.info('Object read in from role request capture:' +
315 str(tempText))
316 roleTimestamp = float(tempText[1]) * 1000.0
317 else:
318 main.log.error('Tshark output file for role request' +
319 ' returned unexpected results')
320 timeRoleRequest = 0
321 assertion = main.FALSE
322 roleFile.close()
323
324 # Get feature reply output
325 featureFile = open(tsharkFeatureOutput, 'r')
326 tempText = featureFile.readline()
327 tempText = tempText.split(' ')
328 if len(tempText) > 1:
329 main.log.info('Object read in from feature reply capture: '+
330 str(tempText))
331 featureTimestamp = float(tempText[1]) * 1000.0
332 else:
333 main.log.error('Tshark output file for feature reply' +
334 ' returned unexpected results')
335 timeFeatureReply = 0
336 assertion = main.FALSE
337 featureFile.close()
338
339 # TODO: calculate feature reply, role request times
340 # stack measurements correctly and report
341
jenkins8ba10ab2015-03-24 10:31:31 -0700342 #TODO: Refactor in progress
343
344 for node in range(0, clusterCount):
345 nodeNum = node+1
jenkins3e5a3912015-04-02 18:14:16 -0700346 metricsSwUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700347 jsonStr = metricsSwUp()
348 jsonObj = json.loads(jsonStr)
jenkins3e5a3912015-04-02 18:14:16 -0700349 if jsonObj:
350 graphTimestamp = jsonObj[graphTimestampKey]['value']
351 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700352 else:
jenkins3e5a3912015-04-02 18:14:16 -0700353 main.log.error( "Unexpected JSON object" )
354 # If we could not obtain the JSON object,
355 # set the timestamps to 0, which will be
356 # excluded from the measurement later on
357 # (realized as invalid)
358 graphTimestamp = 0
359 deviceTimestamp = 0
360
361 endToEnd = int(graphTimestamp) - int(t0Tcp)
362
363 # Below are measurement breakdowns of the end-to-end
364 # measurement.
365 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
366 featureToRole = int(roleTimestamp) - int(featureTimestamp)
367 roleToOfp = int(t0Ofp) - int(roleTimestamp)
368 ofpToDevice = int(deviceTimestamp) - int(t0Ofp)
369 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
370
371 if endToEnd > thresholdMin and\
372 endToEnd < thresholdMax and i >= iterIgnore:
373 endToEndLatNodeIter[node][i] = endToEnd
374 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
375 str(endToEnd) + " ms")
376 else:
377 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700378 "measurement ignored due to excess in "+
379 "threshold or premature iteration")
380
jenkins3e5a3912015-04-02 18:14:16 -0700381 if tcpToFeature > thresholdMin and\
382 tcpToFeature < thresholdMax and i >= iterIgnore:
383 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
384 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
385 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700386 else:
jenkins3e5a3912015-04-02 18:14:16 -0700387 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700388 "measurement ignored due to excess in "+
389 "threshold or premature iteration")
390
jenkins3e5a3912015-04-02 18:14:16 -0700391 if featureToRole > thresholdMin and\
392 featureToRole < thresholdMax and i >= iterIgnore:
393 featureToRoleRequestLatNodeIter[node][i] = featureToRole
394 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
395 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700396 else:
jenkins3e5a3912015-04-02 18:14:16 -0700397 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700398 "measurement ignored due to excess in "+
399 "threshold or premature iteration")
400
jenkins3e5a3912015-04-02 18:14:16 -0700401 if roleToOfp > thresholdMin and\
402 roleToOfp < thresholdMax and i >= iterIgnore:
403 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
404 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
405 str(roleToOfp) + " ms")
406 else:
407 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
408 "measurement ignored due to excess in "+
409 "threshold or premature iteration")
410
411 if ofpToDevice > thresholdMin and\
412 ofpToDevice < thresholdMax and i >= iterIgnore:
413 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
414 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
415 str(ofpToDevice) + " ms")
416 else:
417 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
418 "measurement ignored due to excess in "+
419 "threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700420
jenkins3e5a3912015-04-02 18:14:16 -0700421 if deviceToGraph > thresholdMin and\
422 deviceToGraph < thresholdMax and i >= iterIgnore:
423 deviceToGraphLatNodeIter[node][i] = deviceToGraph
424 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
425 str(deviceToGraph) + " ms")
426 else:
427 main.log.info("ONOS "+str(nodeNum)+ " device=to-graph "+
428 "measurement ignored due to excess in "+
429 "threshold or premature iteration")
430
jenkins8ba10ab2015-03-24 10:31:31 -0700431 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700432 time.sleep(5)
433
434 # Get device id to remove
435 deviceIdJsonStr = main.ONOS1cli.devices()
436
437 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
438 deviceId = json.loads(deviceIdJsonStr)
439
440 deviceList = []
441 for device in deviceId:
442 deviceList.append(device['id'])
jenkins3e5a3912015-04-02 18:14:16 -0700443
444 # TODO: Measure switch down metrics
445 # TCP FIN/ACK -> TCP FIN
446 # TCP FIN -> Device Event
447 # Device Event -> Graph Event
448
449 # Capture switch down FIN / ACK packets
450
451 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
452 grepOptions = '-A 1' )
453
454 time.sleep( 5 )
455
jenkins7ead5a82015-03-13 10:28:21 -0700456 main.step('Remove switch from controller')
457 main.Mininet1.deleteSwController('s3')
jenkins7ead5a82015-03-13 10:28:21 -0700458 #firstDevice = deviceList[0]
459 firstDevice = "of:0000000000000003"
460 main.log.info( "Removing device " +str(firstDevice)+
461 " from ONOS" )
462 #if deviceId:
463 main.ONOS1cli.deviceRemove(firstDevice)
jenkins3e5a3912015-04-02 18:14:16 -0700464
465 time.sleep( 5 )
466 main.ONOS1.tsharkStop()
467
468 main.log.info('Copying over tshark files')
469 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
470 ':' + tsharkFinAckOutput + ' /tmp/')
471
472 time.sleep( 10 )
473 finAckOutputList = []
474 with open(tsharkFinAckOutput, 'r') as f:
475 tempLine = f.readlines()
476 main.log.info('Object read in from FinAck capture: ' +
477 str(tempLine))
478
479 index = 1
480 for line in tempLine:
481 obj = line.split(' ')
jenkins7ead5a82015-03-13 10:28:21 -0700482
jenkins3e5a3912015-04-02 18:14:16 -0700483 if len(obj) > 1:
484 if index == 1:
485 tFinAck = float(obj[1]) * 1000.0
486 print "*** fin ack time :"+str(tFinAck)
487 elif index == 3:
488 tAck = float(obj[1]) * 1000.0
489 print "*** Ack time: "+str(tAck)
490 else:
491 main.log.error('Tshark output file for OFP' +
492 ' returned unexpected results')
493 tFinAck = 0
494 tAck = 0
495 assertion = main.FALSE
496
497 index = index+1
498
499 # with open() as f takes care of closing file
500
jenkins7ead5a82015-03-13 10:28:21 -0700501 time.sleep(5)
jenkins3e5a3912015-04-02 18:14:16 -0700502
503 for node in range(0, clusterCount):
504 nodeNum = node+1
505 metricsSwDown = CLIs[node].topologyEventsMetrics
506 jsonStr = metricsSwDown()
507 jsonObj = json.loads(jsonStr)
508 if jsonObj:
509 graphTimestamp = jsonObj[graphTimestampKey]['value']
510 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
511 main.log.info("Graph timestamp: "+str(graphTimestamp))
512 main.log.info("Device timestamp: "+str(deviceTimestamp))
513 else:
514 main.log.error( "Unexpected JSON object" )
515 # If we could not obtain the JSON object,
516 # set the timestamps to 0, which will be
517 # excluded from the measurement later on
518 # (realized as invalid)
519 graphTimestamp = 0
520 deviceTimestamp = 0
521
522 finAckTransaction = int(tAck) - int(tFinAck)
523 ackToDevice = int(deviceTimestamp) - int(tAck)
524 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
525
526 if finAckTransaction > thresholdMin and\
527 finAckTransaction < thresholdMax and i >= iterIgnore:
528 finAckTransactionLatNodeIter[node][i] = finAckTransaction
529 main.log.info("ONOS "+str(nodeNum)+
530 " fin/ack transaction: "+
531 str(finAckTransaction) + " ms")
532 else:
533 main.log.info("ONOS "+str(nodeNum)+
534 " fin/ack transaction "+
535 "measurement ignored due to excess in "+
536 "threshold or premature iteration")
537
538 if ackToDevice > thresholdMin and\
539 ackToDevice < thresholdMax and i >= iterIgnore:
540 ackToDeviceLatNodeIter[node][i] = ackToDevice
541 main.log.info("ONOS "+str(nodeNum)+
542 " ack-to-device: "+
543 str(ackToDevice) + " ms")
544 else:
545 main.log.info("ONOS "+str(nodeNum)+
546 " ack-to-device "+
547 "measurement ignored due to excess in "+
548 "threshold or premature iteration")
549
550 if deviceToGraph > thresholdMin and\
551 deviceToGraph < thresholdMax and i >= iterIgnore:
552 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
553 main.log.info("ONOS "+str(nodeNum)+
554 " device-to-graph disconnect: "+
555 str(deviceToGraph) + " ms")
556 else:
557 main.log.info("ONOS "+str(nodeNum)+
558 " device-to-graph disconnect "+
559 "measurement ignored due to excess in "+
560 "threshold or premature iteration")
jenkins7ead5a82015-03-13 10:28:21 -0700561
562 endToEndAvg = 0
563 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700564 dbCmdList = []
565 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700566 # List of latency for each node
567 endToEndList = []
jenkins3e5a3912015-04-02 18:14:16 -0700568
jenkins8ba10ab2015-03-24 10:31:31 -0700569 tcpToFeatureList = []
jenkins3e5a3912015-04-02 18:14:16 -0700570 featureToRoleList = []
571 roleToOfpList = []
572 ofpToDeviceList = []
573 deviceToGraphList = []
574 finAckTransactionList = []
575 ackToDeviceList = []
576 deviceToGraphDiscList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700577
578 # LatNodeIter 2d arrays contain all iteration latency
579 # for each node of the current scale cluster size
jenkins3e5a3912015-04-02 18:14:16 -0700580
581 # Switch connection measurements
jenkins7ead5a82015-03-13 10:28:21 -0700582 for item in endToEndLatNodeIter[node]:
583 if item > 0.0:
584 endToEndList.append(item)
585
jenkins3e5a3912015-04-02 18:14:16 -0700586 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700587 if item > 0.0:
588 tcpToFeatureList.append(item)
589
jenkins3e5a3912015-04-02 18:14:16 -0700590 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700591 if item > 0.0:
jenkins3e5a3912015-04-02 18:14:16 -0700592 featureToRoleList.append(item)
593
594 for item in roleRequestToRoleReplyLatNodeIter[node]:
595 if item > 0.0:
596 roleToOfpList.append(item)
597
598 for item in roleReplyToDeviceLatNodeIter[node]:
599 if item > 0.0:
600 ofpToDeviceList.append(item)
601
602 for item in deviceToGraphLatNodeIter[node]:
603 if item > 0.0:
604 deviceToGraphList.append(item)
605
606 # Switch disconnect measurements
607 for item in finAckTransactionLatNodeIter[node]:
608 if item > 0.0:
609 finAckTransactionList.append(item)
610
611 for item in ackToDeviceLatNodeIter[node]:
612 if item > 0.0:
613 ackToDeviceList.append(item)
614
615 for item in deviceToGraphDiscLatNodeIter[node]:
616 if item > 0.0:
617 deviceToGraphDiscList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700618
jenkins7ead5a82015-03-13 10:28:21 -0700619 endToEndAvg = round(numpy.mean(endToEndList), 2)
jenkins3e5a3912015-04-02 18:14:16 -0700620 endToEndStdDev = round(numpy.std(endToEndList), 2)
621
jenkins8ba10ab2015-03-24 10:31:31 -0700622 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
jenkins3e5a3912015-04-02 18:14:16 -0700623 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
624
625 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
626 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
627
628 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
629 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
630
jenkins7ead5a82015-03-13 10:28:21 -0700631 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
jenkins3e5a3912015-04-02 18:14:16 -0700632 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
633
634 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
635 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
636
637 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
638 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
639
640 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
641 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
642
643 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
644 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
645
jenkins7ead5a82015-03-13 10:28:21 -0700646 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
jenkins3e5a3912015-04-02 18:14:16 -0700647 main.log.report(' - Switch Connection Statistics - ')
648
jenkins7ead5a82015-03-13 10:28:21 -0700649 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
650 ' ms' + ' End-to-end Std dev: ' +
jenkins3e5a3912015-04-02 18:14:16 -0700651 str(endToEndStdDev) + ' ms')
652
653 main.log.report(' Tcp-to-feature-reply Avg: ' +
654 str(tcpToFeatureAvg) + ' ms')
655 main.log.report(' Tcp-to-feature-reply Std dev: '+
656 str(tcpToFeatureStdDev) + ' ms')
657
658 main.log.report(' Feature-reply-to-role-request Avg: ' +
659 str(featureToRoleAvg) + ' ms')
660 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
661 str(featureToRoleStdDev) + ' ms')
662
663 main.log.report(' Role-request-to-role-reply Avg: ' +
664 str(roleToOfpAvg) +' ms')
665 main.log.report(' Role-request-to-role-reply Std dev: ' +
666 str(roleToOfpStdDev) + ' ms')
667
668 main.log.report(' Role-reply-to-device Avg: ' +
669 str(ofpToDeviceAvg) +' ms')
670 main.log.report(' Role-reply-to-device Std dev: ' +
671 str(ofpToDeviceStdDev) + ' ms')
672
673 main.log.report(' Device-to-graph Avg: ' +
674 str(deviceToGraphAvg) + ' ms')
675 main.log.report( 'Device-to-graph Std dev: ' +
676 str(deviceToGraphStdDev) + ' ms')
677
678 main.log.report(' - Switch Disconnection Statistics - ')
679 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
680 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
681 str(finAckStdDev) + ' ms')
682
683 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
684 ' ms')
685 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
686 ' ms')
687
688 main.log.report(' Device-to-graph (disconnect) Avg: ' +
689 str(deviceToGraphDiscAvg) + ' ms')
690 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
691 str(deviceToGraphDiscStdDev) + ' ms')
692
jenkins7ead5a82015-03-13 10:28:21 -0700693 dbCmdList.append(
694 "INSERT INTO switch_latency_tests VALUES('" +
695 timeToPost + "','switch_latency_results'," +
696 runNum + ',' + str(clusterCount) + ",'baremetal" +
697 str(node + 1) + "'," + str(endToEndAvg) + ',' +
jenkins3e5a3912015-04-02 18:14:16 -0700698 str(endToEndStdDev) + ',0,0);')
jenkins7ead5a82015-03-13 10:28:21 -0700699
700 if debugMode == 'on':
701 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
702 '/tmp/', copyFileName='sw_lat_karaf')
703 fResult = open(resultPath, 'a')
704 for line in dbCmdList:
705 if line:
706 fResult.write(line + '\n')
707
708 fResult.close()
709 assertion = main.TRUE
710 utilities.assert_equals(expect=main.TRUE, actual=assertion,
711 onpass='Switch latency test successful',
712 onfail='Switch latency test failed')
713
714 def CASE3(self, main):
715 """
716 Bring port up / down and measure latency.
717 Port enable / disable is simulated by ifconfig up / down
718
719 In ONOS-next, we must ensure that the port we are
720 manipulating is connected to another switch with a valid
721 connection. Otherwise, graph view will not be updated.
722 """
723 global timeToPost
724 import time
725 import subprocess
726 import os
727 import requests
728 import json
729 import numpy
730 ONOS1Ip = main.params['CTRL']['ip1']
731 ONOS2Ip = main.params['CTRL']['ip2']
732 ONOS3Ip = main.params['CTRL']['ip3']
733 ONOSUser = main.params['CTRL']['user']
734 defaultSwPort = main.params['CTRL']['port1']
735 assertion = main.TRUE
736 numIter = main.params['TEST']['numIter']
737 iterIgnore = int(main.params['TEST']['iterIgnore'])
738 deviceTimestamp = main.params['JSON']['deviceTimestamp']
739 graphTimestamp = main.params['JSON']['graphTimestamp']
740 linkTimestamp = main.params['JSON']['linkTimestamp']
741
742 tsharkPortUp = '/tmp/tshark_port_up.txt'
743 tsharkPortDown = '/tmp/tshark_port_down.txt'
744 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
745
746 debugMode = main.params['TEST']['debugMode']
747 postToDB = main.params['DB']['postToDB']
748 resultPath = main.params['DB']['portEventResultPath']
749 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
750 localTime = time.strftime('%x %X')
751 localTime = localTime.replace('/', '')
752 localTime = localTime.replace(' ', '_')
753 localTime = localTime.replace(':', '')
754
755 if debugMode == 'on':
756 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
757
758 upThresholdStr = main.params['TEST']['portUpThreshold']
759 downThresholdStr = main.params['TEST']['portDownThreshold']
760 upThresholdObj = upThresholdStr.split(',')
761 downThresholdObj = downThresholdStr.split(',')
762 upThresholdMin = int(upThresholdObj[0])
763 upThresholdMax = int(upThresholdObj[1])
764 downThresholdMin = int(downThresholdObj[0])
765 downThresholdMax = int(downThresholdObj[1])
766
767 interfaceConfig = 's1-eth1'
768 main.log.report('Port enable / disable latency')
769 main.log.report('Simulated by ifconfig up / down')
770 main.log.report('Total iterations of test: ' + str(numIter))
771 main.step('Assign switches s1 and s2 to controller 1')
772
773 main.Mininet1.assignSwController(sw='1',
774 ip1=ONOS1Ip, port1=defaultSwPort)
775 main.Mininet1.assignSwController(sw='2',
776 ip1=ONOS1Ip, port1=defaultSwPort)
777
778 time.sleep(15)
779
780 portUpDeviceToOfpList = []
781 portUpGraphToOfpList = []
782 portDownDeviceToOfpList = []
783 portDownGraphToOfpList = []
784
785 portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
786 portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
787 portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
788 portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
789 portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
790 portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
791 portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
792
793 for i in range(0, int(numIter)):
794 main.step('Starting wireshark capture for port status down')
795 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
796 time.sleep(5)
797 main.step('Disable port: ' + interfaceConfig)
798 main.Mininet1.handle.sendline('sh ifconfig ' +
799 interfaceConfig + ' down')
800 main.Mininet1.handle.expect('mininet>')
801 time.sleep(3)
802 main.ONOS1.tsharkStop()
803 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
804 tsharkPortDown + ' /tmp/')
805 fPortDown = open(tsharkPortDown, 'r')
806 fLine = fPortDown.readline()
807 objDown = fLine.split(' ')
808 if len(fLine) > 0:
809 timestampBeginPtDown = int(float(objDown[1]) * 1000)
810 if timestampBeginPtDown < 1400000000000:
811 timestampBeginPtDown = int(float(objDown[2]) * 1000)
812 main.log.info('Port down begin timestamp: ' +
813 str(timestampBeginPtDown))
814 else:
815 main.log.info('Tshark output file returned unexpected' +
816 ' results: ' + str(objDown))
817 timestampBeginPtDown = 0
818 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700819
jenkins8ba10ab2015-03-24 10:31:31 -0700820 for node in range(0, clusterCount):
821 nodeNum = node+1
jenkins3e5a3912015-04-02 18:14:16 -0700822 metricsDown = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700823 jsonStrDown = metricsDown()
824 jsonObj = json.loads(jsonStrDown)
825
jenkins3e5a3912015-04-02 18:14:16 -0700826 if jsonObj:
827 graphTimestamp = jsonObj[graphTimestamp]['value']
828 deviceTimestamp = jsonObj[deviceTimestamp]['value']
829 linkTimestamp = jsonObj[linkTimestamp]['value']
830 else:
831 main.log.error( "Unexpected json object" )
832 graphTimestamp = 0
833 deviceTimestamp = 0
834 linkTimestamp = 0
835
jenkins8ba10ab2015-03-24 10:31:31 -0700836 ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown)
837 ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown)
838 ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown)
839
840 if ptDownGraphToOfp > downThresholdMin and\
841 ptDownGraphToOfp < downThresholdMax and i > iterIgnore:
842 portDownGraphNodeIter[node][i] = ptDownGraphToOfp
843 main.log.info("ONOS "+str(nodeNum)+
844 " port down graph-to-ofp: "+
845 str(ptDownGraphToOfp) + " ms")
846 else:
847 main.log.info("ONOS "+str(nodeNum)+
848 " port down graph-to-ofp ignored"+
849 " due to excess in threshold or premature iteration")
850
851 if ptDownDeviceToOfp > downThresholdMin and\
852 ptDownDeviceToOfp < downThresholdMax and i > iterIgnore:
853 portDownDeviceNodeIter[node][i] = ptDownDeviceToOfp
854 main.log.info("ONOS "+str(nodeNum)+
855 " port down device-to-ofp: "+
856 str(ptDownDeviceToOfp) + " ms")
857 else:
858 main.log.info("ONOS "+str(nodeNum)+
859 " port down device-to-ofp ignored"+
860 " due to excess in threshold or premature iteration")
861
862 if ptDownLinkToOfp > downThresholdMin and\
863 ptDownLinkToOfp < downThresholdMax and i > iterIgnore:
864 portDownLinkNodeIter[node][i] = ptDownLinkToOfp
865 main.log.info("ONOS "+str(nodeNum)+
866 " port down link-to-ofp: "+
867 str(ptDownLinkToOfp) + " ms")
868 else:
869 main.log.info("ONOS "+str(nodeNum)+
870 " port down link-to-ofp ignored"+
871 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700872
jenkins7ead5a82015-03-13 10:28:21 -0700873 time.sleep(3)
874
875 main.step('Starting wireshark capture for port status up')
876 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
877
878 time.sleep(5)
879 main.step('Enable port and obtain timestamp')
880 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
881 main.Mininet1.handle.expect('mininet>')
882
883 time.sleep(5)
884 main.ONOS1.tsharkStop()
885
886 time.sleep(3)
887 os.system('scp ' + ONOSUser + '@' +
888 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
889
890 fPortUp = open(tsharkPortUp, 'r')
891 fLine = fPortUp.readline()
892 objUp = fLine.split(' ')
893 if len(fLine) > 0:
894 timestampBeginPtUp = int(float(objUp[1]) * 1000)
895 if timestampBeginPtUp < 1400000000000:
896 timestampBeginPtUp = int(float(objUp[2]) * 1000)
897 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
898 else:
899 main.log.info('Tshark output file returned unexpected' + ' results.')
900 timestampBeginPtUp = 0
901 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700902
903 for node in range(0, clusterCount):
904 nodeNum = node+1
jenkins3e5a3912015-04-02 18:14:16 -0700905 metricsUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700906 jsonStrUp = metricsUp()
907 jsonObj = json.loads(jsonStrUp)
jenkins3e5a3912015-04-02 18:14:16 -0700908
909 if jsonObj:
910 graphTimestamp = jsonObj[graphTimestamp]['value']
911 deviceTimestamp = jsonObj[deviceTimestamp]['value']
912 linkTimestamp = jsonObj[linkTimestamp]['value']
913 else:
914 main.log.error( "Unexpected json object" )
915 graphTimestamp = 0
916 deviceTimestamp = 0
917 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700918
jenkins8ba10ab2015-03-24 10:31:31 -0700919 ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp)
920 ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp)
921 ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp)
922
923 if ptUpGraphToOfp > upThresholdMin and\
924 ptUpGraphToOfp < upThresholdMax and i > iterIgnore:
925 portUpGraphNodeIter[node][i] = ptUpGraphToOfp
926 main.log.info("ONOS "+str(nodeNum)+
927 " port up graph-to-ofp: "+
928 str(ptUpGraphToOfp) + " ms")
929 else:
930 main.log.info("ONOS "+str(nodeNum)+
931 " port up graph-to-ofp ignored"+
932 " due to excess in threshold or premature iteration")
933
934 if ptUpDeviceToOfp > upThresholdMin and\
935 ptUpDeviceToOfp < upThresholdMax and i > iterIgnore:
936 portUpDeviceNodeIter[node][i] = ptUpDeviceToOfp
937 main.log.info("ONOS "+str(nodeNum)+
938 " port up device-to-ofp: "+
939 str(ptUpDeviceToOfp) + " ms")
940 else:
941 main.log.info("ONOS "+str(nodeNum)+
942 " port up device-to-ofp ignored"+
943 " due to excess in threshold or premature iteration")
944
945 if ptUpLinkToOfp > upThresholdMin and\
946 ptUpLinkToOfp < upThresholdMax and i > iterIgnore:
947 portUpLinkNodeIter[node][i] = ptUpLinkToOfp
948 main.log.info("ONOS "+str(nodeNum)+
949 " port up link-to-ofp: "+
950 str(ptUpLinkToOfp) + " ms")
951 else:
952 main.log.info("ONOS "+str(nodeNum)+
953 " port up link-to-ofp ignored"+
954 " due to excess in threshold or premature iteration")
955
jenkins7ead5a82015-03-13 10:28:21 -0700956 dbCmdList = []
957 for node in range(0, clusterCount):
958 portUpDevList = []
959 portUpGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700960 portUpLinkList = []
jenkins7ead5a82015-03-13 10:28:21 -0700961 portDownDevList = []
962 portDownGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700963 portDownLinkList = []
964
jenkins7ead5a82015-03-13 10:28:21 -0700965 portUpDevAvg = 0
966 portUpGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700967 portUpLinkAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700968 portDownDevAvg = 0
969 portDownGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700970 portDownLinkAvg = 0
971
jenkins7ead5a82015-03-13 10:28:21 -0700972 for item in portUpDevNodeIter[node]:
973 if item > 0.0:
974 portUpDevList.append(item)
975
976 for item in portUpGraphNodeIter[node]:
977 if item > 0.0:
978 portUpGraphList.append(item)
979
jenkins8ba10ab2015-03-24 10:31:31 -0700980 for item in portUpLinkNodeIter[node]:
981 if item > 0.0:
982 portUpLinkList.append(item)
983
jenkins7ead5a82015-03-13 10:28:21 -0700984 for item in portDownDevNodeIter[node]:
985 if item > 0.0:
986 portDownDevList.append(item)
987
988 for item in portDownGraphNodeIter[node]:
989 if item > 0.0:
990 portDownGraphList.append(item)
991
jenkins8ba10ab2015-03-24 10:31:31 -0700992 for item in portDownLinkNodeIter[node]:
993 if item > 0.0:
994 portDownLinkList.append(item)
995
jenkins7ead5a82015-03-13 10:28:21 -0700996 portUpDevAvg = round(numpy.mean(portUpDevList), 2)
997 portUpGraphAvg = round(numpy.mean(portUpGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -0700998 portUpLinkAvg = round(numpy.mean(portUpLinkList), 2)
999
jenkins7ead5a82015-03-13 10:28:21 -07001000 portDownDevAvg = round(numpy.mean(portDownDevList), 2)
1001 portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001002 portDownLinkAvg = round(numpy.mean(portDownLinkList), 2)
1003
jenkins7ead5a82015-03-13 10:28:21 -07001004 portUpStdDev = round(numpy.std(portUpGraphList), 2)
1005 portDownStdDev = round(numpy.std(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001006
jenkins7ead5a82015-03-13 10:28:21 -07001007 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
1008 main.log.report(' Port up ofp-to-device ' +
jenkins8ba10ab2015-03-24 10:31:31 -07001009 str(portUpDevAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001010 main.log.report(' Port up ofp-to-graph ' +
1011 str(portUpGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001012 main.log.report(' Port up ofp-to-link ' +
1013 str(portUpLinkAvg) + ' ms')
1014
jenkins7ead5a82015-03-13 10:28:21 -07001015 main.log.report(' Port down ofp-to-device ' +
1016 str(round(portDownDevAvg, 2)) + ' ms')
1017 main.log.report(' Port down ofp-to-graph ' +
1018 str(portDownGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001019 main.log.report(' Port down ofp-to-link ' +
1020 str(portDownLinkAvg) + ' ms')
1021
jenkins7ead5a82015-03-13 10:28:21 -07001022 dbCmdList.append("INSERT INTO port_latency_tests VALUES('" +
1023 timeToPost + "','port_latency_results'," + runNum +
1024 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
1025 "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) +
1026 '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');')
1027
1028 fResult = open(resultPath, 'a')
1029 for line in dbCmdList:
1030 if line:
1031 fResult.write(line + '\n')
1032
1033 fResult.close()
1034 main.Mininet1.deleteSwController('s1')
1035 main.Mininet1.deleteSwController('s2')
1036 utilities.assert_equals(expect=main.TRUE,
1037 actual=assertion,
1038 onpass='Port discovery latency calculation successful',
1039 onfail='Port discovery test failed')
1040
1041 def CASE4(self, main):
1042 """
1043 Increase number of nodes and initiate CLI
1044
1045 With the most recent implementation, we need a method to
1046 ensure all ONOS nodes are killed, as well as redefine
1047 the cell files to ensure all nodes that will be used
1048 is in the cell file. Otherwise, exceptions will
1049 prohibit test from running successfully.
1050
1051 3/12/15
1052
1053 """
1054 global clusterCount
1055 import time
1056 import os
1057
1058 clusterCount += 2
1059
1060 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1061 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1062 cellName = main.params[ 'ENV' ][ 'cellName' ]
1063 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1064
1065 main.log.report('Increasing cluster size to ' + str(clusterCount))
1066
1067 main.log.step( "Killing all ONOS processes before scale-out" )
1068
1069 for i in range( 1, 8 ):
1070 main.ONOSbench.onosDie(
1071 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1072 main.ONOSbench.onosUninstall(
1073 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1074
1075 main.step( "Creating scale-out cell file" )
1076 cellIp = []
1077 for node in range( 1, clusterCount + 1 ):
1078 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1079
1080 main.log.info( "Cell Ip list: " + str(cellIp) )
1081 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1082 str(features), *cellIp )
1083
1084 main.step( "Setting cell definition" )
1085 main.ONOSbench.setCell(cellName)
1086
1087 main.step( "Packaging cell definition" )
1088 main.ONOSbench.onosPackage()
1089
jenkins7ead5a82015-03-13 10:28:21 -07001090 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001091 main.ONOSbench.onosInstall(
1092 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1093
1094 time.sleep( 20 )
1095
jenkins7ead5a82015-03-13 10:28:21 -07001096 for node in range( 1, clusterCount + 1):
1097 for i in range( 2 ):
1098 isup = main.ONOSbench.isup(
1099 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1100 if isup:
1101 main.log.info( "ONOS "+str(node) + " is up\n")
1102 break
1103 if not isup:
1104 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001105
1106 for node in range( 1, clusterCount + 1):
jenkins3e5a3912015-04-02 18:14:16 -07001107 CLIs[node-1].startOnosCli
1108
1109 main.step( 'activating essential applications' )
1110 CLIs[node-1].activateApp( 'org.onosproject.metrics' )
1111 CLIs[node-1].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001112