blob: 699bc69a951f2c46c8d6c50784cff3bcbbf3d186 [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
andrew@onlab.us3b20f7f2015-04-29 15:10:04 -040042 # it 0 instead, ensuring that
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040043 # the DB post will recognize it as a non-jenkins run
andrew@onlab.us3b20f7f2015-04-29 15:10:04 -040044 jenkinsBuildNumber = str(0)
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040045 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 """
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400160 Assign s3 to ONOS1 and measure latency
jenkins7ead5a82015-03-13 10:28:21 -0700161
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.us55711ed2015-04-23 14:28:08 -0400195 thresholdMin = int(thresholdObj[0])
196 thresholdMax = int(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)
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400269
270 jsonStr = []
271 for node in range (0, clusterCount):
272 metricsSwUp = CLIs[node].topologyEventsMetrics()
273 jsonStr.append(metricsSwUp)
274
275 time.sleep(1)
jenkins7ead5a82015-03-13 10:28:21 -0700276
277 main.log.info('Stopping all Tshark processes')
278 main.ONOS1.tsharkStop()
279
280 main.log.info('Copying over tshark files')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400281 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins7ead5a82015-03-13 10:28:21 -0700282 ':' + tsharkTcpOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400283 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700284 ':' + tsharkRoleOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400285 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700286 ':' + tsharkFeatureOutput + ' /tmp/')
287 os.system('scp ' + ONOSUser + '@' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400288 nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700289
290 # Get tcp syn / ack output
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400291 # time.sleep(1)
jenkins7ead5a82015-03-13 10:28:21 -0700292 tcpFile = open(tsharkTcpOutput, 'r')
293 tempText = tcpFile.readline()
294 tempText = tempText.split(' ')
295 main.log.info('Object read in from TCP capture: ' +
296 str(tempText))
297
298 if len(tempText) > 1:
299 t0Tcp = float(tempText[1]) * 1000.0
300 else:
301 main.log.error('Tshark output file for TCP' +
302 ' returned unexpected results')
303 t0Tcp = 0
304 assertion = main.FALSE
305 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700306
307 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700308 ofFile = open(tsharkOfOutput, 'r')
309 lineOfp = ''
310 while True:
311 tempText = ofFile.readline()
312 if tempText != '':
313 lineOfp = tempText
314 else:
315 break
jenkins7ead5a82015-03-13 10:28:21 -0700316 obj = lineOfp.split(' ')
317 main.log.info('Object read in from OFP capture: ' +
318 str(lineOfp))
319 if len(obj) > 1:
320 t0Ofp = float(obj[1]) * 1000.0
321 else:
322 main.log.error('Tshark output file for OFP' +
323 ' returned unexpected results')
324 t0Ofp = 0
325 assertion = main.FALSE
326 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700327
328 # Get role request output
329 roleFile = open(tsharkRoleOutput, 'r')
330 tempText = roleFile.readline()
331 tempText = tempText.split(' ')
332 if len(tempText) > 1:
333 main.log.info('Object read in from role request capture:' +
334 str(tempText))
335 roleTimestamp = float(tempText[1]) * 1000.0
336 else:
337 main.log.error('Tshark output file for role request' +
338 ' returned unexpected results')
339 timeRoleRequest = 0
340 assertion = main.FALSE
341 roleFile.close()
342
343 # Get feature reply output
344 featureFile = open(tsharkFeatureOutput, 'r')
345 tempText = featureFile.readline()
346 tempText = tempText.split(' ')
347 if len(tempText) > 1:
348 main.log.info('Object read in from feature reply capture: '+
349 str(tempText))
andrew@onlab.us3b20f7f2015-04-29 15:10:04 -0400350 if tempText[1] != ' ' and float(tempText[1]) > 1400000000.0:
351 temp = tempText[1]
352 elif tempText[2] != ' ' and float(tempText[2]) > 1400000000.0:
353 temp = tempText[2]
354 else:
355 temp = 0
356 featureTimestamp = float(temp) * 1000.0
jenkins8ba10ab2015-03-24 10:31:31 -0700357 else:
358 main.log.error('Tshark output file for feature reply' +
359 ' returned unexpected results')
360 timeFeatureReply = 0
361 assertion = main.FALSE
362 featureFile.close()
363
jenkins8ba10ab2015-03-24 10:31:31 -0700364 for node in range(0, clusterCount):
365 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400366 #metricsSwUp = CLIs[node].topologyEventsMetrics
367 #jsonStr = metricsSwUp()
368 jsonObj = json.loads(jsonStr[node])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400369 if jsonObj:
370 graphTimestamp = jsonObj[graphTimestampKey]['value']
371 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700372 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400373 main.log.error( "Unexpected JSON object" )
374 # If we could not obtain the JSON object,
375 # set the timestamps to 0, which will be
376 # excluded from the measurement later on
377 # (realized as invalid)
378 graphTimestamp = 0
379 deviceTimestamp = 0
380
381 endToEnd = int(graphTimestamp) - int(t0Tcp)
382
383 # Below are measurement breakdowns of the end-to-end
384 # measurement.
385 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
386 featureToRole = int(roleTimestamp) - int(featureTimestamp)
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400387 roleToOfp = float(t0Ofp) - float(roleTimestamp)
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400388 ofpToDevice = float(deviceTimestamp) - float(t0Ofp)
389 # Timestamps gathered from ONOS are millisecond
390 # precision. They are returned as integers, thus no
391 # need to be more precise than 'int'. However,
392 # the processing seems to be mostly under 1 ms,
393 # thus this may be a problem point to handle any
394 # submillisecond output that we are unsure of.
395 # For now, this will be treated as 0 ms if less than 1 ms
396 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400397
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400398 if endToEnd >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400399 endToEnd < thresholdMax and i >= iterIgnore:
400 endToEndLatNodeIter[node][i] = endToEnd
401 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
402 str(endToEnd) + " ms")
403 else:
404 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700405 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400406 "threshold or premature iteration: ")
407 main.log.info(str(endToEnd))
408
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400409 if tcpToFeature >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400410 tcpToFeature < thresholdMax and i >= iterIgnore:
411 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
412 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
413 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700414 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400415 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700416 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400417 "threshold or premature iteration: ")
418 main.log.info(str(tcpToFeature))
jenkins8ba10ab2015-03-24 10:31:31 -0700419
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400420 if featureToRole >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400421 featureToRole < thresholdMax and i >= iterIgnore:
422 featureToRoleRequestLatNodeIter[node][i] = featureToRole
423 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
424 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700425 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400426 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700427 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400428 "threshold or premature iteration: ")
429 main.log.info(str(featureToRole))
jenkins8ba10ab2015-03-24 10:31:31 -0700430
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400431 if roleToOfp >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400432 roleToOfp < thresholdMax and i >= iterIgnore:
433 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
434 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
435 str(roleToOfp) + " ms")
436 else:
437 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
438 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400439 "threshold or premature iteration: ")
440 main.log.info(str(roleToOfp))
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400441
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400442 if ofpToDevice >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400443 ofpToDevice < thresholdMax and i >= iterIgnore:
444 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
445 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
446 str(ofpToDevice) + " ms")
447 else:
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400448 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400449 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400450 "threshold or premature iteration: ")
451 main.log.info(str(ofpToDevice))
jenkins8ba10ab2015-03-24 10:31:31 -0700452
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400453 if deviceToGraph >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400454 deviceToGraph < thresholdMax and i >= iterIgnore:
455 deviceToGraphLatNodeIter[node][i] = deviceToGraph
456 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
457 str(deviceToGraph) + " ms")
458 else:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400459 if deviceToGraph == 0:
460 deviceToGraphLatNodeIter[node][i] = 0
461 main.log.info("ONOS "+str(nodeNum) +
462 " device-to-graph measurement "+
463 "was set to 0 ms because of precision "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400464 "uncertainty. ")
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400465 else:
466 main.log.info("ONOS "+str(nodeNum)+
467 " device-to-graph "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400468 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400469 "threshold or premature iteration: ")
470 main.log.info(str(deviceToGraph))
471
jenkins8ba10ab2015-03-24 10:31:31 -0700472 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700473 time.sleep(5)
474
475 # Get device id to remove
476 deviceIdJsonStr = main.ONOS1cli.devices()
477
478 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
479 deviceId = json.loads(deviceIdJsonStr)
480
481 deviceList = []
482 for device in deviceId:
483 deviceList.append(device['id'])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400484
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400485 # Measure switch down metrics
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400486 # TCP FIN/ACK -> TCP FIN
487 # TCP FIN -> Device Event
488 # Device Event -> Graph Event
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400489 # Capture switch down FIN / ACK packets
490
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400491 # The -A 1 grep option allows us to grab 1 extra line after the
492 # last tshark output grepped originally
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400493 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
494 grepOptions = '-A 1' )
495
496 time.sleep( 5 )
497
498 removeJsonList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400499
jenkins7ead5a82015-03-13 10:28:21 -0700500 main.step('Remove switch from controller')
501 main.Mininet1.deleteSwController('s3')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400502 firstDevice = deviceList[0]
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400503
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400504 # We need to get metrics before removing
505 # device from the store below.
506 for node in range(0, clusterCount):
507 metricsSwDown = CLIs[node].topologyEventsMetrics
508 jsonStr = metricsSwDown()
509 removeJsonList.append( json.loads(jsonStr) )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400510
511 main.ONOS1.tsharkStop()
andrew@onlab.us3b20f7f2015-04-29 15:10:04 -0400512
513 main.log.info( "Removing device " +str(firstDevice)+
514 " from ONOS" )
515
516 #if deviceId:
517 main.ONOS1cli.deviceRemove(firstDevice)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400518
519 main.log.info('Copying over tshark files')
520 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
521 ':' + tsharkFinAckOutput + ' /tmp/')
522
523 time.sleep( 10 )
524 finAckOutputList = []
525 with open(tsharkFinAckOutput, 'r') as f:
526 tempLine = f.readlines()
527 main.log.info('Object read in from FinAck capture: ' +
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400528 "\n".join(tempLine))
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400529
530 index = 1
531 for line in tempLine:
532 obj = line.split(' ')
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400533
534 # There are at least 3 objects in field (valid
535 # tshark output is lengthy)
536 if len(obj) > 2:
537 # If first index of object is like an epoch time
andrew@onlab.us3b20f7f2015-04-29 15:10:04 -0400538 if obj[1] != ' ' and float(obj[1]) > 1400000000.0:
539 temp = obj[1]
540 elif obj[2] != ' 'and float(obj[2]) > 1400000000.0:
541 temp = obj[2]
542 elif obj[3] != ' 'and float(obj[3]) > 1400000000.0:
andrew@onlab.usa838a062015-04-23 19:10:25 -0400543 temp = obj[3]
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400544 else:
545 temp = 0
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400546 if index == 1:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400547 tFinAck = float(temp) * 1000.0
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400548 elif index == 3:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400549 tAck = float(temp) * 1000.0
550
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400551 else:
552 main.log.error('Tshark output file for OFP' +
553 ' returned unexpected results')
554 tFinAck = 0
555 tAck = 0
556 assertion = main.FALSE
557
558 index = index+1
559
560 # with open() as f takes care of closing file
561
jenkins7ead5a82015-03-13 10:28:21 -0700562 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400563
564 for node in range(0, clusterCount):
565 nodeNum = node+1
566 jsonObj = removeJsonList[node]
567 if jsonObj:
568 graphTimestamp = jsonObj[graphTimestampKey]['value']
569 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
570 main.log.info("Graph timestamp: "+str(graphTimestamp))
571 main.log.info("Device timestamp: "+str(deviceTimestamp))
572 else:
573 main.log.error( "Unexpected JSON object" )
574 # If we could not obtain the JSON object,
575 # set the timestamps to 0, which will be
576 # excluded from the measurement later on
577 # (realized as invalid)
578 graphTimestamp = 0
579 deviceTimestamp = 0
580
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400581 finAckTransaction = float(tAck) - float(tFinAck)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400582 ackToDevice = float(deviceTimestamp) - float(tAck)
583 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400584 endToEndDisc = int(graphTimestamp) - int(tFinAck)
585
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400586 if endToEndDisc >= thresholdMin and\
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400587 endToEndDisc < thresholdMax and i >= iterIgnore:
588 endToEndDiscLatNodeIter[node][i] = endToEndDisc
589 main.log.info("ONOS "+str(nodeNum) +
590 "end-to-end disconnection: "+
591 str(endToEndDisc) + " ms" )
592 else:
593 main.log.info("ONOS " + str(nodeNum) +
594 " end-to-end disconnection "+
595 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400596 "threshold or premature iteration: ")
597 main.log.info(str(endToEndDisc))
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400598
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400599 if finAckTransaction >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400600 finAckTransaction < thresholdMax and i >= iterIgnore:
601 finAckTransactionLatNodeIter[node][i] = finAckTransaction
602 main.log.info("ONOS "+str(nodeNum)+
603 " fin/ack transaction: "+
604 str(finAckTransaction) + " ms")
605 else:
606 main.log.info("ONOS "+str(nodeNum)+
607 " fin/ack transaction "+
608 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400609 "threshold or premature iteration: ")
610 main.log.info(str(finAckTransaction))
611
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400612 if ackToDevice >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400613 ackToDevice < thresholdMax and i >= iterIgnore:
614 ackToDeviceLatNodeIter[node][i] = ackToDevice
615 main.log.info("ONOS "+str(nodeNum)+
616 " ack-to-device: "+
617 str(ackToDevice) + " ms")
618 else:
619 main.log.info("ONOS "+str(nodeNum)+
620 " ack-to-device "+
621 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400622 "threshold or premature iteration: ")
623 main.log.info(str(ackToDevice))
624
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400625 if deviceToGraph >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400626 deviceToGraph < thresholdMax and i >= iterIgnore:
627 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
628 main.log.info("ONOS "+str(nodeNum)+
629 " device-to-graph disconnect: "+
630 str(deviceToGraph) + " ms")
631 else:
632 main.log.info("ONOS "+str(nodeNum)+
633 " device-to-graph disconnect "+
634 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400635 "threshold or premature iteration: ")
636 main.log.info(str(deviceToGraph))
jenkins7ead5a82015-03-13 10:28:21 -0700637
638 endToEndAvg = 0
639 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700640 dbCmdList = []
641 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700642 # List of latency for each node
643 endToEndList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700644 tcpToFeatureList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400645 featureToRoleList = []
646 roleToOfpList = []
647 ofpToDeviceList = []
648 deviceToGraphList = []
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400649
650 finAckTransactionList = []
651 ackToDeviceList = []
652 deviceToGraphDiscList = []
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400653 endToEndDiscList = []
654
jenkins8ba10ab2015-03-24 10:31:31 -0700655 # LatNodeIter 2d arrays contain all iteration latency
656 # for each node of the current scale cluster size
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400657 # Switch connection measurements
658 # Set further acceptance criteria for measurements
659 # here if you would like to filter reporting results
jenkins7ead5a82015-03-13 10:28:21 -0700660 for item in endToEndLatNodeIter[node]:
661 if item > 0.0:
662 endToEndList.append(item)
663
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400664 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700665 if item > 0.0:
666 tcpToFeatureList.append(item)
667
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400668 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700669 if item > 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400670 featureToRoleList.append(item)
671
672 for item in roleRequestToRoleReplyLatNodeIter[node]:
673 if item > 0.0:
674 roleToOfpList.append(item)
675
676 for item in roleReplyToDeviceLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400677 if item >= 0.0:
678 ofpToDeviceList.append(item)
679
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400680 for item in featureToRoleRequestLatNodeIter[node]:
681 if item > 0.0:
682 featureToRoleList.append(item)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400683
684 for item in deviceToGraphLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400685 if item >= 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400686 deviceToGraphList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700687
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400688 # Switch disconnect measurements
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400689 for item in endToEndDiscLatNodeIter[node]:
690 if item > 0.0:
691 endToEndDiscList.append(item)
692
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400693 for item in finAckTransactionLatNodeIter[node]:
694 if item > 0.0:
695 finAckTransactionList.append(item)
696
697 for item in ackToDeviceLatNodeIter[node]:
698 if item > 0.0:
699 ackToDeviceList.append(item)
700
701 for item in deviceToGraphDiscLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400702 if item >= 0.0:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400703 deviceToGraphDiscList.append(item)
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400704
jenkins7ead5a82015-03-13 10:28:21 -0700705 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400706 endToEndStdDev = round(numpy.std(endToEndList), 2)
707
jenkins8ba10ab2015-03-24 10:31:31 -0700708 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400709 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
710
711 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
712 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
713
714 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
715 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
716
jenkins7ead5a82015-03-13 10:28:21 -0700717 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400718 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
719
720 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
721 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
722
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400723 endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2)
724 endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2)
725
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400726 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
727 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
728
729 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
730 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
731
732 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
733 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
734
jenkins7ead5a82015-03-13 10:28:21 -0700735 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400736 main.log.report(' - Switch Connection Statistics - ')
737
jenkins7ead5a82015-03-13 10:28:21 -0700738 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
739 ' ms' + ' End-to-end Std dev: ' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400740 str(endToEndStdDev) + ' ms')
741
742 main.log.report(' Tcp-to-feature-reply Avg: ' +
743 str(tcpToFeatureAvg) + ' ms')
744 main.log.report(' Tcp-to-feature-reply Std dev: '+
745 str(tcpToFeatureStdDev) + ' ms')
746
747 main.log.report(' Feature-reply-to-role-request Avg: ' +
748 str(featureToRoleAvg) + ' ms')
749 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
750 str(featureToRoleStdDev) + ' ms')
751
752 main.log.report(' Role-request-to-role-reply Avg: ' +
753 str(roleToOfpAvg) +' ms')
754 main.log.report(' Role-request-to-role-reply Std dev: ' +
755 str(roleToOfpStdDev) + ' ms')
756
757 main.log.report(' Role-reply-to-device Avg: ' +
758 str(ofpToDeviceAvg) +' ms')
759 main.log.report(' Role-reply-to-device Std dev: ' +
760 str(ofpToDeviceStdDev) + ' ms')
761
762 main.log.report(' Device-to-graph Avg: ' +
763 str(deviceToGraphAvg) + ' ms')
764 main.log.report( 'Device-to-graph Std dev: ' +
765 str(deviceToGraphStdDev) + ' ms')
766
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400767 main.log.report(' - Switch Disconnection Statistics - ')
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400768 main.log.report(' End-to-end switch disconnect Avg: ' +
769 str(endToEndDiscAvg) + ' ms')
770 main.log.report(' End-to-end switch disconnect Std dev: ' +
771 str(endToEndDiscStdDev) + ' ms')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400772 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
773 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
774 str(finAckStdDev) + ' ms')
775
776 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
777 ' ms')
778 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
779 ' ms')
780
781 main.log.report(' Device-to-graph (disconnect) Avg: ' +
782 str(deviceToGraphDiscAvg) + ' ms')
783 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
784 str(deviceToGraphDiscStdDev) + ' ms')
785
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400786 # For database schema, refer to Amazon web services
jenkins7ead5a82015-03-13 10:28:21 -0700787 dbCmdList.append(
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400788 "INSERT INTO switch_latency_details VALUES('" +
jenkins7ead5a82015-03-13 10:28:21 -0700789 timeToPost + "','switch_latency_results'," +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400790 jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400791 str(node + 1) + "'," +
792 str(endToEndAvg) + ',' +
793 str(tcpToFeatureAvg) + ',' +
794 str(featureToRoleAvg) + ',' +
795 str(roleToOfpAvg) + ',' +
796 str(ofpToDeviceAvg) + ',' +
797 str(deviceToGraphAvg) + ',' +
798 str(endToEndDiscAvg) + ',' +
799 str(finAckAvg) + ',' +
800 str(ackToDeviceAvg) + ',' +
801 str(deviceToGraphDiscAvg) +
802 ');')
jenkins7ead5a82015-03-13 10:28:21 -0700803
804 if debugMode == 'on':
805 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
806 '/tmp/', copyFileName='sw_lat_karaf')
807 fResult = open(resultPath, 'a')
808 for line in dbCmdList:
809 if line:
810 fResult.write(line + '\n')
jenkins7ead5a82015-03-13 10:28:21 -0700811 fResult.close()
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400812
jenkins7ead5a82015-03-13 10:28:21 -0700813 assertion = main.TRUE
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400814
jenkins7ead5a82015-03-13 10:28:21 -0700815 utilities.assert_equals(expect=main.TRUE, actual=assertion,
816 onpass='Switch latency test successful',
817 onfail='Switch latency test failed')
818
819 def CASE3(self, main):
820 """
821 Bring port up / down and measure latency.
822 Port enable / disable is simulated by ifconfig up / down
823
824 In ONOS-next, we must ensure that the port we are
825 manipulating is connected to another switch with a valid
826 connection. Otherwise, graph view will not be updated.
827 """
jenkins7ead5a82015-03-13 10:28:21 -0700828 import time
829 import subprocess
830 import os
831 import requests
832 import json
833 import numpy
834 ONOS1Ip = main.params['CTRL']['ip1']
835 ONOS2Ip = main.params['CTRL']['ip2']
836 ONOS3Ip = main.params['CTRL']['ip3']
837 ONOSUser = main.params['CTRL']['user']
838 defaultSwPort = main.params['CTRL']['port1']
839 assertion = main.TRUE
840 numIter = main.params['TEST']['numIter']
841 iterIgnore = int(main.params['TEST']['iterIgnore'])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400842
843 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
844 graphTimestampKey = main.params['JSON']['graphTimestamp']
845 linkTimestampKey = main.params['JSON']['linkTimestamp']
jenkins7ead5a82015-03-13 10:28:21 -0700846
847 tsharkPortUp = '/tmp/tshark_port_up.txt'
848 tsharkPortDown = '/tmp/tshark_port_down.txt'
849 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
850
851 debugMode = main.params['TEST']['debugMode']
852 postToDB = main.params['DB']['postToDB']
853 resultPath = main.params['DB']['portEventResultPath']
jenkins7ead5a82015-03-13 10:28:21 -0700854 localTime = time.strftime('%x %X')
855 localTime = localTime.replace('/', '')
856 localTime = localTime.replace(' ', '_')
857 localTime = localTime.replace(':', '')
858
859 if debugMode == 'on':
860 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
861
862 upThresholdStr = main.params['TEST']['portUpThreshold']
863 downThresholdStr = main.params['TEST']['portDownThreshold']
864 upThresholdObj = upThresholdStr.split(',')
865 downThresholdObj = downThresholdStr.split(',')
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400866 upThresholdMin = int(upThresholdObj[0])
867 upThresholdMax = int(upThresholdObj[1])
868 downThresholdMin = int(downThresholdObj[0])
869 downThresholdMax = int(downThresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700870
871 interfaceConfig = 's1-eth1'
872 main.log.report('Port enable / disable latency')
873 main.log.report('Simulated by ifconfig up / down')
874 main.log.report('Total iterations of test: ' + str(numIter))
875 main.step('Assign switches s1 and s2 to controller 1')
876
877 main.Mininet1.assignSwController(sw='1',
878 ip1=ONOS1Ip, port1=defaultSwPort)
879 main.Mininet1.assignSwController(sw='2',
880 ip1=ONOS1Ip, port1=defaultSwPort)
881
882 time.sleep(15)
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400883
884 portUpEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
885 portUpOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
886 portUpDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
887 portUpLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
888
889 portDownEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
890 portDownOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
891 portDownDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
892 portDownLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700893
894 for i in range(0, int(numIter)):
895 main.step('Starting wireshark capture for port status down')
896 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400897
jenkins7ead5a82015-03-13 10:28:21 -0700898 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400899
jenkins7ead5a82015-03-13 10:28:21 -0700900 main.step('Disable port: ' + interfaceConfig)
901 main.Mininet1.handle.sendline('sh ifconfig ' +
902 interfaceConfig + ' down')
903 main.Mininet1.handle.expect('mininet>')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400904
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400905 jsonStrPtDown = []
906 for node in range (0, clusterCount):
907 metricsPortDown = CLIs[node].topologyEventsMetrics()
908 jsonStrPtDown.append(metricsPortDown)
909
jenkins7ead5a82015-03-13 10:28:21 -0700910 time.sleep(3)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400911
jenkins7ead5a82015-03-13 10:28:21 -0700912 main.ONOS1.tsharkStop()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400913
jenkins7ead5a82015-03-13 10:28:21 -0700914 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
915 tsharkPortDown + ' /tmp/')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400916
jenkins7ead5a82015-03-13 10:28:21 -0700917 fPortDown = open(tsharkPortDown, 'r')
918 fLine = fPortDown.readline()
919 objDown = fLine.split(' ')
920 if len(fLine) > 0:
921 timestampBeginPtDown = int(float(objDown[1]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400922 # At times, tshark reports timestamp at the 3rd
923 # index of the array. If initial readings were
924 # unlike the epoch timestamp, then check the 3rd
925 # index and set that as a timestamp
jenkins7ead5a82015-03-13 10:28:21 -0700926 if timestampBeginPtDown < 1400000000000:
927 timestampBeginPtDown = int(float(objDown[2]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400928 # If there are any suspicion of invalid results
929 # check this reported value
jenkins7ead5a82015-03-13 10:28:21 -0700930 main.log.info('Port down begin timestamp: ' +
931 str(timestampBeginPtDown))
932 else:
933 main.log.info('Tshark output file returned unexpected' +
934 ' results: ' + str(objDown))
935 timestampBeginPtDown = 0
936 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700937
jenkins8ba10ab2015-03-24 10:31:31 -0700938 for node in range(0, clusterCount):
939 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400940 # metricsDown = CLIs[node].topologyEventsMetrics
941 #jsonStrPtDown[node] = metricsDown()
942 jsonObj = json.loads(jsonStrPtDown[node])
jenkins8ba10ab2015-03-24 10:31:31 -0700943
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400944 if jsonObj:
945 graphTimestamp = jsonObj[graphTimestampKey]['value']
946 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
947 linkTimestamp = jsonObj[linkTimestampKey]['value']
948 else:
949 main.log.error( "Unexpected json object" )
950 graphTimestamp = 0
951 deviceTimestamp = 0
952 linkTimestamp = 0
953
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400954 ptDownEndToEnd = int(graphTimestamp) - int(timestampBeginPtDown)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400955 ptDownOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtDown)
956 ptDownDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
957 ptDownLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
jenkins8ba10ab2015-03-24 10:31:31 -0700958
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400959 if ptDownEndToEnd >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400960 ptDownEndToEnd < downThresholdMax and i >= iterIgnore:
961 portDownEndToEndNodeIter[node][i] = ptDownEndToEnd
jenkins8ba10ab2015-03-24 10:31:31 -0700962 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400963 " port down End-to-end: "+
964 str(ptDownEndToEnd) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700965 else:
966 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400967 " port down End-to-end ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -0700968 " due to excess in threshold or premature iteration")
969
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400970 if ptDownOfpToDevice >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400971 ptDownOfpToDevice < downThresholdMax and i >= iterIgnore:
972 portDownOfpToDevNodeIter[node][i] = ptDownOfpToDevice
jenkins8ba10ab2015-03-24 10:31:31 -0700973 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400974 " port down Ofp-to-device: "+
975 str(ptDownOfpToDevice) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700976 else:
977 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400978 " port down Ofp-to-device ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -0700979 " due to excess in threshold or premature iteration")
980
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400981 if ptDownDeviceToLink >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400982 ptDownDeviceToLink < downThresholdMax and i >= iterIgnore:
983 portDownDevToLinkNodeIter[node][i] = ptDownDeviceToLink
jenkins8ba10ab2015-03-24 10:31:31 -0700984 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400985 " port down Device-to-link "+
986 str(ptDownDeviceToLink) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700987 else:
988 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400989 " port down Device-to-link ignored"+
990 " due to excess in threshold or premature iteration")
991
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400992 if ptDownLinkToGraph >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400993 ptDownLinkToGraph < downThresholdMax and i >= iterIgnore:
994 portDownLinkToGraphNodeIter[node][i] = ptDownLinkToGraph
995 main.log.info("ONOS "+str(nodeNum)+
996 " port down Link-to-graph "+
997 str(ptDownLinkToGraph) + " ms")
998 else:
999 main.log.info("ONOS "+str(nodeNum)+
1000 " port down Link-to-graph ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001001 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -07001002
jenkins7ead5a82015-03-13 10:28:21 -07001003 time.sleep(3)
1004
1005 main.step('Starting wireshark capture for port status up')
1006 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
1007
1008 time.sleep(5)
1009 main.step('Enable port and obtain timestamp')
1010 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
1011 main.Mininet1.handle.expect('mininet>')
1012
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001013 jsonStrPtUp = []
1014 for node in range (0, clusterCount):
1015 metricsPortUp = CLIs[node].topologyEventsMetrics()
1016 jsonStrPtUp.append(metricsPortUp)
1017
jenkins7ead5a82015-03-13 10:28:21 -07001018 time.sleep(5)
1019 main.ONOS1.tsharkStop()
1020
1021 time.sleep(3)
1022 os.system('scp ' + ONOSUser + '@' +
1023 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
1024
1025 fPortUp = open(tsharkPortUp, 'r')
1026 fLine = fPortUp.readline()
1027 objUp = fLine.split(' ')
1028 if len(fLine) > 0:
1029 timestampBeginPtUp = int(float(objUp[1]) * 1000)
1030 if timestampBeginPtUp < 1400000000000:
1031 timestampBeginPtUp = int(float(objUp[2]) * 1000)
1032 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
1033 else:
1034 main.log.info('Tshark output file returned unexpected' + ' results.')
1035 timestampBeginPtUp = 0
1036 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -07001037
1038 for node in range(0, clusterCount):
1039 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001040 #metricsUp = CLIs[node].topologyEventsMetrics
1041 #jsonStrUp = metricsUp()
1042 jsonObj = json.loads(jsonStrPtUp[node])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001043
1044 if jsonObj:
1045 graphTimestamp = jsonObj[graphTimestampKey]['value']
1046 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
1047 linkTimestamp = jsonObj[linkTimestampKey]['value']
1048 else:
1049 main.log.error( "Unexpected json object" )
1050 graphTimestamp = 0
1051 deviceTimestamp = 0
1052 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001053
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001054 ptUpEndToEnd = int(graphTimestamp) - int(timestampBeginPtUp)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001055 ptUpOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtUp)
1056 ptUpDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
1057 ptUpLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
jenkins8ba10ab2015-03-24 10:31:31 -07001058
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001059 if ptUpEndToEnd >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001060 ptUpEndToEnd < upThresholdMax and i > iterIgnore:
1061 portUpEndToEndNodeIter[node][i] = ptUpEndToEnd
jenkins8ba10ab2015-03-24 10:31:31 -07001062 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001063 " port up End-to-end: "+
1064 str(ptUpEndToEnd) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001065 else:
1066 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001067 " port up End-to-end ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001068 " due to excess in threshold or premature iteration")
1069
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001070 if ptUpOfpToDevice >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001071 ptUpOfpToDevice < upThresholdMax and i > iterIgnore:
1072 portUpOfpToDevNodeIter[node][i] = ptUpOfpToDevice
jenkins8ba10ab2015-03-24 10:31:31 -07001073 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001074 " port up Ofp-to-device: "+
1075 str(ptUpOfpToDevice) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001076 else:
1077 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001078 " port up Ofp-to-device ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001079 " due to excess in threshold or premature iteration")
1080
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001081 if ptUpDeviceToLink >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001082 ptUpDeviceToLink < upThresholdMax and i > iterIgnore:
1083 portUpDevToLinkNodeIter[node][i] = ptUpDeviceToLink
jenkins8ba10ab2015-03-24 10:31:31 -07001084 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001085 " port up Device-to-link: "+
1086 str(ptUpDeviceToLink) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001087 else:
1088 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001089 " port up Device-to-link ignored"+
1090 " due to excess in threshold or premature iteration")
1091
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001092 if ptUpLinkToGraph >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001093 ptUpLinkToGraph < upThresholdMax and i > iterIgnore:
1094 portUpLinkToGraphNodeIter[node][i] = ptUpLinkToGraph
1095 main.log.info("ONOS "+str(nodeNum)+
1096 " port up Link-to-graph: "+
1097 str(ptUpLinkToGraph) + " ms")
1098 else:
1099 main.log.info("ONOS "+str(nodeNum)+
1100 " port up Link-to-graph ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001101 " due to excess in threshold or premature iteration")
1102
jenkins7ead5a82015-03-13 10:28:21 -07001103 dbCmdList = []
1104 for node in range(0, clusterCount):
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001105 portUpEndToEndList = []
1106 portUpOfpToDevList = []
1107 portUpDevToLinkList = []
1108 portUpLinkToGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001109
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001110 portDownEndToEndList = []
1111 portDownOfpToDevList = []
1112 portDownDevToLinkList = []
1113 portDownLinkToGraphList = []
1114
1115 portUpEndToEndAvg = 0
1116 portUpOfpToDevAvg = 0
1117 portUpDevToLinkAvg = 0
1118 portUpLinkToGraphAvg = 0
1119
1120 portDownEndToEndAvg = 0
1121 portDownOfpToDevAvg = 0
1122 portDownDevToLinkAvg = 0
1123 portDownLinkToGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001124
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -04001125 # TODO: Update for more pythonic way to get list
1126 # portUpDevList = [item for item in portUpDevNodeIter[node]
1127 # if item > 0.0]
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001128 for item in portUpEndToEndNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001129 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001130 portUpEndToEndList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001131
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001132 for item in portUpOfpToDevNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001133 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001134 portUpOfpToDevList.append(item)
1135
1136 for item in portUpDevToLinkNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -07001137 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001138 portUpDevToLinkList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001139
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001140 for item in portUpLinkToGraphNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001141 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001142 portUpLinkToGraphList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001143
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001144 for item in portDownEndToEndNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001145 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001146 portDownEndToEndList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001147
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001148 for item in portDownOfpToDevNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -07001149 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001150 portDownOfpToDevList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001151
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001152 for item in portDownDevToLinkNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001153 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001154 portDownDevToLinkList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001155
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001156 for item in portDownLinkToGraphNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001157 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001158 portDownLinkToGraphList.append(item)
1159
1160 portUpEndToEndAvg = round(numpy.mean(portUpEndToEndList), 2)
1161 portUpOfpToDevAvg = round(numpy.mean(portUpOfpToDevList), 2)
1162 portUpDevToLinkAvg = round(numpy.mean(portUpDevToLinkList), 2)
1163 portUpLinkToGraphAvg = round(numpy.mean(portUpLinkToGraphList), 2)
1164
1165 portDownEndToEndAvg = round(numpy.mean(portDownEndToEndList), 2)
1166 portDownOfpToDevAvg = round(numpy.mean(portDownOfpToDevList), 2)
1167 portDownDevToLinkAvg = round(numpy.mean(portDownDevToLinkList), 2)
1168 portDownLinkToGraphAvg = round(numpy.mean(portDownLinkToGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001169
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001170 portUpStdDev = round(numpy.std(portUpEndToEndList), 2)
1171 portDownStdDev = round(numpy.std(portDownEndToEndList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001172
jenkins7ead5a82015-03-13 10:28:21 -07001173 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001174 main.log.report(' Port up End-to-end ' +
1175 str(portUpEndToEndAvg) + ' ms')
1176 main.log.report(' Port up Ofp-to-device ' +
1177 str(portUpOfpToDevAvg) + ' ms')
1178 main.log.report(' Port up Device-to-link ' +
1179 str(portUpDevToLinkAvg) + ' ms')
1180 main.log.report(' Port up Link-to-graph ' +
1181 str(portUpLinkToGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001182
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001183 main.log.report(' Port down End-to-end ' +
1184 str(round(portDownEndToEndAvg, 2)) + ' ms')
1185 main.log.report(' Port down Ofp-to-device ' +
1186 str(portDownOfpToDevAvg) + ' ms')
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001187 main.log.report(' Port down Device-to-link ' +
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001188 str(portDownDevToLinkAvg) + ' ms')
1189 main.log.report(' Port down Link-to-graph' +
1190 str(portDownLinkToGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001191
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001192 dbCmdList.append("INSERT INTO port_latency_details VALUES('" +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -04001193 timeToPost + "','port_latency_results'," + jenkinsBuildNumber +
jenkins7ead5a82015-03-13 10:28:21 -07001194 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001195 "'," +
1196 str(portUpEndToEndAvg) +',' +
1197 str(portUpOfpToDevAvg) + ',' +
1198 str(portUpDevToLinkAvg) + ',' +
1199 str(portUpLinkToGraphAvg) + ',' +
1200 str(portDownEndToEndAvg) + ',' +
1201 str(portDownOfpToDevAvg) + ',' +
1202 str(portDownDevToLinkAvg) + ',' +
1203 str(portDownLinkToGraphAvg) +
1204 ');')
jenkins7ead5a82015-03-13 10:28:21 -07001205
1206 fResult = open(resultPath, 'a')
1207 for line in dbCmdList:
1208 if line:
1209 fResult.write(line + '\n')
1210
1211 fResult.close()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001212
1213 # Delete switches from controller to prepare for next
1214 # set of tests
jenkins7ead5a82015-03-13 10:28:21 -07001215 main.Mininet1.deleteSwController('s1')
1216 main.Mininet1.deleteSwController('s2')
1217 utilities.assert_equals(expect=main.TRUE,
1218 actual=assertion,
1219 onpass='Port discovery latency calculation successful',
1220 onfail='Port discovery test failed')
1221
1222 def CASE4(self, main):
1223 """
1224 Increase number of nodes and initiate CLI
1225
1226 With the most recent implementation, we need a method to
1227 ensure all ONOS nodes are killed, as well as redefine
1228 the cell files to ensure all nodes that will be used
1229 is in the cell file. Otherwise, exceptions will
1230 prohibit test from running successfully.
1231
1232 3/12/15
1233
1234 """
1235 global clusterCount
1236 import time
1237 import os
1238
1239 clusterCount += 2
1240
1241 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1242 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1243 cellName = main.params[ 'ENV' ][ 'cellName' ]
1244 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1245
1246 main.log.report('Increasing cluster size to ' + str(clusterCount))
1247
1248 main.log.step( "Killing all ONOS processes before scale-out" )
1249
1250 for i in range( 1, 8 ):
1251 main.ONOSbench.onosDie(
1252 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1253 main.ONOSbench.onosUninstall(
1254 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1255
1256 main.step( "Creating scale-out cell file" )
1257 cellIp = []
1258 for node in range( 1, clusterCount + 1 ):
1259 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1260
1261 main.log.info( "Cell Ip list: " + str(cellIp) )
1262 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1263 str(features), *cellIp )
1264
1265 main.step( "Setting cell definition" )
1266 main.ONOSbench.setCell(cellName)
1267
1268 main.step( "Packaging cell definition" )
1269 main.ONOSbench.onosPackage()
1270
jenkins7ead5a82015-03-13 10:28:21 -07001271 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001272 main.ONOSbench.onosInstall(
1273 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1274
1275 time.sleep( 20 )
1276
jenkins7ead5a82015-03-13 10:28:21 -07001277 for node in range( 1, clusterCount + 1):
1278 for i in range( 2 ):
1279 isup = main.ONOSbench.isup(
1280 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1281 if isup:
1282 main.log.info( "ONOS "+str(node) + " is up\n")
1283 break
1284 if not isup:
1285 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001286
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001287 for node in range( 0, clusterCount ):
1288 CLIs[node].startOnosCli( cellIp[node] )
1289
1290 main.step( 'Setting configurations for metrics' )
1291 configParam = 'maxEvents 1'
1292 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1293 configParam = 'maxBatchMs 0'
1294 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1295 configParam = 'maxIdleMs 0'
1296 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1297
1298 main.step( 'Activating essential applications' )
1299 CLIs[0].activateApp( 'org.onosproject.metrics' )
1300 CLIs[0].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001301