1
2
3
4
6
9
11 import sys
12 import re
13 import os
14 import time
15
16 global init
17 try:
18 if type(init) is not bool:
19 init = Fals
20 except NameError:
21 init = False
22
23
24 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
25 gitPull = main.params[ 'GIT' ][ 'autopull' ]
26 cellName = main.params[ 'ENV' ][ 'cellName' ]
27 Apps = main.params[ 'ENV' ][ 'cellApps' ]
28 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
29 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
30 main.maxNodes = int(main.params[ 'max' ])
31 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 homeDir = os.path.expanduser('~')
33 topoCfgFile = main.params['TEST']['topoConfigFile']
34 topoCfgName = main.params['TEST']['topoConfigName']
35 switchEventResultPath = main.params['DB']['switchEventResultPath']
36 skipMvn = main.params ['TEST']['mci']
37 testONpath = re.sub( "(tests)$", "bin", main.testDir )
38 user = main.params[ 'CTRL' ][ 'user' ]
39
40
41 if init == False:
42 init = True
43 global clusterCount
44 global scale
45 global commit
46 global timeToPost
47 global runNum
48 global jenkinsBuildNumber
49 global CLIs
50 CLIs = []
51 main.ONOSIp = []
52
53 for i in range( 1, 8 ):
54 CLIs.append( getattr( main, 'ONOS' + str( i ) + 'cli' ) )
55
56 timeToPost = time.strftime('%Y-%m-%d %H:%M:%S')
57 runNum = time.strftime('%d%H%M%S')
58
59 try:
60 jenkinsBuildNumber = str(os.environ['BUILD_NUMBER'])
61 main.log.report( 'Jenkins build number: ' + jenkinsBuildNumber )
62 except KeyError:
63 jenkinsBuildNumber = str(0)
64 main.log.info( 'Job is not run by jenkins. ' + 'Build number set to: ' + jenkinsBuildNumber)
65
66 clusterCount = 0
67 main.ONOSIp = main.ONOSbench.getOnosIps()
68
69 scale = (main.params[ 'SCALE' ]).split(",")
70 clusterCount = int(scale[0])
71
72
73 if skipMvn != "off":
74 mvnResult = main.ONOSbench.cleanInstall()
75
76
77 main.step( "Git checkout and pull " + checkoutBranch )
78 if gitPull == 'on':
79 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
80 pullResult = main.ONOSbench.gitPull()
81
82 else:
83 checkoutResult = main.TRUE
84 pullResult = main.TRUE
85 main.log.info( "Skipped git checkout and pull" )
86
87 main.log.step("Grabbing commit number")
88 commit = main.ONOSbench.getVersion()
89 commit = (commit.split(" "))[1]
90
91 temp = testONpath.replace("bin","") + "tests/SCPFswitchLat/Dependency/"
92 main.ONOSbench.copyMininetFile("topo-perf-1sw.py", temp, user, "localhost" )
93
94
95 main.step('Clearing previous DB log file')
96 print switchEventResultPath
97 fSwitchLog = open(switchEventResultPath, "w+")
98 fSwitchLog.write("")
99 fSwitchLog.close()
100
101
102
103 main.log.step("Adjusting scale")
104 clusterCount = int(scale[0])
105 scale.remove(scale[0])
106
107
108 main.log.step("Safety check, killing all ONOS processes before initiating enviornment setup")
109 for node in range(main.maxNodes):
110 main.ONOSbench.onosDie(main.ONOSIp[node])
111
112
113 main.log.step( "Cleaning Enviornment..." )
114 for i in range(main.maxNodes):
115 main.log.info(" Uninstalling ONOS " + str(i) )
116 main.ONOSbench.onosUninstall( main.ONOSIp[i] )
117 main.log.info("Sleep 10 second for uninstall to settle...")
118 time.sleep(10)
119 main.ONOSbench.handle.sendline(" ")
120 main.ONOSbench.handle.expect(":~")
121
122
123 main.log.info("Creating cell file")
124 cellIp = []
125 for node in range (clusterCount):
126 cellIp.append(main.ONOSIp[node])
127
128 main.ONOSbench.createCellFile(main.ONOSbench.ip_address, cellName, MN1Ip, str(Apps), cellIp)
129
130 main.step( "Set Cell" )
131 main.ONOSbench.setCell(cellName)
132
133 main.step( "Creating ONOS package" )
134 packageResult = main.ONOSbench.onosPackage()
135
136 main.step( "verify cells" )
137 verifyCellResult = main.ONOSbench.verifyCell()
138
139 main.step('Starting mininet topology ')
140 main.Mininet1.startNet()
141
142 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
143 for node in range(clusterCount):
144 main.log.info("Starting ONOS " + str(node) + " at IP: " + main.ONOSIp[node])
145 main.ONOSbench.onosInstall( node=main.ONOSIp[node])
146
147 for i in range(50):
148 time.sleep(15)
149 print "attempt " + str(i)
150 main.ONOSbench.handle.sendline("onos $OC1 summary")
151 main.ONOSbench.handle.expect(":~")
152 print main.ONOSbench.handle.before
153 if "nodes=" in main.ONOSbench.handle.before:
154 break
155
156 for node in range(clusterCount):
157 for i in range( 2 ):
158 isup = main.ONOSbench.isup( main.ONOSIp[node] )
159 if isup:
160 main.log.info("ONOS " + str(node) + " is up\n")
161 break
162 if not isup:
163 main.log.report( "ONOS " + str(node) + " didn't start!" )
164 main.log.info("Startup sequence complete")
165
166
167
168 main.step('Start onos cli')
169 for i in range(0,clusterCount):
170 cli1 = CLIs[i].startOnosCli(main.ONOSIp[i])
171
172 main.step( 'Configuring application parameters' )
173
174 configName = 'org.onosproject.net.topology.impl.DefaultTopologyProvider'
175 configParam = 'maxEvents 1'
176 main.ONOSbench.onosCfgSet( main.ONOSIp[0], configName, configParam )
177 configParam = 'maxBatchMs 0'
178 main.ONOSbench.onosCfgSet( main.ONOSIp[0], configName, configParam )
179 configParam = 'maxIdleMs 0'
180 main.ONOSbench.onosCfgSet( main.ONOSIp[0], configName, configParam )
181
183 print "Cluster size: " + str(clusterCount)
184 """
185 Assign s3 to ONOSbench and measure latency
186
187 There are 4 levels of latency measurements to this test:
188 1 ) End-to-end measurement: Complete end-to-end measurement
189 from TCP ( SYN/ACK ) handshake to Graph change
190 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
191 measurement from OFP Vendor message to Graph change
192 3 ) OFP-to-device measurement: 'ONOS processing without
193 graph change' snippet of measurement from OFP vendor
194 message to Device change timestamp
195 4 ) T0-to-device measurement: Measurement that includes
196 the switch handshake to devices timestamp without
197 the graph view change. ( TCP handshake -> Device
198 change )
199 """
200 import time
201 import subprocess
202 import json
203 import requests
204 import os
205 import numpy
206
207 ONOSUser = main.params['CTRL']['user']
208 numIter = main.params['TEST']['numIter']
209 iterIgnore = int(main.params['TEST']['iterIgnore'])
210
211 deviceTimestampKey = main.params['JSON']['deviceTimestamp']
212 graphTimestampKey = main.params['JSON']['graphTimestamp']
213
214 debugMode = main.params['TEST']['debugMode']
215 onosLog = main.params['TEST']['onosLogFile']
216 resultPath = main.params['DB']['switchEventResultPath']
217 thresholdStr = main.params['TEST']['singleSwThreshold']
218 thresholdObj = thresholdStr.split(',')
219 thresholdMin = int(thresholdObj[0])
220 thresholdMax = int(thresholdObj[1])
221
222
223
224
225 tsharkTcpString = main.params[ 'TSHARK' ][ 'tcpSynAck' ]
226 tsharkFeatureReply = main.params[ 'TSHARK' ][ 'featureReply' ]
227 tsharkRoleRequest = main.params[ 'TSHARK' ][ 'roleRequest' ]
228 tsharkOfString = main.params[ 'TSHARK' ][ 'ofpRoleReply' ]
229 tsharkFinAckSequence = main.params[ 'TSHARK' ][ 'finAckSequence' ]
230
231 tsharkOfOutput = '/tmp/tshark_of_topo.txt'
232 tsharkTcpOutput = '/tmp/tshark_tcp_topo.txt'
233 tsharkRoleOutput = '/tmp/tshark_role_request.txt'
234 tsharkFeatureOutput = '/tmp/tshark_feature_reply.txt'
235 tsharkFinAckOutput = '/tmp/tshark_fin_ack.txt'
236
237
238
239 tcpToFeatureLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
240
241 featureToRoleRequestLatNodeIter = numpy.zeros((clusterCount,
242 int(numIter)))
243
244 roleRequestToRoleReplyLatNodeIter = numpy.zeros((clusterCount,
245 int(numIter)))
246
247 roleReplyToDeviceLatNodeIter = numpy.zeros((clusterCount,
248 int(numIter)))
249
250 deviceToGraphLatNodeIter = numpy.zeros((clusterCount,
251 int(numIter)))
252 endToEndLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
253
254
255
256 finAckTransactionLatNodeIter = numpy.zeros((clusterCount,
257 int(numIter)))
258
259 ackToDeviceLatNodeIter = numpy.zeros((clusterCount,
260 int(numIter)))
261
262 deviceToGraphDiscLatNodeIter = numpy.zeros((clusterCount,
263 int(numIter)))
264 endToEndDiscLatNodeIter = numpy.zeros((clusterCount, int(numIter)))
265
266 assertion = main.TRUE
267 localTime = time.strftime('%x %X')
268 localTime = localTime.replace('/', '')
269 localTime = localTime.replace(' ', '_')
270 localTime = localTime.replace(':', '')
271
272 if debugMode == 'on':
273 main.ONOSbench.tsharkPcap('eth0', '/tmp/single_sw_lat_pcap_' + localTime)
274 main.log.info('Debug mode is on')
275
276 main.log.report('Latency of adding one switch to controller')
277 main.log.report('First ' + str(iterIgnore) + ' iterations ignored' + ' for jvm warmup time')
278 main.log.report('Total iterations of test: ' + str(numIter))
279
280 for i in range(0, int(numIter)):
281 main.log.info('Starting tshark capture')
282 main.ONOSbench.tsharkGrep(tsharkTcpString, tsharkTcpOutput)
283 main.ONOSbench.tsharkGrep(tsharkOfString, tsharkOfOutput)
284 main.ONOSbench.tsharkGrep(tsharkRoleRequest, tsharkRoleOutput)
285 main.ONOSbench.tsharkGrep(tsharkFeatureReply, tsharkFeatureOutput)
286
287 time.sleep(10)
288
289 main.log.info('Assigning s3 to controller')
290 main.Mininet1.assignSwController(sw='s3',
291 ip=main.ONOSIp[0])
292
293 jsonStr = []
294 for node in range (0, clusterCount):
295 metricsSwUp = CLIs[node].topologyEventsMetrics()
296 jsonStr.append(metricsSwUp)
297
298 time.sleep(10)
299
300 main.log.info('Stopping all Tshark processes')
301 main.ONOSbench.tsharkStop()
302
303 time.sleep(5)
304
305 '''
306 main.log.info('Copying over tshark files')
307 os.system('scp ' + ONOSUser + '@' + main.ONOSIp[0] +
308 ':' + tsharkTcpOutput + ' /tmp/')
309 os.system('scp ' + ONOSUser + '@' + main.ONOSIp[0] +
310 ':' + tsharkRoleOutput + ' /tmp/')
311 os.system('scp ' + ONOSUser + '@' + main.ONOSIp[0] +
312 ':' + tsharkFeatureOutput + ' /tmp/')
313 os.system('scp ' + ONOSUser + '@' +
314 main.ONOSIp[0] + ':' + tsharkOfOutput + ' /tmp/')
315 '''
316
317
318 time.sleep(1)
319
320 tcpFile = open(tsharkTcpOutput, 'r')
321 tempText = tcpFile.readline()
322 tempText = tempText.split(' ')
323 main.log.info('Object read in from TCP capture: ' + str(tempText))
324
325 if len(tempText) > 1:
326 t0Tcp = float(tempText[1]) * 1000.0
327 else:
328 main.log.error('Tshark output file for TCP' + ' returned unexpected results')
329 t0Tcp = 0
330 assertion = main.FALSE
331 tcpFile.close()
332
333
334 ofFile = open(tsharkOfOutput, 'r')
335 lineOfp = ''
336 while True:
337 tempText = ofFile.readline()
338 if tempText != '':
339 lineOfp = tempText
340 else:
341 break
342 obj = lineOfp.split(' ')
343 main.log.info('Object read in from OFP capture: ' +
344 str(lineOfp))
345 if len(obj) > 1:
346 t0Ofp = float(obj[1]) * 1000.0
347 else:
348 main.log.error('Tshark output file for OFP' +
349 ' returned unexpected results')
350 t0Ofp = 0
351 assertion = main.FALSE
352 ofFile.close()
353
354
355 roleFile = open(tsharkRoleOutput, 'r')
356 tempText = roleFile.readline()
357 tempText = tempText.split(' ')
358 if len(tempText) > 1:
359 main.log.info('Object read in from role request capture:' +
360 str(tempText))
361 roleTimestamp = float(tempText[1]) * 1000.0
362 else:
363 main.log.error('Tshark output file for role request' +
364 ' returned unexpected results')
365 timeRoleRequest = 0
366 assertion = main.FALSE
367 roleFile.close()
368
369
370 featureFile = open(tsharkFeatureOutput, 'r')
371 tempText = featureFile.readline()
372 tempText = tempText.split(' ')
373 if len(tempText) > 1:
374 main.log.info('Object read in from feature reply capture: '+
375 str(tempText))
376 if tempText[1] != ' ' and float(tempText[1]) > 1400000000.0:
377 temp = tempText[1]
378 elif tempText[2] != ' ' and float(tempText[2]) > 1400000000.0:
379 temp = tempText[2]
380 else:
381 temp = 0
382 featureTimestamp = float(temp) * 1000.0
383 else:
384 main.log.error('Tshark output file for feature reply' +
385 ' returned unexpected results')
386 timeFeatureReply = 0
387 assertion = main.FALSE
388 featureFile.close()
389
390 for node in range(0, clusterCount):
391 nodeNum = node+1
392
393
394 jsonObj = json.loads(jsonStr[node])
395 if jsonObj:
396 graphTimestamp = jsonObj[graphTimestampKey]['value']
397 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
398 else:
399 main.log.error( "Unexpected JSON object" )
400
401
402
403
404 graphTimestamp = 0
405 deviceTimestamp = 0
406
407 endToEnd = int(graphTimestamp) - int(t0Tcp)
408
409
410
411 tcpToFeature = int(featureTimestamp) - int(t0Tcp)
412 featureToRole = int(roleTimestamp) - int(featureTimestamp)
413 roleToOfp = float(t0Ofp) - float(roleTimestamp)
414 ofpToDevice = float(deviceTimestamp) - float(t0Ofp)
415
416
417
418
419
420
421
422 deviceToGraph = int(graphTimestamp) - int(deviceTimestamp)
423
424 if endToEnd >= thresholdMin and\
425 endToEnd < thresholdMax and i >= iterIgnore:
426 endToEndLatNodeIter[node][i] = endToEnd
427 main.log.info("ONOS "+str(nodeNum)+ " end-to-end: "+
428 str(endToEnd) + " ms")
429 else:
430 main.log.info("ONOS "+str(nodeNum)+ " end-to-end "+
431 "measurement ignored due to excess in "+
432 "threshold or premature iteration: ")
433 main.log.info(str(endToEnd))
434
435 if tcpToFeature >= thresholdMin and\
436 tcpToFeature < thresholdMax and i >= iterIgnore:
437 tcpToFeatureLatNodeIter[node][i] = tcpToFeature
438 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature: "+
439 str(tcpToFeature) + " ms")
440 else:
441 main.log.info("ONOS "+str(nodeNum)+ " tcp-to-feature "+
442 "measurement ignored due to excess in "+
443 "threshold or premature iteration: ")
444 main.log.info(str(tcpToFeature))
445
446 if featureToRole >= thresholdMin and\
447 featureToRole < thresholdMax and i >= iterIgnore:
448 featureToRoleRequestLatNodeIter[node][i] = featureToRole
449 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role: "+
450 str(featureToRole) + " ms")
451 else:
452 main.log.info("ONOS "+str(nodeNum)+ " feature-to-role "+
453 "measurement ignored due to excess in "+
454 "threshold or premature iteration: ")
455 main.log.info(str(featureToRole))
456
457 if roleToOfp >= thresholdMin and\
458 roleToOfp < thresholdMax and i >= iterIgnore:
459 roleRequestToRoleReplyLatNodeIter[node][i] = roleToOfp
460 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply: "+
461 str(roleToOfp) + " ms")
462 else:
463 main.log.info("ONOS "+str(nodeNum)+ " role-to-reply "+
464 "measurement ignored due to excess in "+
465 "threshold or premature iteration: ")
466 main.log.info(str(roleToOfp))
467
468 if ofpToDevice >= thresholdMin and\
469 ofpToDevice < thresholdMax and i >= iterIgnore:
470 roleReplyToDeviceLatNodeIter[node][i] = ofpToDevice
471 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device: "+
472 str(ofpToDevice) + " ms")
473 else:
474 main.log.info("ONOS "+str(nodeNum)+ " reply-to-device "+
475 "measurement ignored due to excess in "+
476 "threshold or premature iteration: ")
477 main.log.info(str(ofpToDevice))
478
479 if deviceToGraph >= thresholdMin and\
480 deviceToGraph < thresholdMax and i >= iterIgnore:
481 deviceToGraphLatNodeIter[node][i] = deviceToGraph
482 main.log.info("ONOS "+str(nodeNum)+ " device-to-graph: "+
483 str(deviceToGraph) + " ms")
484 else:
485 if deviceToGraph == 0:
486 deviceToGraphLatNodeIter[node][i] = 0
487 main.log.info("ONOS "+str(nodeNum) +
488 " device-to-graph measurement "+
489 "was set to 0 ms because of precision "+
490 "uncertainty. ")
491 else:
492 main.log.info("ONOS "+str(nodeNum)+
493 " device-to-graph "+
494 "measurement ignored due to excess in "+
495 "threshold or premature iteration: ")
496 main.log.info(str(deviceToGraph))
497
498
499 time.sleep(5)
500
501
502 deviceIdJsonStr = main.ONOS1cli.devices()
503
504 main.log.info( "Device obj obtained: " + str(deviceIdJsonStr) )
505 deviceId = json.loads(deviceIdJsonStr)
506
507 deviceList = []
508 for device in deviceId:
509 deviceList.append(device['id'])
510
511
512
513
514
515
516
517
518
519 main.ONOSbench.tsharkGrep( tsharkFinAckSequence, tsharkFinAckOutput,
520 grepOptions = '-A 1' )
521
522 time.sleep( 5 )
523
524 removeJsonList = []
525 main.step('Remove switch from controller')
526 main.Mininet1.deleteSwController('s3')
527 firstDevice = deviceList[0]
528
529 time.sleep( 5 )
530
531
532
533 for node in range(0, clusterCount):
534 metricsSwDown = CLIs[node].topologyEventsMetrics
535 jsonStr = metricsSwDown()
536 removeJsonList.append( json.loads(jsonStr) )
537
538 main.ONOSbench.tsharkStop()
539
540 main.log.info( "Removing device " +str(firstDevice)+
541 " from ONOS" )
542
543
544 main.ONOS1cli.deviceRemove(firstDevice)
545
546
547
548
549 time.sleep( 10 )
550 finAckOutputList = []
551 with open(tsharkFinAckOutput, 'r') as f:
552 tempLine = f.readlines()
553 main.log.info('Object read in from FinAck capture: ' +
554 "\n".join(tempLine))
555
556 index = 1
557 for line in tempLine:
558 obj = line.split(' ')
559
560
561
562 if len(obj) > 2:
563
564 if obj[1] != ' ' and float(obj[1]) > 1400000000.0:
565 temp = obj[1]
566 elif obj[2] != ' 'and float(obj[2]) > 1400000000.0:
567 temp = obj[2]
568 elif obj[3] != ' 'and float(obj[3]) > 1400000000.0:
569 temp = obj[3]
570 else:
571 temp = 0
572 if index == 1:
573 tFinAck = float(temp) * 1000.0
574 main.log.info("DEBUG-- tFinAck: " + str(tFinAck))
575 elif index == 3:
576 tAck = float(temp) * 1000.0
577 main.log.info("DEBUG-- tAck: " + str(tAck))
578 else:
579 tAck = 0
580 else:
581 main.log.error('Tshark output file for OFP' +
582 ' returned unexpected results')
583 tFinAck = 0
584 tAck = 0
585 assertion = main.FALSE
586
587 index += 1
588 main.log.info("DEBUG-- tFinAck: " + str(tFinAck))
589 main.log.info("DEBUG-- tAck: " + str(tAck))
590
591
592
593 time.sleep(5)
594
595 for node in range(0, clusterCount):
596 nodeNum = node+1
597 jsonObj = removeJsonList[node]
598 if jsonObj:
599 graphTimestamp = jsonObj[graphTimestampKey]['value']
600 deviceTimestamp = jsonObj[deviceTimestampKey]['value']
601 main.log.info("Graph timestamp: "+str(graphTimestamp))
602 main.log.info("Device timestamp: "+str(deviceTimestamp))
603 else:
604 main.log.error( "Unexpected JSON object" )
605
606
607
608
609 graphTimestamp = 0
610 deviceTimestamp = 0
611
612 finAckTransaction = float(tAck) - float(tFinAck)
613 ackToDevice = float(deviceTimestamp) - float(tAck)
614 deviceToGraph = float(graphTimestamp) - float(deviceTimestamp)
615 endToEndDisc = int(graphTimestamp) - int(tFinAck)
616 main.log.info("DEBUG-- endToEndDisc = graphTimestamp - tFinAck == (" + str(graphTimestamp) + "-" + str(tFinAck) + ")")
617
618 if endToEndDisc >= thresholdMin and\
619 endToEndDisc < thresholdMax and i >= iterIgnore:
620 endToEndDiscLatNodeIter[node][i] = endToEndDisc
621 main.log.info("ONOS "+str(nodeNum) +
622 "end-to-end disconnection: "+
623 str(endToEndDisc) + " ms" )
624 else:
625 main.log.info("ONOS " + str(nodeNum) +
626 " end-to-end disconnection "+
627 "measurement ignored due to excess in "+
628 "threshold or premature iteration: ")
629 main.log.info(str(endToEndDisc))
630
631 if finAckTransaction >= thresholdMin and\
632 finAckTransaction < thresholdMax and i >= iterIgnore:
633 finAckTransactionLatNodeIter[node][i] = finAckTransaction
634 main.log.info("ONOS "+str(nodeNum)+
635 " fin/ack transaction: "+
636 str(finAckTransaction) + " ms")
637 else:
638 main.log.info("ONOS "+str(nodeNum)+
639 " fin/ack transaction "+
640 "measurement ignored due to excess in "+
641 "threshold or premature iteration: ")
642 main.log.info(str(finAckTransaction))
643
644 if ackToDevice >= thresholdMin and\
645 ackToDevice < thresholdMax and i >= iterIgnore:
646 ackToDeviceLatNodeIter[node][i] = ackToDevice
647 main.log.info("ONOS "+str(nodeNum)+
648 " ack-to-device: "+
649 str(ackToDevice) + " ms")
650 else:
651 main.log.info("ONOS "+str(nodeNum)+
652 " ack-to-device "+
653 "measurement ignored due to excess in "+
654 "threshold or premature iteration: ")
655 main.log.info(str(ackToDevice))
656
657 if deviceToGraph >= thresholdMin and\
658 deviceToGraph < thresholdMax and i >= iterIgnore:
659 deviceToGraphDiscLatNodeIter[node][i] = deviceToGraph
660 main.log.info("ONOS "+str(nodeNum)+
661 " device-to-graph disconnect: "+
662 str(deviceToGraph) + " ms")
663 else:
664 main.log.info("ONOS "+str(nodeNum)+
665 " device-to-graph disconnect "+
666 "measurement ignored due to excess in "+
667 "threshold or premature iteration: ")
668 main.log.info(str(deviceToGraph))
669
670 endToEndAvg = 0
671 ofpToGraphAvg = 0
672 dbCmdList = []
673 for node in range(0, clusterCount):
674
675 endToEndList = []
676 tcpToFeatureList = []
677 featureToRoleList = []
678 roleToOfpList = []
679 ofpToDeviceList = []
680 deviceToGraphList = []
681
682 finAckTransactionList = []
683 ackToDeviceList = []
684 deviceToGraphDiscList = []
685 endToEndDiscList = []
686
687
688
689
690
691
692 for item in endToEndLatNodeIter[node]:
693 if item > 0.0:
694 endToEndList.append(item)
695
696 for item in tcpToFeatureLatNodeIter[node]:
697 if item > 0.0:
698 tcpToFeatureList.append(item)
699
700 for item in featureToRoleRequestLatNodeIter[node]:
701 if item > 0.0:
702 featureToRoleList.append(item)
703
704 for item in roleRequestToRoleReplyLatNodeIter[node]:
705 if item > 0.0:
706 roleToOfpList.append(item)
707
708 for item in roleReplyToDeviceLatNodeIter[node]:
709 if item >= 0.0:
710 ofpToDeviceList.append(item)
711
712 for item in featureToRoleRequestLatNodeIter[node]:
713 if item > 0.0:
714 featureToRoleList.append(item)
715
716 for item in deviceToGraphLatNodeIter[node]:
717 if item >= 0.0:
718 deviceToGraphList.append(item)
719
720
721 for item in endToEndDiscLatNodeIter[node]:
722 if item > 0.0:
723 endToEndDiscList.append(item)
724
725 for item in finAckTransactionLatNodeIter[node]:
726 if item > 0.0:
727 finAckTransactionList.append(item)
728
729 for item in ackToDeviceLatNodeIter[node]:
730 if item > 0.0:
731 ackToDeviceList.append(item)
732
733 for item in deviceToGraphDiscLatNodeIter[node]:
734 if item >= 0.0:
735 deviceToGraphDiscList.append(item)
736
737 endToEndAvg = round(numpy.mean(endToEndList), 2)
738 endToEndStdDev = round(numpy.std(endToEndList), 2)
739 main.log.info("endToEndList: " + str(endToEndList))
740
741 tcpToFeatureAvg = round(numpy.mean(tcpToFeatureList), 2)
742 tcpToFeatureStdDev = round(numpy.std(tcpToFeatureList), 2)
743 main.log.info("tcpToFeatureList: " + str(tcpToFeatureList))
744
745 featureToRoleAvg = round(numpy.mean(featureToRoleList), 2)
746 featureToRoleStdDev = round(numpy.std(featureToRoleList), 2)
747 main.log.info("featureToRoleList: " + str(featureToRoleList))
748
749 roleToOfpAvg = round(numpy.mean(roleToOfpList), 2)
750 roleToOfpStdDev = round(numpy.std(roleToOfpList), 2)
751 main.log.info("roleToOfList: " + str(roleToOfpList))
752
753 ofpToDeviceAvg = round(numpy.mean(ofpToDeviceList), 2)
754 ofpToDeviceStdDev = round(numpy.std(ofpToDeviceList), 2)
755 main.log.info("ofpToDeviceList: " + str(ofpToDeviceList))
756
757 deviceToGraphAvg = round(numpy.mean(deviceToGraphList), 2)
758 deviceToGraphStdDev = round(numpy.std(deviceToGraphList), 2)
759 main.log.info("deviceToGraphList: " + str(deviceToGraphList))
760
761 endToEndDiscAvg = round(numpy.mean(endToEndDiscList), 2)
762 endToEndDiscStdDev = round(numpy.std(endToEndDiscList), 2)
763 main.log.info("endToEndDiscList: " + str(endToEndDiscList))
764
765 finAckAvg = round(numpy.mean(finAckTransactionList), 2)
766 finAckStdDev = round(numpy.std(finAckTransactionList), 2)
767 main.log.info("finAckTransactionList: " + str(finAckTransactionList))
768
769 ackToDeviceAvg = round(numpy.mean(ackToDeviceList), 2)
770 ackToDeviceStdDev = round(numpy.std(ackToDeviceList), 2)
771 main.log.info("ackToDeviceList: " + str(ackToDeviceList))
772
773 deviceToGraphDiscAvg = round(numpy.mean(deviceToGraphDiscList), 2)
774 deviceToGraphDiscStdDev = round(numpy.std(deviceToGraphDiscList), 2)
775 main.log.info("deviceToGraphDiscList: " + str(deviceToGraphDiscList))
776
777 main.log.report(' - Node ' + str(node + 1) + ' Summary - ')
778 main.log.report(' - Switch Connection Statistics - ')
779
780 main.log.report(' End-to-end Avg: ' + str(endToEndAvg) +
781 ' ms' + ' End-to-end Std dev: ' +
782 str(endToEndStdDev) + ' ms')
783
784 main.log.report(' Tcp-to-feature-reply Avg: ' +
785 str(tcpToFeatureAvg) + ' ms')
786 main.log.report(' Tcp-to-feature-reply Std dev: '+
787 str(tcpToFeatureStdDev) + ' ms')
788
789 main.log.report(' Feature-reply-to-role-request Avg: ' +
790 str(featureToRoleAvg) + ' ms')
791 main.log.report(' Feature-reply-to-role-request Std Dev: ' +
792 str(featureToRoleStdDev) + ' ms')
793
794 main.log.report(' Role-request-to-role-reply Avg: ' +
795 str(roleToOfpAvg) +' ms')
796 main.log.report(' Role-request-to-role-reply Std dev: ' +
797 str(roleToOfpStdDev) + ' ms')
798
799 main.log.report(' Role-reply-to-device Avg: ' +
800 str(ofpToDeviceAvg) +' ms')
801 main.log.report(' Role-reply-to-device Std dev: ' +
802 str(ofpToDeviceStdDev) + ' ms')
803
804 main.log.report(' Device-to-graph Avg: ' +
805 str(deviceToGraphAvg) + ' ms')
806 main.log.report( 'Device-to-graph Std dev: ' +
807 str(deviceToGraphStdDev) + ' ms')
808
809 main.log.report(' - Switch Disconnection Statistics - ')
810 main.log.report(' End-to-end switch disconnect Avg: ' +
811 str(endToEndDiscAvg) + ' ms')
812 main.log.report(' End-to-end switch disconnect Std dev: ' +
813 str(endToEndDiscStdDev) + ' ms')
814 main.log.report(' Fin/Ack-to-Ack Avg: ' + str(finAckAvg) + ' ms')
815 main.log.report(' Fin/Ack-to-Ack Std dev: ' +
816 str(finAckStdDev) + ' ms')
817
818 main.log.report(' Ack-to-device Avg: ' + str(ackToDeviceAvg) +
819 ' ms')
820 main.log.report(' Ack-to-device Std dev: ' + str(ackToDeviceStdDev) +
821 ' ms')
822
823 main.log.report(' Device-to-graph (disconnect) Avg: ' +
824 str(deviceToGraphDiscAvg) + ' ms')
825 main.log.report(' Device-to-graph (disconnect) Std dev: ' +
826 str(deviceToGraphDiscStdDev) + ' ms')
827
828
829 dbCmdList.append(
830 "INSERT INTO switch_latency_details VALUES('" +
831 timeToPost + "','switch_latency_results'," +
832 jenkinsBuildNumber + ',' + str(clusterCount) + ",'baremetal" +
833 str(node + 1) + "'," +
834 str(endToEndAvg) + ',' +
835 str(tcpToFeatureAvg) + ',' +
836 str(featureToRoleAvg) + ',' +
837 str(roleToOfpAvg) + ',' +
838 str(ofpToDeviceAvg) + ',' +
839 str(deviceToGraphAvg) + ',' +
840 str(endToEndDiscAvg) + ',' +
841 str(finAckAvg) + ',' +
842 str(ackToDeviceAvg) + ',' +
843 str(deviceToGraphDiscAvg) +
844 ');')
845
846 if debugMode == 'on':
847 main.ONOSbench.cpLogsToDir('/opt/onos/log/karaf.log',
848 '/tmp/', copyFileName='sw_lat_karaf')
849 fResult = open(resultPath, 'a')
850 for line in dbCmdList:
851 if line:
852 fResult.write(line + '\n')
853 main.log.report(line)
854 fResult.close()
855
856 assertion = main.TRUE
857
858 utilities.assert_equals(expect=main.TRUE, actual=assertion,
859 onpass='Switch latency test successful',
860 onfail='Switch latency test failed')
861
862 main.Mininet1.stopNet()
863