blob: 2ffcdb09022eac28ca9122aff82c001124816be0 [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
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040020 global jenkinsBuildNumber
andrew@onlab.us0f468c42015-04-02 17:05:47 -040021
jenkins7ead5a82015-03-13 10:28:21 -070022 import time
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040023 import os
24
jenkins7ead5a82015-03-13 10:28:21 -070025 clusterCount = 1
26 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
27 runNum = time.strftime('%d%H%M%S')
28 cellName = main.params['ENV']['cellName']
29 gitPull = main.params['GIT']['autoPull']
30 checkoutBranch = main.params['GIT']['checkout']
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040031
32 # Get jenkins build number from environment.
33 # This environment variable will only exist when
34 # triggered by a jenkins job
35 try:
36 jenkinsBuildNumber = str(os.environ['BUILD_NUMBER'])
37 main.log.report( 'Jenkins build number: ' +
38 jenkinsBuildNumber )
39 except KeyError:
40 # Jenkins build number is also used in posting to DB
41 # If this test is not triggered by jenkins, give
42 # it the runNum variable instead, ensuring that
43 # the DB post will recognize it as a non-jenkins run
44 jenkinsBuildNumber = str(runNum)
45 main.log.info( 'Job is not run by jenkins. '+
46 'Build number set to: ' + jenkinsBuildNumber)
47
andrew@onlab.us0f468c42015-04-02 17:05:47 -040048 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
jenkins7ead5a82015-03-13 10:28:21 -070059 MN1Ip = main.params['MN']['ip1']
60 BENCHIp = main.params['BENCH']['ip']
andrew@onlab.us0f468c42015-04-02 17:05:47 -040061 cellFeatures = main.params['ENV']['cellFeatures']
jenkins7ead5a82015-03-13 10:28:21 -070062 topoCfgFile = main.params['TEST']['topoConfigFile']
63 topoCfgName = main.params['TEST']['topoConfigName']
64 portEventResultPath = main.params['DB']['portEventResultPath']
65 switchEventResultPath = main.params['DB']['switchEventResultPath']
66 mvnCleanInstall = main.params['TEST']['mci']
67
68 main.case('Setting up test environment')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040069
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('\\$')
jenkins7ead5a82015-03-13 10:28:21 -070077
78 main.log.report('Setting up test environment')
79
80 main.step('Starting mininet topology ')
81 main.Mininet1.startNet()
82
83 main.step('Cleaning previously installed ONOS if any')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040084 # Nodes 2 ~ 7
85 for i in range( 1, 7 ):
86 main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i])
jenkins7ead5a82015-03-13 10:28:21 -070087
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
jenkins7ead5a82015-03-13 10:28:21 -070097 main.step('Creating cell file')
98 cellFileResult = main.ONOSbench.createCellFile(
andrew@onlab.us0f468c42015-04-02 17:05:47 -040099 BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700100
101 main.step('Applying cell file to environment')
102 cellApplyResult = main.ONOSbench.setCell(cellName)
103 verifyCellResult = main.ONOSbench.verifyCell()
104
105 main.step('Git checkout and pull ' + checkoutBranch)
106 if gitPull == 'on':
107 checkoutResult = main.TRUE
108 pullResult = main.ONOSbench.gitPull()
109 else:
110 checkoutResult = main.TRUE
111 pullResult = main.TRUE
112 main.log.info('Skipped git checkout and pull')
113
114 main.log.report('Commit information - ')
115 main.ONOSbench.getVersion(report=True)
116 main.step('Using mvn clean & install')
117 if mvnCleanInstall == 'on':
118 mvnResult = main.ONOSbench.cleanInstall()
119 elif mvnCleanInstall == 'off':
120 main.log.info('mci turned off by settings')
121 mvnResult = main.TRUE
122 main.step('Set cell for ONOS cli env')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400123 CLIs[0].setCell(cellName)
jenkins7ead5a82015-03-13 10:28:21 -0700124
125 main.step('Creating ONOS package')
126 packageResult = main.ONOSbench.onosPackage()
127
128 main.step('Installing ONOS package')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400129 install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700130
131 time.sleep(10)
132
133 main.step('Start onos cli')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400134 cli1 = CLIs[0].startOnosCli(nodeIpList[0])
135
136 main.step( 'activating essential applications' )
137 CLIs[0].activateApp( 'org.onosproject.metrics' )
138 CLIs[0].activateApp( 'org.onosproject.openflow' )
139
140 main.step( 'Configuring application parameters' )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400141
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
jenkins7ead5a82015-03-13 10:28:21 -0700150 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 s1 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
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400181
jenkins7ead5a82015-03-13 10:28:21 -0700182 ONOSUser = main.params['CTRL']['user']
183 defaultSwPort = main.params['CTRL']['port1']
184 numIter = main.params['TEST']['numIter']
185 iterIgnore = int(main.params['TEST']['iterIgnore'])
jenkins8ba10ab2015-03-24 10:31:31 -0700186
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400187 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
188 graphTimestampKey = main.params['JSON']['graphTimestamp']
jenkins8ba10ab2015-03-24 10:31:31 -0700189
jenkins7ead5a82015-03-13 10:28:21 -0700190 debugMode = main.params['TEST']['debugMode']
191 onosLog = main.params['TEST']['onosLogFile']
192 resultPath = main.params['DB']['switchEventResultPath']
193 thresholdStr = main.params['TEST']['singleSwThreshold']
194 thresholdObj = thresholdStr.split(',')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400195 thresholdMin = float(thresholdObj[0])
196 thresholdMax = float(thresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700197
jenkins8ba10ab2015-03-24 10:31:31 -0700198 # Look for 'role-request' messages,
199 # which replaces the 'vendor' messages previously seen
200 # on OVS 2.0.1
jenkins7ead5a82015-03-13 10:28:21 -0700201 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700202 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
203 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
204 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400205 tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700206
jenkins7ead5a82015-03-13 10:28:21 -0700207 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
208 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
jenkins8ba10ab2015-03-24 10:31:31 -0700209 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
210 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400211 tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
212
213 # Switch connect measurement list
214 # TCP Syn/Ack -> Feature Reply latency collection for each node
215 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
216 # Feature Reply -> Role Request latency collection for each node
217 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
218 int(numIter)))
219 # Role Request -> Role Reply latency collection for each node
220 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
221 int(numIter)))
222 # Role Reply -> Device Update latency collection for each node
223 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
224 int(numIter)))
225 # Device Update -> Graph Update latency collection for each node
226 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
227 int(numIter)))
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400228 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400229
230 # Switch disconnect measurement lists
231 # Mininet Fin / Ack -> Mininet Ack
232 finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
233 int(numIter)))
234 # Mininet Ack -> Device Event
235 ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
236 int(numIter)))
237 # Device event -> Graph event
238 deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
239 int(numIter)))
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400240 endToEndDiscLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700241
jenkins7ead5a82015-03-13 10:28:21 -0700242 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)
jenkins8ba10ab2015-03-24 10:31:31 -0700261 main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
262 main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
263
jenkins7ead5a82015-03-13 10:28:21 -0700264 time.sleep(10)
265
266 main.log.info('Assigning s3 to controller')
267 main.Mininet1.assignSwController(sw='3',
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400268 ip1=nodeIpList[0], port1=defaultSwPort)
jenkins7ead5a82015-03-13 10:28:21 -0700269
270 time.sleep(10)
271
272 main.log.info('Stopping all Tshark processes')
273 main.ONOS1.tsharkStop()
274
275 main.log.info('Copying over tshark files')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400276 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins7ead5a82015-03-13 10:28:21 -0700277 ':' + tsharkTcpOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400278 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700279 ':' + tsharkRoleOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400280 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700281 ':' + tsharkFeatureOutput + ' /tmp/')
282 os.system('scp ' + ONOSUser + '@' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400283 nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700284
285 # Get tcp syn / ack output
jenkins7ead5a82015-03-13 10:28:21 -0700286 time.sleep(5)
287 tcpFile = open(tsharkTcpOutput, 'r')
288 tempText = tcpFile.readline()
289 tempText = tempText.split(' ')
290 main.log.info('Object read in from TCP capture: ' +
291 str(tempText))
292
293 if len(tempText) > 1:
294 t0Tcp = float(tempText[1]) * 1000.0
295 else:
296 main.log.error('Tshark output file for TCP' +
297 ' returned unexpected results')
298 t0Tcp = 0
299 assertion = main.FALSE
300 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700301
302 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700303 time.sleep(5)
304 ofFile = open(tsharkOfOutput, 'r')
305 lineOfp = ''
306 while True:
307 tempText = ofFile.readline()
308 if tempText != '':
309 lineOfp = tempText
310 else:
311 break
jenkins7ead5a82015-03-13 10:28:21 -0700312 obj = lineOfp.split(' ')
313 main.log.info('Object read in from OFP capture: ' +
314 str(lineOfp))
315 if len(obj) > 1:
316 t0Ofp = float(obj[1]) * 1000.0
317 else:
318 main.log.error('Tshark output file for OFP' +
319 ' returned unexpected results')
320 t0Ofp = 0
321 assertion = main.FALSE
322 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700323
324 # Get role request output
325 roleFile = open(tsharkRoleOutput, 'r')
326 tempText = roleFile.readline()
327 tempText = tempText.split(' ')
328 if len(tempText) > 1:
329 main.log.info('Object read in from role request capture:' +
330 str(tempText))
331 roleTimestamp = float(tempText[1]) * 1000.0
332 else:
333 main.log.error('Tshark output file for role request' +
334 ' returned unexpected results')
335 timeRoleRequest = 0
336 assertion = main.FALSE
337 roleFile.close()
338
339 # Get feature reply output
340 featureFile = open(tsharkFeatureOutput, 'r')
341 tempText = featureFile.readline()
342 tempText = tempText.split(' ')
343 if len(tempText) > 1:
344 main.log.info('Object read in from feature reply capture: '+
345 str(tempText))
346 featureTimestamp = float(tempText[1]) * 1000.0
347 else:
348 main.log.error('Tshark output file for feature reply' +
349 ' returned unexpected results')
350 timeFeatureReply = 0
351 assertion = main.FALSE
352 featureFile.close()
353
354 # TODO: calculate feature reply, role request times
355 # stack measurements correctly and report
356
jenkins8ba10ab2015-03-24 10:31:31 -0700357 #TODO: Refactor in progress
358
359 for node in range(0, clusterCount):
360 nodeNum = node+1
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400361 metricsSwUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700362 jsonStr = metricsSwUp()
363 jsonObj = json.loads(jsonStr)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400364 if jsonObj:
365 graphTimestamp = jsonObj[graphTimestampKey]['value']
366 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700367 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400368 main.log.error( "Unexpected JSON object" )
369 # If we could not obtain the JSON object,
370 # set the timestamps to 0, which will be
371 # excluded from the measurement later on
372 # (realized as invalid)
373 graphTimestamp = 0
374 deviceTimestamp = 0
375
376 endToEnd = int(graphTimestamp) - int(t0Tcp)
377
378 # Below are measurement breakdowns of the end-to-end
379 # measurement.
380 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
381 featureToRole = int(roleTimestamp) - int(featureTimestamp)
382 roleToOfp = int(t0Ofp) - int(roleTimestamp)
383 ofpToDevice = int(deviceTimestamp) - int(t0Ofp)
384 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
385
386 if endToEnd > thresholdMin and\
387 endToEnd < thresholdMax and i >= iterIgnore:
388 endToEndLatNodeIter[node][i] = endToEnd
389 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
390 str(endToEnd) + " ms")
391 else:
392 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700393 "measurement ignored due to excess in "+
394 "threshold or premature iteration")
395
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400396 if tcpToFeature > thresholdMin and\
397 tcpToFeature < thresholdMax and i >= iterIgnore:
398 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
399 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
400 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700401 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400402 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700403 "measurement ignored due to excess in "+
404 "threshold or premature iteration")
405
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400406 if featureToRole > thresholdMin and\
407 featureToRole < thresholdMax and i >= iterIgnore:
408 featureToRoleRequestLatNodeIter[node][i] = featureToRole
409 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
410 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700411 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400412 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700413 "measurement ignored due to excess in "+
414 "threshold or premature iteration")
415
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400416 if roleToOfp > thresholdMin and\
417 roleToOfp < thresholdMax and i >= iterIgnore:
418 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
419 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
420 str(roleToOfp) + " ms")
421 else:
422 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
423 "measurement ignored due to excess in "+
424 "threshold or premature iteration")
425
426 if ofpToDevice > thresholdMin and\
427 ofpToDevice < thresholdMax and i >= iterIgnore:
428 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
429 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
430 str(ofpToDevice) + " ms")
431 else:
432 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
433 "measurement ignored due to excess in "+
434 "threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700435
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400436 if deviceToGraph > thresholdMin and\
437 deviceToGraph < thresholdMax and i >= iterIgnore:
438 deviceToGraphLatNodeIter[node][i] = deviceToGraph
439 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
440 str(deviceToGraph) + " ms")
441 else:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400442 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400443 "measurement ignored due to excess in "+
444 "threshold or premature iteration")
445
jenkins8ba10ab2015-03-24 10:31:31 -0700446 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700447 time.sleep(5)
448
449 # Get device id to remove
450 deviceIdJsonStr = main.ONOS1cli.devices()
451
452 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
453 deviceId = json.loads(deviceIdJsonStr)
454
455 deviceList = []
456 for device in deviceId:
457 deviceList.append(device['id'])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400458
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400459 # Measure switch down metrics
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400460 # TCP FIN/ACK -> TCP FIN
461 # TCP FIN -> Device Event
462 # Device Event -> Graph Event
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400463 # Capture switch down FIN / ACK packets
464
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400465 # The -A 1 grep option allows us to grab 1 extra line after the
466 # last tshark output grepped originally
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400467 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
468 grepOptions = '-A 1' )
469
470 time.sleep( 5 )
471
472 removeJsonList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400473
jenkins7ead5a82015-03-13 10:28:21 -0700474 main.step('Remove switch from controller')
475 main.Mininet1.deleteSwController('s3')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400476 firstDevice = deviceList[0]
jenkins7ead5a82015-03-13 10:28:21 -0700477 main.log.info( "Removing device " +str(firstDevice)+
478 " from ONOS" )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400479
480 time.sleep( 5 )
481
482 # We need to get metrics before removing
483 # device from the store below.
484 for node in range(0, clusterCount):
485 metricsSwDown = CLIs[node].topologyEventsMetrics
486 jsonStr = metricsSwDown()
487 removeJsonList.append( json.loads(jsonStr) )
488
jenkins7ead5a82015-03-13 10:28:21 -0700489 #if deviceId:
490 main.ONOS1cli.deviceRemove(firstDevice)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400491
492 main.ONOS1.tsharkStop()
493
494 main.log.info('Copying over tshark files')
495 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
496 ':' + tsharkFinAckOutput + ' /tmp/')
497
498 time.sleep( 10 )
499 finAckOutputList = []
500 with open(tsharkFinAckOutput, 'r') as f:
501 tempLine = f.readlines()
502 main.log.info('Object read in from FinAck capture: ' +
503 str(tempLine))
504
505 index = 1
506 for line in tempLine:
507 obj = line.split(' ')
jenkins7ead5a82015-03-13 10:28:21 -0700508
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400509 if len(obj) > 1:
510 if index == 1:
511 tFinAck = float(obj[1]) * 1000.0
512 elif index == 3:
513 tAck = float(obj[1]) * 1000.0
514 else:
515 main.log.error('Tshark output file for OFP' +
516 ' returned unexpected results')
517 tFinAck = 0
518 tAck = 0
519 assertion = main.FALSE
520
521 index = index+1
522
523 # with open() as f takes care of closing file
524
jenkins7ead5a82015-03-13 10:28:21 -0700525 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400526
527 for node in range(0, clusterCount):
528 nodeNum = node+1
529 jsonObj = removeJsonList[node]
530 if jsonObj:
531 graphTimestamp = jsonObj[graphTimestampKey]['value']
532 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
533 main.log.info("Graph timestamp: "+str(graphTimestamp))
534 main.log.info("Device timestamp: "+str(deviceTimestamp))
535 else:
536 main.log.error( "Unexpected JSON object" )
537 # If we could not obtain the JSON object,
538 # set the timestamps to 0, which will be
539 # excluded from the measurement later on
540 # (realized as invalid)
541 graphTimestamp = 0
542 deviceTimestamp = 0
543
544 finAckTransaction = int(tAck) - int(tFinAck)
545 ackToDevice = int(deviceTimestamp) - int(tAck)
546 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400547 endToEndDisc = int(graphTimestamp) - int(tFinAck)
548
549 if endToEndDisc > thresholdMin and\
550 endToEndDisc < thresholdMax and i >= iterIgnore:
551 endToEndDiscLatNodeIter[node][i] = endToEndDisc
552 main.log.info("ONOS "+str(nodeNum) +
553 "end-to-end disconnection: "+
554 str(endToEndDisc) + " ms" )
555 else:
556 main.log.info("ONOS " + str(nodeNum) +
557 " end-to-end disconnection "+
558 "measurement ignored due to excess in "+
559 "threshold or premature iteration")
560
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400561 if finAckTransaction > thresholdMin and\
562 finAckTransaction < thresholdMax and i >= iterIgnore:
563 finAckTransactionLatNodeIter[node][i] = finAckTransaction
564 main.log.info("ONOS "+str(nodeNum)+
565 " fin/ack transaction: "+
566 str(finAckTransaction) + " ms")
567 else:
568 main.log.info("ONOS "+str(nodeNum)+
569 " fin/ack transaction "+
570 "measurement ignored due to excess in "+
571 "threshold or premature iteration")
572
573 if ackToDevice > thresholdMin and\
574 ackToDevice < thresholdMax and i >= iterIgnore:
575 ackToDeviceLatNodeIter[node][i] = ackToDevice
576 main.log.info("ONOS "+str(nodeNum)+
577 " ack-to-device: "+
578 str(ackToDevice) + " ms")
579 else:
580 main.log.info("ONOS "+str(nodeNum)+
581 " ack-to-device "+
582 "measurement ignored due to excess in "+
583 "threshold or premature iteration")
584
585 if deviceToGraph > thresholdMin and\
586 deviceToGraph < thresholdMax and i >= iterIgnore:
587 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
588 main.log.info("ONOS "+str(nodeNum)+
589 " device-to-graph disconnect: "+
590 str(deviceToGraph) + " ms")
591 else:
592 main.log.info("ONOS "+str(nodeNum)+
593 " device-to-graph disconnect "+
594 "measurement ignored due to excess in "+
595 "threshold or premature iteration")
jenkins7ead5a82015-03-13 10:28:21 -0700596
597 endToEndAvg = 0
598 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700599 dbCmdList = []
600 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700601 # List of latency for each node
602 endToEndList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700603 tcpToFeatureList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400604 featureToRoleList = []
605 roleToOfpList = []
606 ofpToDeviceList = []
607 deviceToGraphList = []
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400608
609 finAckTransactionList = []
610 ackToDeviceList = []
611 deviceToGraphDiscList = []
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400612 endToEndDiscList = []
613
jenkins8ba10ab2015-03-24 10:31:31 -0700614 # LatNodeIter 2d arrays contain all iteration latency
615 # for each node of the current scale cluster size
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400616 # Switch connection measurements
617 # Set further acceptance criteria for measurements
618 # here if you would like to filter reporting results
jenkins7ead5a82015-03-13 10:28:21 -0700619 for item in endToEndLatNodeIter[node]:
620 if item > 0.0:
621 endToEndList.append(item)
622
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400623 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700624 if item > 0.0:
625 tcpToFeatureList.append(item)
626
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400627 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700628 if item > 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400629 featureToRoleList.append(item)
630
631 for item in roleRequestToRoleReplyLatNodeIter[node]:
632 if item > 0.0:
633 roleToOfpList.append(item)
634
635 for item in roleReplyToDeviceLatNodeIter[node]:
636 if item > 0.0:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400637 tcpToFeatureList.append(item)
638
639 for item in featureToRoleRequestLatNodeIter[node]:
640 if item > 0.0:
641 featureToRoleList.append(item)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400642
643 for item in deviceToGraphLatNodeIter[node]:
644 if item > 0.0:
645 deviceToGraphList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700646
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400647 # Switch disconnect measurements
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400648 for item in endToEndDiscLatNodeIter[node]:
649 if item > 0.0:
650 endToEndDiscList.append(item)
651
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400652 for item in finAckTransactionLatNodeIter[node]:
653 if item > 0.0:
654 finAckTransactionList.append(item)
655
656 for item in ackToDeviceLatNodeIter[node]:
657 if item > 0.0:
658 ackToDeviceList.append(item)
659
660 for item in deviceToGraphDiscLatNodeIter[node]:
661 if item > 0.0:
662 deviceToGraphDiscList.append(item)
663
jenkins7ead5a82015-03-13 10:28:21 -0700664 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400665 endToEndStdDev = round(numpy.std(endToEndList), 2)
666
jenkins8ba10ab2015-03-24 10:31:31 -0700667 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400668 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
669
670 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
671 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
672
673 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
674 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
675
jenkins7ead5a82015-03-13 10:28:21 -0700676 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400677 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
678
679 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
680 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
681
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400682 endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2)
683 endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2)
684
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400685 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
686 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
687
688 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
689 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
690
691 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
692 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
693
jenkins7ead5a82015-03-13 10:28:21 -0700694 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400695 main.log.report(' - Switch Connection Statistics - ')
696
jenkins7ead5a82015-03-13 10:28:21 -0700697 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
698 ' ms' + ' End-to-end Std dev: ' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400699 str(endToEndStdDev) + ' ms')
700
701 main.log.report(' Tcp-to-feature-reply Avg: ' +
702 str(tcpToFeatureAvg) + ' ms')
703 main.log.report(' Tcp-to-feature-reply Std dev: '+
704 str(tcpToFeatureStdDev) + ' ms')
705
706 main.log.report(' Feature-reply-to-role-request Avg: ' +
707 str(featureToRoleAvg) + ' ms')
708 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
709 str(featureToRoleStdDev) + ' ms')
710
711 main.log.report(' Role-request-to-role-reply Avg: ' +
712 str(roleToOfpAvg) +' ms')
713 main.log.report(' Role-request-to-role-reply Std dev: ' +
714 str(roleToOfpStdDev) + ' ms')
715
716 main.log.report(' Role-reply-to-device Avg: ' +
717 str(ofpToDeviceAvg) +' ms')
718 main.log.report(' Role-reply-to-device Std dev: ' +
719 str(ofpToDeviceStdDev) + ' ms')
720
721 main.log.report(' Device-to-graph Avg: ' +
722 str(deviceToGraphAvg) + ' ms')
723 main.log.report( 'Device-to-graph Std dev: ' +
724 str(deviceToGraphStdDev) + ' ms')
725
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400726 main.log.report(' - Switch Disconnection Statistics - ')
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400727 main.log.report(' End-to-end switch disconnect Avg: ' +
728 str(endToEndDiscAvg) + ' ms')
729 main.log.report(' End-to-end switch disconnect Std dev: ' +
730 str(endToEndDiscStdDev) + ' ms')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400731 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
732 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
733 str(finAckStdDev) + ' ms')
734
735 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
736 ' ms')
737 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
738 ' ms')
739
740 main.log.report(' Device-to-graph (disconnect) Avg: ' +
741 str(deviceToGraphDiscAvg) + ' ms')
742 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
743 str(deviceToGraphDiscStdDev) + ' ms')
744
jenkins7ead5a82015-03-13 10:28:21 -0700745 dbCmdList.append(
746 "INSERT INTO switch_latency_tests VALUES('" +
747 timeToPost + "','switch_latency_results'," +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400748 jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
jenkins7ead5a82015-03-13 10:28:21 -0700749 str(node + 1) + "'," + str(endToEndAvg) + ',' +
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400750 str(endToEndStdDev) + ',0,0);')
jenkins7ead5a82015-03-13 10:28:21 -0700751
752 if debugMode == 'on':
753 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
754 '/tmp/', copyFileName='sw_lat_karaf')
755 fResult = open(resultPath, 'a')
756 for line in dbCmdList:
757 if line:
758 fResult.write(line + '\n')
759
760 fResult.close()
761 assertion = main.TRUE
762 utilities.assert_equals(expect=main.TRUE, actual=assertion,
763 onpass='Switch latency test successful',
764 onfail='Switch latency test failed')
765
766 def CASE3(self, main):
767 """
768 Bring port up / down and measure latency.
769 Port enable / disable is simulated by ifconfig up / down
770
771 In ONOS-next, we must ensure that the port we are
772 manipulating is connected to another switch with a valid
773 connection. Otherwise, graph view will not be updated.
774 """
775 global timeToPost
776 import time
777 import subprocess
778 import os
779 import requests
780 import json
781 import numpy
782 ONOS1Ip = main.params['CTRL']['ip1']
783 ONOS2Ip = main.params['CTRL']['ip2']
784 ONOS3Ip = main.params['CTRL']['ip3']
785 ONOSUser = main.params['CTRL']['user']
786 defaultSwPort = main.params['CTRL']['port1']
787 assertion = main.TRUE
788 numIter = main.params['TEST']['numIter']
789 iterIgnore = int(main.params['TEST']['iterIgnore'])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400790
791 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
792 graphTimestampKey = main.params['JSON']['graphTimestamp']
793 linkTimestampKey = main.params['JSON']['linkTimestamp']
jenkins7ead5a82015-03-13 10:28:21 -0700794
795 tsharkPortUp = '/tmp/tshark_port_up.txt'
796 tsharkPortDown = '/tmp/tshark_port_down.txt'
797 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
798
799 debugMode = main.params['TEST']['debugMode']
800 postToDB = main.params['DB']['postToDB']
801 resultPath = main.params['DB']['portEventResultPath']
802 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
803 localTime = time.strftime('%x %X')
804 localTime = localTime.replace('/', '')
805 localTime = localTime.replace(' ', '_')
806 localTime = localTime.replace(':', '')
807
808 if debugMode == 'on':
809 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
810
811 upThresholdStr = main.params['TEST']['portUpThreshold']
812 downThresholdStr = main.params['TEST']['portDownThreshold']
813 upThresholdObj = upThresholdStr.split(',')
814 downThresholdObj = downThresholdStr.split(',')
815 upThresholdMin = int(upThresholdObj[0])
816 upThresholdMax = int(upThresholdObj[1])
817 downThresholdMin = int(downThresholdObj[0])
818 downThresholdMax = int(downThresholdObj[1])
819
820 interfaceConfig = 's1-eth1'
821 main.log.report('Port enable / disable latency')
822 main.log.report('Simulated by ifconfig up / down')
823 main.log.report('Total iterations of test: ' + str(numIter))
824 main.step('Assign switches s1 and s2 to controller 1')
825
826 main.Mininet1.assignSwController(sw='1',
827 ip1=ONOS1Ip, port1=defaultSwPort)
828 main.Mininet1.assignSwController(sw='2',
829 ip1=ONOS1Ip, port1=defaultSwPort)
830
831 time.sleep(15)
832
833 portUpDeviceToOfpList = []
834 portUpGraphToOfpList = []
835 portDownDeviceToOfpList = []
836 portDownGraphToOfpList = []
837
838 portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
839 portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
840 portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
841 portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
842 portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
843 portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
844 portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
845
846 for i in range(0, int(numIter)):
847 main.step('Starting wireshark capture for port status down')
848 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400849
jenkins7ead5a82015-03-13 10:28:21 -0700850 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400851
jenkins7ead5a82015-03-13 10:28:21 -0700852 main.step('Disable port: ' + interfaceConfig)
853 main.Mininet1.handle.sendline('sh ifconfig ' +
854 interfaceConfig + ' down')
855 main.Mininet1.handle.expect('mininet>')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400856
jenkins7ead5a82015-03-13 10:28:21 -0700857 time.sleep(3)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400858
jenkins7ead5a82015-03-13 10:28:21 -0700859 main.ONOS1.tsharkStop()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400860
jenkins7ead5a82015-03-13 10:28:21 -0700861 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
862 tsharkPortDown + ' /tmp/')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400863
jenkins7ead5a82015-03-13 10:28:21 -0700864 fPortDown = open(tsharkPortDown, 'r')
865 fLine = fPortDown.readline()
866 objDown = fLine.split(' ')
867 if len(fLine) > 0:
868 timestampBeginPtDown = int(float(objDown[1]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400869 # At times, tshark reports timestamp at the 3rd
870 # index of the array. If initial readings were
871 # unlike the epoch timestamp, then check the 3rd
872 # index and set that as a timestamp
jenkins7ead5a82015-03-13 10:28:21 -0700873 if timestampBeginPtDown < 1400000000000:
874 timestampBeginPtDown = int(float(objDown[2]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400875 # If there are any suspicion of invalid results
876 # check this reported value
jenkins7ead5a82015-03-13 10:28:21 -0700877 main.log.info('Port down begin timestamp: ' +
878 str(timestampBeginPtDown))
879 else:
880 main.log.info('Tshark output file returned unexpected' +
881 ' results: ' + str(objDown))
882 timestampBeginPtDown = 0
883 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700884
jenkins8ba10ab2015-03-24 10:31:31 -0700885 for node in range(0, clusterCount):
886 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400887 metricsDown = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700888 jsonStrDown = metricsDown()
889 jsonObj = json.loads(jsonStrDown)
890
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400891 if jsonObj:
892 graphTimestamp = jsonObj[graphTimestampKey]['value']
893 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
894 linkTimestamp = jsonObj[linkTimestampKey]['value']
895 else:
896 main.log.error( "Unexpected json object" )
897 graphTimestamp = 0
898 deviceTimestamp = 0
899 linkTimestamp = 0
900
jenkins8ba10ab2015-03-24 10:31:31 -0700901 ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown)
902 ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown)
903 ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown)
904
905 if ptDownGraphToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400906 ptDownGraphToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700907 portDownGraphNodeIter[node][i] = ptDownGraphToOfp
908 main.log.info("ONOS "+str(nodeNum)+
909 " port down graph-to-ofp: "+
910 str(ptDownGraphToOfp) + " ms")
911 else:
912 main.log.info("ONOS "+str(nodeNum)+
913 " port down graph-to-ofp ignored"+
914 " due to excess in threshold or premature iteration")
915
916 if ptDownDeviceToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400917 ptDownDeviceToOfp < downThresholdMax and i >= iterIgnore:
918 portDownDevNodeIter[node][i] = ptDownDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -0700919 main.log.info("ONOS "+str(nodeNum)+
920 " port down device-to-ofp: "+
921 str(ptDownDeviceToOfp) + " ms")
922 else:
923 main.log.info("ONOS "+str(nodeNum)+
924 " port down device-to-ofp ignored"+
925 " due to excess in threshold or premature iteration")
926
927 if ptDownLinkToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400928 ptDownLinkToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700929 portDownLinkNodeIter[node][i] = ptDownLinkToOfp
930 main.log.info("ONOS "+str(nodeNum)+
931 " port down link-to-ofp: "+
932 str(ptDownLinkToOfp) + " ms")
933 else:
934 main.log.info("ONOS "+str(nodeNum)+
935 " port down link-to-ofp ignored"+
936 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700937
jenkins7ead5a82015-03-13 10:28:21 -0700938 time.sleep(3)
939
940 main.step('Starting wireshark capture for port status up')
941 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
942
943 time.sleep(5)
944 main.step('Enable port and obtain timestamp')
945 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
946 main.Mininet1.handle.expect('mininet>')
947
948 time.sleep(5)
949 main.ONOS1.tsharkStop()
950
951 time.sleep(3)
952 os.system('scp ' + ONOSUser + '@' +
953 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
954
955 fPortUp = open(tsharkPortUp, 'r')
956 fLine = fPortUp.readline()
957 objUp = fLine.split(' ')
958 if len(fLine) > 0:
959 timestampBeginPtUp = int(float(objUp[1]) * 1000)
960 if timestampBeginPtUp < 1400000000000:
961 timestampBeginPtUp = int(float(objUp[2]) * 1000)
962 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
963 else:
964 main.log.info('Tshark output file returned unexpected' + ' results.')
965 timestampBeginPtUp = 0
966 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700967
968 for node in range(0, clusterCount):
969 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400970 metricsUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700971 jsonStrUp = metricsUp()
972 jsonObj = json.loads(jsonStrUp)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400973
974 if jsonObj:
975 graphTimestamp = jsonObj[graphTimestampKey]['value']
976 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
977 linkTimestamp = jsonObj[linkTimestampKey]['value']
978 else:
979 main.log.error( "Unexpected json object" )
980 graphTimestamp = 0
981 deviceTimestamp = 0
982 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700983
jenkins8ba10ab2015-03-24 10:31:31 -0700984 ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp)
985 ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp)
986 ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp)
987
988 if ptUpGraphToOfp > upThresholdMin and\
989 ptUpGraphToOfp < upThresholdMax and i > iterIgnore:
990 portUpGraphNodeIter[node][i] = ptUpGraphToOfp
991 main.log.info("ONOS "+str(nodeNum)+
992 " port up graph-to-ofp: "+
993 str(ptUpGraphToOfp) + " ms")
994 else:
995 main.log.info("ONOS "+str(nodeNum)+
996 " port up graph-to-ofp ignored"+
997 " due to excess in threshold or premature iteration")
998
999 if ptUpDeviceToOfp > upThresholdMin and\
1000 ptUpDeviceToOfp < upThresholdMax and i > iterIgnore:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001001 portUpDevNodeIter[node][i] = ptUpDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -07001002 main.log.info("ONOS "+str(nodeNum)+
1003 " port up device-to-ofp: "+
1004 str(ptUpDeviceToOfp) + " ms")
1005 else:
1006 main.log.info("ONOS "+str(nodeNum)+
1007 " port up device-to-ofp ignored"+
1008 " due to excess in threshold or premature iteration")
1009
1010 if ptUpLinkToOfp > upThresholdMin and\
1011 ptUpLinkToOfp < upThresholdMax and i > iterIgnore:
1012 portUpLinkNodeIter[node][i] = ptUpLinkToOfp
1013 main.log.info("ONOS "+str(nodeNum)+
1014 " port up link-to-ofp: "+
1015 str(ptUpLinkToOfp) + " ms")
1016 else:
1017 main.log.info("ONOS "+str(nodeNum)+
1018 " port up link-to-ofp ignored"+
1019 " due to excess in threshold or premature iteration")
1020
jenkins7ead5a82015-03-13 10:28:21 -07001021 dbCmdList = []
1022 for node in range(0, clusterCount):
1023 portUpDevList = []
1024 portUpGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001025 portUpLinkList = []
jenkins7ead5a82015-03-13 10:28:21 -07001026 portDownDevList = []
1027 portDownGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001028 portDownLinkList = []
1029
jenkins7ead5a82015-03-13 10:28:21 -07001030 portUpDevAvg = 0
1031 portUpGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001032 portUpLinkAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -07001033 portDownDevAvg = 0
1034 portDownGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001035 portDownLinkAvg = 0
1036
jenkins7ead5a82015-03-13 10:28:21 -07001037 for item in portUpDevNodeIter[node]:
1038 if item > 0.0:
1039 portUpDevList.append(item)
1040
1041 for item in portUpGraphNodeIter[node]:
1042 if item > 0.0:
1043 portUpGraphList.append(item)
1044
jenkins8ba10ab2015-03-24 10:31:31 -07001045 for item in portUpLinkNodeIter[node]:
1046 if item > 0.0:
1047 portUpLinkList.append(item)
1048
jenkins7ead5a82015-03-13 10:28:21 -07001049 for item in portDownDevNodeIter[node]:
1050 if item > 0.0:
1051 portDownDevList.append(item)
1052
1053 for item in portDownGraphNodeIter[node]:
1054 if item > 0.0:
1055 portDownGraphList.append(item)
1056
jenkins8ba10ab2015-03-24 10:31:31 -07001057 for item in portDownLinkNodeIter[node]:
1058 if item > 0.0:
1059 portDownLinkList.append(item)
1060
jenkins7ead5a82015-03-13 10:28:21 -07001061 portUpDevAvg = round(numpy.mean(portUpDevList), 2)
1062 portUpGraphAvg = round(numpy.mean(portUpGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001063 portUpLinkAvg = round(numpy.mean(portUpLinkList), 2)
1064
jenkins7ead5a82015-03-13 10:28:21 -07001065 portDownDevAvg = round(numpy.mean(portDownDevList), 2)
1066 portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001067 portDownLinkAvg = round(numpy.mean(portDownLinkList), 2)
1068
jenkins7ead5a82015-03-13 10:28:21 -07001069 portUpStdDev = round(numpy.std(portUpGraphList), 2)
1070 portDownStdDev = round(numpy.std(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001071
jenkins7ead5a82015-03-13 10:28:21 -07001072 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
1073 main.log.report(' Port up ofp-to-device ' +
jenkins8ba10ab2015-03-24 10:31:31 -07001074 str(portUpDevAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001075 main.log.report(' Port up ofp-to-graph ' +
1076 str(portUpGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001077 main.log.report(' Port up ofp-to-link ' +
1078 str(portUpLinkAvg) + ' ms')
1079
jenkins7ead5a82015-03-13 10:28:21 -07001080 main.log.report(' Port down ofp-to-device ' +
1081 str(round(portDownDevAvg, 2)) + ' ms')
1082 main.log.report(' Port down ofp-to-graph ' +
1083 str(portDownGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001084 main.log.report(' Port down ofp-to-link ' +
1085 str(portDownLinkAvg) + ' ms')
1086
jenkins7ead5a82015-03-13 10:28:21 -07001087 dbCmdList.append("INSERT INTO port_latency_tests VALUES('" +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -04001088 timeToPost + "','port_latency_results'," + jenkinsBuildNumber +
jenkins7ead5a82015-03-13 10:28:21 -07001089 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
1090 "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) +
1091 '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');')
1092
1093 fResult = open(resultPath, 'a')
1094 for line in dbCmdList:
1095 if line:
1096 fResult.write(line + '\n')
1097
1098 fResult.close()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001099
1100 # Delete switches from controller to prepare for next
1101 # set of tests
jenkins7ead5a82015-03-13 10:28:21 -07001102 main.Mininet1.deleteSwController('s1')
1103 main.Mininet1.deleteSwController('s2')
1104 utilities.assert_equals(expect=main.TRUE,
1105 actual=assertion,
1106 onpass='Port discovery latency calculation successful',
1107 onfail='Port discovery test failed')
1108
1109 def CASE4(self, main):
1110 """
1111 Increase number of nodes and initiate CLI
1112
1113 With the most recent implementation, we need a method to
1114 ensure all ONOS nodes are killed, as well as redefine
1115 the cell files to ensure all nodes that will be used
1116 is in the cell file. Otherwise, exceptions will
1117 prohibit test from running successfully.
1118
1119 3/12/15
1120
1121 """
1122 global clusterCount
1123 import time
1124 import os
1125
1126 clusterCount += 2
1127
1128 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1129 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1130 cellName = main.params[ 'ENV' ][ 'cellName' ]
1131 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1132
1133 main.log.report('Increasing cluster size to ' + str(clusterCount))
1134
1135 main.log.step( "Killing all ONOS processes before scale-out" )
1136
1137 for i in range( 1, 8 ):
1138 main.ONOSbench.onosDie(
1139 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1140 main.ONOSbench.onosUninstall(
1141 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1142
1143 main.step( "Creating scale-out cell file" )
1144 cellIp = []
1145 for node in range( 1, clusterCount + 1 ):
1146 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1147
1148 main.log.info( "Cell Ip list: " + str(cellIp) )
1149 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1150 str(features), *cellIp )
1151
1152 main.step( "Setting cell definition" )
1153 main.ONOSbench.setCell(cellName)
1154
1155 main.step( "Packaging cell definition" )
1156 main.ONOSbench.onosPackage()
1157
jenkins7ead5a82015-03-13 10:28:21 -07001158 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001159 main.ONOSbench.onosInstall(
1160 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1161
1162 time.sleep( 20 )
1163
jenkins7ead5a82015-03-13 10:28:21 -07001164 for node in range( 1, clusterCount + 1):
1165 for i in range( 2 ):
1166 isup = main.ONOSbench.isup(
1167 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1168 if isup:
1169 main.log.info( "ONOS "+str(node) + " is up\n")
1170 break
1171 if not isup:
1172 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001173
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001174 for node in range( 0, clusterCount ):
1175 CLIs[node].startOnosCli( cellIp[node] )
1176
1177 main.step( 'Setting configurations for metrics' )
1178 configParam = 'maxEvents 1'
1179 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1180 configParam = 'maxBatchMs 0'
1181 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1182 configParam = 'maxIdleMs 0'
1183 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1184
1185 main.step( 'Activating essential applications' )
1186 CLIs[0].activateApp( 'org.onosproject.metrics' )
1187 CLIs[0].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001188