blob: d4dc087b31c2fc0932d843dc3e6cdfb802aa02fe [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 """
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))
350 featureTimestamp = float(tempText[1]) * 1000.0
351 else:
352 main.log.error('Tshark output file for feature reply' +
353 ' returned unexpected results')
354 timeFeatureReply = 0
355 assertion = main.FALSE
356 featureFile.close()
357
jenkins8ba10ab2015-03-24 10:31:31 -0700358 for node in range(0, clusterCount):
359 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400360 #metricsSwUp = CLIs[node].topologyEventsMetrics
361 #jsonStr = metricsSwUp()
362 jsonObj = json.loads(jsonStr[node])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400363 if jsonObj:
364 graphTimestamp = jsonObj[graphTimestampKey]['value']
365 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700366 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400367 main.log.error( "Unexpected JSON object" )
368 # If we could not obtain the JSON object,
369 # set the timestamps to 0, which will be
370 # excluded from the measurement later on
371 # (realized as invalid)
372 graphTimestamp = 0
373 deviceTimestamp = 0
374
375 endToEnd = int(graphTimestamp) - int(t0Tcp)
376
377 # Below are measurement breakdowns of the end-to-end
378 # measurement.
379 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
380 featureToRole = int(roleTimestamp) - int(featureTimestamp)
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400381 roleToOfp = float(t0Ofp) - float(roleTimestamp)
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400382 ofpToDevice = float(deviceTimestamp) - float(t0Ofp)
383 # Timestamps gathered from ONOS are millisecond
384 # precision. They are returned as integers, thus no
385 # need to be more precise than 'int'. However,
386 # the processing seems to be mostly under 1 ms,
387 # thus this may be a problem point to handle any
388 # submillisecond output that we are unsure of.
389 # For now, this will be treated as 0 ms if less than 1 ms
390 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400391
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400392 if endToEnd >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400393 endToEnd < thresholdMax and i >= iterIgnore:
394 endToEndLatNodeIter[node][i] = endToEnd
395 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
396 str(endToEnd) + " ms")
397 else:
398 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700399 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400400 "threshold or premature iteration: ")
401 main.log.info(str(endToEnd))
402
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400403 if tcpToFeature >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400404 tcpToFeature < thresholdMax and i >= iterIgnore:
405 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
406 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
407 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700408 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400409 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700410 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400411 "threshold or premature iteration: ")
412 main.log.info(str(tcpToFeature))
jenkins8ba10ab2015-03-24 10:31:31 -0700413
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400414 if featureToRole >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400415 featureToRole < thresholdMax and i >= iterIgnore:
416 featureToRoleRequestLatNodeIter[node][i] = featureToRole
417 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
418 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700419 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400420 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700421 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400422 "threshold or premature iteration: ")
423 main.log.info(str(featureToRole))
jenkins8ba10ab2015-03-24 10:31:31 -0700424
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400425 if roleToOfp >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400426 roleToOfp < thresholdMax and i >= iterIgnore:
427 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
428 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
429 str(roleToOfp) + " ms")
430 else:
431 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
432 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400433 "threshold or premature iteration: ")
434 main.log.info(str(roleToOfp))
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400435
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400436 if ofpToDevice >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400437 ofpToDevice < thresholdMax and i >= iterIgnore:
438 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
439 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
440 str(ofpToDevice) + " ms")
441 else:
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400442 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400443 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400444 "threshold or premature iteration: ")
445 main.log.info(str(ofpToDevice))
jenkins8ba10ab2015-03-24 10:31:31 -0700446
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400447 if deviceToGraph >= thresholdMin and\
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400448 deviceToGraph < thresholdMax and i >= iterIgnore:
449 deviceToGraphLatNodeIter[node][i] = deviceToGraph
450 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
451 str(deviceToGraph) + " ms")
452 else:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400453 if deviceToGraph == 0:
454 deviceToGraphLatNodeIter[node][i] = 0
455 main.log.info("ONOS "+str(nodeNum) +
456 " device-to-graph measurement "+
457 "was set to 0 ms because of precision "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400458 "uncertainty. ")
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400459 else:
460 main.log.info("ONOS "+str(nodeNum)+
461 " device-to-graph "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400462 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400463 "threshold or premature iteration: ")
464 main.log.info(str(deviceToGraph))
465
jenkins8ba10ab2015-03-24 10:31:31 -0700466 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700467 time.sleep(5)
468
469 # Get device id to remove
470 deviceIdJsonStr = main.ONOS1cli.devices()
471
472 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
473 deviceId = json.loads(deviceIdJsonStr)
474
475 deviceList = []
476 for device in deviceId:
477 deviceList.append(device['id'])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400478
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400479 # Measure switch down metrics
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400480 # TCP FIN/ACK -> TCP FIN
481 # TCP FIN -> Device Event
482 # Device Event -> Graph Event
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400483 # Capture switch down FIN / ACK packets
484
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400485 # The -A 1 grep option allows us to grab 1 extra line after the
486 # last tshark output grepped originally
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400487 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
488 grepOptions = '-A 1' )
489
490 time.sleep( 5 )
491
492 removeJsonList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400493
jenkins7ead5a82015-03-13 10:28:21 -0700494 main.step('Remove switch from controller')
495 main.Mininet1.deleteSwController('s3')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400496 firstDevice = deviceList[0]
jenkins7ead5a82015-03-13 10:28:21 -0700497 main.log.info( "Removing device " +str(firstDevice)+
498 " from ONOS" )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400499
500 time.sleep( 5 )
501
502 # We need to get metrics before removing
503 # device from the store below.
504 for node in range(0, clusterCount):
505 metricsSwDown = CLIs[node].topologyEventsMetrics
506 jsonStr = metricsSwDown()
507 removeJsonList.append( json.loads(jsonStr) )
508
jenkins7ead5a82015-03-13 10:28:21 -0700509 #if deviceId:
510 main.ONOS1cli.deviceRemove(firstDevice)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400511
512 main.ONOS1.tsharkStop()
513
514 main.log.info('Copying over tshark files')
515 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
516 ':' + tsharkFinAckOutput + ' /tmp/')
517
518 time.sleep( 10 )
519 finAckOutputList = []
520 with open(tsharkFinAckOutput, 'r') as f:
521 tempLine = f.readlines()
522 main.log.info('Object read in from FinAck capture: ' +
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400523 "\n".join(tempLine))
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400524
525 index = 1
526 for line in tempLine:
527 obj = line.split(' ')
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400528
529 # There are at least 3 objects in field (valid
530 # tshark output is lengthy)
531 if len(obj) > 2:
532 # If first index of object is like an epoch time
533 if obj[1] > 1400000000:
534 temp = obj[1]
535 elif obj[2] > 1400000000:
536 temp = obj[2]
537 else:
538 temp = 0
539
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400540 if index == 1:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400541 tFinAck = float(temp) * 1000.0
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400542 elif index == 3:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400543 tAck = float(temp) * 1000.0
544
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400545 else:
546 main.log.error('Tshark output file for OFP' +
547 ' returned unexpected results')
548 tFinAck = 0
549 tAck = 0
550 assertion = main.FALSE
551
552 index = index+1
553
554 # with open() as f takes care of closing file
555
jenkins7ead5a82015-03-13 10:28:21 -0700556 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400557
558 for node in range(0, clusterCount):
559 nodeNum = node+1
560 jsonObj = removeJsonList[node]
561 if jsonObj:
562 graphTimestamp = jsonObj[graphTimestampKey]['value']
563 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
564 main.log.info("Graph timestamp: "+str(graphTimestamp))
565 main.log.info("Device timestamp: "+str(deviceTimestamp))
566 else:
567 main.log.error( "Unexpected JSON object" )
568 # If we could not obtain the JSON object,
569 # set the timestamps to 0, which will be
570 # excluded from the measurement later on
571 # (realized as invalid)
572 graphTimestamp = 0
573 deviceTimestamp = 0
574
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400575 finAckTransaction = float(tAck) - float(tFinAck)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400576 ackToDevice = float(deviceTimestamp) - float(tAck)
577 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400578 endToEndDisc = int(graphTimestamp) - int(tFinAck)
579
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400580 if endToEndDisc >= thresholdMin and\
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400581 endToEndDisc < thresholdMax and i >= iterIgnore:
582 endToEndDiscLatNodeIter[node][i] = endToEndDisc
583 main.log.info("ONOS "+str(nodeNum) +
584 "end-to-end disconnection: "+
585 str(endToEndDisc) + " ms" )
586 else:
587 main.log.info("ONOS " + str(nodeNum) +
588 " end-to-end disconnection "+
589 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400590 "threshold or premature iteration: ")
591 main.log.info(str(endToEndDisc))
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400592
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400593 if finAckTransaction >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400594 finAckTransaction < thresholdMax and i >= iterIgnore:
595 finAckTransactionLatNodeIter[node][i] = finAckTransaction
596 main.log.info("ONOS "+str(nodeNum)+
597 " fin/ack transaction: "+
598 str(finAckTransaction) + " ms")
599 else:
600 main.log.info("ONOS "+str(nodeNum)+
601 " fin/ack transaction "+
602 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400603 "threshold or premature iteration: ")
604 main.log.info(str(finAckTransaction))
605
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400606 if ackToDevice >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400607 ackToDevice < thresholdMax and i >= iterIgnore:
608 ackToDeviceLatNodeIter[node][i] = ackToDevice
609 main.log.info("ONOS "+str(nodeNum)+
610 " ack-to-device: "+
611 str(ackToDevice) + " ms")
612 else:
613 main.log.info("ONOS "+str(nodeNum)+
614 " ack-to-device "+
615 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400616 "threshold or premature iteration: ")
617 main.log.info(str(ackToDevice))
618
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400619 if deviceToGraph >= thresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400620 deviceToGraph < thresholdMax and i >= iterIgnore:
621 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
622 main.log.info("ONOS "+str(nodeNum)+
623 " device-to-graph disconnect: "+
624 str(deviceToGraph) + " ms")
625 else:
626 main.log.info("ONOS "+str(nodeNum)+
627 " device-to-graph disconnect "+
628 "measurement ignored due to excess in "+
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400629 "threshold or premature iteration: ")
630 main.log.info(str(deviceToGraph))
jenkins7ead5a82015-03-13 10:28:21 -0700631
632 endToEndAvg = 0
633 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700634 dbCmdList = []
635 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700636 # List of latency for each node
637 endToEndList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700638 tcpToFeatureList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400639 featureToRoleList = []
640 roleToOfpList = []
641 ofpToDeviceList = []
642 deviceToGraphList = []
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400643
644 finAckTransactionList = []
645 ackToDeviceList = []
646 deviceToGraphDiscList = []
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400647 endToEndDiscList = []
648
jenkins8ba10ab2015-03-24 10:31:31 -0700649 # LatNodeIter 2d arrays contain all iteration latency
650 # for each node of the current scale cluster size
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400651 # Switch connection measurements
652 # Set further acceptance criteria for measurements
653 # here if you would like to filter reporting results
jenkins7ead5a82015-03-13 10:28:21 -0700654 for item in endToEndLatNodeIter[node]:
655 if item > 0.0:
656 endToEndList.append(item)
657
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400658 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700659 if item > 0.0:
660 tcpToFeatureList.append(item)
661
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400662 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700663 if item > 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400664 featureToRoleList.append(item)
665
666 for item in roleRequestToRoleReplyLatNodeIter[node]:
667 if item > 0.0:
668 roleToOfpList.append(item)
669
670 for item in roleReplyToDeviceLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400671 if item >= 0.0:
672 ofpToDeviceList.append(item)
673
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400674 for item in featureToRoleRequestLatNodeIter[node]:
675 if item > 0.0:
676 featureToRoleList.append(item)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400677
678 for item in deviceToGraphLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400679 if item >= 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400680 deviceToGraphList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700681
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400682 # Switch disconnect measurements
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400683 for item in endToEndDiscLatNodeIter[node]:
684 if item > 0.0:
685 endToEndDiscList.append(item)
686
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400687 for item in finAckTransactionLatNodeIter[node]:
688 if item > 0.0:
689 finAckTransactionList.append(item)
690
691 for item in ackToDeviceLatNodeIter[node]:
692 if item > 0.0:
693 ackToDeviceList.append(item)
694
695 for item in deviceToGraphDiscLatNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400696 if item >= 0.0:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400697 deviceToGraphDiscList.append(item)
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400698
jenkins7ead5a82015-03-13 10:28:21 -0700699 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400700 endToEndStdDev = round(numpy.std(endToEndList), 2)
701
jenkins8ba10ab2015-03-24 10:31:31 -0700702 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400703 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
704
705 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
706 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
707
708 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
709 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
710
jenkins7ead5a82015-03-13 10:28:21 -0700711 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400712 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
713
714 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
715 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
716
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400717 endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2)
718 endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2)
719
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400720 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
721 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
722
723 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
724 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
725
726 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
727 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
728
jenkins7ead5a82015-03-13 10:28:21 -0700729 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400730 main.log.report(' - Switch Connection Statistics - ')
731
jenkins7ead5a82015-03-13 10:28:21 -0700732 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
733 ' ms' + ' End-to-end Std dev: ' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400734 str(endToEndStdDev) + ' ms')
735
736 main.log.report(' Tcp-to-feature-reply Avg: ' +
737 str(tcpToFeatureAvg) + ' ms')
738 main.log.report(' Tcp-to-feature-reply Std dev: '+
739 str(tcpToFeatureStdDev) + ' ms')
740
741 main.log.report(' Feature-reply-to-role-request Avg: ' +
742 str(featureToRoleAvg) + ' ms')
743 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
744 str(featureToRoleStdDev) + ' ms')
745
746 main.log.report(' Role-request-to-role-reply Avg: ' +
747 str(roleToOfpAvg) +' ms')
748 main.log.report(' Role-request-to-role-reply Std dev: ' +
749 str(roleToOfpStdDev) + ' ms')
750
751 main.log.report(' Role-reply-to-device Avg: ' +
752 str(ofpToDeviceAvg) +' ms')
753 main.log.report(' Role-reply-to-device Std dev: ' +
754 str(ofpToDeviceStdDev) + ' ms')
755
756 main.log.report(' Device-to-graph Avg: ' +
757 str(deviceToGraphAvg) + ' ms')
758 main.log.report( 'Device-to-graph Std dev: ' +
759 str(deviceToGraphStdDev) + ' ms')
760
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400761 main.log.report(' - Switch Disconnection Statistics - ')
andrew@onlab.us9210ba12015-04-09 14:11:27 -0400762 main.log.report(' End-to-end switch disconnect Avg: ' +
763 str(endToEndDiscAvg) + ' ms')
764 main.log.report(' End-to-end switch disconnect Std dev: ' +
765 str(endToEndDiscStdDev) + ' ms')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400766 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
767 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
768 str(finAckStdDev) + ' ms')
769
770 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
771 ' ms')
772 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
773 ' ms')
774
775 main.log.report(' Device-to-graph (disconnect) Avg: ' +
776 str(deviceToGraphDiscAvg) + ' ms')
777 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
778 str(deviceToGraphDiscStdDev) + ' ms')
779
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400780 # For database schema, refer to Amazon web services
jenkins7ead5a82015-03-13 10:28:21 -0700781 dbCmdList.append(
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400782 "INSERT INTO switch_latency_details VALUES('" +
jenkins7ead5a82015-03-13 10:28:21 -0700783 timeToPost + "','switch_latency_results'," +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400784 jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400785 str(node + 1) + "'," +
786 str(endToEndAvg) + ',' +
787 str(tcpToFeatureAvg) + ',' +
788 str(featureToRoleAvg) + ',' +
789 str(roleToOfpAvg) + ',' +
790 str(ofpToDeviceAvg) + ',' +
791 str(deviceToGraphAvg) + ',' +
792 str(endToEndDiscAvg) + ',' +
793 str(finAckAvg) + ',' +
794 str(ackToDeviceAvg) + ',' +
795 str(deviceToGraphDiscAvg) +
796 ');')
jenkins7ead5a82015-03-13 10:28:21 -0700797
798 if debugMode == 'on':
799 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
800 '/tmp/', copyFileName='sw_lat_karaf')
801 fResult = open(resultPath, 'a')
802 for line in dbCmdList:
803 if line:
804 fResult.write(line + '\n')
jenkins7ead5a82015-03-13 10:28:21 -0700805 fResult.close()
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400806
jenkins7ead5a82015-03-13 10:28:21 -0700807 assertion = main.TRUE
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -0400808
jenkins7ead5a82015-03-13 10:28:21 -0700809 utilities.assert_equals(expect=main.TRUE, actual=assertion,
810 onpass='Switch latency test successful',
811 onfail='Switch latency test failed')
812
813 def CASE3(self, main):
814 """
815 Bring port up / down and measure latency.
816 Port enable / disable is simulated by ifconfig up / down
817
818 In ONOS-next, we must ensure that the port we are
819 manipulating is connected to another switch with a valid
820 connection. Otherwise, graph view will not be updated.
821 """
jenkins7ead5a82015-03-13 10:28:21 -0700822 import time
823 import subprocess
824 import os
825 import requests
826 import json
827 import numpy
828 ONOS1Ip = main.params['CTRL']['ip1']
829 ONOS2Ip = main.params['CTRL']['ip2']
830 ONOS3Ip = main.params['CTRL']['ip3']
831 ONOSUser = main.params['CTRL']['user']
832 defaultSwPort = main.params['CTRL']['port1']
833 assertion = main.TRUE
834 numIter = main.params['TEST']['numIter']
835 iterIgnore = int(main.params['TEST']['iterIgnore'])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400836
837 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
838 graphTimestampKey = main.params['JSON']['graphTimestamp']
839 linkTimestampKey = main.params['JSON']['linkTimestamp']
jenkins7ead5a82015-03-13 10:28:21 -0700840
841 tsharkPortUp = '/tmp/tshark_port_up.txt'
842 tsharkPortDown = '/tmp/tshark_port_down.txt'
843 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
844
845 debugMode = main.params['TEST']['debugMode']
846 postToDB = main.params['DB']['postToDB']
847 resultPath = main.params['DB']['portEventResultPath']
jenkins7ead5a82015-03-13 10:28:21 -0700848 localTime = time.strftime('%x %X')
849 localTime = localTime.replace('/', '')
850 localTime = localTime.replace(' ', '_')
851 localTime = localTime.replace(':', '')
852
853 if debugMode == 'on':
854 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
855
856 upThresholdStr = main.params['TEST']['portUpThreshold']
857 downThresholdStr = main.params['TEST']['portDownThreshold']
858 upThresholdObj = upThresholdStr.split(',')
859 downThresholdObj = downThresholdStr.split(',')
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400860 upThresholdMin = int(upThresholdObj[0])
861 upThresholdMax = int(upThresholdObj[1])
862 downThresholdMin = int(downThresholdObj[0])
863 downThresholdMax = int(downThresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700864
865 interfaceConfig = 's1-eth1'
866 main.log.report('Port enable / disable latency')
867 main.log.report('Simulated by ifconfig up / down')
868 main.log.report('Total iterations of test: ' + str(numIter))
869 main.step('Assign switches s1 and s2 to controller 1')
870
871 main.Mininet1.assignSwController(sw='1',
872 ip1=ONOS1Ip, port1=defaultSwPort)
873 main.Mininet1.assignSwController(sw='2',
874 ip1=ONOS1Ip, port1=defaultSwPort)
875
876 time.sleep(15)
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400877
878 portUpEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
879 portUpOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
880 portUpDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
881 portUpLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
882
883 portDownEndToEndNodeIter = numpy.zeros((clusterCount, int(numIter)))
884 portDownOfpToDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
885 portDownDevToLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
886 portDownLinkToGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700887
888 for i in range(0, int(numIter)):
889 main.step('Starting wireshark capture for port status down')
890 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400891
jenkins7ead5a82015-03-13 10:28:21 -0700892 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400893
jenkins7ead5a82015-03-13 10:28:21 -0700894 main.step('Disable port: ' + interfaceConfig)
895 main.Mininet1.handle.sendline('sh ifconfig ' +
896 interfaceConfig + ' down')
897 main.Mininet1.handle.expect('mininet>')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400898
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400899 jsonStrPtDown = []
900 for node in range (0, clusterCount):
901 metricsPortDown = CLIs[node].topologyEventsMetrics()
902 jsonStrPtDown.append(metricsPortDown)
903
jenkins7ead5a82015-03-13 10:28:21 -0700904 time.sleep(3)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400905
jenkins7ead5a82015-03-13 10:28:21 -0700906 main.ONOS1.tsharkStop()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400907
jenkins7ead5a82015-03-13 10:28:21 -0700908 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
909 tsharkPortDown + ' /tmp/')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400910
jenkins7ead5a82015-03-13 10:28:21 -0700911 fPortDown = open(tsharkPortDown, 'r')
912 fLine = fPortDown.readline()
913 objDown = fLine.split(' ')
914 if len(fLine) > 0:
915 timestampBeginPtDown = int(float(objDown[1]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400916 # At times, tshark reports timestamp at the 3rd
917 # index of the array. If initial readings were
918 # unlike the epoch timestamp, then check the 3rd
919 # index and set that as a timestamp
jenkins7ead5a82015-03-13 10:28:21 -0700920 if timestampBeginPtDown < 1400000000000:
921 timestampBeginPtDown = int(float(objDown[2]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400922 # If there are any suspicion of invalid results
923 # check this reported value
jenkins7ead5a82015-03-13 10:28:21 -0700924 main.log.info('Port down begin timestamp: ' +
925 str(timestampBeginPtDown))
926 else:
927 main.log.info('Tshark output file returned unexpected' +
928 ' results: ' + str(objDown))
929 timestampBeginPtDown = 0
930 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700931
jenkins8ba10ab2015-03-24 10:31:31 -0700932 for node in range(0, clusterCount):
933 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -0400934 # metricsDown = CLIs[node].topologyEventsMetrics
935 #jsonStrPtDown[node] = metricsDown()
936 jsonObj = json.loads(jsonStrPtDown[node])
jenkins8ba10ab2015-03-24 10:31:31 -0700937
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400938 if jsonObj:
939 graphTimestamp = jsonObj[graphTimestampKey]['value']
940 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
941 linkTimestamp = jsonObj[linkTimestampKey]['value']
942 else:
943 main.log.error( "Unexpected json object" )
944 graphTimestamp = 0
945 deviceTimestamp = 0
946 linkTimestamp = 0
947
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400948 ptDownEndToEnd = int(graphTimestamp) - int(timestampBeginPtDown)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400949 ptDownOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtDown)
950 ptDownDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
951 ptDownLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
jenkins8ba10ab2015-03-24 10:31:31 -0700952
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400953 if ptDownEndToEnd >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400954 ptDownEndToEnd < downThresholdMax and i >= iterIgnore:
955 portDownEndToEndNodeIter[node][i] = ptDownEndToEnd
jenkins8ba10ab2015-03-24 10:31:31 -0700956 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400957 " port down End-to-end: "+
958 str(ptDownEndToEnd) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700959 else:
960 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400961 " port down End-to-end ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -0700962 " due to excess in threshold or premature iteration")
963
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400964 if ptDownOfpToDevice >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400965 ptDownOfpToDevice < downThresholdMax and i >= iterIgnore:
966 portDownOfpToDevNodeIter[node][i] = ptDownOfpToDevice
jenkins8ba10ab2015-03-24 10:31:31 -0700967 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400968 " port down Ofp-to-device: "+
969 str(ptDownOfpToDevice) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700970 else:
971 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400972 " port down Ofp-to-device ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -0700973 " due to excess in threshold or premature iteration")
974
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400975 if ptDownDeviceToLink >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400976 ptDownDeviceToLink < downThresholdMax and i >= iterIgnore:
977 portDownDevToLinkNodeIter[node][i] = ptDownDeviceToLink
jenkins8ba10ab2015-03-24 10:31:31 -0700978 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400979 " port down Device-to-link "+
980 str(ptDownDeviceToLink) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700981 else:
982 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400983 " port down Device-to-link ignored"+
984 " due to excess in threshold or premature iteration")
985
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -0400986 if ptDownLinkToGraph >= downThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -0400987 ptDownLinkToGraph < downThresholdMax and i >= iterIgnore:
988 portDownLinkToGraphNodeIter[node][i] = ptDownLinkToGraph
989 main.log.info("ONOS "+str(nodeNum)+
990 " port down Link-to-graph "+
991 str(ptDownLinkToGraph) + " ms")
992 else:
993 main.log.info("ONOS "+str(nodeNum)+
994 " port down Link-to-graph ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -0700995 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700996
jenkins7ead5a82015-03-13 10:28:21 -0700997 time.sleep(3)
998
999 main.step('Starting wireshark capture for port status up')
1000 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
1001
1002 time.sleep(5)
1003 main.step('Enable port and obtain timestamp')
1004 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
1005 main.Mininet1.handle.expect('mininet>')
1006
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001007 jsonStrPtUp = []
1008 for node in range (0, clusterCount):
1009 metricsPortUp = CLIs[node].topologyEventsMetrics()
1010 jsonStrPtUp.append(metricsPortUp)
1011
jenkins7ead5a82015-03-13 10:28:21 -07001012 time.sleep(5)
1013 main.ONOS1.tsharkStop()
1014
1015 time.sleep(3)
1016 os.system('scp ' + ONOSUser + '@' +
1017 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
1018
1019 fPortUp = open(tsharkPortUp, 'r')
1020 fLine = fPortUp.readline()
1021 objUp = fLine.split(' ')
1022 if len(fLine) > 0:
1023 timestampBeginPtUp = int(float(objUp[1]) * 1000)
1024 if timestampBeginPtUp < 1400000000000:
1025 timestampBeginPtUp = int(float(objUp[2]) * 1000)
1026 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
1027 else:
1028 main.log.info('Tshark output file returned unexpected' + ' results.')
1029 timestampBeginPtUp = 0
1030 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -07001031
1032 for node in range(0, clusterCount):
1033 nodeNum = node+1
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001034 #metricsUp = CLIs[node].topologyEventsMetrics
1035 #jsonStrUp = metricsUp()
1036 jsonObj = json.loads(jsonStrPtUp[node])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001037
1038 if jsonObj:
1039 graphTimestamp = jsonObj[graphTimestampKey]['value']
1040 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
1041 linkTimestamp = jsonObj[linkTimestampKey]['value']
1042 else:
1043 main.log.error( "Unexpected json object" )
1044 graphTimestamp = 0
1045 deviceTimestamp = 0
1046 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001047
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001048 ptUpEndToEnd = int(graphTimestamp) - int(timestampBeginPtUp)
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001049 ptUpOfpToDevice = float(deviceTimestamp) - float(timestampBeginPtUp)
1050 ptUpDeviceToLink = float(linkTimestamp) - float(deviceTimestamp)
1051 ptUpLinkToGraph = float(graphTimestamp) - float(linkTimestamp)
jenkins8ba10ab2015-03-24 10:31:31 -07001052
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001053 if ptUpEndToEnd >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001054 ptUpEndToEnd < upThresholdMax and i > iterIgnore:
1055 portUpEndToEndNodeIter[node][i] = ptUpEndToEnd
jenkins8ba10ab2015-03-24 10:31:31 -07001056 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001057 " port up End-to-end: "+
1058 str(ptUpEndToEnd) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001059 else:
1060 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001061 " port up End-to-end ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001062 " due to excess in threshold or premature iteration")
1063
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001064 if ptUpOfpToDevice >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001065 ptUpOfpToDevice < upThresholdMax and i > iterIgnore:
1066 portUpOfpToDevNodeIter[node][i] = ptUpOfpToDevice
jenkins8ba10ab2015-03-24 10:31:31 -07001067 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001068 " port up Ofp-to-device: "+
1069 str(ptUpOfpToDevice) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001070 else:
1071 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001072 " port up Ofp-to-device ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001073 " due to excess in threshold or premature iteration")
1074
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001075 if ptUpDeviceToLink >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001076 ptUpDeviceToLink < upThresholdMax and i > iterIgnore:
1077 portUpDevToLinkNodeIter[node][i] = ptUpDeviceToLink
jenkins8ba10ab2015-03-24 10:31:31 -07001078 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001079 " port up Device-to-link: "+
1080 str(ptUpDeviceToLink) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -07001081 else:
1082 main.log.info("ONOS "+str(nodeNum)+
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001083 " port up Device-to-link ignored"+
1084 " due to excess in threshold or premature iteration")
1085
andrew@onlab.us9a3d2bb2015-04-14 19:33:32 -04001086 if ptUpLinkToGraph >= upThresholdMin and\
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001087 ptUpLinkToGraph < upThresholdMax and i > iterIgnore:
1088 portUpLinkToGraphNodeIter[node][i] = ptUpLinkToGraph
1089 main.log.info("ONOS "+str(nodeNum)+
1090 " port up Link-to-graph: "+
1091 str(ptUpLinkToGraph) + " ms")
1092 else:
1093 main.log.info("ONOS "+str(nodeNum)+
1094 " port up Link-to-graph ignored"+
jenkins8ba10ab2015-03-24 10:31:31 -07001095 " due to excess in threshold or premature iteration")
1096
jenkins7ead5a82015-03-13 10:28:21 -07001097 dbCmdList = []
1098 for node in range(0, clusterCount):
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001099 portUpEndToEndList = []
1100 portUpOfpToDevList = []
1101 portUpDevToLinkList = []
1102 portUpLinkToGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001103
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001104 portDownEndToEndList = []
1105 portDownOfpToDevList = []
1106 portDownDevToLinkList = []
1107 portDownLinkToGraphList = []
1108
1109 portUpEndToEndAvg = 0
1110 portUpOfpToDevAvg = 0
1111 portUpDevToLinkAvg = 0
1112 portUpLinkToGraphAvg = 0
1113
1114 portDownEndToEndAvg = 0
1115 portDownOfpToDevAvg = 0
1116 portDownDevToLinkAvg = 0
1117 portDownLinkToGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001118
andrew@onlab.usaa1f0dc2015-04-10 12:18:01 -04001119 # TODO: Update for more pythonic way to get list
1120 # portUpDevList = [item for item in portUpDevNodeIter[node]
1121 # if item > 0.0]
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001122 for item in portUpEndToEndNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001123 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001124 portUpEndToEndList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001125
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001126 for item in portUpOfpToDevNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001127 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001128 portUpOfpToDevList.append(item)
1129
1130 for item in portUpDevToLinkNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -07001131 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001132 portUpDevToLinkList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001133
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001134 for item in portUpLinkToGraphNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001135 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001136 portUpLinkToGraphList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001137
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001138 for item in portDownEndToEndNodeIter[node]:
jenkins7ead5a82015-03-13 10:28:21 -07001139 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001140 portDownEndToEndList.append(item)
jenkins7ead5a82015-03-13 10:28:21 -07001141
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001142 for item in portDownOfpToDevNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -07001143 if item > 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001144 portDownOfpToDevList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001145
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001146 for item in portDownDevToLinkNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001147 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001148 portDownDevToLinkList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -07001149
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001150 for item in portDownLinkToGraphNodeIter[node]:
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001151 if item >= 0.0:
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001152 portDownLinkToGraphList.append(item)
1153
1154 portUpEndToEndAvg = round(numpy.mean(portUpEndToEndList), 2)
1155 portUpOfpToDevAvg = round(numpy.mean(portUpOfpToDevList), 2)
1156 portUpDevToLinkAvg = round(numpy.mean(portUpDevToLinkList), 2)
1157 portUpLinkToGraphAvg = round(numpy.mean(portUpLinkToGraphList), 2)
1158
1159 portDownEndToEndAvg = round(numpy.mean(portDownEndToEndList), 2)
1160 portDownOfpToDevAvg = round(numpy.mean(portDownOfpToDevList), 2)
1161 portDownDevToLinkAvg = round(numpy.mean(portDownDevToLinkList), 2)
1162 portDownLinkToGraphAvg = round(numpy.mean(portDownLinkToGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001163
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001164 portUpStdDev = round(numpy.std(portUpEndToEndList), 2)
1165 portDownStdDev = round(numpy.std(portDownEndToEndList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001166
jenkins7ead5a82015-03-13 10:28:21 -07001167 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001168 main.log.report(' Port up End-to-end ' +
1169 str(portUpEndToEndAvg) + ' ms')
1170 main.log.report(' Port up Ofp-to-device ' +
1171 str(portUpOfpToDevAvg) + ' ms')
1172 main.log.report(' Port up Device-to-link ' +
1173 str(portUpDevToLinkAvg) + ' ms')
1174 main.log.report(' Port up Link-to-graph ' +
1175 str(portUpLinkToGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001176
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001177 main.log.report(' Port down End-to-end ' +
1178 str(round(portDownEndToEndAvg, 2)) + ' ms')
1179 main.log.report(' Port down Ofp-to-device ' +
1180 str(portDownOfpToDevAvg) + ' ms')
andrew@onlab.us55711ed2015-04-23 14:28:08 -04001181 main.log.report(' Port down Device-to-link ' +
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001182 str(portDownDevToLinkAvg) + ' ms')
1183 main.log.report(' Port down Link-to-graph' +
1184 str(portDownLinkToGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001185
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001186 dbCmdList.append("INSERT INTO port_latency_details VALUES('" +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -04001187 timeToPost + "','port_latency_results'," + jenkinsBuildNumber +
jenkins7ead5a82015-03-13 10:28:21 -07001188 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
andrew@onlab.usede8aaf2015-04-10 14:32:26 -04001189 "'," +
1190 str(portUpEndToEndAvg) +',' +
1191 str(portUpOfpToDevAvg) + ',' +
1192 str(portUpDevToLinkAvg) + ',' +
1193 str(portUpLinkToGraphAvg) + ',' +
1194 str(portDownEndToEndAvg) + ',' +
1195 str(portDownOfpToDevAvg) + ',' +
1196 str(portDownDevToLinkAvg) + ',' +
1197 str(portDownLinkToGraphAvg) +
1198 ');')
jenkins7ead5a82015-03-13 10:28:21 -07001199
1200 fResult = open(resultPath, 'a')
1201 for line in dbCmdList:
1202 if line:
1203 fResult.write(line + '\n')
1204
1205 fResult.close()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001206
1207 # Delete switches from controller to prepare for next
1208 # set of tests
jenkins7ead5a82015-03-13 10:28:21 -07001209 main.Mininet1.deleteSwController('s1')
1210 main.Mininet1.deleteSwController('s2')
1211 utilities.assert_equals(expect=main.TRUE,
1212 actual=assertion,
1213 onpass='Port discovery latency calculation successful',
1214 onfail='Port discovery test failed')
1215
1216 def CASE4(self, main):
1217 """
1218 Increase number of nodes and initiate CLI
1219
1220 With the most recent implementation, we need a method to
1221 ensure all ONOS nodes are killed, as well as redefine
1222 the cell files to ensure all nodes that will be used
1223 is in the cell file. Otherwise, exceptions will
1224 prohibit test from running successfully.
1225
1226 3/12/15
1227
1228 """
1229 global clusterCount
1230 import time
1231 import os
1232
1233 clusterCount += 2
1234
1235 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1236 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1237 cellName = main.params[ 'ENV' ][ 'cellName' ]
1238 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1239
1240 main.log.report('Increasing cluster size to ' + str(clusterCount))
1241
1242 main.log.step( "Killing all ONOS processes before scale-out" )
1243
1244 for i in range( 1, 8 ):
1245 main.ONOSbench.onosDie(
1246 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1247 main.ONOSbench.onosUninstall(
1248 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1249
1250 main.step( "Creating scale-out cell file" )
1251 cellIp = []
1252 for node in range( 1, clusterCount + 1 ):
1253 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1254
1255 main.log.info( "Cell Ip list: " + str(cellIp) )
1256 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1257 str(features), *cellIp )
1258
1259 main.step( "Setting cell definition" )
1260 main.ONOSbench.setCell(cellName)
1261
1262 main.step( "Packaging cell definition" )
1263 main.ONOSbench.onosPackage()
1264
jenkins7ead5a82015-03-13 10:28:21 -07001265 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001266 main.ONOSbench.onosInstall(
1267 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1268
1269 time.sleep( 20 )
1270
jenkins7ead5a82015-03-13 10:28:21 -07001271 for node in range( 1, clusterCount + 1):
1272 for i in range( 2 ):
1273 isup = main.ONOSbench.isup(
1274 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1275 if isup:
1276 main.log.info( "ONOS "+str(node) + " is up\n")
1277 break
1278 if not isup:
1279 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001280
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001281 for node in range( 0, clusterCount ):
1282 CLIs[node].startOnosCli( cellIp[node] )
1283
1284 main.step( 'Setting configurations for metrics' )
1285 configParam = 'maxEvents 1'
1286 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1287 configParam = 'maxBatchMs 0'
1288 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1289 configParam = 'maxIdleMs 0'
1290 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1291
1292 main.step( 'Activating essential applications' )
1293 CLIs[0].activateApp( 'org.onosproject.metrics' )
1294 CLIs[0].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001295