blob: 8060607633669d1f3f95759c148385e325bcb541 [file] [log] [blame]
jenkins7ead5a82015-03-13 10:28:21 -07001# 2015.03.12 10:22:05 PDT
2#Embedded file name: ../tests/TopoPerfNextBM/TopoPerfNextBM.py
3import time
4import sys
5import os
6import re
7
8class TopoPerfNextBM:
9
10 def __init__(self):
11 self.default = ''
12
13 def CASE1(self, main):
14 """
15 ONOS startup sequence
16 """
17 global clusterCount
18 global timeToPost
19 global runNum
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040020 global jenkinsBuildNumber
andrew@onlab.us0f468c42015-04-02 17:05:47 -040021
jenkins7ead5a82015-03-13 10:28:21 -070022 import time
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040023 import os
24
jenkins7ead5a82015-03-13 10:28:21 -070025 clusterCount = 1
26 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
27 runNum = time.strftime('%d%H%M%S')
28 cellName = main.params['ENV']['cellName']
29 gitPull = main.params['GIT']['autoPull']
30 checkoutBranch = main.params['GIT']['checkout']
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -040031
32 # Get jenkins build number from environment.
33 # This environment variable will only exist when
34 # triggered by a jenkins job
35 try:
36 jenkinsBuildNumber = str(os.environ['BUILD_NUMBER'])
37 main.log.report( 'Jenkins build number: ' +
38 jenkinsBuildNumber )
39 except KeyError:
40 # Jenkins build number is also used in posting to DB
41 # If this test is not triggered by jenkins, give
42 # it the runNum variable instead, ensuring that
43 # the DB post will recognize it as a non-jenkins run
44 jenkinsBuildNumber = str(runNum)
45 main.log.info( 'Job is not run by jenkins. '+
46 'Build number set to: ' + jenkinsBuildNumber)
47
andrew@onlab.us0f468c42015-04-02 17:05:47 -040048 global CLIs
49 CLIs = []
50 global nodes
51 nodes = []
52 global nodeIpList
53 nodeIpList = []
54 for i in range( 1, 8 ):
55 CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) )
56 nodes.append( getattr( main, 'ONOS' + str( i ) ) )
57 nodeIpList.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] )
58
jenkins7ead5a82015-03-13 10:28:21 -070059 MN1Ip = main.params['MN']['ip1']
60 BENCHIp = main.params['BENCH']['ip']
andrew@onlab.us0f468c42015-04-02 17:05:47 -040061 cellFeatures = main.params['ENV']['cellFeatures']
jenkins7ead5a82015-03-13 10:28:21 -070062 topoCfgFile = main.params['TEST']['topoConfigFile']
63 topoCfgName = main.params['TEST']['topoConfigName']
64 portEventResultPath = main.params['DB']['portEventResultPath']
65 switchEventResultPath = main.params['DB']['switchEventResultPath']
66 mvnCleanInstall = main.params['TEST']['mci']
67
68 main.case('Setting up test environment')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040069
70 # NOTE: Below is deprecated after new way to install features
71 #main.log.info('Copying topology event accumulator config' +
72 # ' to ONOS /package/etc')
73 #main.ONOSbench.handle.sendline('cp ~/' +
74 # topoCfgFile + ' ~/ONOS/tools/package/etc/' +
75 # topoCfgName)
76 #main.ONOSbench.handle.expect('\\$')
jenkins7ead5a82015-03-13 10:28:21 -070077
78 main.log.report('Setting up test environment')
79
80 main.step('Starting mininet topology ')
81 main.Mininet1.startNet()
82
83 main.step('Cleaning previously installed ONOS if any')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040084 # Nodes 2 ~ 7
85 for i in range( 1, 7 ):
86 main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i])
jenkins7ead5a82015-03-13 10:28:21 -070087
88 main.step('Clearing previous DB log file')
89
90 fPortLog = open(portEventResultPath, 'w')
91 fPortLog.write('')
92 fPortLog.close()
93 fSwitchLog = open(switchEventResultPath, 'w')
94 fSwitchLog.write('')
95 fSwitchLog.close()
96
jenkins7ead5a82015-03-13 10:28:21 -070097 main.step('Creating cell file')
98 cellFileResult = main.ONOSbench.createCellFile(
andrew@onlab.us0f468c42015-04-02 17:05:47 -040099 BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700100
101 main.step('Applying cell file to environment')
102 cellApplyResult = main.ONOSbench.setCell(cellName)
103 verifyCellResult = main.ONOSbench.verifyCell()
104
105 main.step('Git checkout and pull ' + checkoutBranch)
106 if gitPull == 'on':
107 checkoutResult = main.TRUE
108 pullResult = main.ONOSbench.gitPull()
109 else:
110 checkoutResult = main.TRUE
111 pullResult = main.TRUE
112 main.log.info('Skipped git checkout and pull')
113
114 main.log.report('Commit information - ')
115 main.ONOSbench.getVersion(report=True)
116 main.step('Using mvn clean & install')
117 if mvnCleanInstall == 'on':
118 mvnResult = main.ONOSbench.cleanInstall()
119 elif mvnCleanInstall == 'off':
120 main.log.info('mci turned off by settings')
121 mvnResult = main.TRUE
122 main.step('Set cell for ONOS cli env')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400123 CLIs[0].setCell(cellName)
jenkins7ead5a82015-03-13 10:28:21 -0700124
125 main.step('Creating ONOS package')
126 packageResult = main.ONOSbench.onosPackage()
127
128 main.step('Installing ONOS package')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400129 install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700130
131 time.sleep(10)
132
133 main.step('Start onos cli')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400134 cli1 = CLIs[0].startOnosCli(nodeIpList[0])
135
136 main.step( 'activating essential applications' )
137 CLIs[0].activateApp( 'org.onosproject.metrics' )
138 CLIs[0].activateApp( 'org.onosproject.openflow' )
139
140 main.step( 'Configuring application parameters' )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400141
142 configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider'
143 configParam = 'maxEvents 1'
144 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
145 configParam = 'maxBatchMs 0'
146 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
147 configParam = 'maxIdleMs 0'
148 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
149
jenkins7ead5a82015-03-13 10:28:21 -0700150 utilities.assert_equals(expect=main.TRUE,
151 actual=cellFileResult and cellApplyResult and\
152 verifyCellResult and checkoutResult and\
153 pullResult and mvnResult and\
154 install1Result,
155 onpass='Test Environment setup successful',
156 onfail='Failed to setup test environment')
157
158 def CASE2(self, main):
159 """
160 Assign s1 to ONOS1 and measure latency
161
162 There are 4 levels of latency measurements to this test:
163 1 ) End-to-end measurement: Complete end-to-end measurement
164 from TCP ( SYN/ACK ) handshake to Graph change
165 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
166 measurement from OFP Vendor message to Graph change
167 3 ) OFP-to-device measurement: 'ONOS processing without
168 graph change' snippet of measurement from OFP vendor
169 message to Device change timestamp
170 4 ) T0-to-device measurement: Measurement that includes
171 the switch handshake to devices timestamp without
172 the graph view change. ( TCP handshake -> Device
173 change )
174 """
175 import time
176 import subprocess
177 import json
178 import requests
179 import os
180 import numpy
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400181
jenkins7ead5a82015-03-13 10:28:21 -0700182 ONOSUser = main.params['CTRL']['user']
183 defaultSwPort = main.params['CTRL']['port1']
184 numIter = main.params['TEST']['numIter']
185 iterIgnore = int(main.params['TEST']['iterIgnore'])
jenkins8ba10ab2015-03-24 10:31:31 -0700186
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400187 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
188 graphTimestampKey = main.params['JSON']['graphTimestamp']
jenkins8ba10ab2015-03-24 10:31:31 -0700189
jenkins7ead5a82015-03-13 10:28:21 -0700190 debugMode = main.params['TEST']['debugMode']
191 onosLog = main.params['TEST']['onosLogFile']
192 resultPath = main.params['DB']['switchEventResultPath']
193 thresholdStr = main.params['TEST']['singleSwThreshold']
194 thresholdObj = thresholdStr.split(',')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400195 thresholdMin = float(thresholdObj[0])
196 thresholdMax = float(thresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700197
jenkins8ba10ab2015-03-24 10:31:31 -0700198 # Look for 'role-request' messages,
199 # which replaces the 'vendor' messages previously seen
200 # on OVS 2.0.1
jenkins7ead5a82015-03-13 10:28:21 -0700201 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700202 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
203 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
204 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400205 tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700206
jenkins7ead5a82015-03-13 10:28:21 -0700207 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
208 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
jenkins8ba10ab2015-03-24 10:31:31 -0700209 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
210 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400211 tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
212
213 # Switch connect measurement list
214 # TCP Syn/Ack -> Feature Reply latency collection for each node
215 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
216 # Feature Reply -> Role Request latency collection for each node
217 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
218 int(numIter)))
219 # Role Request -> Role Reply latency collection for each node
220 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
221 int(numIter)))
222 # Role Reply -> Device Update latency collection for each node
223 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
224 int(numIter)))
225 # Device Update -> Graph Update latency collection for each node
226 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
227 int(numIter)))
228
229 # Switch disconnect measurement lists
230 # Mininet Fin / Ack -> Mininet Ack
231 finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
232 int(numIter)))
233 # Mininet Ack -> Device Event
234 ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
235 int(numIter)))
236 # Device event -> Graph event
237 deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
238 int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700239
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400240 # TCP Syn/Ack -> Feature Reply latency collection for each node
241 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
242 # Feature Reply -> Role Request latency collection for each node
243 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
244 int(numIter)))
245 # Role Request -> Role Reply latency collection for each node
246 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
247 int(numIter)))
248 # Role Reply -> Device Update latency collection for each node
249 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
250 int(numIter)))
251 # Device Update -> Graph Update latency collection for each node
252 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
253 int(numIter)))
254
255
jenkins7ead5a82015-03-13 10:28:21 -0700256 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
257 ofpToGraphLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
258 ofpToDeviceLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
259
260 tcpToOfpLatIter = []
jenkins8ba10ab2015-03-24 10:31:31 -0700261 tcpToFeatureLatIter = []
262 tcpToRoleLatIter = []
jenkins7ead5a82015-03-13 10:28:21 -0700263 assertion = main.TRUE
264 localTime = time.strftime('%x %X')
265 localTime = localTime.replace('/', '')
266 localTime = localTime.replace(' ', '_')
267 localTime = localTime.replace(':', '')
268
269 if debugMode == 'on':
270 main.ONOS1.tsharkPcap('eth0',
271 '/tmp/single_sw_lat_pcap_' + localTime)
272 main.log.info('Debug mode is on')
273 main.log.report('Latency of adding one switch to controller')
274 main.log.report('First ' + str(iterIgnore) +
275 ' iterations ignored' + ' for jvm warmup time')
276 main.log.report('Total iterations of test: ' + str(numIter))
277
278 for i in range(0, int(numIter)):
279 main.log.info('Starting tshark capture')
280 main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
281 main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput)
jenkins8ba10ab2015-03-24 10:31:31 -0700282 main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
283 main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
284
jenkins7ead5a82015-03-13 10:28:21 -0700285 time.sleep(10)
286
287 main.log.info('Assigning s3 to controller')
288 main.Mininet1.assignSwController(sw='3',
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400289 ip1=nodeIpList[0], port1=defaultSwPort)
jenkins7ead5a82015-03-13 10:28:21 -0700290
291 time.sleep(10)
292
293 main.log.info('Stopping all Tshark processes')
294 main.ONOS1.tsharkStop()
295
296 main.log.info('Copying over tshark files')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400297 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins7ead5a82015-03-13 10:28:21 -0700298 ':' + tsharkTcpOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400299 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700300 ':' + tsharkRoleOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400301 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700302 ':' + tsharkFeatureOutput + ' /tmp/')
303 os.system('scp ' + ONOSUser + '@' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400304 nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700305
306 # Get tcp syn / ack output
jenkins7ead5a82015-03-13 10:28:21 -0700307 time.sleep(5)
308 tcpFile = open(tsharkTcpOutput, 'r')
309 tempText = tcpFile.readline()
310 tempText = tempText.split(' ')
311 main.log.info('Object read in from TCP capture: ' +
312 str(tempText))
313
314 if len(tempText) > 1:
315 t0Tcp = float(tempText[1]) * 1000.0
316 else:
317 main.log.error('Tshark output file for TCP' +
318 ' returned unexpected results')
319 t0Tcp = 0
320 assertion = main.FALSE
321 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700322
323 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700324 time.sleep(5)
325 ofFile = open(tsharkOfOutput, 'r')
326 lineOfp = ''
327 while True:
328 tempText = ofFile.readline()
329 if tempText != '':
330 lineOfp = tempText
331 else:
332 break
jenkins7ead5a82015-03-13 10:28:21 -0700333 obj = lineOfp.split(' ')
334 main.log.info('Object read in from OFP capture: ' +
335 str(lineOfp))
336 if len(obj) > 1:
337 t0Ofp = float(obj[1]) * 1000.0
338 else:
339 main.log.error('Tshark output file for OFP' +
340 ' returned unexpected results')
341 t0Ofp = 0
342 assertion = main.FALSE
343 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700344
345 # Get role request output
346 roleFile = open(tsharkRoleOutput, 'r')
347 tempText = roleFile.readline()
348 tempText = tempText.split(' ')
349 if len(tempText) > 1:
350 main.log.info('Object read in from role request capture:' +
351 str(tempText))
352 roleTimestamp = float(tempText[1]) * 1000.0
353 else:
354 main.log.error('Tshark output file for role request' +
355 ' returned unexpected results')
356 timeRoleRequest = 0
357 assertion = main.FALSE
358 roleFile.close()
359
360 # Get feature reply output
361 featureFile = open(tsharkFeatureOutput, 'r')
362 tempText = featureFile.readline()
363 tempText = tempText.split(' ')
364 if len(tempText) > 1:
365 main.log.info('Object read in from feature reply capture: '+
366 str(tempText))
367 featureTimestamp = float(tempText[1]) * 1000.0
368 else:
369 main.log.error('Tshark output file for feature reply' +
370 ' returned unexpected results')
371 timeFeatureReply = 0
372 assertion = main.FALSE
373 featureFile.close()
374
375 # TODO: calculate feature reply, role request times
376 # stack measurements correctly and report
377
jenkins8ba10ab2015-03-24 10:31:31 -0700378 #TODO: Refactor in progress
379
380 for node in range(0, clusterCount):
381 nodeNum = node+1
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400382 metricsSwUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700383 jsonStr = metricsSwUp()
384 jsonObj = json.loads(jsonStr)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400385 if jsonObj:
386 graphTimestamp = jsonObj[graphTimestampKey]['value']
387 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700388 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400389 main.log.error( "Unexpected JSON object" )
390 # If we could not obtain the JSON object,
391 # set the timestamps to 0, which will be
392 # excluded from the measurement later on
393 # (realized as invalid)
394 graphTimestamp = 0
395 deviceTimestamp = 0
396
397 endToEnd = int(graphTimestamp) - int(t0Tcp)
398
399 # Below are measurement breakdowns of the end-to-end
400 # measurement.
401 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
402 featureToRole = int(roleTimestamp) - int(featureTimestamp)
403 roleToOfp = int(t0Ofp) - int(roleTimestamp)
404 ofpToDevice = int(deviceTimestamp) - int(t0Ofp)
405 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
406
407 if endToEnd > thresholdMin and\
408 endToEnd < thresholdMax and i >= iterIgnore:
409 endToEndLatNodeIter[node][i] = endToEnd
410 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
411 str(endToEnd) + " ms")
412 else:
413 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700414 "measurement ignored due to excess in "+
415 "threshold or premature iteration")
416
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400417 if tcpToFeature > thresholdMin and\
418 tcpToFeature < thresholdMax and i >= iterIgnore:
419 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
420 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
421 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700422 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400423 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700424 "measurement ignored due to excess in "+
425 "threshold or premature iteration")
426
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400427 if featureToRole > thresholdMin and\
428 featureToRole < thresholdMax and i >= iterIgnore:
429 featureToRoleRequestLatNodeIter[node][i] = featureToRole
430 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
431 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700432 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400433 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700434 "measurement ignored due to excess in "+
435 "threshold or premature iteration")
436
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400437 if roleToOfp > thresholdMin and\
438 roleToOfp < thresholdMax and i >= iterIgnore:
439 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
440 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
441 str(roleToOfp) + " ms")
442 else:
443 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
444 "measurement ignored due to excess in "+
445 "threshold or premature iteration")
446
447 if ofpToDevice > thresholdMin and\
448 ofpToDevice < thresholdMax and i >= iterIgnore:
449 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
450 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
451 str(ofpToDevice) + " ms")
452 else:
453 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
454 "measurement ignored due to excess in "+
455 "threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700456
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400457 if deviceToGraph > thresholdMin and\
458 deviceToGraph < thresholdMax and i >= iterIgnore:
459 deviceToGraphLatNodeIter[node][i] = deviceToGraph
460 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
461 str(deviceToGraph) + " ms")
462 else:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400463 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400464 "measurement ignored due to excess in "+
465 "threshold or premature iteration")
466
jenkins8ba10ab2015-03-24 10:31:31 -0700467 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700468 time.sleep(5)
469
470 # Get device id to remove
471 deviceIdJsonStr = main.ONOS1cli.devices()
472
473 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
474 deviceId = json.loads(deviceIdJsonStr)
475
476 deviceList = []
477 for device in deviceId:
478 deviceList.append(device['id'])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400479
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400480 # Measure switch down metrics
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400481 # TCP FIN/ACK -> TCP FIN
482 # TCP FIN -> Device Event
483 # Device Event -> Graph Event
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400484 # Capture switch down FIN / ACK packets
485
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400486 # The -A 1 grep option allows us to grab 1 extra line after the
487 # last tshark output grepped originally
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400488 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
489 grepOptions = '-A 1' )
490
491 time.sleep( 5 )
492
493 removeJsonList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400494
jenkins7ead5a82015-03-13 10:28:21 -0700495 main.step('Remove switch from controller')
496 main.Mininet1.deleteSwController('s3')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400497 firstDevice = deviceList[0]
jenkins7ead5a82015-03-13 10:28:21 -0700498 main.log.info( "Removing device " +str(firstDevice)+
499 " from ONOS" )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400500
501 time.sleep( 5 )
502
503 # We need to get metrics before removing
504 # device from the store below.
505 for node in range(0, clusterCount):
506 metricsSwDown = CLIs[node].topologyEventsMetrics
507 jsonStr = metricsSwDown()
508 removeJsonList.append( json.loads(jsonStr) )
509
jenkins7ead5a82015-03-13 10:28:21 -0700510 #if deviceId:
511 main.ONOS1cli.deviceRemove(firstDevice)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400512
513 main.ONOS1.tsharkStop()
514
515 main.log.info('Copying over tshark files')
516 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
517 ':' + tsharkFinAckOutput + ' /tmp/')
518
519 time.sleep( 10 )
520 finAckOutputList = []
521 with open(tsharkFinAckOutput, 'r') as f:
522 tempLine = f.readlines()
523 main.log.info('Object read in from FinAck capture: ' +
524 str(tempLine))
525
526 index = 1
527 for line in tempLine:
528 obj = line.split(' ')
jenkins7ead5a82015-03-13 10:28:21 -0700529
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400530 if len(obj) > 1:
531 if index == 1:
532 tFinAck = float(obj[1]) * 1000.0
533 elif index == 3:
534 tAck = float(obj[1]) * 1000.0
535 else:
536 main.log.error('Tshark output file for OFP' +
537 ' returned unexpected results')
538 tFinAck = 0
539 tAck = 0
540 assertion = main.FALSE
541
542 index = index+1
543
544 # with open() as f takes care of closing file
545
jenkins7ead5a82015-03-13 10:28:21 -0700546 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400547
548 for node in range(0, clusterCount):
549 nodeNum = node+1
550 jsonObj = removeJsonList[node]
551 if jsonObj:
552 graphTimestamp = jsonObj[graphTimestampKey]['value']
553 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
554 main.log.info("Graph timestamp: "+str(graphTimestamp))
555 main.log.info("Device timestamp: "+str(deviceTimestamp))
556 else:
557 main.log.error( "Unexpected JSON object" )
558 # If we could not obtain the JSON object,
559 # set the timestamps to 0, which will be
560 # excluded from the measurement later on
561 # (realized as invalid)
562 graphTimestamp = 0
563 deviceTimestamp = 0
564
565 finAckTransaction = int(tAck) - int(tFinAck)
566 ackToDevice = int(deviceTimestamp) - int(tAck)
567 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
568
569 if finAckTransaction > thresholdMin and\
570 finAckTransaction < thresholdMax and i >= iterIgnore:
571 finAckTransactionLatNodeIter[node][i] = finAckTransaction
572 main.log.info("ONOS "+str(nodeNum)+
573 " fin/ack transaction: "+
574 str(finAckTransaction) + " ms")
575 else:
576 main.log.info("ONOS "+str(nodeNum)+
577 " fin/ack transaction "+
578 "measurement ignored due to excess in "+
579 "threshold or premature iteration")
580
581 if ackToDevice > thresholdMin and\
582 ackToDevice < thresholdMax and i >= iterIgnore:
583 ackToDeviceLatNodeIter[node][i] = ackToDevice
584 main.log.info("ONOS "+str(nodeNum)+
585 " ack-to-device: "+
586 str(ackToDevice) + " ms")
587 else:
588 main.log.info("ONOS "+str(nodeNum)+
589 " ack-to-device "+
590 "measurement ignored due to excess in "+
591 "threshold or premature iteration")
592
593 if deviceToGraph > thresholdMin and\
594 deviceToGraph < thresholdMax and i >= iterIgnore:
595 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
596 main.log.info("ONOS "+str(nodeNum)+
597 " device-to-graph disconnect: "+
598 str(deviceToGraph) + " ms")
599 else:
600 main.log.info("ONOS "+str(nodeNum)+
601 " device-to-graph disconnect "+
602 "measurement ignored due to excess in "+
603 "threshold or premature iteration")
jenkins7ead5a82015-03-13 10:28:21 -0700604
605 endToEndAvg = 0
606 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700607 dbCmdList = []
608 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700609 # List of latency for each node
610 endToEndList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400611
jenkins8ba10ab2015-03-24 10:31:31 -0700612 tcpToFeatureList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400613 featureToRoleList = []
614 roleToOfpList = []
615 ofpToDeviceList = []
616 deviceToGraphList = []
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400617
618 finAckTransactionList = []
619 ackToDeviceList = []
620 deviceToGraphDiscList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700621
622 # LatNodeIter 2d arrays contain all iteration latency
623 # for each node of the current scale cluster size
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400624 # Switch connection measurements
625 # Set further acceptance criteria for measurements
626 # here if you would like to filter reporting results
jenkins7ead5a82015-03-13 10:28:21 -0700627 for item in endToEndLatNodeIter[node]:
628 if item > 0.0:
629 endToEndList.append(item)
630
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400631 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700632 if item > 0.0:
633 tcpToFeatureList.append(item)
634
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400635 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700636 if item > 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400637 featureToRoleList.append(item)
638
639 for item in roleRequestToRoleReplyLatNodeIter[node]:
640 if item > 0.0:
641 roleToOfpList.append(item)
642
643 for item in roleReplyToDeviceLatNodeIter[node]:
644 if item > 0.0:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400645 tcpToFeatureList.append(item)
646
647 for item in featureToRoleRequestLatNodeIter[node]:
648 if item > 0.0:
649 featureToRoleList.append(item)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400650
651 for item in deviceToGraphLatNodeIter[node]:
652 if item > 0.0:
653 deviceToGraphList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700654
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400655 # Switch disconnect measurements
656 for item in finAckTransactionLatNodeIter[node]:
657 if item > 0.0:
658 finAckTransactionList.append(item)
659
660 for item in ackToDeviceLatNodeIter[node]:
661 if item > 0.0:
662 ackToDeviceList.append(item)
663
664 for item in deviceToGraphDiscLatNodeIter[node]:
665 if item > 0.0:
666 deviceToGraphDiscList.append(item)
667
jenkins7ead5a82015-03-13 10:28:21 -0700668 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400669 endToEndStdDev = round(numpy.std(endToEndList), 2)
670
jenkins8ba10ab2015-03-24 10:31:31 -0700671 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400672 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
673
674 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
675 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
676
677 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
678 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
679
jenkins7ead5a82015-03-13 10:28:21 -0700680 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400681 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
682
683 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
684 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
685
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400686 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
687 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
688
689 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
690 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
691
692 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
693 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
694
jenkins7ead5a82015-03-13 10:28:21 -0700695 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400696 main.log.report(' - Switch Connection Statistics - ')
697
jenkins7ead5a82015-03-13 10:28:21 -0700698 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
699 ' ms' + ' End-to-end Std dev: ' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400700 str(endToEndStdDev) + ' ms')
701
702 main.log.report(' Tcp-to-feature-reply Avg: ' +
703 str(tcpToFeatureAvg) + ' ms')
704 main.log.report(' Tcp-to-feature-reply Std dev: '+
705 str(tcpToFeatureStdDev) + ' ms')
706
707 main.log.report(' Feature-reply-to-role-request Avg: ' +
708 str(featureToRoleAvg) + ' ms')
709 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
710 str(featureToRoleStdDev) + ' ms')
711
712 main.log.report(' Role-request-to-role-reply Avg: ' +
713 str(roleToOfpAvg) +' ms')
714 main.log.report(' Role-request-to-role-reply Std dev: ' +
715 str(roleToOfpStdDev) + ' ms')
716
717 main.log.report(' Role-reply-to-device Avg: ' +
718 str(ofpToDeviceAvg) +' ms')
719 main.log.report(' Role-reply-to-device Std dev: ' +
720 str(ofpToDeviceStdDev) + ' ms')
721
722 main.log.report(' Device-to-graph Avg: ' +
723 str(deviceToGraphAvg) + ' ms')
724 main.log.report( 'Device-to-graph Std dev: ' +
725 str(deviceToGraphStdDev) + ' ms')
726
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400727 main.log.report(' - Switch Disconnection Statistics - ')
728 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
729 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
730 str(finAckStdDev) + ' ms')
731
732 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
733 ' ms')
734 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
735 ' ms')
736
737 main.log.report(' Device-to-graph (disconnect) Avg: ' +
738 str(deviceToGraphDiscAvg) + ' ms')
739 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
740 str(deviceToGraphDiscStdDev) + ' ms')
741
jenkins7ead5a82015-03-13 10:28:21 -0700742 dbCmdList.append(
743 "INSERT INTO switch_latency_tests VALUES('" +
744 timeToPost + "','switch_latency_results'," +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -0400745 jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
jenkins7ead5a82015-03-13 10:28:21 -0700746 str(node + 1) + "'," + str(endToEndAvg) + ',' +
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400747 str(endToEndStdDev) + ',0,0);')
jenkins7ead5a82015-03-13 10:28:21 -0700748
749 if debugMode == 'on':
750 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
751 '/tmp/', copyFileName='sw_lat_karaf')
752 fResult = open(resultPath, 'a')
753 for line in dbCmdList:
754 if line:
755 fResult.write(line + '\n')
756
757 fResult.close()
758 assertion = main.TRUE
759 utilities.assert_equals(expect=main.TRUE, actual=assertion,
760 onpass='Switch latency test successful',
761 onfail='Switch latency test failed')
762
763 def CASE3(self, main):
764 """
765 Bring port up / down and measure latency.
766 Port enable / disable is simulated by ifconfig up / down
767
768 In ONOS-next, we must ensure that the port we are
769 manipulating is connected to another switch with a valid
770 connection. Otherwise, graph view will not be updated.
771 """
772 global timeToPost
773 import time
774 import subprocess
775 import os
776 import requests
777 import json
778 import numpy
779 ONOS1Ip = main.params['CTRL']['ip1']
780 ONOS2Ip = main.params['CTRL']['ip2']
781 ONOS3Ip = main.params['CTRL']['ip3']
782 ONOSUser = main.params['CTRL']['user']
783 defaultSwPort = main.params['CTRL']['port1']
784 assertion = main.TRUE
785 numIter = main.params['TEST']['numIter']
786 iterIgnore = int(main.params['TEST']['iterIgnore'])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400787
788 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
789 graphTimestampKey = main.params['JSON']['graphTimestamp']
790 linkTimestampKey = main.params['JSON']['linkTimestamp']
jenkins7ead5a82015-03-13 10:28:21 -0700791
792 tsharkPortUp = '/tmp/tshark_port_up.txt'
793 tsharkPortDown = '/tmp/tshark_port_down.txt'
794 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
795
796 debugMode = main.params['TEST']['debugMode']
797 postToDB = main.params['DB']['postToDB']
798 resultPath = main.params['DB']['portEventResultPath']
799 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
800 localTime = time.strftime('%x %X')
801 localTime = localTime.replace('/', '')
802 localTime = localTime.replace(' ', '_')
803 localTime = localTime.replace(':', '')
804
805 if debugMode == 'on':
806 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
807
808 upThresholdStr = main.params['TEST']['portUpThreshold']
809 downThresholdStr = main.params['TEST']['portDownThreshold']
810 upThresholdObj = upThresholdStr.split(',')
811 downThresholdObj = downThresholdStr.split(',')
812 upThresholdMin = int(upThresholdObj[0])
813 upThresholdMax = int(upThresholdObj[1])
814 downThresholdMin = int(downThresholdObj[0])
815 downThresholdMax = int(downThresholdObj[1])
816
817 interfaceConfig = 's1-eth1'
818 main.log.report('Port enable / disable latency')
819 main.log.report('Simulated by ifconfig up / down')
820 main.log.report('Total iterations of test: ' + str(numIter))
821 main.step('Assign switches s1 and s2 to controller 1')
822
823 main.Mininet1.assignSwController(sw='1',
824 ip1=ONOS1Ip, port1=defaultSwPort)
825 main.Mininet1.assignSwController(sw='2',
826 ip1=ONOS1Ip, port1=defaultSwPort)
827
828 time.sleep(15)
829
830 portUpDeviceToOfpList = []
831 portUpGraphToOfpList = []
832 portDownDeviceToOfpList = []
833 portDownGraphToOfpList = []
834
835 portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
836 portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
837 portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
838 portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
839 portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
840 portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
841 portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
842
843 for i in range(0, int(numIter)):
844 main.step('Starting wireshark capture for port status down')
845 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400846
jenkins7ead5a82015-03-13 10:28:21 -0700847 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400848
jenkins7ead5a82015-03-13 10:28:21 -0700849 main.step('Disable port: ' + interfaceConfig)
850 main.Mininet1.handle.sendline('sh ifconfig ' +
851 interfaceConfig + ' down')
852 main.Mininet1.handle.expect('mininet>')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400853
jenkins7ead5a82015-03-13 10:28:21 -0700854 time.sleep(3)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400855
jenkins7ead5a82015-03-13 10:28:21 -0700856 main.ONOS1.tsharkStop()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400857
jenkins7ead5a82015-03-13 10:28:21 -0700858 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
859 tsharkPortDown + ' /tmp/')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400860
jenkins7ead5a82015-03-13 10:28:21 -0700861 fPortDown = open(tsharkPortDown, 'r')
862 fLine = fPortDown.readline()
863 objDown = fLine.split(' ')
864 if len(fLine) > 0:
865 timestampBeginPtDown = int(float(objDown[1]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400866 # At times, tshark reports timestamp at the 3rd
867 # index of the array. If initial readings were
868 # unlike the epoch timestamp, then check the 3rd
869 # index and set that as a timestamp
jenkins7ead5a82015-03-13 10:28:21 -0700870 if timestampBeginPtDown < 1400000000000:
871 timestampBeginPtDown = int(float(objDown[2]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400872 # If there are any suspicion of invalid results
873 # check this reported value
jenkins7ead5a82015-03-13 10:28:21 -0700874 main.log.info('Port down begin timestamp: ' +
875 str(timestampBeginPtDown))
876 else:
877 main.log.info('Tshark output file returned unexpected' +
878 ' results: ' + str(objDown))
879 timestampBeginPtDown = 0
880 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700881
jenkins8ba10ab2015-03-24 10:31:31 -0700882 for node in range(0, clusterCount):
883 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400884 metricsDown = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700885 jsonStrDown = metricsDown()
886 jsonObj = json.loads(jsonStrDown)
887
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400888 if jsonObj:
889 graphTimestamp = jsonObj[graphTimestampKey]['value']
890 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
891 linkTimestamp = jsonObj[linkTimestampKey]['value']
892 else:
893 main.log.error( "Unexpected json object" )
894 graphTimestamp = 0
895 deviceTimestamp = 0
896 linkTimestamp = 0
897
jenkins8ba10ab2015-03-24 10:31:31 -0700898 ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown)
899 ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown)
900 ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown)
901
902 if ptDownGraphToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400903 ptDownGraphToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700904 portDownGraphNodeIter[node][i] = ptDownGraphToOfp
905 main.log.info("ONOS "+str(nodeNum)+
906 " port down graph-to-ofp: "+
907 str(ptDownGraphToOfp) + " ms")
908 else:
909 main.log.info("ONOS "+str(nodeNum)+
910 " port down graph-to-ofp ignored"+
911 " due to excess in threshold or premature iteration")
912
913 if ptDownDeviceToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400914 ptDownDeviceToOfp < downThresholdMax and i >= iterIgnore:
915 portDownDevNodeIter[node][i] = ptDownDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -0700916 main.log.info("ONOS "+str(nodeNum)+
917 " port down device-to-ofp: "+
918 str(ptDownDeviceToOfp) + " ms")
919 else:
920 main.log.info("ONOS "+str(nodeNum)+
921 " port down device-to-ofp ignored"+
922 " due to excess in threshold or premature iteration")
923
924 if ptDownLinkToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400925 ptDownLinkToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700926 portDownLinkNodeIter[node][i] = ptDownLinkToOfp
927 main.log.info("ONOS "+str(nodeNum)+
928 " port down link-to-ofp: "+
929 str(ptDownLinkToOfp) + " ms")
930 else:
931 main.log.info("ONOS "+str(nodeNum)+
932 " port down link-to-ofp ignored"+
933 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700934
jenkins7ead5a82015-03-13 10:28:21 -0700935 time.sleep(3)
936
937 main.step('Starting wireshark capture for port status up')
938 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
939
940 time.sleep(5)
941 main.step('Enable port and obtain timestamp')
942 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
943 main.Mininet1.handle.expect('mininet>')
944
945 time.sleep(5)
946 main.ONOS1.tsharkStop()
947
948 time.sleep(3)
949 os.system('scp ' + ONOSUser + '@' +
950 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
951
952 fPortUp = open(tsharkPortUp, 'r')
953 fLine = fPortUp.readline()
954 objUp = fLine.split(' ')
955 if len(fLine) > 0:
956 timestampBeginPtUp = int(float(objUp[1]) * 1000)
957 if timestampBeginPtUp < 1400000000000:
958 timestampBeginPtUp = int(float(objUp[2]) * 1000)
959 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
960 else:
961 main.log.info('Tshark output file returned unexpected' + ' results.')
962 timestampBeginPtUp = 0
963 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700964
965 for node in range(0, clusterCount):
966 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400967 metricsUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700968 jsonStrUp = metricsUp()
969 jsonObj = json.loads(jsonStrUp)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400970
971 if jsonObj:
972 graphTimestamp = jsonObj[graphTimestampKey]['value']
973 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
974 linkTimestamp = jsonObj[linkTimestampKey]['value']
975 else:
976 main.log.error( "Unexpected json object" )
977 graphTimestamp = 0
978 deviceTimestamp = 0
979 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700980
jenkins8ba10ab2015-03-24 10:31:31 -0700981 ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp)
982 ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp)
983 ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp)
984
985 if ptUpGraphToOfp > upThresholdMin and\
986 ptUpGraphToOfp < upThresholdMax and i > iterIgnore:
987 portUpGraphNodeIter[node][i] = ptUpGraphToOfp
988 main.log.info("ONOS "+str(nodeNum)+
989 " port up graph-to-ofp: "+
990 str(ptUpGraphToOfp) + " ms")
991 else:
992 main.log.info("ONOS "+str(nodeNum)+
993 " port up graph-to-ofp ignored"+
994 " due to excess in threshold or premature iteration")
995
996 if ptUpDeviceToOfp > upThresholdMin and\
997 ptUpDeviceToOfp < upThresholdMax and i > iterIgnore:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400998 portUpDevNodeIter[node][i] = ptUpDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -0700999 main.log.info("ONOS "+str(nodeNum)+
1000 " port up device-to-ofp: "+
1001 str(ptUpDeviceToOfp) + " ms")
1002 else:
1003 main.log.info("ONOS "+str(nodeNum)+
1004 " port up device-to-ofp ignored"+
1005 " due to excess in threshold or premature iteration")
1006
1007 if ptUpLinkToOfp > upThresholdMin and\
1008 ptUpLinkToOfp < upThresholdMax and i > iterIgnore:
1009 portUpLinkNodeIter[node][i] = ptUpLinkToOfp
1010 main.log.info("ONOS "+str(nodeNum)+
1011 " port up link-to-ofp: "+
1012 str(ptUpLinkToOfp) + " ms")
1013 else:
1014 main.log.info("ONOS "+str(nodeNum)+
1015 " port up link-to-ofp ignored"+
1016 " due to excess in threshold or premature iteration")
1017
jenkins7ead5a82015-03-13 10:28:21 -07001018 dbCmdList = []
1019 for node in range(0, clusterCount):
1020 portUpDevList = []
1021 portUpGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001022 portUpLinkList = []
jenkins7ead5a82015-03-13 10:28:21 -07001023 portDownDevList = []
1024 portDownGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001025 portDownLinkList = []
1026
jenkins7ead5a82015-03-13 10:28:21 -07001027 portUpDevAvg = 0
1028 portUpGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001029 portUpLinkAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -07001030 portDownDevAvg = 0
1031 portDownGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001032 portDownLinkAvg = 0
1033
jenkins7ead5a82015-03-13 10:28:21 -07001034 for item in portUpDevNodeIter[node]:
1035 if item > 0.0:
1036 portUpDevList.append(item)
1037
1038 for item in portUpGraphNodeIter[node]:
1039 if item > 0.0:
1040 portUpGraphList.append(item)
1041
jenkins8ba10ab2015-03-24 10:31:31 -07001042 for item in portUpLinkNodeIter[node]:
1043 if item > 0.0:
1044 portUpLinkList.append(item)
1045
jenkins7ead5a82015-03-13 10:28:21 -07001046 for item in portDownDevNodeIter[node]:
1047 if item > 0.0:
1048 portDownDevList.append(item)
1049
1050 for item in portDownGraphNodeIter[node]:
1051 if item > 0.0:
1052 portDownGraphList.append(item)
1053
jenkins8ba10ab2015-03-24 10:31:31 -07001054 for item in portDownLinkNodeIter[node]:
1055 if item > 0.0:
1056 portDownLinkList.append(item)
1057
jenkins7ead5a82015-03-13 10:28:21 -07001058 portUpDevAvg = round(numpy.mean(portUpDevList), 2)
1059 portUpGraphAvg = round(numpy.mean(portUpGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001060 portUpLinkAvg = round(numpy.mean(portUpLinkList), 2)
1061
jenkins7ead5a82015-03-13 10:28:21 -07001062 portDownDevAvg = round(numpy.mean(portDownDevList), 2)
1063 portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001064 portDownLinkAvg = round(numpy.mean(portDownLinkList), 2)
1065
jenkins7ead5a82015-03-13 10:28:21 -07001066 portUpStdDev = round(numpy.std(portUpGraphList), 2)
1067 portDownStdDev = round(numpy.std(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001068
jenkins7ead5a82015-03-13 10:28:21 -07001069 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
1070 main.log.report(' Port up ofp-to-device ' +
jenkins8ba10ab2015-03-24 10:31:31 -07001071 str(portUpDevAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001072 main.log.report(' Port up ofp-to-graph ' +
1073 str(portUpGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001074 main.log.report(' Port up ofp-to-link ' +
1075 str(portUpLinkAvg) + ' ms')
1076
jenkins7ead5a82015-03-13 10:28:21 -07001077 main.log.report(' Port down ofp-to-device ' +
1078 str(round(portDownDevAvg, 2)) + ' ms')
1079 main.log.report(' Port down ofp-to-graph ' +
1080 str(portDownGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001081 main.log.report(' Port down ofp-to-link ' +
1082 str(portDownLinkAvg) + ' ms')
1083
jenkins7ead5a82015-03-13 10:28:21 -07001084 dbCmdList.append("INSERT INTO port_latency_tests VALUES('" +
andrew@onlab.us09a4a0c2015-04-09 13:38:13 -04001085 timeToPost + "','port_latency_results'," + jenkinsBuildNumber +
jenkins7ead5a82015-03-13 10:28:21 -07001086 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
1087 "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) +
1088 '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');')
1089
1090 fResult = open(resultPath, 'a')
1091 for line in dbCmdList:
1092 if line:
1093 fResult.write(line + '\n')
1094
1095 fResult.close()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001096
1097 # Delete switches from controller to prepare for next
1098 # set of tests
jenkins7ead5a82015-03-13 10:28:21 -07001099 main.Mininet1.deleteSwController('s1')
1100 main.Mininet1.deleteSwController('s2')
1101 utilities.assert_equals(expect=main.TRUE,
1102 actual=assertion,
1103 onpass='Port discovery latency calculation successful',
1104 onfail='Port discovery test failed')
1105
1106 def CASE4(self, main):
1107 """
1108 Increase number of nodes and initiate CLI
1109
1110 With the most recent implementation, we need a method to
1111 ensure all ONOS nodes are killed, as well as redefine
1112 the cell files to ensure all nodes that will be used
1113 is in the cell file. Otherwise, exceptions will
1114 prohibit test from running successfully.
1115
1116 3/12/15
1117
1118 """
1119 global clusterCount
1120 import time
1121 import os
1122
1123 clusterCount += 2
1124
1125 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1126 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1127 cellName = main.params[ 'ENV' ][ 'cellName' ]
1128 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1129
1130 main.log.report('Increasing cluster size to ' + str(clusterCount))
1131
1132 main.log.step( "Killing all ONOS processes before scale-out" )
1133
1134 for i in range( 1, 8 ):
1135 main.ONOSbench.onosDie(
1136 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1137 main.ONOSbench.onosUninstall(
1138 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1139
1140 main.step( "Creating scale-out cell file" )
1141 cellIp = []
1142 for node in range( 1, clusterCount + 1 ):
1143 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1144
1145 main.log.info( "Cell Ip list: " + str(cellIp) )
1146 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1147 str(features), *cellIp )
1148
1149 main.step( "Setting cell definition" )
1150 main.ONOSbench.setCell(cellName)
1151
1152 main.step( "Packaging cell definition" )
1153 main.ONOSbench.onosPackage()
1154
jenkins7ead5a82015-03-13 10:28:21 -07001155 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001156 main.ONOSbench.onosInstall(
1157 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1158
1159 time.sleep( 20 )
1160
jenkins7ead5a82015-03-13 10:28:21 -07001161 for node in range( 1, clusterCount + 1):
1162 for i in range( 2 ):
1163 isup = main.ONOSbench.isup(
1164 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1165 if isup:
1166 main.log.info( "ONOS "+str(node) + " is up\n")
1167 break
1168 if not isup:
1169 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001170
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001171 for node in range( 0, clusterCount ):
1172 CLIs[node].startOnosCli( cellIp[node] )
1173
1174 main.step( 'Setting configurations for metrics' )
1175 configParam = 'maxEvents 1'
1176 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1177 configParam = 'maxBatchMs 0'
1178 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1179 configParam = 'maxIdleMs 0'
1180 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1181
1182 main.step( 'Activating essential applications' )
1183 CLIs[0].activateApp( 'org.onosproject.metrics' )
1184 CLIs[0].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001185