diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2017-01-13 16:00:37 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:05:22 +0000 |
commit | 7171710acde94bafdefd676756b4a6617e6ae320 (patch) | |
tree | 4cf1e0c5b1e17fc2468086c4d771b45bdc8397f7 /meta | |
parent | 8e01802c9f5dc3ed0a15cfc0dca4fc042610c847 (diff) | |
download | poky-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')
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 63 |
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 | |||
19 | import time | 19 | import time |
20 | import unittest | 20 | import unittest |
21 | import xml.etree.ElementTree as ET | 21 | import xml.etree.ElementTree as ET |
22 | from collections import OrderedDict | ||
22 | from datetime import datetime, timedelta | 23 | from datetime import datetime, timedelta |
23 | from functools import partial | 24 | from functools import partial |
24 | from multiprocessing import Process | 25 | from 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)) |