blob: 8a9591d6b4073d297b4c2df91e1672c23f7b7a3b [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
20 import time
21 clusterCount = 1
22 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
23 runNum = time.strftime('%d%H%M%S')
24 cellName = main.params['ENV']['cellName']
25 gitPull = main.params['GIT']['autoPull']
26 checkoutBranch = main.params['GIT']['checkout']
27
28 ONOS1Ip = main.params['CTRL']['ip1']
29 ONOS2Ip = main.params['CTRL']['ip2']
30 ONOS3Ip = main.params['CTRL']['ip3']
31 ONOS4Ip = main.params['CTRL']['ip4']
32 ONOS5Ip = main.params['CTRL']['ip5']
33 ONOS6Ip = main.params['CTRL']['ip6']
34 ONOS7Ip = main.params['CTRL']['ip7']
35 MN1Ip = main.params['MN']['ip1']
36 BENCHIp = main.params['BENCH']['ip']
37
38 topoCfgFile = main.params['TEST']['topoConfigFile']
39 topoCfgName = main.params['TEST']['topoConfigName']
40 portEventResultPath = main.params['DB']['portEventResultPath']
41 switchEventResultPath = main.params['DB']['switchEventResultPath']
42 mvnCleanInstall = main.params['TEST']['mci']
43
44 main.case('Setting up test environment')
45 main.log.info('Copying topology event accumulator config' +
46 ' to ONOS /package/etc')
47 main.ONOSbench.handle.sendline('cp ~/' +
48 topoCfgFile + ' ~/ONOS/tools/package/etc/' +
49 topoCfgName)
50 main.ONOSbench.handle.expect('\\$')
51
52 main.log.report('Setting up test environment')
53
54 main.step('Starting mininet topology ')
55 main.Mininet1.startNet()
56
57 main.step('Cleaning previously installed ONOS if any')
58 main.ONOSbench.onosUninstall(nodeIp=ONOS2Ip)
59 main.ONOSbench.onosUninstall(nodeIp=ONOS3Ip)
60 main.ONOSbench.onosUninstall(nodeIp=ONOS4Ip)
61 main.ONOSbench.onosUninstall(nodeIp=ONOS5Ip)
62 main.ONOSbench.onosUninstall(nodeIp=ONOS6Ip)
63 main.ONOSbench.onosUninstall(nodeIp=ONOS7Ip)
64
65 main.step('Clearing previous DB log file')
66
67 fPortLog = open(portEventResultPath, 'w')
68 fPortLog.write('')
69 fPortLog.close()
70 fSwitchLog = open(switchEventResultPath, 'w')
71 fSwitchLog.write('')
72 fSwitchLog.close()
73
74 cellStr = 'webconsole,onos-core,onos-api,onos-app-metrics,' +\
75 'onos-app-gui,onos-cli,onos-openflow'
76
77 main.step('Creating cell file')
78 cellFileResult = main.ONOSbench.createCellFile(
79 BENCHIp, cellName, MN1Ip, cellStr, ONOS1Ip)
80
81 main.step('Applying cell file to environment')
82 cellApplyResult = main.ONOSbench.setCell(cellName)
83 verifyCellResult = main.ONOSbench.verifyCell()
84
85 main.step('Git checkout and pull ' + checkoutBranch)
86 if gitPull == 'on':
87 checkoutResult = main.TRUE
88 pullResult = main.ONOSbench.gitPull()
89 else:
90 checkoutResult = main.TRUE
91 pullResult = main.TRUE
92 main.log.info('Skipped git checkout and pull')
93
94 main.log.report('Commit information - ')
95 main.ONOSbench.getVersion(report=True)
96 main.step('Using mvn clean & install')
97 if mvnCleanInstall == 'on':
98 mvnResult = main.ONOSbench.cleanInstall()
99 elif mvnCleanInstall == 'off':
100 main.log.info('mci turned off by settings')
101 mvnResult = main.TRUE
102 main.step('Set cell for ONOS cli env')
103 main.ONOS1cli.setCell(cellName)
104
105 main.step('Creating ONOS package')
106 packageResult = main.ONOSbench.onosPackage()
107
108 main.step('Installing ONOS package')
109 install1Result = main.ONOSbench.onosInstall(node=ONOS1Ip)
110
111 time.sleep(10)
112
113 main.step('Start onos cli')
114 cli1 = main.ONOS1cli.startOnosCli(ONOS1Ip)
115 utilities.assert_equals(expect=main.TRUE,
116 actual=cellFileResult and cellApplyResult and\
117 verifyCellResult and checkoutResult and\
118 pullResult and mvnResult and\
119 install1Result,
120 onpass='Test Environment setup successful',
121 onfail='Failed to setup test environment')
122
123 def CASE2(self, main):
124 """
125 Assign s1 to ONOS1 and measure latency
126
127 There are 4 levels of latency measurements to this test:
128 1 ) End-to-end measurement: Complete end-to-end measurement
129 from TCP ( SYN/ACK ) handshake to Graph change
130 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
131 measurement from OFP Vendor message to Graph change
132 3 ) OFP-to-device measurement: 'ONOS processing without
133 graph change' snippet of measurement from OFP vendor
134 message to Device change timestamp
135 4 ) T0-to-device measurement: Measurement that includes
136 the switch handshake to devices timestamp without
137 the graph view change. ( TCP handshake -> Device
138 change )
139 """
140 import time
141 import subprocess
142 import json
143 import requests
144 import os
145 import numpy
146
147 ONOS1Ip = main.params['CTRL']['ip1']
148 ONOS2Ip = main.params['CTRL']['ip2']
149 ONOS3Ip = main.params['CTRL']['ip3']
150 ONOS4Ip = main.params['CTRL']['ip4']
151 ONOS5Ip = main.params['CTRL']['ip5']
152 ONOS6Ip = main.params['CTRL']['ip6']
153 ONOS7Ip = main.params['CTRL']['ip7']
154
155 ONOSUser = main.params['CTRL']['user']
156 defaultSwPort = main.params['CTRL']['port1']
157 numIter = main.params['TEST']['numIter']
158 iterIgnore = int(main.params['TEST']['iterIgnore'])
jenkins8ba10ab2015-03-24 10:31:31 -0700159
jenkins7ead5a82015-03-13 10:28:21 -0700160 deviceTimestamp = main.params['JSON']['deviceTimestamp']
161 graphTimestamp = main.params['JSON']['graphTimestamp']
jenkins8ba10ab2015-03-24 10:31:31 -0700162
jenkins7ead5a82015-03-13 10:28:21 -0700163 debugMode = main.params['TEST']['debugMode']
164 onosLog = main.params['TEST']['onosLogFile']
165 resultPath = main.params['DB']['switchEventResultPath']
166 thresholdStr = main.params['TEST']['singleSwThreshold']
167 thresholdObj = thresholdStr.split(',')
168 thresholdMin = int(thresholdObj[0])
169 thresholdMax = int(thresholdObj[1])
170
jenkins8ba10ab2015-03-24 10:31:31 -0700171 # Look for 'role-request' messages,
172 # which replaces the 'vendor' messages previously seen
173 # on OVS 2.0.1
jenkins7ead5a82015-03-13 10:28:21 -0700174 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
jenkins8ba10ab2015-03-24 10:31:31 -0700175 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
176 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
177 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
178
jenkins7ead5a82015-03-13 10:28:21 -0700179 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
180 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
jenkins8ba10ab2015-03-24 10:31:31 -0700181 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
182 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
jenkins7ead5a82015-03-13 10:28:21 -0700183
jenkins7ead5a82015-03-13 10:28:21 -0700184 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
185 ofpToGraphLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
186 ofpToDeviceLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
187
188 tcpToOfpLatIter = []
jenkins8ba10ab2015-03-24 10:31:31 -0700189 tcpToFeatureLatIter = []
190 tcpToRoleLatIter = []
jenkins7ead5a82015-03-13 10:28:21 -0700191 assertion = main.TRUE
192 localTime = time.strftime('%x %X')
193 localTime = localTime.replace('/', '')
194 localTime = localTime.replace(' ', '_')
195 localTime = localTime.replace(':', '')
196
197 if debugMode == 'on':
198 main.ONOS1.tsharkPcap('eth0',
199 '/tmp/single_sw_lat_pcap_' + localTime)
200 main.log.info('Debug mode is on')
201 main.log.report('Latency of adding one switch to controller')
202 main.log.report('First ' + str(iterIgnore) +
203 ' iterations ignored' + ' for jvm warmup time')
204 main.log.report('Total iterations of test: ' + str(numIter))
205
206 for i in range(0, int(numIter)):
207 main.log.info('Starting tshark capture')
208 main.ONOS1.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
209 main.ONOS1.tsharkGrep(tsharkOfString, tsharkOfOutput)
jenkins8ba10ab2015-03-24 10:31:31 -0700210 main.ONOS1.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
211 main.ONOS1.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
212
jenkins7ead5a82015-03-13 10:28:21 -0700213 time.sleep(10)
214
215 main.log.info('Assigning s3 to controller')
216 main.Mininet1.assignSwController(sw='3',
217 ip1=ONOS1Ip, port1=defaultSwPort)
218
219 time.sleep(10)
220
221 main.log.info('Stopping all Tshark processes')
222 main.ONOS1.tsharkStop()
223
224 main.log.info('Copying over tshark files')
225 os.system('scp ' + ONOSUser + '@' + ONOS1Ip +
226 ':' + tsharkTcpOutput + ' /tmp/')
jenkins8ba10ab2015-03-24 10:31:31 -0700227 os.system('scp ' + ONOSUser + '@' + ONOS1Ip +
228 ':' + tsharkRoleOutput + ' /tmp/')
229 os.system('scp ' + ONOSUser + '@' + ONOS1Ip +
230 ':' + tsharkFeatureOutput + ' /tmp/')
231 os.system('scp ' + ONOSUser + '@' +
232 ONOS1Ip + ':' + tsharkOfOutput + ' /tmp/')
233
234 # Get tcp syn / ack output
jenkins7ead5a82015-03-13 10:28:21 -0700235 time.sleep(5)
236 tcpFile = open(tsharkTcpOutput, 'r')
237 tempText = tcpFile.readline()
238 tempText = tempText.split(' ')
239 main.log.info('Object read in from TCP capture: ' +
240 str(tempText))
241
242 if len(tempText) > 1:
243 t0Tcp = float(tempText[1]) * 1000.0
244 else:
245 main.log.error('Tshark output file for TCP' +
246 ' returned unexpected results')
247 t0Tcp = 0
248 assertion = main.FALSE
249 tcpFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700250
251 # Get Role reply output
jenkins7ead5a82015-03-13 10:28:21 -0700252 time.sleep(5)
253 ofFile = open(tsharkOfOutput, 'r')
254 lineOfp = ''
255 while True:
256 tempText = ofFile.readline()
257 if tempText != '':
258 lineOfp = tempText
259 else:
260 break
jenkins7ead5a82015-03-13 10:28:21 -0700261 obj = lineOfp.split(' ')
262 main.log.info('Object read in from OFP capture: ' +
263 str(lineOfp))
264 if len(obj) > 1:
265 t0Ofp = float(obj[1]) * 1000.0
266 else:
267 main.log.error('Tshark output file for OFP' +
268 ' returned unexpected results')
269 t0Ofp = 0
270 assertion = main.FALSE
271 ofFile.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700272
273 # Get role request output
274 roleFile = open(tsharkRoleOutput, 'r')
275 tempText = roleFile.readline()
276 tempText = tempText.split(' ')
277 if len(tempText) > 1:
278 main.log.info('Object read in from role request capture:' +
279 str(tempText))
280 roleTimestamp = float(tempText[1]) * 1000.0
281 else:
282 main.log.error('Tshark output file for role request' +
283 ' returned unexpected results')
284 timeRoleRequest = 0
285 assertion = main.FALSE
286 roleFile.close()
287
288 # Get feature reply output
289 featureFile = open(tsharkFeatureOutput, 'r')
290 tempText = featureFile.readline()
291 tempText = tempText.split(' ')
292 if len(tempText) > 1:
293 main.log.info('Object read in from feature reply capture: '+
294 str(tempText))
295 featureTimestamp = float(tempText[1]) * 1000.0
296 else:
297 main.log.error('Tshark output file for feature reply' +
298 ' returned unexpected results')
299 timeFeatureReply = 0
300 assertion = main.FALSE
301 featureFile.close()
302
303 # TODO: calculate feature reply, role request times
304 # stack measurements correctly and report
305
306 """
307 #TODO: Refactor in progress
308
309 for node in range(0, clusterCount):
310 nodeNum = node+1
311 exec "metricsSwUp = main.ONOS%scli.topologyEventsMetrics"%str(nodeNum)
312 jsonStr = metricsSwUp()
313 jsonObj = json.loads(jsonStr)
314 graphTimestamp = jsonObj[graphTimestamp]['value']
315 deviceTimestamp = jsonObj[deviceTimestamp]['value']
316
317 deltaGraphTcp = int(graphTimestamp) - int(t0Tcp)
318 deltaDeviceTcp = int(deviceTimestamp) - int(t0Tcp)
319 deltaGraphOfp = int(graphTimestamp) - int(t0Ofp)
320 deltaDeviceOfp = int(deviceTimestamp) - int(t0Ofp)
321 deltaRoleTcp = int(roleTimestamp) - int(t0Tcp)
322 deltaFeatureTcp = int(featureTimestamp) - int(t0Tcp)
323 deltaOfpTcp = int(t0Ofp) - int(t0Tcp)
324
325 if deltaGraphTcp > thresholdMin and\
326 deltaGraphTcp < thresholdMax and i >= iterIgnore:
327 endToEndLatNodeIter[node][i] = deltaGraphTcp
328 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-graph: "+
329 str(deltaGraphTcp) + " ms")
330 else:
331 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-graph "+
332 "measurement ignored due to excess in "+
333 "threshold or premature iteration")
334
335 if deltaGraphOfp > thresholdMin and\
336 deltaGraphOfp < thresholdMax and i >= iterIgnore:
337 ofpToGraphLatNodeIter[node][i] = deltaGraphOfp
338 main.log.info("ONOS "+str(nodeNum)+ " ofp-to-graph: "+
339 str(deltaGraphOfp) + " ms")
340 else:
341 main.log.info("ONOS "+str(nodeNum)+ " ofp-to-graph: "+
342 "measurement ignored due to excess in "+
343 "threshold or premature iteration")
344
345 if deltaDeviceOfp > thresholdMin and\
346 deltaDeviceOfp < thresholdMax and i >= iterIgnore:
347 ofpToDeviceLatNodeIter[node][i] = deltaDeviceOfp
348 main.log.info("ONOS "+str(nodeNum)+ " ofp-to-device: "+
349 str(deltaDeviceOfp) + " ms")
350 else:
351 main.log.info("ONOS "+str(nodeNum)+ " ofp-to-device: "+
352 "measurement ignored due to excess in "+
353 "threshold or premature iteration")
354
355
356 # ********************
357 """
jenkins7ead5a82015-03-13 10:28:21 -0700358 jsonStr1 = main.ONOS1cli.topologyEventsMetrics()
359 jsonStr2 = ''
360 jsonStr3 = ''
361 jsonStr4 = ''
362 jsonStr5 = ''
363 jsonStr6 = ''
364 jsonStr7 = ''
365
366 jsonObj1 = json.loads(jsonStr1)
367 jsonObj2 = ''
368 jsonObj3 = ''
369 jsonObj4 = ''
370 jsonObj5 = ''
371 jsonObj6 = ''
372 jsonObj7 = ''
jenkins8ba10ab2015-03-24 10:31:31 -0700373
374
jenkins7ead5a82015-03-13 10:28:21 -0700375 graphTimestamp1 = jsonObj1[graphTimestamp]['value']
376 deviceTimestamp1 = jsonObj1[deviceTimestamp]['value']
377
378 main.log.info(' GraphTimestamp: ' + str(graphTimestamp1))
379 main.log.info(' DeviceTimestamp: ' + str(deviceTimestamp1))
380
381 deltaDevice1 = int(deviceTimestamp1) - int(t0Tcp)
382 deltaGraph1 = int(graphTimestamp1) - int(t0Tcp)
383 deltaOfpGraph1 = int(graphTimestamp1) - int(t0Ofp)
384 deltaOfpDevice1 = int(deviceTimestamp1) - int(t0Ofp)
jenkins8ba10ab2015-03-24 10:31:31 -0700385 # Tshark timestamps
jenkins7ead5a82015-03-13 10:28:21 -0700386 deltaTcpOfp1 = int(t0Ofp) - int(t0Tcp)
jenkins8ba10ab2015-03-24 10:31:31 -0700387 deltaRoleTcp1 = int(roleTimestamp) - int(t0Tcp)
388 deltaFeatureTcp1 = int(featureTimestamp) - int(t0Tcp)
389 deltaOfpTcp1 = int(t0Ofp) - int(t0Tcp)
jenkins7ead5a82015-03-13 10:28:21 -0700390
391 if deltaTcpOfp1 > thresholdMin and\
392 deltaTcpOfp1 < thresholdMax and i >= iterIgnore:
393 tcpToOfpLatIter.append(deltaTcpOfp1)
jenkins8ba10ab2015-03-24 10:31:31 -0700394 main.log.info('ONOS1 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700395 ' tcp-to-ofp: ' +
396 str(deltaTcpOfp1) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -0700397 if deltaFeatureTcp1 > thresholdMin and\
398 deltaFeatureTcp1 < thresholdMax and i >= iterIgnore:
399 tcpToFeatureLatIter.append(deltaFeatureTcp1)
400 main.log.info('ONOS1 iter' + str(i) +
401 ' tcp-to-feature-reply: ' +
402 str(deltaFeatureTcp1) + ' ms')
403 if deltaRoleTcp1 > thresholdMin and\
404 deltaRoleTcp1 < thresholdMax and i >= iterIgnore:
405 tcpToRoleLatIter.append(deltaRoleTcp1)
406 main.log.info('ONOS1 iter' + str(i) +
407 ' tcp-to-role-request: ' +
408 str(deltaRoleTcp1) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -0700409 if deltaGraph1 > thresholdMin and\
410 deltaGraph1 < thresholdMax and i >= iterIgnore:
411 endToEndLatNodeIter[0][i] = deltaGraph1
jenkins8ba10ab2015-03-24 10:31:31 -0700412 main.log.info('ONOS1 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700413 ' end-to-end: ' +
414 str(deltaGraph1) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -0700415 if deltaOfpGraph1 > thresholdMin and \
416 deltaOfpGraph1 < thresholdMax and i >= iterIgnore:
417 ofpToGraphLatNodeIter[0][i] = deltaOfpGraph1
jenkins8ba10ab2015-03-24 10:31:31 -0700418 main.log.info('ONOS1 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700419 ' ofp-to-graph: ' +
420 str(deltaOfpGraph1) + ' ms')
421 if deltaOfpDevice1 > thresholdMin and\
422 deltaOfpDevice1 < thresholdMax and i >= iterIgnore:
423 ofpToDeviceLatNodeIter[0][i] = deltaOfpDevice1
jenkins8ba10ab2015-03-24 10:31:31 -0700424 main.log.info('ONOS1 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700425 ' ofp-to-device: ' +
426 str(deltaOfpDevice1))
427
428 if clusterCount >= 3:
429 jsonStr2 = main.ONOS2cli.topologyEventsMetrics()
430 jsonStr3 = main.ONOS3cli.topologyEventsMetrics()
431 jsonObj2 = json.loads(jsonStr2)
432 jsonObj3 = json.loads(jsonStr3)
433 graphTimestamp2 = jsonObj2[graphTimestamp]['value']
434 graphTimestamp3 = jsonObj3[graphTimestamp]['value']
435 deviceTimestamp2 = jsonObj2[deviceTimestamp]['value']
436 deviceTimestamp3 = jsonObj3[deviceTimestamp]['value']
437 deltaDevice2 = int(deviceTimestamp2) - int(t0Tcp)
438 deltaDevice3 = int(deviceTimestamp3) - int(t0Tcp)
439 deltaGraph2 = int(graphTimestamp2) - int(t0Tcp)
440 deltaGraph3 = int(graphTimestamp3) - int(t0Tcp)
441 deltaOfpGraph2 = int(graphTimestamp2) - int(t0Ofp)
442 deltaOfpGraph3 = int(graphTimestamp3) - int(t0Ofp)
443 deltaOfpDevice2 = int(deviceTimestamp2) - int(t0Ofp)
444 deltaOfpDevice3 = int(deviceTimestamp3) - int(t0Ofp)
445 if deltaGraph2 > thresholdMin and\
446 deltaGraph2 < thresholdMax and i >= iterIgnore:
447 endToEndLatNodeIter[1][i] = deltaGraph2
jenkins8ba10ab2015-03-24 10:31:31 -0700448 main.log.info('ONOS2 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700449 ' end-to-end: ' +
450 str(deltaGraph2) + ' ms')
451 if deltaOfpGraph2 > thresholdMin and\
452 deltaOfpGraph2 < thresholdMax and i >= iterIgnore:
453 ofpToGraphLatNodeIter[1][i] = deltaOfpGraph2
jenkins8ba10ab2015-03-24 10:31:31 -0700454 main.log.info('ONOS2 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700455 ' ofp-to-graph: ' +
456 str(deltaOfpGraph2) + ' ms')
457 if deltaOfpDevice2 > thresholdMin and\
458 deltaOfpDevice2 < thresholdMax and i >= iterIgnore:
459 ofpToDeviceLatNodeIter[1][i] = deltaOfpDevice2
jenkins8ba10ab2015-03-24 10:31:31 -0700460 main.log.info('ONOS2 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700461 ' ofp-to-device: ' +
jenkins8ba10ab2015-03-24 10:31:31 -0700462 str(deltaOfpDevice2)+ ' ms')
jenkins7ead5a82015-03-13 10:28:21 -0700463 if deltaGraph3 > thresholdMin and\
464 deltaGraph3 < thresholdMax and i >= iterIgnore:
465 endToEndLatNodeIter[2][i] = deltaGraph3
jenkins8ba10ab2015-03-24 10:31:31 -0700466 main.log.info('ONOS3 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700467 ' end-to-end: ' + str(deltaGraph3) + ' ms')
468 if deltaOfpGraph3 > thresholdMin and\
469 deltaOfpGraph3 < thresholdMax and i >= iterIgnore:
470 ofpToGraphLatNodeIter[2][i] = deltaOfpGraph3
jenkins8ba10ab2015-03-24 10:31:31 -0700471 main.log.info('ONOS3 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700472 ' ofp-to-graph: ' +
473 str(deltaOfpGraph3) + ' ms')
474 if deltaOfpDevice3 > thresholdMin and\
jenkins8ba10ab2015-03-24 10:31:31 -0700475 deltaOfpDevice3 < thresholdMax and i >= iterIgnore:
jenkins7ead5a82015-03-13 10:28:21 -0700476 ofpToDeviceLatNodeIter[2][i] = deltaOfpDevice3
jenkins8ba10ab2015-03-24 10:31:31 -0700477 main.log.info('ONOS3 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700478 ' ofp-to-device: ' + str(deltaOfpDevice3))
479 if clusterCount >= 5:
480 jsonStr4 = main.ONOS4cli.topologyEventsMetrics()
481 jsonStr5 = main.ONOS5cli.topologyEventsMetrics()
482 jsonObj4 = json.loads(jsonStr4)
483 jsonObj5 = json.loads(jsonStr5)
484 graphTimestamp4 = jsonObj4[graphTimestamp]['value']
485 graphTimestamp5 = jsonObj5[graphTimestamp]['value']
486 deviceTimestamp4 = jsonObj4[deviceTimestamp]['value']
487 deviceTimestamp5 = jsonObj5[deviceTimestamp]['value']
488 deltaDevice4 = int(deviceTimestamp4) - int(t0Tcp)
489 deltaDevice5 = int(deviceTimestamp5) - int(t0Tcp)
490 deltaGraph4 = int(graphTimestamp4) - int(t0Tcp)
491 deltaGraph5 = int(graphTimestamp5) - int(t0Tcp)
492 deltaOfpGraph4 = int(graphTimestamp4) - int(t0Ofp)
493 deltaOfpGraph5 = int(graphTimestamp5) - int(t0Ofp)
494 deltaOfpDevice4 = int(deviceTimestamp4) - int(t0Ofp)
495 deltaOfpDevice5 = int(deviceTimestamp5) - int(t0Ofp)
496 if deltaGraph4 > thresholdMin and \
497 deltaGraph4 < thresholdMax and i >= iterIgnore:
498 endToEndLatNodeIter[3][i] = deltaGraph4
jenkins8ba10ab2015-03-24 10:31:31 -0700499 main.log.info('ONOS4 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700500 ' end-to-end: ' + str(deltaGraph4) + ' ms')
501 if deltaOfpDevice4 > thresholdMin and \
502 deltaOfpDevice4 < thresholdMax and i >= iterIgnore:
503 ofpToDeviceLatNodeIter[3][i] = deltaOfpDevice4
jenkins8ba10ab2015-03-24 10:31:31 -0700504 main.log.info('ONOS4 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700505 ' ofp-to-device: ' + str(deltaOfpDevice4))
506 if deltaOfpGraph4 > thresholdMin and \
507 deltaOfpGraph4 < thresholdMax and i >= iterIgnore:
508 ofpToGraphLatNodeIter[3][i] = deltaOfpGraph4
jenkins8ba10ab2015-03-24 10:31:31 -0700509 main.log.info('ONOS4 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700510 ' ofp-to-graph: ' + str(deltaOfpGraph4) + ' ms')
511 if deltaGraph5 > thresholdMin and\
512 deltaGraph5 < thresholdMax and i >= iterIgnore:
513 endToEndLatNodeIter[4][i] = deltaGraph5
jenkins8ba10ab2015-03-24 10:31:31 -0700514 main.log.info('ONOS5 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700515 ' end-to-end: ' + str(deltaGraph5) + ' ms')
516 if deltaOfpDevice5 > thresholdMin and\
517 deltaOfpDevice5 < thresholdMax and i >= iterIgnore:
518 ofpToDeviceLatNodeIter[4][i] = deltaOfpDevice5
jenkins8ba10ab2015-03-24 10:31:31 -0700519 main.log.info('ONOS5 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700520 ' ofp-to-device: ' + str(deltaOfpDevice5))
521 if deltaOfpGraph5 > thresholdMin and\
522 deltaOfpGraph5 < thresholdMax and i >= iterIgnore:
523 ofpToGraphLatNodeIter[4][i] = deltaOfpGraph5
jenkins8ba10ab2015-03-24 10:31:31 -0700524 main.log.info('ONOS5 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700525 ' ofp-to-graph: ' +
526 str(deltaOfpGraph5) + ' ms')
527 if clusterCount >= 7:
528 jsonStr6 = main.ONOS6cli.topologyEventsMetrics()
529 jsonStr7 = main.ONOS7cli.topologyEventsMetrics()
530 jsonObj6 = json.loads(jsonStr6)
531 jsonObj7 = json.loads(jsonStr7)
532 graphTimestamp6 = jsonObj6[graphTimestamp]['value']
533 graphTimestamp7 = jsonObj7[graphTimestamp]['value']
534 deviceTimestamp6 = jsonObj6[deviceTimestamp]['value']
535 deviceTimestamp7 = jsonObj7[deviceTimestamp]['value']
536 deltaDevice6 = int(deviceTimestamp6) - int(t0Tcp)
537 deltaDevice7 = int(deviceTimestamp7) - int(t0Tcp)
538 deltaGraph6 = int(graphTimestamp6) - int(t0Tcp)
539 deltaGraph7 = int(graphTimestamp7) - int(t0Tcp)
540 deltaOfpGraph6 = int(graphTimestamp6) - int(t0Ofp)
541 deltaOfpGraph7 = int(graphTimestamp7) - int(t0Ofp)
542 deltaOfpDevice6 = int(deviceTimestamp6) - int(t0Ofp)
543 deltaOfpDevice7 = int(deviceTimestamp7) - int(t0Ofp)
544 if deltaGraph6 > thresholdMin and \
545 deltaGraph6 < thresholdMax and i >= iterIgnore:
546 endToEndLatNodeIter[5][i] = deltaGraph6
jenkins8ba10ab2015-03-24 10:31:31 -0700547 main.log.info('ONOS6 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700548 ' end-to-end: ' + str(deltaGraph6) + ' ms')
549 if deltaOfpDevice6 > thresholdMin and\
550 deltaOfpDevice6 < thresholdMax and i >= iterIgnore:
551 ofpToDeviceLatNodeIter[5][i] = deltaOfpDevice6
jenkins8ba10ab2015-03-24 10:31:31 -0700552 main.log.info('ONOS6 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700553 ' ofp-to-device: ' + str(deltaOfpDevice6))
554 if deltaOfpGraph6 > thresholdMin and\
555 deltaOfpGraph6 < thresholdMax and i >= iterIgnore:
556 ofpToGraphLatNodeIter[5][i] = deltaOfpGraph6
jenkins8ba10ab2015-03-24 10:31:31 -0700557 main.log.info('ONOS6 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700558 ' ofp-to-graph: ' +
559 str(deltaOfpGraph6) + ' ms')
560 if deltaGraph7 > thresholdMin and \
561 deltaGraph7 < thresholdMax and i >= iterIgnore:
562 endToEndLatNodeIter[6][i] = deltaGraph7
jenkins8ba10ab2015-03-24 10:31:31 -0700563 main.log.info('ONOS7 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700564 ' end-to-end: ' +
565 str(deltaGraph7) + ' ms')
566 if deltaOfpDevice7 > thresholdMin and\
567 deltaOfpDevice7 < thresholdMax and i >= iterIgnore:
568 ofpToDeviceLatNodeIter[6][i] = deltaOfpDevice7
jenkins8ba10ab2015-03-24 10:31:31 -0700569 main.log.info('ONOS7 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700570 ' ofp-to-device: ' +
571 str(deltaOfpDevice7))
572 if deltaOfpGraph7 > thresholdMin and \
573 deltaOfpGraph7 < thresholdMax and i >= iterIgnore:
574 ofpToGraphLatNodeIter[6][i] = deltaOfpGraph7
jenkins8ba10ab2015-03-24 10:31:31 -0700575 main.log.info('ONOS7 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -0700576 ' ofp-to-graph: ' +
577 str(deltaOfpGraph7) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -0700578
jenkins7ead5a82015-03-13 10:28:21 -0700579 time.sleep(5)
580
581 # Get device id to remove
582 deviceIdJsonStr = main.ONOS1cli.devices()
583
584 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
585 deviceId = json.loads(deviceIdJsonStr)
586
587 deviceList = []
588 for device in deviceId:
589 deviceList.append(device['id'])
590
591 main.step('Remove switch from controller')
592 main.Mininet1.deleteSwController('s3')
593
594 #firstDevice = deviceList[0]
595 firstDevice = "of:0000000000000003"
596 main.log.info( "Removing device " +str(firstDevice)+
597 " from ONOS" )
598 #if deviceId:
599 main.ONOS1cli.deviceRemove(firstDevice)
600
601 time.sleep(5)
602
603 endToEndAvg = 0
604 ofpToGraphAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -0700605 dbCmdList = []
606 for node in range(0, clusterCount):
jenkins8ba10ab2015-03-24 10:31:31 -0700607 # List of latency for each node
608 endToEndList = []
609 ofpToGraphList = []
610 ofpToDeviceList = []
611 tcpToOfpList = []
612 tcpToFeatureList = []
613 tcpToRoleList = []
614
615 # LatNodeIter 2d arrays contain all iteration latency
616 # for each node of the current scale cluster size
617
jenkins7ead5a82015-03-13 10:28:21 -0700618 for item in endToEndLatNodeIter[node]:
619 if item > 0.0:
620 endToEndList.append(item)
621
622 for item in ofpToGraphLatNodeIter[node]:
623 if item > 0.0:
624 ofpToGraphList.append(item)
625
626 for item in ofpToDeviceLatNodeIter[node]:
627 if item > 0.0:
628 ofpToDeviceList.append(item)
629
jenkins8ba10ab2015-03-24 10:31:31 -0700630 for item in tcpToOfpLatIter:
631 if item > 0.0:
632 tcpToOfpList.append(item)
633
634 for item in tcpToFeatureLatIter:
635 if item > 0.0:
636 tcpToFeatureList.append(item)
637
638 for item in tcpToRoleLatIter:
639 if item > 0.0:
640 tcpToRoleList.append(item)
641
jenkins7ead5a82015-03-13 10:28:21 -0700642 endToEndAvg = round(numpy.mean(endToEndList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -0700643 tcpToOfpAvg = round(numpy.mean(tcpToOfpList), 2)
644 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
645 tcpToRoleAvg = round(numpy.mean(tcpToRoleList), 2)
jenkins7ead5a82015-03-13 10:28:21 -0700646 ofpToGraphAvg = round(numpy.mean(ofpToGraphList), 2)
647 endToEndStd = round(numpy.std(endToEndList), 2)
648 ofpToGraphStd = round(numpy.std(ofpToGraphList), 2)
649 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
650 ofpToDeviceStd = round(numpy.std(ofpToDeviceList), 2)
651 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
652 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
653 ' ms' + ' End-to-end Std dev: ' +
654 str(endToEndStd) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -0700655 main.log.report(' Tcp-to-role-reply : ' + str(tcpToOfpAvg) + ' ms')
656 main.log.report(' Tcp-to-feature-reply : ' + str(tcpToFeatureAvg) + ' ms')
657 main.log.report(' Tcp-to-role-request : ' + str(tcpToRoleAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -0700658 main.log.report(' Ofp-to-graph Avg: ' + str(ofpToGraphAvg) +
659 ' ms' + ' Ofp-to-graph Std dev: ' +
660 str(ofpToGraphStd) + ' ms')
661 main.log.report(' Ofp-to-device Avg: ' + str(ofpToDeviceAvg) +
662 ' ms' + ' Ofp-to-device Std dev: ' +
663 str(ofpToDeviceStd) + ' ms')
664 dbCmdList.append(
665 "INSERT INTO switch_latency_tests VALUES('" +
666 timeToPost + "','switch_latency_results'," +
667 runNum + ',' + str(clusterCount) + ",'baremetal" +
668 str(node + 1) + "'," + str(endToEndAvg) + ',' +
669 str(endToEndStd) + ',0,0);')
670
671 if debugMode == 'on':
672 main.ONOS1.cpLogsToDir('/opt/onos/log/karaf.log',
673 '/tmp/', copyFileName='sw_lat_karaf')
674 fResult = open(resultPath, 'a')
675 for line in dbCmdList:
676 if line:
677 fResult.write(line + '\n')
678
679 fResult.close()
680 assertion = main.TRUE
681 utilities.assert_equals(expect=main.TRUE, actual=assertion,
682 onpass='Switch latency test successful',
683 onfail='Switch latency test failed')
684
685 def CASE3(self, main):
686 """
687 Bring port up / down and measure latency.
688 Port enable / disable is simulated by ifconfig up / down
689
690 In ONOS-next, we must ensure that the port we are
691 manipulating is connected to another switch with a valid
692 connection. Otherwise, graph view will not be updated.
693 """
694 global timeToPost
695 import time
696 import subprocess
697 import os
698 import requests
699 import json
700 import numpy
701 ONOS1Ip = main.params['CTRL']['ip1']
702 ONOS2Ip = main.params['CTRL']['ip2']
703 ONOS3Ip = main.params['CTRL']['ip3']
704 ONOSUser = main.params['CTRL']['user']
705 defaultSwPort = main.params['CTRL']['port1']
706 assertion = main.TRUE
707 numIter = main.params['TEST']['numIter']
708 iterIgnore = int(main.params['TEST']['iterIgnore'])
709 deviceTimestamp = main.params['JSON']['deviceTimestamp']
710 graphTimestamp = main.params['JSON']['graphTimestamp']
711 linkTimestamp = main.params['JSON']['linkTimestamp']
712
713 tsharkPortUp = '/tmp/tshark_port_up.txt'
714 tsharkPortDown = '/tmp/tshark_port_down.txt'
715 tsharkPortStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
716
717 debugMode = main.params['TEST']['debugMode']
718 postToDB = main.params['DB']['postToDB']
719 resultPath = main.params['DB']['portEventResultPath']
720 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
721 localTime = time.strftime('%x %X')
722 localTime = localTime.replace('/', '')
723 localTime = localTime.replace(' ', '_')
724 localTime = localTime.replace(':', '')
725
726 if debugMode == 'on':
727 main.ONOS1.tsharkPcap('eth0', '/tmp/port_lat_pcap_' + localTime)
728
729 upThresholdStr = main.params['TEST']['portUpThreshold']
730 downThresholdStr = main.params['TEST']['portDownThreshold']
731 upThresholdObj = upThresholdStr.split(',')
732 downThresholdObj = downThresholdStr.split(',')
733 upThresholdMin = int(upThresholdObj[0])
734 upThresholdMax = int(upThresholdObj[1])
735 downThresholdMin = int(downThresholdObj[0])
736 downThresholdMax = int(downThresholdObj[1])
737
738 interfaceConfig = 's1-eth1'
739 main.log.report('Port enable / disable latency')
740 main.log.report('Simulated by ifconfig up / down')
741 main.log.report('Total iterations of test: ' + str(numIter))
742 main.step('Assign switches s1 and s2 to controller 1')
743
744 main.Mininet1.assignSwController(sw='1',
745 ip1=ONOS1Ip, port1=defaultSwPort)
746 main.Mininet1.assignSwController(sw='2',
747 ip1=ONOS1Ip, port1=defaultSwPort)
748
749 time.sleep(15)
750
751 portUpDeviceToOfpList = []
752 portUpGraphToOfpList = []
753 portDownDeviceToOfpList = []
754 portDownGraphToOfpList = []
755
756 portUpDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
757 portUpGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
758 portUpLinkLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
759 portDownDevNodeIter = numpy.zeros((clusterCount, int(numIter)))
760 portDownGraphNodeIter = numpy.zeros((clusterCount, int(numIter)))
761 portDownLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
762 portUpLinkNodeIter = numpy.zeros((clusterCount, int(numIter)))
763
764 for i in range(0, int(numIter)):
765 main.step('Starting wireshark capture for port status down')
766 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortDown)
767 time.sleep(5)
768 main.step('Disable port: ' + interfaceConfig)
769 main.Mininet1.handle.sendline('sh ifconfig ' +
770 interfaceConfig + ' down')
771 main.Mininet1.handle.expect('mininet>')
772 time.sleep(3)
773 main.ONOS1.tsharkStop()
774 os.system('scp ' + ONOSUser + '@' + ONOS1Ip + ':' +
775 tsharkPortDown + ' /tmp/')
776 fPortDown = open(tsharkPortDown, 'r')
777 fLine = fPortDown.readline()
778 objDown = fLine.split(' ')
779 if len(fLine) > 0:
780 timestampBeginPtDown = int(float(objDown[1]) * 1000)
781 if timestampBeginPtDown < 1400000000000:
782 timestampBeginPtDown = int(float(objDown[2]) * 1000)
783 main.log.info('Port down begin timestamp: ' +
784 str(timestampBeginPtDown))
785 else:
786 main.log.info('Tshark output file returned unexpected' +
787 ' results: ' + str(objDown))
788 timestampBeginPtDown = 0
789 fPortDown.close()
jenkins8ba10ab2015-03-24 10:31:31 -0700790
791 """
792 # TODO: Refactor in progress
793
794 for node in range(0, clusterCount):
795 nodeNum = node+1
796 exec "metricsDown = main.ONOS%scli.topologyEventsMetrics"%str(nodeNum)
797 jsonStrDown = metricsDown()
798 jsonObj = json.loads(jsonStrDown)
799
800 graphTimestamp = jsonObj[graphTimestamp]['value']
801 deviceTimestamp = jsonObj[deviceTimestamp]['value']
802 linkTimestamp = jsonObj[linkTimestamp]['value']
803
804 ptDownGraphToOfp = int(graphTimestamp) - int(timestampBeginPtDown)
805 ptDownDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtDown)
806 ptDownLinkToOfp = int(linkTimestamp) - int(timestampBeginPtDown)
807
808 if ptDownGraphToOfp > downThresholdMin and\
809 ptDownGraphToOfp < downThresholdMax and i > iterIgnore:
810 portDownGraphNodeIter[node][i] = ptDownGraphToOfp
811 main.log.info("ONOS "+str(nodeNum)+
812 " port down graph-to-ofp: "+
813 str(ptDownGraphToOfp) + " ms")
814 else:
815 main.log.info("ONOS "+str(nodeNum)+
816 " port down graph-to-ofp ignored"+
817 " due to excess in threshold or premature iteration")
818
819 if ptDownDeviceToOfp > downThresholdMin and\
820 ptDownDeviceToOfp < downThresholdMax and i > iterIgnore:
821 portDownDeviceNodeIter[node][i] = ptDownDeviceToOfp
822 main.log.info("ONOS "+str(nodeNum)+
823 " port down device-to-ofp: "+
824 str(ptDownDeviceToOfp) + " ms")
825 else:
826 main.log.info("ONOS "+str(nodeNum)+
827 " port down device-to-ofp ignored"+
828 " due to excess in threshold or premature iteration")
829
830 if ptDownLinkToOfp > downThresholdMin and\
831 ptDownLinkToOfp < downThresholdMax and i > iterIgnore:
832 portDownLinkNodeIter[node][i] = ptDownLinkToOfp
833 main.log.info("ONOS "+str(nodeNum)+
834 " port down link-to-ofp: "+
835 str(ptDownLinkToOfp) + " ms")
836 else:
837 main.log.info("ONOS "+str(nodeNum)+
838 " port down link-to-ofp ignored"+
839 " due to excess in threshold or premature iteration")
840 """
841 # *************************
842
jenkins7ead5a82015-03-13 10:28:21 -0700843 main.step('Obtain t1 by metrics call')
844
845 jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
846 jsonObj1 = json.loads(jsonStrUp1)
847 graphTimestamp1 = jsonObj1[graphTimestamp]['value']
848 deviceTimestamp1 = jsonObj1[deviceTimestamp]['value']
849 linkTimestamp1 = jsonObj1[linkTimestamp]['value']
850 ptDownGraphToOfp1 = int(graphTimestamp1) - int(timestampBeginPtDown)
851 ptDownDeviceToOfp1 = int(deviceTimestamp1) - int(timestampBeginPtDown)
852 ptDownLinkToOfp1 = int(linkTimestamp1) - int(timestampBeginPtDown)
jenkins8ba10ab2015-03-24 10:31:31 -0700853
jenkins7ead5a82015-03-13 10:28:21 -0700854 if ptDownGraphToOfp1 > downThresholdMin and\
855 ptDownGraphToOfp1 < downThresholdMax and i > iterIgnore:
856 portDownGraphNodeIter[0][i] = ptDownGraphToOfp1
857 main.log.info('ONOS1 iter' + str(i) +
858 ' port down graph-to-ofp: ' +
859 str(ptDownGraphToOfp1) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -0700860
jenkins7ead5a82015-03-13 10:28:21 -0700861 if ptDownDeviceToOfp1 > downThresholdMin and \
862 ptDownDeviceToOfp1 < downThresholdMax and i > iterIgnore:
863 portDownDevNodeIter[0][i] = ptDownDeviceToOfp1
864 main.log.info('ONOS1 iter' + str(i) +
865 ' port down device-to-ofp: ' +
866 str(ptDownDeviceToOfp1) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -0700867 if ptDownLinkToOfp1 > downThresholdMin and\
868 ptDownLinkToOfp1 < downThresholdMax and i > iterIgnore:
869 portDownLinkNodeIter[0][i] = ptDownLinkToOfp1
870 main.log.info('ONOS1 iter' + str(i) +
871 ' port down link-to-ofp: ' +
872 str(ptDownLinkToOfp1) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -0700873
jenkins7ead5a82015-03-13 10:28:21 -0700874 if clusterCount >= 3:
875 jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
876 jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
877 jsonObj2 = json.loads(jsonStrUp2)
878 jsonObj3 = json.loads(jsonStrUp3)
879 graphTimestamp2 = jsonObj2[graphTimestamp]['value']
880 graphTimestamp3 = jsonObj3[graphTimestamp]['value']
881 deviceTimestamp2 = jsonObj2[deviceTimestamp]['value']
882 deviceTimestamp3 = jsonObj3[deviceTimestamp]['value']
883 linkTimestamp2 = jsonObj2[linkTimestamp]['value']
884 linkTimestamp3 = jsonObj3[linkTimestamp]['value']
885 ptDownGraphToOfp2 = int(graphTimestamp2) - int(timestampBeginPtDown)
886 ptDownGraphToOfp3 = int(graphTimestamp3) - int(timestampBeginPtDown)
887 ptDownDeviceToOfp2 = int(deviceTimestamp2) - int(timestampBeginPtDown)
888 ptDownDeviceToOfp3 = int(deviceTimestamp3) - int(timestampBeginPtDown)
889 ptDownLinkToOfp2 = int(linkTimestamp2) - int(timestampBeginPtDown)
890 ptDownLinkToOfp3 = int(linkTimestamp3) - int(timestampBeginPtDown)
891 if ptDownGraphToOfp2 > downThresholdMin and\
892 ptDownGraphToOfp2 < downThresholdMax and i > iterIgnore:
893 portDownGraphNodeIter[1][i] = ptDownGraphToOfp2
894 main.log.info('ONOS2 iter' + str(i) +
895 ' graph-to-ofp: ' +
896 str(ptDownGraphToOfp2) + ' ms')
897 if ptDownDeviceToOfp2 > downThresholdMin and \
898 ptDownDeviceToOfp2 < downThresholdMax and i > iterIgnore:
899 portDownDevNodeIter[1][i] = ptDownDeviceToOfp2
900 main.log.info('ONOS2 iter' + str(i) +
901 ' device-to-ofp: ' +
902 str(ptDownDeviceToOfp2) + ' ms')
903 if ptDownLinkToOfp2 > downThresholdMin and\
904 ptDownLinkToOfp2 < downThresholdMax and i > iterIgnore:
905 portDownLinkNodeIter[1][i] = ptDownLinkToOfp2
906 main.log.info('ONOS2 iter' + str(i) +
907 ' link-to-ofp: ' +
908 str(ptDownLinkToOfp2) + ' ms')
909 if ptDownGraphToOfp3 > downThresholdMin and\
910 ptDownGraphToOfp3 < downThresholdMax and i > iterIgnore:
911 portDownGraphNodeIter[2][i] = ptDownGraphToOfp3
912 main.log.info('ONOS3 iter' + str(i) +
913 ' graph-to-ofp: ' +
914 str(ptDownGraphToOfp3) + ' ms')
915 if ptDownDeviceToOfp3 > downThresholdMin and\
916 ptDownDeviceToOfp3 < downThresholdMax and i > iterIgnore:
917 portDownDevNodeIter[2][i] = ptDownDeviceToOfp3
918 main.log.info('ONOS3 iter' + str(i) +
919 ' device-to-ofp: ' +
920 str(ptDownDeviceToOfp3) + ' ms')
921 if ptDownLinkToOfp3 > downThresholdMin and\
922 ptDownLinkToOfp3 < downThresholdMax and i > iterIgnore:
923 portDownLinkNodeIter[2][i] = ptDownLinkToOfp3
924 main.log.info('ONOS3 iter' + str(i) +
925 ' link-to-ofp: ' +
926 str(ptDownLinkToOfp3) + ' ms')
927 if clusterCount >= 5:
928 jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
929 jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
930 jsonObj4 = json.loads(jsonStrUp4)
931 jsonObj5 = json.loads(jsonStrUp5)
932 graphTimestamp4 = jsonObj4[graphTimestamp]['value']
933 graphTimestamp5 = jsonObj5[graphTimestamp]['value']
934 deviceTimestamp4 = jsonObj4[deviceTimestamp]['value']
935 deviceTimestamp5 = jsonObj5[deviceTimestamp]['value']
936 linkTimestamp4 = jsonObj4[linkTimestamp]['value']
937 linkTimestamp5 = jsonObj5[linkTimestamp]['value']
938 ptDownGraphToOfp4 = int(graphTimestamp4) - int(timestampBeginPtDown)
939 ptDownGraphToOfp5 = int(graphTimestamp5) - int(timestampBeginPtDown)
940 ptDownDeviceToOfp4 = int(deviceTimestamp4) - int(timestampBeginPtDown)
941 ptDownDeviceToOfp5 = int(deviceTimestamp5) - int(timestampBeginPtDown)
942 ptDownLinkToOfp4 = int(linkTimestamp4) - int(timestampBeginPtDown)
943 ptDownLinkToOfp5 = int(linkTimestamp5) - int(timestampBeginPtDown)
944 if ptDownGraphToOfp4 > downThresholdMin and \
945 ptDownGraphToOfp4 < downThresholdMax and i > iterIgnore:
946 portDownGraphNodeIter[3][i] = ptDownGraphToOfp4
947 main.log.info('ONOS4 iter' + str(i) +
948 ' graph-to-ofp: ' +
949 str(ptDownGraphToOfp4) + ' ms')
950 if ptDownDeviceToOfp4 > downThresholdMin and\
951 ptDownDeviceToOfp4 < downThresholdMax and i > iterIgnore:
952 portDownDevNodeIter[3][i] = ptDownDeviceToOfp4
953 main.log.info('ONOS4 iter' + str(i) +
954 ' device-to-ofp: ' +
955 str(ptDownDeviceToOfp4) + ' ms')
956 if ptDownLinkToOfp4 > downThresholdMin and\
957 ptDownLinkToOfp4 < downThresholdMax and i > iterIgnore:
958 portDownLinkNodeIter[3][i] = ptDownLinkToOfp4
959 main.log.info('ONOS4 iter' + str(i) +
960 ' link-to-ofp: ' +
961 str(ptDownLinkToOfp4) + ' ms')
962 if ptDownGraphToOfp5 > downThresholdMin and\
963 ptDownGraphToOfp5 < downThresholdMax and i > iterIgnore:
964 portDownGraphNodeIter[4][i] = ptDownGraphToOfp5
965 main.log.info('ONOS5 iter' + str(i) +
966 ' graph-to-ofp: ' +
967 str(ptDownGraphToOfp5) + ' ms')
968 if ptDownDeviceToOfp5 > downThresholdMin and\
969 ptDownDeviceToOfp5 < downThresholdMax and i > iterIgnore:
970 portDownDevNodeIter[4][i] = ptDownDeviceToOfp5
971 main.log.info('ONOS5 iter' + str(i) +
972 ' device-to-ofp: ' +
973 str(ptDownDeviceToOfp5) + ' ms')
974 if ptDownLinkToOfp5 > downThresholdMin and\
975 ptDownLinkToOfp5 < downThresholdMax and i > iterIgnore:
976 portDownLinkNodeIter[4][i] = ptDownLinkToOfp5
977 main.log.info('ONOS5 iter' + str(i) +
978 ' link-to-ofp: ' +
979 str(ptDownLinkToOfp5) + ' ms')
980 if clusterCount >= 7:
981 jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
982 jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
983 jsonObj6 = json.loads(jsonStrUp6)
984 jsonObj7 = json.loads(jsonStrUp7)
985 graphTimestamp6 = jsonObj6[graphTimestamp]['value']
986 graphTimestamp7 = jsonObj7[graphTimestamp]['value']
987 deviceTimestamp6 = jsonObj6[deviceTimestamp]['value']
988 deviceTimestamp7 = jsonObj7[deviceTimestamp]['value']
989 linkTimestamp6 = jsonObj6[linkTimestamp]['value']
990 linkTimestamp7 = jsonObj7[linkTimestamp]['value']
991 ptDownGraphToOfp6 = int(graphTimestamp6) - int(timestampBeginPtDown)
992 ptDownGraphToOfp7 = int(graphTimestamp7) - int(timestampBeginPtDown)
993 ptDownDeviceToOfp6 = int(deviceTimestamp6) - int(timestampBeginPtDown)
994 ptDownDeviceToOfp7 = int(deviceTimestamp7) - int(timestampBeginPtDown)
995 ptDownLinkToOfp6 = int(linkTimestamp6) - int(timestampBeginPtDown)
996 ptDownLinkToOfp7 = int(linkTimestamp7) - int(timestampBeginPtDown)
997 if ptDownGraphToOfp6 > downThresholdMin and\
998 ptDownGraphToOfp6 < downThresholdMax and i > iterIgnore:
999 portDownGraphNodeIter[5][i] = ptDownGraphToOfp6
1000 main.log.info('ONOS6 iter' + str(i) +
1001 ' graph-to-ofp: ' +
1002 str(ptDownGraphToOfp6) + ' ms')
1003 if ptDownDeviceToOfp6 > downThresholdMin and\
1004 ptDownDeviceToOfp6 < downThresholdMax and i > iterIgnore:
1005 portDownDevNodeIter[5][i] = ptDownDeviceToOfp6
1006 main.log.info('ONOS6 iter' + str(i) +
1007 ' device-to-ofp: ' +
1008 str(ptDownDeviceToOfp6) + ' ms')
1009 if ptDownLinkToOfp6 > downThresholdMin and\
1010 ptDownLinkToOfp6 < downThresholdMax and i > iterIgnore:
1011 portDownLinkNodeIter[5][i] = ptDownLinkToOfp6
1012 main.log.info('ONOS6 iter' + str(i) +
1013 ' link-to-ofp: ' +
1014 str(ptDownLinkToOfp6) + ' ms')
1015 if ptDownGraphToOfp7 > downThresholdMin and\
1016 ptDownGraphToOfp7 < downThresholdMax and i > iterIgnore:
1017 portDownGraphNodeIter[6][i] = ptDownGraphToOfp7
1018 main.log.info('ONOS7 iter' + str(i) +
1019 ' graph-to-ofp: ' +
1020 str(ptDownGraphToOfp7) + ' ms')
1021 if ptDownDeviceToOfp7 > downThresholdMin and\
1022 ptDownDeviceToOfp7 < downThresholdMax and i > iterIgnore:
1023 portDownDevNodeIter[6][i] = ptDownDeviceToOfp7
1024 main.log.info('ONOS7 iter' + str(i) +
1025 ' device-to-ofp: ' +
1026 str(ptDownDeviceToOfp7) + ' ms')
1027 if ptDownLinkToOfp7 > downThresholdMin and\
1028 ptDownLinkToOfp7 < downThresholdMax and i > iterIgnore:
1029 portDownLinkNodeIter[6][i] = ptDownLinkToOfp7
1030 main.log.info('ONOS7 iter' + str(i) +
1031 ' link-to-ofp: ' +
1032 str(ptDownLinkToOfp7) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001033
jenkins7ead5a82015-03-13 10:28:21 -07001034 time.sleep(3)
1035
1036 main.step('Starting wireshark capture for port status up')
1037 main.ONOS1.tsharkGrep(tsharkPortStatus, tsharkPortUp)
1038
1039 time.sleep(5)
1040 main.step('Enable port and obtain timestamp')
1041 main.Mininet1.handle.sendline('sh ifconfig ' + interfaceConfig + ' up')
1042 main.Mininet1.handle.expect('mininet>')
1043
1044 time.sleep(5)
1045 main.ONOS1.tsharkStop()
1046
1047 time.sleep(3)
1048 os.system('scp ' + ONOSUser + '@' +
1049 ONOS1Ip + ':' + tsharkPortUp + ' /tmp/')
1050
1051 fPortUp = open(tsharkPortUp, 'r')
1052 fLine = fPortUp.readline()
1053 objUp = fLine.split(' ')
1054 if len(fLine) > 0:
1055 timestampBeginPtUp = int(float(objUp[1]) * 1000)
1056 if timestampBeginPtUp < 1400000000000:
1057 timestampBeginPtUp = int(float(objUp[2]) * 1000)
1058 main.log.info('Port up begin timestamp: ' + str(timestampBeginPtUp))
1059 else:
1060 main.log.info('Tshark output file returned unexpected' + ' results.')
1061 timestampBeginPtUp = 0
1062 fPortUp.close()
jenkins8ba10ab2015-03-24 10:31:31 -07001063 """
1064 # TODO: Refactoring in progress
1065
1066 for node in range(0, clusterCount):
1067 nodeNum = node+1
1068 exec "metricsUp = main.ONOS%scli.topologyEventsMetrics"%str(nodeNum)
1069 jsonStrUp = metricsUp()
1070 jsonObj = json.loads(jsonStrUp)
1071
1072 print jsonObj
1073
1074 graphTimestamp = jsonObj[graphTimestamp]['value']
1075 deviceTimestamp = jsonObj[deviceTimestamp]['value']
1076 linkTimestamp = jsonObj[linkTimestamp]['value']
1077
1078 ptUpGraphToOfp = int(graphTimestamp) - int(timestampBeginPtUp)
1079 ptUpDeviceToOfp = int(deviceTimestamp) - int(timestampBeginPtUp)
1080 ptUpLinkToOfp = int(linkTimestamp) - int(timestampBeginPtUp)
1081
1082 if ptUpGraphToOfp > upThresholdMin and\
1083 ptUpGraphToOfp < upThresholdMax and i > iterIgnore:
1084 portUpGraphNodeIter[node][i] = ptUpGraphToOfp
1085 main.log.info("ONOS "+str(nodeNum)+
1086 " port up graph-to-ofp: "+
1087 str(ptUpGraphToOfp) + " ms")
1088 else:
1089 main.log.info("ONOS "+str(nodeNum)+
1090 " port up graph-to-ofp ignored"+
1091 " due to excess in threshold or premature iteration")
1092
1093 if ptUpDeviceToOfp > upThresholdMin and\
1094 ptUpDeviceToOfp < upThresholdMax and i > iterIgnore:
1095 portUpDeviceNodeIter[node][i] = ptUpDeviceToOfp
1096 main.log.info("ONOS "+str(nodeNum)+
1097 " port up device-to-ofp: "+
1098 str(ptUpDeviceToOfp) + " ms")
1099 else:
1100 main.log.info("ONOS "+str(nodeNum)+
1101 " port up device-to-ofp ignored"+
1102 " due to excess in threshold or premature iteration")
1103
1104 if ptUpLinkToOfp > upThresholdMin and\
1105 ptUpLinkToOfp < upThresholdMax and i > iterIgnore:
1106 portUpLinkNodeIter[node][i] = ptUpLinkToOfp
1107 main.log.info("ONOS "+str(nodeNum)+
1108 " port up link-to-ofp: "+
1109 str(ptUpLinkToOfp) + " ms")
1110 else:
1111 main.log.info("ONOS "+str(nodeNum)+
1112 " port up link-to-ofp ignored"+
1113 " due to excess in threshold or premature iteration")
1114
1115 """
1116
1117 # *****************************
1118
jenkins7ead5a82015-03-13 10:28:21 -07001119 main.step('Obtain t1 by REST call')
1120 jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
1121 jsonObj1 = json.loads(jsonStrUp1)
1122 graphTimestamp1 = jsonObj1[graphTimestamp]['value']
1123 deviceTimestamp1 = jsonObj1[deviceTimestamp]['value']
1124 linkTimestamp1 = jsonObj1[linkTimestamp]['value']
1125 ptUpGraphToOfp1 = int(graphTimestamp1) - int(timestampBeginPtUp)
1126 ptUpDeviceToOfp1 = int(deviceTimestamp1) - int(timestampBeginPtUp)
1127 ptUpLinkToOfp1 = int(linkTimestamp1) - int(timestampBeginPtUp)
1128 if ptUpGraphToOfp1 > upThresholdMin and\
1129 ptUpGraphToOfp1 < upThresholdMax and i > iterIgnore:
1130 portUpGraphNodeIter[0][i] = ptUpGraphToOfp1
1131 main.log.info('ONOS1 iter' + str(i) +
1132 ' port up graph-to-ofp: ' +
1133 str(ptUpGraphToOfp1) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001134 if ptUpDeviceToOfp1 > upThresholdMin and \
1135 ptUpDeviceToOfp1 < upThresholdMax and i > iterIgnore:
1136 portUpDevNodeIter[0][i] = ptUpDeviceToOfp1
1137 main.log.info('ONOS1 iter' + str(i) +
1138 ' port up device-to-ofp: ' +
1139 str(ptUpDeviceToOfp1) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001140 if ptUpLinkToOfp1 > downThresholdMin and\
1141 ptUpLinkToOfp1 < downThresholdMax and i > iterIgnore:
1142 portUpLinkNodeIter[0][i] = ptUpLinkToOfp1
1143 main.log.info('ONOS1 iter' + str(i) +
1144 ' link-to-ofp: ' +
1145 str(ptUpLinkToOfp1) + ' ms')
1146 if clusterCount >= 3:
1147 jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
1148 jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
1149 jsonObj2 = json.loads(jsonStrUp2)
1150 jsonObj3 = json.loads(jsonStrUp3)
1151 graphTimestamp2 = jsonObj2[graphTimestamp]['value']
1152 graphTimestamp3 = jsonObj3[graphTimestamp]['value']
1153 deviceTimestamp2 = jsonObj2[deviceTimestamp]['value']
1154 deviceTimestamp3 = jsonObj3[deviceTimestamp]['value']
1155 linkTimestamp2 = jsonObj2[linkTimestamp]['value']
1156 linkTimestamp3 = jsonObj3[linkTimestamp]['value']
1157 ptUpGraphToOfp2 = int(graphTimestamp2) - int(timestampBeginPtUp)
1158 ptUpGraphToOfp3 = int(graphTimestamp3) - int(timestampBeginPtUp)
1159 ptUpDeviceToOfp2 = int(deviceTimestamp2) - int(timestampBeginPtUp)
1160 ptUpDeviceToOfp3 = int(deviceTimestamp3) - int(timestampBeginPtUp)
1161 ptUpLinkToOfp2 = int(linkTimestamp2) - int(timestampBeginPtUp)
1162 ptUpLinkToOfp3 = int(linkTimestamp3) - int(timestampBeginPtUp)
1163 if ptUpGraphToOfp2 > upThresholdMin and\
1164 ptUpGraphToOfp2 < upThresholdMax and i > iterIgnore:
1165 portUpGraphNodeIter[1][i] = ptUpGraphToOfp2
1166 main.log.info('ONOS2 iter' + str(i) +
1167 ' port up graph-to-ofp: ' +
1168 str(ptUpGraphToOfp2) + ' ms')
1169 if ptUpDeviceToOfp2 > upThresholdMin and\
1170 ptUpDeviceToOfp2 < upThresholdMax and i > iterIgnore:
1171 portUpDevNodeIter[1][i] = ptUpDeviceToOfp2
1172 main.log.info('ONOS2 iter' + str(i) +
1173 ' port up device-to-ofp: ' +
1174 str(ptUpDeviceToOfp2) + ' ms')
1175 if ptUpLinkToOfp2 > downThresholdMin and\
1176 ptUpLinkToOfp2 < downThresholdMax and i > iterIgnore:
1177 portUpLinkNodeIter[1][i] = ptUpLinkToOfp2
1178 main.log.info('ONOS2 iter' + str(i) +
1179 ' port up link-to-ofp: ' +
1180 str(ptUpLinkToOfp2) + ' ms')
1181 if ptUpGraphToOfp3 > upThresholdMin and\
1182 ptUpGraphToOfp3 < upThresholdMax and i > iterIgnore:
1183 portUpGraphNodeIter[2][i] = ptUpGraphToOfp3
1184 main.log.info('ONOS3 iter' + str(i) +
1185 ' port up graph-to-ofp: ' +
1186 str(ptUpGraphToOfp3) + ' ms')
1187 if ptUpDeviceToOfp3 > upThresholdMin and\
1188 ptUpDeviceToOfp3 < upThresholdMax and i > iterIgnore:
1189 portUpDevNodeIter[2][i] = ptUpDeviceToOfp3
1190 main.log.info('ONOS3 iter' + str(i) +
1191 ' port up device-to-ofp: ' +
1192 str(ptUpDeviceToOfp3) + ' ms')
1193 if ptUpLinkToOfp3 > downThresholdMin and\
1194 ptUpLinkToOfp3 < downThresholdMax and i > iterIgnore:
1195 portUpLinkNodeIter[2][i] = ptUpLinkToOfp3
1196 main.log.info('ONOS3 iter' + str(i) +
1197 ' port up link-to-ofp: ' +
1198 str(ptUpLinkToOfp3) + ' ms')
1199 if clusterCount >= 5:
1200 jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
1201 jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
1202 jsonObj4 = json.loads(jsonStrUp4)
1203 jsonObj5 = json.loads(jsonStrUp5)
1204 graphTimestamp4 = jsonObj4[graphTimestamp]['value']
1205 graphTimestamp5 = jsonObj5[graphTimestamp]['value']
1206 deviceTimestamp4 = jsonObj4[deviceTimestamp]['value']
1207 deviceTimestamp5 = jsonObj5[deviceTimestamp]['value']
1208 linkTimestamp4 = jsonObj4[linkTimestamp]['value']
1209 linkTimestamp5 = jsonObj5[linkTimestamp]['value']
1210 ptUpGraphToOfp4 = int(graphTimestamp4) - int(timestampBeginPtUp)
1211 ptUpGraphToOfp5 = int(graphTimestamp5) - int(timestampBeginPtUp)
1212 ptUpDeviceToOfp4 = int(deviceTimestamp4) - int(timestampBeginPtUp)
1213 ptUpDeviceToOfp5 = int(deviceTimestamp5) - int(timestampBeginPtUp)
1214 ptUpLinkToOfp4 = int(linkTimestamp4) - int(timestampBeginPtUp)
1215 ptUpLinkToOfp5 = int(linkTimestamp5) - int(timestampBeginPtUp)
1216 if ptUpGraphToOfp4 > upThresholdMin and\
1217 ptUpGraphToOfp4 < upThresholdMax and i > iterIgnore:
1218 portUpGraphNodeIter[3][i] = ptUpGraphToOfp4
1219 main.log.info('ONOS4 iter' + str(i) +
1220 ' port up graph-to-ofp: ' +
1221 str(ptUpGraphToOfp4) + ' ms')
1222 if ptUpDeviceToOfp4 > upThresholdMin and\
1223 ptUpDeviceToOfp4 < upThresholdMax and i > iterIgnore:
1224 portUpDevNodeIter[3][i] = ptUpDeviceToOfp4
1225 main.log.info('ONOS4 iter' + str(i) +
1226 ' port up device-to-ofp: ' +
1227 str(ptUpDeviceToOfp4) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001228 if ptUpLinkToOfp4 > downThresholdMin and\
1229 ptUpLinkToOfp4 < downThresholdMax and i > iterIgnore:
1230 portUpLinkNodeIter[3][i] = ptUpLinkToOfp4
1231 main.log.info('ONOS4 iter' + str(i) +
1232 ' port up link-to-ofp: ' +
1233 str(ptUpLinkToOfp4) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001234 if ptUpGraphToOfp5 > upThresholdMin and\
1235 ptUpGraphToOfp5 < upThresholdMax and i > iterIgnore:
1236 portUpGraphNodeIter[4][i] = ptUpGraphToOfp5
jenkins8ba10ab2015-03-24 10:31:31 -07001237 main.log.info('ONOS5 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -07001238 ' port up graph-to-ofp: ' +
1239 str(ptUpGraphToOfp5) + ' ms')
1240 if ptUpDeviceToOfp5 > upThresholdMin and \
1241 ptUpDeviceToOfp5 < upThresholdMax and i > iterIgnore:
1242 portUpDevNodeIter[4][i] = ptUpDeviceToOfp5
1243 main.log.info('ONOS5 iter' + str(i) +
1244 ' port up device-to-ofp: ' +
1245 str(ptUpDeviceToOfp5) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001246 if ptUpLinkToOfp5 > downThresholdMin and\
1247 ptUpLinkToOfp5 < downThresholdMax and i > iterIgnore:
1248 portUpLinkNodeIter[4][i] = ptUpLinkToOfp5
1249 main.log.info('ONOS5 iter' + str(i) +
1250 ' port up link-to-ofp: ' +
1251 str(ptUpLinkToOfp5) + ' ms')
1252
jenkins7ead5a82015-03-13 10:28:21 -07001253 if clusterCount >= 7:
1254 jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
1255 jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
1256 jsonObj6 = json.loads(jsonStrUp6)
1257 jsonObj7 = json.loads(jsonStrUp7)
1258 graphTimestamp6 = jsonObj6[graphTimestamp]['value']
1259 graphTimestamp7 = jsonObj7[graphTimestamp]['value']
1260 deviceTimestamp6 = jsonObj6[deviceTimestamp]['value']
1261 deviceTimestamp7 = jsonObj7[deviceTimestamp]['value']
jenkins8ba10ab2015-03-24 10:31:31 -07001262 linkTimestamp6 = jsonObj6[linkTimestamp]['value']
1263 linkTimestamp7 = jsonObj7[linkTimestamp]['value']
jenkins7ead5a82015-03-13 10:28:21 -07001264 ptUpGraphToOfp6 = int(graphTimestamp6) - int(timestampBeginPtUp)
1265 ptUpGraphToOfp7 = int(graphTimestamp7) - int(timestampBeginPtUp)
1266 ptUpDeviceToOfp6 = int(deviceTimestamp6) - int(timestampBeginPtUp)
1267 ptUpDeviceToOfp7 = int(deviceTimestamp7) - int(timestampBeginPtUp)
jenkins8ba10ab2015-03-24 10:31:31 -07001268 ptUpLinkToOfp6 = int(linkTimestamp6) - int(timestampBeginPtUp)
1269 ptUpLinkToOfp7 = int(linkTimestamp7) - int(timestampBeginPtUp)
jenkins7ead5a82015-03-13 10:28:21 -07001270 if ptUpGraphToOfp6 > upThresholdMin and\
1271 ptUpGraphToOfp6 < upThresholdMax and i > iterIgnore:
1272 portUpGraphNodeIter[5][i] = ptUpGraphToOfp6
jenkins8ba10ab2015-03-24 10:31:31 -07001273 main.log.info('ONOS6 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -07001274 ' port up graph-to-ofp: ' +
1275 str(ptUpGraphToOfp6) + ' ms')
1276 if ptUpDeviceToOfp6 > upThresholdMin and\
1277 ptUpDeviceToOfp6 < upThresholdMax and i > iterIgnore:
1278 portUpDevNodeIter[5][i] = ptUpDeviceToOfp6
jenkins8ba10ab2015-03-24 10:31:31 -07001279 main.log.info('ONOS6 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -07001280 ' port up device-to-ofp: ' +
1281 str(ptUpDeviceToOfp6) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001282 if ptUpLinkToOfp6 > downThresholdMin and\
1283 ptUpLinkToOfp6 < downThresholdMax and i > iterIgnore:
1284 portUpLinkNodeIter[5][i] = ptUpLinkToOfp6
1285 main.log.info('ONOS6 iter' + str(i) +
1286 ' port up link-to-ofp: ' +
1287 str(ptUpLinkToOfp6) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001288 if ptUpGraphToOfp7 > upThresholdMin and \
1289 ptUpGraphToOfp7 < upThresholdMax and i > iterIgnore:
1290 portUpGraphNodeIter[6][i] = ptUpGraphToOfp7
jenkins8ba10ab2015-03-24 10:31:31 -07001291 main.log.info('ONOS7 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -07001292 ' port up graph-to-ofp: ' +
1293 str(ptUpGraphToOfp7) + ' ms')
1294 if ptUpDeviceToOfp7 > upThresholdMin and\
1295 ptUpDeviceToOfp7 < upThresholdMax and i > iterIgnore:
1296 portUpDevNodeIter[6][i] = ptUpDeviceToOfp7
jenkins8ba10ab2015-03-24 10:31:31 -07001297 main.log.info('ONOS7 iter' + str(i) +
jenkins7ead5a82015-03-13 10:28:21 -07001298 ' port up device-to-ofp: ' +
1299 str(ptUpDeviceToOfp7) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001300 if ptUpLinkToOfp7 > downThresholdMin and\
1301 ptUpLinkToOfp7 < downThresholdMax and i > iterIgnore:
1302 portUpLinkNodeIter[6][i] = ptUpLinkToOfp7
1303 main.log.info('ONOS7 iter' + str(i) +
1304 ' port up link-to-ofp: ' +
1305 str(ptUpLinkToOfp7) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001306
1307 dbCmdList = []
1308 for node in range(0, clusterCount):
1309 portUpDevList = []
1310 portUpGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001311 portUpLinkList = []
jenkins7ead5a82015-03-13 10:28:21 -07001312 portDownDevList = []
1313 portDownGraphList = []
jenkins8ba10ab2015-03-24 10:31:31 -07001314 portDownLinkList = []
1315
jenkins7ead5a82015-03-13 10:28:21 -07001316 portUpDevAvg = 0
1317 portUpGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001318 portUpLinkAvg = 0
jenkins7ead5a82015-03-13 10:28:21 -07001319 portDownDevAvg = 0
1320 portDownGraphAvg = 0
jenkins8ba10ab2015-03-24 10:31:31 -07001321 portDownLinkAvg = 0
1322
jenkins7ead5a82015-03-13 10:28:21 -07001323 for item in portUpDevNodeIter[node]:
1324 if item > 0.0:
1325 portUpDevList.append(item)
1326
1327 for item in portUpGraphNodeIter[node]:
1328 if item > 0.0:
1329 portUpGraphList.append(item)
1330
jenkins8ba10ab2015-03-24 10:31:31 -07001331 for item in portUpLinkNodeIter[node]:
1332 if item > 0.0:
1333 portUpLinkList.append(item)
1334
jenkins7ead5a82015-03-13 10:28:21 -07001335 for item in portDownDevNodeIter[node]:
1336 if item > 0.0:
1337 portDownDevList.append(item)
1338
1339 for item in portDownGraphNodeIter[node]:
1340 if item > 0.0:
1341 portDownGraphList.append(item)
1342
jenkins8ba10ab2015-03-24 10:31:31 -07001343 for item in portDownLinkNodeIter[node]:
1344 if item > 0.0:
1345 portDownLinkList.append(item)
1346
jenkins7ead5a82015-03-13 10:28:21 -07001347 portUpDevAvg = round(numpy.mean(portUpDevList), 2)
1348 portUpGraphAvg = round(numpy.mean(portUpGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001349 portUpLinkAvg = round(numpy.mean(portUpLinkList), 2)
1350
jenkins7ead5a82015-03-13 10:28:21 -07001351 portDownDevAvg = round(numpy.mean(portDownDevList), 2)
1352 portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001353 portDownLinkAvg = round(numpy.mean(portDownLinkList), 2)
1354
jenkins7ead5a82015-03-13 10:28:21 -07001355 portUpStdDev = round(numpy.std(portUpGraphList), 2)
1356 portDownStdDev = round(numpy.std(portDownGraphList), 2)
jenkins8ba10ab2015-03-24 10:31:31 -07001357
jenkins7ead5a82015-03-13 10:28:21 -07001358 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
1359 main.log.report(' Port up ofp-to-device ' +
jenkins8ba10ab2015-03-24 10:31:31 -07001360 str(portUpDevAvg) + ' ms')
jenkins7ead5a82015-03-13 10:28:21 -07001361 main.log.report(' Port up ofp-to-graph ' +
1362 str(portUpGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001363 main.log.report(' Port up ofp-to-link ' +
1364 str(portUpLinkAvg) + ' ms')
1365
jenkins7ead5a82015-03-13 10:28:21 -07001366 main.log.report(' Port down ofp-to-device ' +
1367 str(round(portDownDevAvg, 2)) + ' ms')
1368 main.log.report(' Port down ofp-to-graph ' +
1369 str(portDownGraphAvg) + ' ms')
jenkins8ba10ab2015-03-24 10:31:31 -07001370 main.log.report(' Port down ofp-to-link ' +
1371 str(portDownLinkAvg) + ' ms')
1372
jenkins7ead5a82015-03-13 10:28:21 -07001373 dbCmdList.append("INSERT INTO port_latency_tests VALUES('" +
1374 timeToPost + "','port_latency_results'," + runNum +
1375 ',' + str(clusterCount) + ",'baremetal" + str(node + 1) +
1376 "'," + str(portUpGraphAvg) + ',' + str(portUpStdDev) +
1377 '' + str(portDownGraphAvg) + ',' + str(portDownStdDev) + ');')
1378
1379 fResult = open(resultPath, 'a')
1380 for line in dbCmdList:
1381 if line:
1382 fResult.write(line + '\n')
1383
1384 fResult.close()
1385 main.Mininet1.deleteSwController('s1')
1386 main.Mininet1.deleteSwController('s2')
1387 utilities.assert_equals(expect=main.TRUE,
1388 actual=assertion,
1389 onpass='Port discovery latency calculation successful',
1390 onfail='Port discovery test failed')
1391
1392 def CASE4(self, main):
1393 """
1394 Increase number of nodes and initiate CLI
1395
1396 With the most recent implementation, we need a method to
1397 ensure all ONOS nodes are killed, as well as redefine
1398 the cell files to ensure all nodes that will be used
1399 is in the cell file. Otherwise, exceptions will
1400 prohibit test from running successfully.
1401
1402 3/12/15
1403
1404 """
1405 global clusterCount
1406 import time
1407 import os
1408
1409 clusterCount += 2
1410
1411 benchIp = main.params[ 'BENCH' ][ 'ip' ]
1412 features = main.params[ 'ENV' ][ 'cellFeatures' ]
1413 cellName = main.params[ 'ENV' ][ 'cellName' ]
1414 mininetIp = main.params[ 'MN' ][ 'ip1' ]
1415
1416 main.log.report('Increasing cluster size to ' + str(clusterCount))
1417
1418 main.log.step( "Killing all ONOS processes before scale-out" )
1419
1420 for i in range( 1, 8 ):
1421 main.ONOSbench.onosDie(
1422 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1423 main.ONOSbench.onosUninstall(
1424 main.params[ 'CTRL' ][ 'ip'+str(i) ] )
1425
1426 main.step( "Creating scale-out cell file" )
1427 cellIp = []
1428 for node in range( 1, clusterCount + 1 ):
1429 cellIp.append( main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1430
1431 main.log.info( "Cell Ip list: " + str(cellIp) )
1432 main.ONOSbench.createCellFile( benchIp, cellName, mininetIp,
1433 str(features), *cellIp )
1434
1435 main.step( "Setting cell definition" )
1436 main.ONOSbench.setCell(cellName)
1437
1438 main.step( "Packaging cell definition" )
1439 main.ONOSbench.onosPackage()
1440
jenkins7ead5a82015-03-13 10:28:21 -07001441 for node in range( 1, clusterCount + 1 ):
jenkinsac38ab72015-03-13 11:24:10 -07001442 main.ONOSbench.onosInstall(
1443 node = main.params[ 'CTRL' ][ 'ip'+str(node) ])
1444
1445 time.sleep( 20 )
1446
jenkins7ead5a82015-03-13 10:28:21 -07001447 for node in range( 1, clusterCount + 1):
1448 for i in range( 2 ):
1449 isup = main.ONOSbench.isup(
1450 main.params[ 'CTRL' ][ 'ip'+str(node) ] )
1451 if isup:
1452 main.log.info( "ONOS "+str(node) + " is up\n")
1453 break
1454 if not isup:
1455 main.log.error( "ONOS "+str(node) + " did not start" )
jenkinsac38ab72015-03-13 11:24:10 -07001456
1457 for node in range( 1, clusterCount + 1):
1458 exec "a = main.ONOS%scli.startOnosCli" %str(node)
1459 a(main.params[ 'CTRL' ][ 'ip'+str(node) ])
1460