diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-16 18:13:00 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-21 12:34:00 +0000 |
commit | 47eb3d00e9d6a66aee1283dab29af8117a006d6d (patch) | |
tree | 9d574720d23da3edeab5648f05fb5d2ee95c9cd2 /scripts/lib/resulttool/merge.py | |
parent | beed7523b667affea71d37d88d2f5c19c935d159 (diff) | |
download | poky-47eb3d00e9d6a66aee1283dab29af8117a006d6d.tar.gz |
resulttool: Improvements to allow integration to the autobuilder
This is a combined patch of the various tweaks and improvements I
made to resulttool:
* Avoid subprocess.run() as its a python 3.6 feature and we
have autobuilder workers with 3.5.
* Avoid python keywords as variable names
* Simplify dict accesses using .get()
* Rename resultsutils -> resultutils to match the resultstool ->
resulttool rename
* Formalised the handling of "file_name" to "TESTSERIES" which the code
will now add into the json configuration data if its not present, based
on the directory name.
* When we don't have failed test cases, print something saying so
instead of an empty table
* Tweak the table headers in the report to be more readable (reference
"Test Series" instead if file_id and ID instead of results_id)
* Improve/simplify the max string length handling
* Merge the counts and percentage data into one table in the report
since printing two reports of the same data confuses the user
* Removed the confusing header in the regression report
* Show matches, then regressions, then unmatched runs in the regression
report, also remove chatting unneeded output
* Try harder to "pair" up matching configurations to reduce noise in
the regressions report
* Abstracted the "mapping" table concept used to pairing in the
regression code to general code in resultutils
* Created multiple mappings for results analysis, results storage and
'flattening' results data in a merge
* Simplify the merge command to take a source and a destination,
letting the destination be a directory or a file, removing the need for
an output directory parameter
* Add the 'IMAGE_PKGTYPE' and 'DISTRO' config options to the regression
mappings
* Have the store command place the testresults files in a layout from
the mapping, making commits into the git repo for results storage more
useful for simple comparison purposes
* Set the oe-git-archive tag format appropriately for oeqa results
storage (and simplify the commit messages closer to their defaults)
* Fix oe-git-archive to use the commit/branch data from the results file
* Cleaned up the command option help to match other changes
* Follow the model of git branch/tag processing used by oe-build-perf-report
and use that to read the data using git show to avoid branch change
* Add ptest summary to the report command
* Update the tests to match the above changes
(From OE-Core rev: ff2c029b568f70aa9960dde04ddd207829812ea0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/resulttool/merge.py')
-rw-r--r-- | scripts/lib/resulttool/merge.py | 69 |
1 files changed, 20 insertions, 49 deletions
diff --git a/scripts/lib/resulttool/merge.py b/scripts/lib/resulttool/merge.py index 1d9cfafd41..3e4b7a38ad 100644 --- a/scripts/lib/resulttool/merge.py +++ b/scripts/lib/resulttool/merge.py | |||
@@ -1,6 +1,7 @@ | |||
1 | # test result tool - merge multiple testresults.json files | 1 | # resulttool - merge multiple testresults.json files into a file or directory |
2 | # | 2 | # |
3 | # Copyright (c) 2019, Intel Corporation. | 3 | # Copyright (c) 2019, Intel Corporation. |
4 | # Copyright (c) 2019, Linux Foundation | ||
4 | # | 5 | # |
5 | # This program is free software; you can redistribute it and/or modify it | 6 | # This program is free software; you can redistribute it and/or modify it |
6 | # under the terms and conditions of the GNU General Public License, | 7 | # under the terms and conditions of the GNU General Public License, |
@@ -11,61 +12,31 @@ | |||
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | # more details. | 13 | # more details. |
13 | # | 14 | # |
14 | from resulttool.resultsutils import load_json_file, get_dict_value, dump_json_data | ||
15 | import os | 15 | import os |
16 | import json | 16 | import json |
17 | 17 | import resulttool.resultutils as resultutils | |
18 | class ResultsMerge(object): | ||
19 | |||
20 | def get_test_results(self, logger, file, result_id): | ||
21 | results = load_json_file(file) | ||
22 | if result_id: | ||
23 | result = get_dict_value(logger, results, result_id) | ||
24 | if result: | ||
25 | return {result_id: result} | ||
26 | return result | ||
27 | return results | ||
28 | |||
29 | def merge_results(self, base_results, target_results): | ||
30 | for k in target_results: | ||
31 | base_results[k] = target_results[k] | ||
32 | return base_results | ||
33 | |||
34 | def _get_write_dir(self): | ||
35 | basepath = os.environ['BUILDDIR'] | ||
36 | return basepath + '/tmp/' | ||
37 | |||
38 | def dump_merged_results(self, results, output_dir): | ||
39 | file_output_dir = output_dir if output_dir else self._get_write_dir() | ||
40 | dump_json_data(file_output_dir, 'testresults.json', results) | ||
41 | print('Successfully merged results to: %s' % os.path.join(file_output_dir, 'testresults.json')) | ||
42 | |||
43 | def run(self, logger, base_result_file, target_result_file, target_result_id, output_dir): | ||
44 | base_results = self.get_test_results(logger, base_result_file, '') | ||
45 | target_results = self.get_test_results(logger, target_result_file, target_result_id) | ||
46 | if base_results and target_results: | ||
47 | merged_results = self.merge_results(base_results, target_results) | ||
48 | self.dump_merged_results(merged_results, output_dir) | ||
49 | 18 | ||
50 | def merge(args, logger): | 19 | def merge(args, logger): |
51 | merge = ResultsMerge() | 20 | if os.path.isdir(args.target_results): |
52 | merge.run(logger, args.base_result_file, args.target_result_file, args.target_result_id, args.output_dir) | 21 | results = resultutils.load_resultsdata(args.target_results, configmap=resultutils.store_map) |
22 | resultutils.append_resultsdata(results, args.base_results, configmap=resultutils.store_map) | ||
23 | resultutils.save_resultsdata(results, args.target_results) | ||
24 | else: | ||
25 | results = resultutils.load_resultsdata(args.base_results, configmap=resultutils.flatten_map) | ||
26 | if os.path.exists(args.target_results): | ||
27 | resultutils.append_resultsdata(results, args.target_results, configmap=resultutils.flatten_map) | ||
28 | resultutils.save_resultsdata(results, os.path.dirname(args.target_results), fn=os.path.basename(args.target_results)) | ||
29 | |||
53 | return 0 | 30 | return 0 |
54 | 31 | ||
55 | def register_commands(subparsers): | 32 | def register_commands(subparsers): |
56 | """Register subcommands from this plugin""" | 33 | """Register subcommands from this plugin""" |
57 | parser_build = subparsers.add_parser('merge', help='merge test results', | 34 | parser_build = subparsers.add_parser('merge', help='merge test result files/directories', |
58 | description='merge results from multiple files', | 35 | description='merge the results from multiple files/directories into the target file or directory', |
59 | group='setup') | 36 | group='setup') |
60 | parser_build.set_defaults(func=merge) | 37 | parser_build.set_defaults(func=merge) |
61 | parser_build.add_argument('base_result_file', | 38 | parser_build.add_argument('base_results', |
62 | help='base result file provide the base result set') | 39 | help='the results file/directory to import') |
63 | parser_build.add_argument('target_result_file', | 40 | parser_build.add_argument('target_results', |
64 | help='target result file provide the target result set for merging into the ' | 41 | help='the target file or directory to merge the base_results with') |
65 | 'base result set') | 42 | |
66 | parser_build.add_argument('-t', '--target-result-id', default='', | ||
67 | help='(optional) default merge all result sets available from target to base ' | ||
68 | 'unless specific target result id was provided') | ||
69 | parser_build.add_argument('-o', '--output-dir', default='', | ||
70 | help='(optional) default write merged results to <poky>/build/tmp/ unless specific ' | ||
71 | 'output directory was provided') | ||