summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/buildperf
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-01-13 16:00:37 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:22 +0000
commit7171710acde94bafdefd676756b4a6617e6ae320 (patch)
tree4cf1e0c5b1e17fc2468086c4d771b45bdc8397f7 /meta/lib/oeqa/buildperf
parent8e01802c9f5dc3ed0a15cfc0dca4fc042610c847 (diff)
downloadpoky-7171710acde94bafdefd676756b4a6617e6ae320.tar.gz
oeqa.buildperf: change sorting in json report
Use OrderedDict() instead of sort_keys=True (of json.dump()). Makes for more logical sorting of the values in the report. [YOCTO #10590] (From OE-Core rev: 75e8aec0e0d81888be47b35c3c84df73edb91868) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/buildperf')
-rw-r--r--meta/lib/oeqa/buildperf/base.py63
1 files changed, 32 insertions, 31 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index f6faedb0d1..28c3e2901d 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -19,6 +19,7 @@ import socket
19import time 19import time
20import unittest 20import unittest
21import xml.etree.ElementTree as ET 21import xml.etree.ElementTree as ET
22from collections import OrderedDict
22from datetime import datetime, timedelta 23from datetime import datetime, timedelta
23from functools import partial 24from functools import partial
24from multiprocessing import Process 25from multiprocessing import Process
@@ -151,31 +152,31 @@ class BuildPerfTestResult(unittest.TextTestResult):
151 152
152 def write_results_json(self): 153 def write_results_json(self):
153 """Write test results into a json-formatted file""" 154 """Write test results into a json-formatted file"""
154 results = {'tester_host': self.hostname, 155 results = OrderedDict([('tester_host', self.hostname),
155 'start_time': self.start_time, 156 ('start_time', self.start_time),
156 'elapsed_time': self.elapsed_time} 157 ('elapsed_time', self.elapsed_time),
158 ('tests', OrderedDict())])
157 159
158 tests = {}
159 for status, test, reason in self.all_results(): 160 for status, test, reason in self.all_results():
160 tests[test.name] = {'name': test.name, 161 test_result = OrderedDict([('name', test.name),
161 'description': test.shortDescription(), 162 ('description', test.shortDescription()),
162 'status': status, 163 ('status', status),
163 'start_time': test.start_time, 164 ('start_time', test.start_time),
164 'elapsed_time': test.elapsed_time, 165 ('elapsed_time', test.elapsed_time),
165 'cmd_log_file': os.path.relpath(test.cmd_log_file, 166 ('cmd_log_file', os.path.relpath(test.cmd_log_file,
166 self.out_dir), 167 self.out_dir)),
167 'measurements': test.measurements} 168 ('measurements', test.measurements)])
168 if status in ('ERROR', 'FAILURE', 'EXPECTED_FAILURE'): 169 if status in ('ERROR', 'FAILURE', 'EXPECTED_FAILURE'):
169 tests[test.name]['message'] = str(test.err[1]) 170 test_result['message'] = str(test.err[1])
170 tests[test.name]['err_type'] = test.err[0].__name__ 171 test_result['err_type'] = test.err[0].__name__
171 tests[test.name]['err_output'] = reason 172 test_result['err_output'] = reason
172 elif reason: 173 elif reason:
173 tests[test.name]['message'] = reason 174 test_result['message'] = reason
174 175
175 results['tests'] = tests 176 results['tests'][test.name] = test_result
176 177
177 with open(os.path.join(self.out_dir, 'results.json'), 'w') as fobj: 178 with open(os.path.join(self.out_dir, 'results.json'), 'w') as fobj:
178 json.dump(results, fobj, indent=4, sort_keys=True, 179 json.dump(results, fobj, indent=4,
179 cls=ResultsJsonEncoder) 180 cls=ResultsJsonEncoder)
180 181
181 def write_results_xml(self): 182 def write_results_xml(self):
@@ -306,12 +307,12 @@ class BuildPerfTestCase(unittest.TestCase):
306 ret = runCmd2(cmd, **kwargs) 307 ret = runCmd2(cmd, **kwargs)
307 etime = datetime.now() - start_time 308 etime = datetime.now() - start_time
308 rusage_struct = resource.getrusage(resource.RUSAGE_CHILDREN) 309 rusage_struct = resource.getrusage(resource.RUSAGE_CHILDREN)
309 iostat = {} 310 iostat = OrderedDict()
310 with open('/proc/{}/io'.format(os.getpid())) as fobj: 311 with open('/proc/{}/io'.format(os.getpid())) as fobj:
311 for line in fobj.readlines(): 312 for line in fobj.readlines():
312 key, val = line.split(':') 313 key, val = line.split(':')
313 iostat[key] = int(val) 314 iostat[key] = int(val)
314 rusage = {} 315 rusage = OrderedDict()
315 # Skip unused fields, (i.e. 'ru_ixrss', 'ru_idrss', 'ru_isrss', 316 # Skip unused fields, (i.e. 'ru_ixrss', 'ru_idrss', 'ru_isrss',
316 # 'ru_nswap', 'ru_msgsnd', 'ru_msgrcv' and 'ru_nsignals') 317 # 'ru_nswap', 'ru_msgsnd', 'ru_msgrcv' and 'ru_nsignals')
317 for key in ['ru_utime', 'ru_stime', 'ru_maxrss', 'ru_minflt', 318 for key in ['ru_utime', 'ru_stime', 'ru_maxrss', 'ru_minflt',
@@ -344,13 +345,13 @@ class BuildPerfTestCase(unittest.TestCase):
344 raise 345 raise
345 etime = data['elapsed_time'] 346 etime = data['elapsed_time']
346 347
347 measurement = {'type': self.SYSRES, 348 measurement = OrderedDict([('type', self.SYSRES),
348 'name': name, 349 ('name', name),
349 'legend': legend} 350 ('legend', legend)])
350 measurement['values'] = {'start_time': data['start_time'], 351 measurement['values'] = OrderedDict([('start_time', data['start_time']),
351 'elapsed_time': etime, 352 ('elapsed_time', etime),
352 'rusage': data['rusage'], 353 ('rusage', data['rusage']),
353 'iostat': data['iostat']} 354 ('iostat', data['iostat'])])
354 if save_bs: 355 if save_bs:
355 bs_file = self.save_buildstats(legend) 356 bs_file = self.save_buildstats(legend)
356 measurement['values']['buildstats_file'] = \ 357 measurement['values']['buildstats_file'] = \
@@ -374,10 +375,10 @@ class BuildPerfTestCase(unittest.TestCase):
374 ret = runCmd2(cmd) 375 ret = runCmd2(cmd)
375 size = int(ret.output.split()[0]) 376 size = int(ret.output.split()[0])
376 log.debug("Size of %s path is %s", path, size) 377 log.debug("Size of %s path is %s", path, size)
377 measurement = {'type': self.DISKUSAGE, 378 measurement = OrderedDict([('type', self.DISKUSAGE),
378 'name': name, 379 ('name', name),
379 'legend': legend} 380 ('legend', legend)])
380 measurement['values'] = {'size': size} 381 measurement['values'] = OrderedDict([('size', size)])
381 self.measurements.append(measurement) 382 self.measurements.append(measurement)
382 # Append to 'sizes' array for globalres log 383 # Append to 'sizes' array for globalres log
383 self.sizes.append(str(size)) 384 self.sizes.append(str(size))