blob: e73c588fa47e4554bb16cf6b78eb57aba620ee67 [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.us0f468c42015-04-02 17:05:47 -040020
jenkins7ead5a82015-03-13 10:28:21 -070021 import time
22 clusterCount = 1
23 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
24 runNum = time.strftime('%d%H%M%S')
25 cellName = main.params['ENV']['cellName']
26 gitPull = main.params['GIT']['autoPull']
27 checkoutBranch = main.params['GIT']['checkout']
andrew@onlab.us0f468c42015-04-02 17:05:47 -040028
29 global CLIs
30 CLIs = []
31 global nodes
32 nodes = []
33 global nodeIpList
34 nodeIpList = []
35 for i in range( 1, 8 ):
36 CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) )
37 nodes.append( getattr( main, 'ONOS' + str( i ) ) )
38 nodeIpList.append( main.params[ 'CTRL' ][ 'ip'+str(i) ] )
39
jenkins7ead5a82015-03-13 10:28:21 -070040 MN1Ip = main.params['MN']['ip1']
41 BENCHIp = main.params['BENCH']['ip']
andrew@onlab.us0f468c42015-04-02 17:05:47 -040042 cellFeatures = main.params['ENV']['cellFeatures']
jenkins7ead5a82015-03-13 10:28:21 -070043 topoCfgFile = main.params['TEST']['topoConfigFile']
44 topoCfgName = main.params['TEST']['topoConfigName']
45 portEventResultPath = main.params['DB']['portEventResultPath']
46 switchEventResultPath = main.params['DB']['switchEventResultPath']
47 mvnCleanInstall = main.params['TEST']['mci']
48
49 main.case('Setting up test environment')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040050
51 # NOTE: Below is deprecated after new way to install features
52 #main.log.info('Copying topology event accumulator config' +
53 # ' to ONOS /package/etc')
54 #main.ONOSbench.handle.sendline('cp ~/' +
55 # topoCfgFile + ' ~/ONOS/tools/package/etc/' +
56 # topoCfgName)
57 #main.ONOSbench.handle.expect('\\$')
jenkins7ead5a82015-03-13 10:28:21 -070058
59 main.log.report('Setting up test environment')
60
61 main.step('Starting mininet topology ')
62 main.Mininet1.startNet()
63
64 main.step('Cleaning previously installed ONOS if any')
andrew@onlab.us0f468c42015-04-02 17:05:47 -040065 # Nodes 2 ~ 7
66 for i in range( 1, 7 ):
67 main.ONOSbench.onosUninstall(nodeIp=nodeIpList[i])
jenkins7ead5a82015-03-13 10:28:21 -070068
69 main.step('Clearing previous DB log file')
70
71 fPortLog = open(portEventResultPath, 'w')
72 fPortLog.write('')
73 fPortLog.close()
74 fSwitchLog = open(switchEventResultPath, 'w')
75 fSwitchLog.write('')
76 fSwitchLog.close()
77
jenkins7ead5a82015-03-13 10:28:21 -070078 main.step('Creating cell file')
79 cellFileResult = main.ONOSbench.createCellFile(
andrew@onlab.us0f468c42015-04-02 17:05:47 -040080 BENCHIp, cellName, MN1Ip, cellFeatures, nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -070081
82 main.step('Applying cell file to environment')
83 cellApplyResult = main.ONOSbench.setCell(cellName)
84 verifyCellResult = main.ONOSbench.verifyCell()
85
86 main.step('Git checkout and pull ' + checkoutBranch)
87 if gitPull == 'on':
88 checkoutResult = main.TRUE
89 pullResult = main.ONOSbench.gitPull()
90 else:
91 checkoutResult = main.TRUE
92 pullResult = main.TRUE
93 main.log.info('Skipped git checkout and pull')
94
95 main.log.report('Commit information - ')
96 main.ONOSbench.getVersion(report=True)
97 main.step('Using mvn clean & install')
98 if mvnCleanInstall == 'on':
99 mvnResult = main.ONOSbench.cleanInstall()
100 elif mvnCleanInstall == 'off':
101 main.log.info('mci turned off by settings')
102 mvnResult = main.TRUE
103 main.step('Set cell for ONOS cli env')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400104 CLIs[0].setCell(cellName)
jenkins7ead5a82015-03-13 10:28:21 -0700105
106 main.step('Creating ONOS package')
107 packageResult = main.ONOSbench.onosPackage()
108
109 main.step('Installing ONOS package')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400110 install1Result = main.ONOSbench.onosInstall(node=nodeIpList[0])
jenkins7ead5a82015-03-13 10:28:21 -0700111
112 time.sleep(10)
113
114 main.step('Start onos cli')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400115 cli1 = CLIs[0].startOnosCli(nodeIpList[0])
116
117 main.step( 'activating essential applications' )
118 CLIs[0].activateApp( 'org.onosproject.metrics' )
119 CLIs[0].activateApp( 'org.onosproject.openflow' )
120
121 main.step( 'Configuring application parameters' )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400122
123 configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider'
124 configParam = 'maxEvents 1'
125 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
126 configParam = 'maxBatchMs 0'
127 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
128 configParam = 'maxIdleMs 0'
129 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
130
jenkins7ead5a82015-03-13 10:28:21 -0700131 utilities.assert_equals(expect=main.TRUE,
132 actual=cellFileResult and cellApplyResult and\
133 verifyCellResult and checkoutResult and\
134 pullResult and mvnResult and\
135 install1Result,
136 onpass='Test Environment setup successful',
137 onfail='Failed to setup test environment')
138
139 def CASE2(self, main):
140 """
141 Assign s1 to ONOS1 and measure latency
142
143 There are 4 levels of latency measurements to this test:
144 1 ) End-to-end measurement: Complete end-to-end measurement
145 from TCP ( SYN/ACK ) handshake to Graph change
146 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
147 measurement from OFP Vendor message to Graph change
148 3 ) OFP-to-device measurement: 'ONOS processing without
149 graph change' snippet of measurement from OFP vendor
150 message to Device change timestamp
151 4 ) T0-to-device measurement: Measurement that includes
152 the switch handshake to devices timestamp without
153 the graph view change. ( TCP handshake -> Device
154 change )
155 """
156 import time
157 import subprocess
158 import json
159 import requests
160 import os
161 import numpy
162
jenkins7ead5a82015-03-13 10:28:21 -0700163 ONOSUser = main.params['CTRL']['user']
164 defaultSwPort = main.params['CTRL']['port1']
165 numIter = main.params['TEST']['numIter']
166 iterIgnore = int(main.params['TEST']['iterIgnore'])
jenkins8ba10ab2015-03-24 10:31:31 -0700167
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400168 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
169 graphTimestampKey = main.params['JSON']['graphTimestamp']
jenkins8ba10ab2015-03-24 10:31:31 -0700170
jenkins7ead5a82015-03-13 10:28:21 -0700171 debugMode = main.params['TEST']['debugMode']
172 onosLog = main.params['TEST']['onosLogFile']
173 resultPath = main.params['DB']['switchEventResultPath']
174 thresholdStr = main.params['TEST']['singleSwThreshold']
175 thresholdObj = thresholdStr.split(',')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400176 thresholdMin = float(thresholdObj[0])
177 thresholdMax = float(thresholdObj[1])
jenkins7ead5a82015-03-13 10:28:21 -0700178
jenkins8ba10ab2015-03-24 10:31:31 -0700179 # Look for 'role-request' messages,
180 # which replaces the 'vendor' messages previously seen
181 # on OVS 2.0.1
jenkins7ead5a82015-03-13 10:28:21 -0700182 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700183 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
184 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
185 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400186 tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700187
jenkins7ead5a82015-03-13 10:28:21 -0700188 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
189 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
jenkins8ba10ab2015-03-24 10:31:31 -0700190 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
191 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400192 tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
193
194 # Switch connect measurement list
195 # TCP Syn/Ack -> Feature Reply latency collection for each node
196 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
197 # Feature Reply -> Role Request latency collection for each node
198 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
199 int(numIter)))
200 # Role Request -> Role Reply latency collection for each node
201 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
202 int(numIter)))
203 # Role Reply -> Device Update latency collection for each node
204 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
205 int(numIter)))
206 # Device Update -> Graph Update latency collection for each node
207 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
208 int(numIter)))
209
210 # Switch disconnect measurement lists
211 # Mininet Fin / Ack -> Mininet Ack
212 finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
213 int(numIter)))
214 # Mininet Ack -> Device Event
215 ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
216 int(numIter)))
217 # Device event -> Graph event
218 deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
219 int(numIter)))
jenkins7ead5a82015-03-13 10:28:21 -0700220
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400221 # TCP Syn/Ack -> Feature Reply latency collection for each node
222 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
223 # Feature Reply -> Role Request latency collection for each node
224 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
225 int(numIter)))
226 # Role Request -> Role Reply latency collection for each node
227 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
228 int(numIter)))
229 # Role Reply -> Device Update latency collection for each node
230 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
231 int(numIter)))
232 # Device Update -> Graph Update latency collection for each node
233 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
234 int(numIter)))
235
236
jenkins7ead5a82015-03-13 10:28:21 -0700237 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
238 ofpToGraphLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
239 ofpToDeviceLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
240
241 tcpToOfpLatIter = []
jenkins8ba10ab2015-03-24 10:31:31 -0700242 tcpToFeatureLatIter = []
243 tcpToRoleLatIter = []
jenkins7ead5a82015-03-13 10:28:21 -0700244 assertion = main.TRUE
245 localTime = time.strftime('%x %X')
246 localTime = localTime.replace('/', '')
247 localTime = localTime.replace(' ', '_')
248 localTime = localTime.replace(':', '')
249
250 if debugMode == 'on':
251 main.ONOS1.tsharkPcap('eth0',
252 '/tmp/single_sw_lat_pcap_' + localTime)
253 main.log.info('Debug mode is on')
254 main.log.report('Latency of adding one switch to controller')
255 main.log.report('First ' + str(iterIgnore) +
256 ' iterations ignored' + ' for jvm warmup time')
257 main.log.report('Total iterations of test: ' + str(numIter))
258
259 for i in range(0, int(numIter)):
260 main.log.info('Starting tshark capture')
261 main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
262 main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput)
jenkins8ba10ab2015-03-24 10:31:31 -0700263 main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
264 main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
265
jenkins7ead5a82015-03-13 10:28:21 -0700266 time.sleep(10)
267
268 main.log.info('Assigning s3 to controller')
269 main.Mininet1.assignSwController(sw='3',
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400270 ip1=nodeIpList[0], port1=defaultSwPort)
jenkins7ead5a82015-03-13 10:28:21 -0700271
272 time.sleep(10)
273
274 main.log.info('Stopping all Tshark processes')
275 main.ONOS1.tsharkStop()
276
277 main.log.info('Copying over tshark files')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400278 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins7ead5a82015-03-13 10:28:21 -0700279 ':' + tsharkTcpOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400280 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700281 ':' + tsharkRoleOutput + ' /tmp/')
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400282 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
jenkins8ba10ab2015-03-24 10:31:31 -0700283 ':' + tsharkFeatureOutput + ' /tmp/')
284 os.system('scp ' + ONOSUser + '@' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400285 nodeIpList[0] + ':' + tsharkOfOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700286
287 # Get tcp syn / ack output
jenkins7ead5a82015-03-13 10:28:21 -0700288 time.sleep(5)
289 tcpFile = open(tsharkTcpOutput, 'r')
290 tempText = tcpFile.readline()
291 tempText = tempText.split(' ')
292 main.log.info('Object read in from TCP capture: ' +
293 str(tempText))
294
295 if len(tempText) > 1:
296 t0Tcp = float(tempText[1]) * 1000.0
297 else:
298 main.log.error('Tshark output file for TCP' +
299 ' returned unexpected results')
300 t0Tcp = 0
301 assertion = main.FALSE
302 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700303
304 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700305 time.sleep(5)
306 ofFile = open(tsharkOfOutput, 'r')
307 lineOfp = ''
308 while True:
309 tempText = ofFile.readline()
310 if tempText != '':
311 lineOfp = tempText
312 else:
313 break
jenkins7ead5a82015-03-13 10:28:21 -0700314 obj = lineOfp.split(' ')
315 main.log.info('Object read in from OFP capture: ' +
316 str(lineOfp))
317 if len(obj) > 1:
318 t0Ofp = float(obj[1]) * 1000.0
319 else:
320 main.log.error('Tshark output file for OFP' +
321 ' returned unexpected results')
322 t0Ofp = 0
323 assertion = main.FALSE
324 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700325
326 # Get role request output
327 roleFile = open(tsharkRoleOutput, 'r')
328 tempText = roleFile.readline()
329 tempText = tempText.split(' ')
330 if len(tempText) > 1:
331 main.log.info('Object read in from role request capture:' +
332 str(tempText))
333 roleTimestamp = float(tempText[1]) * 1000.0
334 else:
335 main.log.error('Tshark output file for role request' +
336 ' returned unexpected results')
337 timeRoleRequest = 0
338 assertion = main.FALSE
339 roleFile.close()
340
341 # Get feature reply output
342 featureFile = open(tsharkFeatureOutput, 'r')
343 tempText = featureFile.readline()
344 tempText = tempText.split(' ')
345 if len(tempText) > 1:
346 main.log.info('Object read in from feature reply capture: '+
347 str(tempText))
348 featureTimestamp = float(tempText[1]) * 1000.0
349 else:
350 main.log.error('Tshark output file for feature reply' +
351 ' returned unexpected results')
352 timeFeatureReply = 0
353 assertion = main.FALSE
354 featureFile.close()
355
356 # TODO: calculate feature reply, role request times
357 # stack measurements correctly and report
358
jenkins8ba10ab2015-03-24 10:31:31 -0700359 #TODO: Refactor in progress
360
361 for node in range(0, clusterCount):
362 nodeNum = node+1
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400363 metricsSwUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700364 jsonStr = metricsSwUp()
365 jsonObj = json.loads(jsonStr)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400366 if jsonObj:
367 graphTimestamp = jsonObj[graphTimestampKey]['value']
368 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
jenkins8ba10ab2015-03-24 10:31:31 -0700369 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400370 main.log.error( "Unexpected JSON object" )
371 # If we could not obtain the JSON object,
372 # set the timestamps to 0, which will be
373 # excluded from the measurement later on
374 # (realized as invalid)
375 graphTimestamp = 0
376 deviceTimestamp = 0
377
378 endToEnd = int(graphTimestamp) - int(t0Tcp)
379
380 # Below are measurement breakdowns of the end-to-end
381 # measurement.
382 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
383 featureToRole = int(roleTimestamp) - int(featureTimestamp)
384 roleToOfp = int(t0Ofp) - int(roleTimestamp)
385 ofpToDevice = int(deviceTimestamp) - int(t0Ofp)
386 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
387
388 if endToEnd > thresholdMin and\
389 endToEnd < thresholdMax and i >= iterIgnore:
390 endToEndLatNodeIter[node][i] = endToEnd
391 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
392 str(endToEnd) + " ms")
393 else:
394 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
jenkins8ba10ab2015-03-24 10:31:31 -0700395 "measurement ignored due to excess in "+
396 "threshold or premature iteration")
397
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400398 if tcpToFeature > thresholdMin and\
399 tcpToFeature < thresholdMax and i >= iterIgnore:
400 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
401 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
402 str(tcpToFeature) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700403 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400404 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
jenkins8ba10ab2015-03-24 10:31:31 -0700405 "measurement ignored due to excess in "+
406 "threshold or premature iteration")
407
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400408 if featureToRole > thresholdMin and\
409 featureToRole < thresholdMax and i >= iterIgnore:
410 featureToRoleRequestLatNodeIter[node][i] = featureToRole
411 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
412 str(featureToRole) + " ms")
jenkins8ba10ab2015-03-24 10:31:31 -0700413 else:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400414 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
jenkins8ba10ab2015-03-24 10:31:31 -0700415 "measurement ignored due to excess in "+
416 "threshold or premature iteration")
417
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400418 if roleToOfp > thresholdMin and\
419 roleToOfp < thresholdMax and i >= iterIgnore:
420 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
421 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
422 str(roleToOfp) + " ms")
423 else:
424 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
425 "measurement ignored due to excess in "+
426 "threshold or premature iteration")
427
428 if ofpToDevice > thresholdMin and\
429 ofpToDevice < thresholdMax and i >= iterIgnore:
430 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
431 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
432 str(ofpToDevice) + " ms")
433 else:
434 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
435 "measurement ignored due to excess in "+
436 "threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700437
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400438 if deviceToGraph > thresholdMin and\
439 deviceToGraph < thresholdMax and i >= iterIgnore:
440 deviceToGraphLatNodeIter[node][i] = deviceToGraph
441 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
442 str(deviceToGraph) + " ms")
443 else:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400444 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph "+
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400445 "measurement ignored due to excess in "+
446 "threshold or premature iteration")
447
jenkins8ba10ab2015-03-24 10:31:31 -0700448 # ********************
jenkins7ead5a82015-03-13 10:28:21 -0700449 time.sleep(5)
450
451 # Get device id to remove
452 deviceIdJsonStr = main.ONOS1cli.devices()
453
454 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
455 deviceId = json.loads(deviceIdJsonStr)
456
457 deviceList = []
458 for device in deviceId:
459 deviceList.append(device['id'])
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400460
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400461 # Measure switch down metrics
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400462 # TCP FIN/ACK -> TCP FIN
463 # TCP FIN -> Device Event
464 # Device Event -> Graph Event
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400465 # Capture switch down FIN / ACK packets
466
467 main.ONOS1.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
468 grepOptions = '-A 1' )
469
470 time.sleep( 5 )
471
472 removeJsonList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400473
jenkins7ead5a82015-03-13 10:28:21 -0700474 main.step('Remove switch from controller')
475 main.Mininet1.deleteSwController('s3')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400476 firstDevice = deviceList[0]
jenkins7ead5a82015-03-13 10:28:21 -0700477 main.log.info( "Removing device " +str(firstDevice)+
478 " from ONOS" )
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400479
480 time.sleep( 5 )
481
482 # We need to get metrics before removing
483 # device from the store below.
484 for node in range(0, clusterCount):
485 metricsSwDown = CLIs[node].topologyEventsMetrics
486 jsonStr = metricsSwDown()
487 removeJsonList.append( json.loads(jsonStr) )
488
jenkins7ead5a82015-03-13 10:28:21 -0700489 #if deviceId:
490 main.ONOS1cli.deviceRemove(firstDevice)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400491
492 main.ONOS1.tsharkStop()
493
494 main.log.info('Copying over tshark files')
495 os.system('scp ' + ONOSUser + '@' + nodeIpList[0] +
496 ':' + tsharkFinAckOutput + ' /tmp/')
497
498 time.sleep( 10 )
499 finAckOutputList = []
500 with open(tsharkFinAckOutput, 'r') as f:
501 tempLine = f.readlines()
502 main.log.info('Object read in from FinAck capture: ' +
503 str(tempLine))
504
505 index = 1
506 for line in tempLine:
507 obj = line.split(' ')
jenkins7ead5a82015-03-13 10:28:21 -0700508
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400509 if len(obj) > 1:
510 if index == 1:
511 tFinAck = float(obj[1]) * 1000.0
512 elif index == 3:
513 tAck = float(obj[1]) * 1000.0
514 else:
515 main.log.error('Tshark output file for OFP' +
516 ' returned unexpected results')
517 tFinAck = 0
518 tAck = 0
519 assertion = main.FALSE
520
521 index = index+1
522
523 # with open() as f takes care of closing file
524
jenkins7ead5a82015-03-13 10:28:21 -0700525 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400526
527 for node in range(0, clusterCount):
528 nodeNum = node+1
529 jsonObj = removeJsonList[node]
530 if jsonObj:
531 graphTimestamp = jsonObj[graphTimestampKey]['value']
532 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
533 main.log.info("Graph timestamp: "+str(graphTimestamp))
534 main.log.info("Device timestamp: "+str(deviceTimestamp))
535 else:
536 main.log.error( "Unexpected JSON object" )
537 # If we could not obtain the JSON object,
538 # set the timestamps to 0, which will be
539 # excluded from the measurement later on
540 # (realized as invalid)
541 graphTimestamp = 0
542 deviceTimestamp = 0
543
544 finAckTransaction = int(tAck) - int(tFinAck)
545 ackToDevice = int(deviceTimestamp) - int(tAck)
546 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
547
548 if finAckTransaction > thresholdMin and\
549 finAckTransaction < thresholdMax and i >= iterIgnore:
550 finAckTransactionLatNodeIter[node][i] = finAckTransaction
551 main.log.info("ONOS "+str(nodeNum)+
552 " fin/ack transaction: "+
553 str(finAckTransaction) + " ms")
554 else:
555 main.log.info("ONOS "+str(nodeNum)+
556 " fin/ack transaction "+
557 "measurement ignored due to excess in "+
558 "threshold or premature iteration")
559
560 if ackToDevice > thresholdMin and\
561 ackToDevice < thresholdMax and i >= iterIgnore:
562 ackToDeviceLatNodeIter[node][i] = ackToDevice
563 main.log.info("ONOS "+str(nodeNum)+
564 " ack-to-device: "+
565 str(ackToDevice) + " ms")
566 else:
567 main.log.info("ONOS "+str(nodeNum)+
568 " ack-to-device "+
569 "measurement ignored due to excess in "+
570 "threshold or premature iteration")
571
572 if deviceToGraph > thresholdMin and\
573 deviceToGraph < thresholdMax and i >= iterIgnore:
574 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
575 main.log.info("ONOS "+str(nodeNum)+
576 " device-to-graph disconnect: "+
577 str(deviceToGraph) + " ms")
578 else:
579 main.log.info("ONOS "+str(nodeNum)+
580 " device-to-graph disconnect "+
581 "measurement ignored due to excess in "+
582 "threshold or premature iteration")
jenkins7ead5a82015-03-13 10:28:21 -0700583
584 endToEndAvg = 0
585 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700586 dbCmdList = []
587 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700588 # List of latency for each node
589 endToEndList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400590
jenkins8ba10ab2015-03-24 10:31:31 -0700591 tcpToFeatureList = []
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400592 featureToRoleList = []
593 roleToOfpList = []
594 ofpToDeviceList = []
595 deviceToGraphList = []
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400596
597 finAckTransactionList = []
598 ackToDeviceList = []
599 deviceToGraphDiscList = []
jenkins8ba10ab2015-03-24 10:31:31 -0700600
601 # LatNodeIter 2d arrays contain all iteration latency
602 # for each node of the current scale cluster size
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400603 # Switch connection measurements
604 # Set further acceptance criteria for measurements
605 # here if you would like to filter reporting results
jenkins7ead5a82015-03-13 10:28:21 -0700606 for item in endToEndLatNodeIter[node]:
607 if item > 0.0:
608 endToEndList.append(item)
609
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400610 for item in tcpToFeatureLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700611 if item > 0.0:
612 tcpToFeatureList.append(item)
613
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400614 for item in featureToRoleRequestLatNodeIter[node]:
jenkins8ba10ab2015-03-24 10:31:31 -0700615 if item > 0.0:
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400616 featureToRoleList.append(item)
617
618 for item in roleRequestToRoleReplyLatNodeIter[node]:
619 if item > 0.0:
620 roleToOfpList.append(item)
621
622 for item in roleReplyToDeviceLatNodeIter[node]:
623 if item > 0.0:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400624 tcpToFeatureList.append(item)
625
626 for item in featureToRoleRequestLatNodeIter[node]:
627 if item > 0.0:
628 featureToRoleList.append(item)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400629
630 for item in deviceToGraphLatNodeIter[node]:
631 if item > 0.0:
632 deviceToGraphList.append(item)
jenkins8ba10ab2015-03-24 10:31:31 -0700633
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400634 # Switch disconnect measurements
635 for item in finAckTransactionLatNodeIter[node]:
636 if item > 0.0:
637 finAckTransactionList.append(item)
638
639 for item in ackToDeviceLatNodeIter[node]:
640 if item > 0.0:
641 ackToDeviceList.append(item)
642
643 for item in deviceToGraphDiscLatNodeIter[node]:
644 if item > 0.0:
645 deviceToGraphDiscList.append(item)
646
jenkins7ead5a82015-03-13 10:28:21 -0700647 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400648 endToEndStdDev = round(numpy.std(endToEndList), 2)
649
jenkins8ba10ab2015-03-24 10:31:31 -0700650 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400651 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
652
653 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
654 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
655
656 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
657 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
658
jenkins7ead5a82015-03-13 10:28:21 -0700659 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400660 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
661
662 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
663 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
664
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400665 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
666 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
667
668 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
669 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
670
671 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
672 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
673
jenkins7ead5a82015-03-13 10:28:21 -0700674 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400675 main.log.report(' - Switch Connection Statistics - ')
676
jenkins7ead5a82015-03-13 10:28:21 -0700677 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
678 ' ms' + ' End-to-end Std dev: ' +
andrew@onlab.us0f468c42015-04-02 17:05:47 -0400679 str(endToEndStdDev) + ' ms')
680
681 main.log.report(' Tcp-to-feature-reply Avg: ' +
682 str(tcpToFeatureAvg) + ' ms')
683 main.log.report(' Tcp-to-feature-reply Std dev: '+
684 str(tcpToFeatureStdDev) + ' ms')
685
686 main.log.report(' Feature-reply-to-role-request Avg: ' +
687 str(featureToRoleAvg) + ' ms')
688 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
689 str(featureToRoleStdDev) + ' ms')
690
691 main.log.report(' Role-request-to-role-reply Avg: ' +
692 str(roleToOfpAvg) +' ms')
693 main.log.report(' Role-request-to-role-reply Std dev: ' +
694 str(roleToOfpStdDev) + ' ms')
695
696 main.log.report(' Role-reply-to-device Avg: ' +
697 str(ofpToDeviceAvg) +' ms')
698 main.log.report(' Role-reply-to-device Std dev: ' +
699 str(ofpToDeviceStdDev) + ' ms')
700
701 main.log.report(' Device-to-graph Avg: ' +
702 str(deviceToGraphAvg) + ' ms')
703 main.log.report( 'Device-to-graph Std dev: ' +
704 str(deviceToGraphStdDev) + ' ms')
705
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400706 main.log.report(' - Switch Disconnection Statistics - ')
707 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
708 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
709 str(finAckStdDev) + ' ms')
710
711 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
712 ' ms')
713 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
714 ' ms')
715
716 main.log.report(' Device-to-graph (disconnect) Avg: ' +
717 str(deviceToGraphDiscAvg) + ' ms')
718 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
719 str(deviceToGraphDiscStdDev) + ' ms')
720
jenkins7ead5a82015-03-13 10:28:21 -0700721 dbCmdList.append(
722 "INSERT INTO switch_latency_tests VALUES('" +
723 timeToPost + "','switch_latency_results'," +
724 runNum + ',' + str(clusterCount) + ",'baremetal" +
725 str(node + 1) + "'," + str(endToEndAvg) + ',' +
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400726 str(endToEndStdDev) + ',0,0);')
jenkins7ead5a82015-03-13 10:28:21 -0700727
728 if debugMode == 'on':
729 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
730 '/tmp/', copyFileName='sw_lat_karaf')
731 fResult = open(resultPath, 'a')
732 for line in dbCmdList:
733 if line:
734 fResult.write(line + '\n')
735
736 fResult.close()
737 assertion = main.TRUE
738 utilities.assert_equals(expect=main.TRUE, actual=assertion,
739 onpass='Switch latency test successful',
740 onfail='Switch latency test failed')
741
742 def CASE3(self, main):
743 """
744 Bring port up / down and measure latency.
745 Port enable / disable is simulated by ifconfig up / down
746
747 In ONOS-next, we must ensure that the port we are
748 manipulating is connected to another switch with a valid
749 connection. Otherwise, graph view will not be updated.
750 """
751 global timeToPost
752 import time
753 import subprocess
754 import os
755 import requests
756 import json
757 import numpy
758 ONOS1Ip = main.params['CTRL']['ip1']
759 ONOS2Ip = main.params['CTRL']['ip2']
760 ONOS3Ip = main.params['CTRL']['ip3']
761 ONOSUser = main.params['CTRL']['user']
762 defaultSwPort = main.params['CTRL']['port1']
763 assertion = main.TRUE
764 numIter = main.params['TEST']['numIter']
765 iterIgnore = int(main.params['TEST']['iterIgnore'])
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400766
767 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
768 graphTimestampKey = main.params['JSON']['graphTimestamp']
769 linkTimestampKey = main.params['JSON']['linkTimestamp']
jenkins7ead5a82015-03-13 10:28:21 -0700770
771 tsharkPortUp = '/tmp/tshark_port_up.txt'
772 tsharkPortDown = '/tmp/tshark_port_down.txt'
773 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
774
775 debugMode = main.params['TEST']['debugMode']
776 postToDB = main.params['DB']['postToDB']
777 resultPath = main.params['DB']['portEventResultPath']
778 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
779 localTime = time.strftime('%x %X')
780 localTime = localTime.replace('/', '')
781 localTime = localTime.replace(' ', '_')
782 localTime = localTime.replace(':', '')
783
784 if debugMode == 'on':
785 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
786
787 upThresholdStr = main.params['TEST']['portUpThreshold']
788 downThresholdStr = main.params['TEST']['portDownThreshold']
789 upThresholdObj = upThresholdStr.split(',')
790 downThresholdObj = downThresholdStr.split(',')
791 upThresholdMin = int(upThresholdObj[0])
792 upThresholdMax = int(upThresholdObj[1])
793 downThresholdMin = int(downThresholdObj[0])
794 downThresholdMax = int(downThresholdObj[1])
795
796 interfaceConfig = 's1-eth1'
797 main.log.report('Port enable / disable latency')
798 main.log.report('Simulated by ifconfig up / down')
799 main.log.report('Total iterations of test: ' + str(numIter))
800 main.step('Assign switches s1 and s2 to controller 1')
801
802 main.Mininet1.assignSwController(sw='1',
803 ip1=ONOS1Ip, port1=defaultSwPort)
804 main.Mininet1.assignSwController(sw='2',
805 ip1=ONOS1Ip, port1=defaultSwPort)
806
807 time.sleep(15)
808
809 portUpDeviceToOfpList = []
810 portUpGraphToOfpList = []
811 portDownDeviceToOfpList = []
812 portDownGraphToOfpList = []
813
814 portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
815 portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
816 portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
817 portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
818 portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
819 portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
820 portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
821
822 for i in range(0, int(numIter)):
823 main.step('Starting wireshark capture for port status down')
824 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400825
jenkins7ead5a82015-03-13 10:28:21 -0700826 time.sleep(5)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400827
jenkins7ead5a82015-03-13 10:28:21 -0700828 main.step('Disable port: ' + interfaceConfig)
829 main.Mininet1.handle.sendline('sh ifconfig ' +
830 interfaceConfig + ' down')
831 main.Mininet1.handle.expect('mininet>')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400832
jenkins7ead5a82015-03-13 10:28:21 -0700833 time.sleep(3)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400834
jenkins7ead5a82015-03-13 10:28:21 -0700835 main.ONOS1.tsharkStop()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400836
jenkins7ead5a82015-03-13 10:28:21 -0700837 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
838 tsharkPortDown + ' /tmp/')
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400839
jenkins7ead5a82015-03-13 10:28:21 -0700840 fPortDown = open(tsharkPortDown, 'r')
841 fLine = fPortDown.readline()
842 objDown = fLine.split(' ')
843 if len(fLine) > 0:
844 timestampBeginPtDown = int(float(objDown[1]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400845 # At times, tshark reports timestamp at the 3rd
846 # index of the array. If initial readings were
847 # unlike the epoch timestamp, then check the 3rd
848 # index and set that as a timestamp
jenkins7ead5a82015-03-13 10:28:21 -0700849 if timestampBeginPtDown < 1400000000000:
850 timestampBeginPtDown = int(float(objDown[2]) * 1000)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400851 # If there are any suspicion of invalid results
852 # check this reported value
jenkins7ead5a82015-03-13 10:28:21 -0700853 main.log.info('Port down begin timestamp: ' +
854 str(timestampBeginPtDown))
855 else:
856 main.log.info('Tshark output file returned unexpected' +
857 ' results: ' + str(objDown))
858 timestampBeginPtDown = 0
859 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700860
jenkins8ba10ab2015-03-24 10:31:31 -0700861 for node in range(0, clusterCount):
862 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400863 metricsDown = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700864 jsonStrDown = metricsDown()
865 jsonObj = json.loads(jsonStrDown)
866
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400867 if jsonObj:
868 graphTimestamp = jsonObj[graphTimestampKey]['value']
869 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
870 linkTimestamp = jsonObj[linkTimestampKey]['value']
871 else:
872 main.log.error( "Unexpected json object" )
873 graphTimestamp = 0
874 deviceTimestamp = 0
875 linkTimestamp = 0
876
jenkins8ba10ab2015-03-24 10:31:31 -0700877 ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown)
878 ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown)
879 ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown)
880
881 if ptDownGraphToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400882 ptDownGraphToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700883 portDownGraphNodeIter[node][i] = ptDownGraphToOfp
884 main.log.info("ONOS "+str(nodeNum)+
885 " port down graph-to-ofp: "+
886 str(ptDownGraphToOfp) + " ms")
887 else:
888 main.log.info("ONOS "+str(nodeNum)+
889 " port down graph-to-ofp ignored"+
890 " due to excess in threshold or premature iteration")
891
892 if ptDownDeviceToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400893 ptDownDeviceToOfp < downThresholdMax and i >= iterIgnore:
894 portDownDevNodeIter[node][i] = ptDownDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -0700895 main.log.info("ONOS "+str(nodeNum)+
896 " port down device-to-ofp: "+
897 str(ptDownDeviceToOfp) + " ms")
898 else:
899 main.log.info("ONOS "+str(nodeNum)+
900 " port down device-to-ofp ignored"+
901 " due to excess in threshold or premature iteration")
902
903 if ptDownLinkToOfp > downThresholdMin and\
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400904 ptDownLinkToOfp < downThresholdMax and i >= iterIgnore:
jenkins8ba10ab2015-03-24 10:31:31 -0700905 portDownLinkNodeIter[node][i] = ptDownLinkToOfp
906 main.log.info("ONOS "+str(nodeNum)+
907 " port down link-to-ofp: "+
908 str(ptDownLinkToOfp) + " ms")
909 else:
910 main.log.info("ONOS "+str(nodeNum)+
911 " port down link-to-ofp ignored"+
912 " due to excess in threshold or premature iteration")
jenkins8ba10ab2015-03-24 10:31:31 -0700913
jenkins7ead5a82015-03-13 10:28:21 -0700914 time.sleep(3)
915
916 main.step('Starting wireshark capture for port status up')
917 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
918
919 time.sleep(5)
920 main.step('Enable port and obtain timestamp')
921 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
922 main.Mininet1.handle.expect('mininet>')
923
924 time.sleep(5)
925 main.ONOS1.tsharkStop()
926
927 time.sleep(3)
928 os.system('scp ' + ONOSUser + '@' +
929 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
930
931 fPortUp = open(tsharkPortUp, 'r')
932 fLine = fPortUp.readline()
933 objUp = fLine.split(' ')
934 if len(fLine) > 0:
935 timestampBeginPtUp = int(float(objUp[1]) * 1000)
936 if timestampBeginPtUp < 1400000000000:
937 timestampBeginPtUp = int(float(objUp[2]) * 1000)
938 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
939 else:
940 main.log.info('Tshark output file returned unexpected' + ' results.')
941 timestampBeginPtUp = 0
942 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700943
944 for node in range(0, clusterCount):
945 nodeNum = node+1
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400946 metricsUp = CLIs[node].topologyEventsMetrics
jenkins8ba10ab2015-03-24 10:31:31 -0700947 jsonStrUp = metricsUp()
948 jsonObj = json.loads(jsonStrUp)
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400949
950 if jsonObj:
951 graphTimestamp = jsonObj[graphTimestampKey]['value']
952 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
953 linkTimestamp = jsonObj[linkTimestampKey]['value']
954 else:
955 main.log.error( "Unexpected json object" )
956 graphTimestamp = 0
957 deviceTimestamp = 0
958 linkTimestamp = 0
jenkins8ba10ab2015-03-24 10:31:31 -0700959
jenkins8ba10ab2015-03-24 10:31:31 -0700960 ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp)
961 ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp)
962 ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp)
963
964 if ptUpGraphToOfp > upThresholdMin and\
965 ptUpGraphToOfp < upThresholdMax and i > iterIgnore:
966 portUpGraphNodeIter[node][i] = ptUpGraphToOfp
967 main.log.info("ONOS "+str(nodeNum)+
968 " port up graph-to-ofp: "+
969 str(ptUpGraphToOfp) + " ms")
970 else:
971 main.log.info("ONOS "+str(nodeNum)+
972 " port up graph-to-ofp ignored"+
973 " due to excess in threshold or premature iteration")
974
975 if ptUpDeviceToOfp > upThresholdMin and\
976 ptUpDeviceToOfp < upThresholdMax and i > iterIgnore:
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -0400977 portUpDevNodeIter[node][i] = ptUpDeviceToOfp
jenkins8ba10ab2015-03-24 10:31:31 -0700978 main.log.info("ONOS "+str(nodeNum)+
979 " port up device-to-ofp: "+
980 str(ptUpDeviceToOfp) + " ms")
981 else:
982 main.log.info("ONOS "+str(nodeNum)+
983 " port up device-to-ofp ignored"+
984 " due to excess in threshold or premature iteration")
985
986 if ptUpLinkToOfp > upThresholdMin and\
987 ptUpLinkToOfp < upThresholdMax and i > iterIgnore:
988 portUpLinkNodeIter[node][i] = ptUpLinkToOfp
989 main.log.info("ONOS "+str(nodeNum)+
990 " port up link-to-ofp: "+
991 str(ptUpLinkToOfp) + " ms")
992 else:
993 main.log.info("ONOS "+str(nodeNum)+
994 " port up link-to-ofp ignored"+
995 " due to excess in threshold or premature iteration")
996
jenkins7ead5a82015-03-13 10:28:21 -0700997 dbCmdList = []
998 for node in range(0, clusterCount):
999 portUpDevList = []
1000 portUpGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001001 portUpLinkList = []
jenkins7ead5a82015-03-13 10:28:21 -07001002 portDownDevList = []
1003 portDownGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001004 portDownLinkList = []
1005
jenkins7ead5a82015-03-13 10:28:21 -07001006 portUpDevAvg = 0
1007 portUpGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001008 portUpLinkAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -07001009 portDownDevAvg = 0
1010 portDownGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001011 portDownLinkAvg = 0
1012
jenkins7ead5a82015-03-13 10:28:21 -07001013 for item in portUpDevNodeIter[node]:
1014 if item > 0.0:
1015 portUpDevList.append(item)
1016
1017 for item in portUpGraphNodeIter[node]:
1018 if item > 0.0:
1019 portUpGraphList.append(item)
1020
jenkins8ba10ab2015-03-24 10:31:31 -07001021 for item in portUpLinkNodeIter[node]:
1022 if item > 0.0:
1023 portUpLinkList.append(item)
1024
jenkins7ead5a82015-03-13 10:28:21 -07001025 for item in portDownDevNodeIter[node]:
1026 if item > 0.0:
1027 portDownDevList.append(item)
1028
1029 for item in portDownGraphNodeIter[node]:
1030 if item > 0.0:
1031 portDownGraphList.append(item)
1032
jenkins8ba10ab2015-03-24 10:31:31 -07001033 for item in portDownLinkNodeIter[node]:
1034 if item > 0.0:
1035 portDownLinkList.append(item)
1036
jenkins7ead5a82015-03-13 10:28:21 -07001037 portUpDevAvg = round(numpy.mean(portUpDevList), 2)
1038 portUpGraphAvg = round(numpy.mean(portUpGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001039 portUpLinkAvg = round(numpy.mean(portUpLinkList), 2)
1040
jenkins7ead5a82015-03-13 10:28:21 -07001041 portDownDevAvg = round(numpy.mean(portDownDevList), 2)
1042 portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001043 portDownLinkAvg = round(numpy.mean(portDownLinkList), 2)
1044
jenkins7ead5a82015-03-13 10:28:21 -07001045 portUpStdDev = round(numpy.std(portUpGraphList), 2)
1046 portDownStdDev = round(numpy.std(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001047
jenkins7ead5a82015-03-13 10:28:21 -07001048 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
1049 main.log.report(' Port up ofp-to-device ' +
jenkins8ba10ab2015-03-24 10:31:31 -07001050 str(portUpDevAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001051 main.log.report(' Port up ofp-to-graph ' +
1052 str(portUpGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001053 main.log.report(' Port up ofp-to-link ' +
1054 str(portUpLinkAvg) + ' ms')
1055
jenkins7ead5a82015-03-13 10:28:21 -07001056 main.log.report(' Port down ofp-to-device ' +
1057 str(round(portDownDevAvg, 2)) + ' ms')
1058 main.log.report(' Port down ofp-to-graph ' +
1059 str(portDownGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001060 main.log.report(' Port down ofp-to-link ' +
1061 str(portDownLinkAvg) + ' ms')
1062
jenkins7ead5a82015-03-13 10:28:21 -07001063 dbCmdList.append("INSERT INTO port_latency_tests VALUES('" +
1064 timeToPost + "','port_latency_results'," + runNum +
1065 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
1066 "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) +
1067 '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');')
1068
1069 fResult = open(resultPath, 'a')
1070 for line in dbCmdList:
1071 if line:
1072 fResult.write(line + '\n')
1073
1074 fResult.close()
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001075
1076 # Delete switches from controller to prepare for next
1077 # set of tests
jenkins7ead5a82015-03-13 10:28:21 -07001078 main.Mininet1.deleteSwController('s1')
1079 main.Mininet1.deleteSwController('s2')
1080 utilities.assert_equals(expect=main.TRUE,
1081 actual=assertion,
1082 onpass='Port discovery latency calculation successful',
1083 onfail='Port discovery test failed')
1084
1085 def CASE4(self, main):
1086 """
1087 Increase number of nodes and initiate CLI
1088
1089 With the most recent implementation, we need a method to
1090 ensure all ONOS nodes are killed, as well as redefine
1091 the cell files to ensure all nodes that will be used
1092 is in the cell file. Otherwise, exceptions will
1093 prohibit test from running successfully.
1094
1095 3/12/15
1096
1097 """
1098 global clusterCount
1099 import time
1100 import os
1101
1102 clusterCount += 2
1103
1104 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1105 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1106 cellName = main.params[ 'ENV' ][ 'cellName' ]
1107 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1108
1109 main.log.report('Increasing cluster size to ' + str(clusterCount))
1110
1111 main.log.step( "Killing all ONOS processes before scale-out" )
1112
1113 for i in range( 1, 8 ):
1114 main.ONOSbench.onosDie(
1115 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1116 main.ONOSbench.onosUninstall(
1117 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1118
1119 main.step( "Creating scale-out cell file" )
1120 cellIp = []
1121 for node in range( 1, clusterCount + 1 ):
1122 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1123
1124 main.log.info( "Cell Ip list: " + str(cellIp) )
1125 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1126 str(features), *cellIp )
1127
1128 main.step( "Setting cell definition" )
1129 main.ONOSbench.setCell(cellName)
1130
1131 main.step( "Packaging cell definition" )
1132 main.ONOSbench.onosPackage()
1133
jenkins7ead5a82015-03-13 10:28:21 -07001134 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001135 main.ONOSbench.onosInstall(
1136 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1137
1138 time.sleep( 20 )
1139
jenkins7ead5a82015-03-13 10:28:21 -07001140 for node in range( 1, clusterCount + 1):
1141 for i in range( 2 ):
1142 isup = main.ONOSbench.isup(
1143 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1144 if isup:
1145 main.log.info( "ONOS "+str(node) + " is up\n")
1146 break
1147 if not isup:
1148 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001149
andrew@onlab.usb4cb2b82015-04-03 14:06:09 -04001150 for node in range( 0, clusterCount ):
1151 CLIs[node].startOnosCli( cellIp[node] )
1152
1153 main.step( 'Setting configurations for metrics' )
1154 configParam = 'maxEvents 1'
1155 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1156 configParam = 'maxBatchMs 0'
1157 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1158 configParam = 'maxIdleMs 0'
1159 main.ONOSbench.onosCfgSet( nodeIpList[0], configName, configParam )
1160
1161 main.step( 'Activating essential applications' )
1162 CLIs[0].activateApp( 'org.onosproject.metrics' )
1163 CLIs[0].activateApp( 'org.onosproject.openflow' )
jenkinsac38ab72015-03-13 11:24:10 -07001164