diff options
| author | Yeoh Ee Peng <ee.peng.yeoh@intel.com> | 2019-02-14 13:50:37 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-21 12:34:00 +0000 |
| commit | 1fd5ebdb06224489ad056e261962e23ece36fc87 (patch) | |
| tree | 790b33a5498a9f97642ead84ce66dfd354bd8626 /scripts/resulttool | |
| parent | 95bd530b772f97e7329749b403bf9e2dff12ff7f (diff) | |
| download | poky-1fd5ebdb06224489ad056e261962e23ece36fc87.tar.gz | |
resulttool: enable merge, store, report and regression analysis
OEQA outputs test results into json files and these files were
archived by Autobuilder during QA releases. Example: each oe-selftest
run by Autobuilder for different host distro generate a
testresults.json file.
These scripts were developed as a test result tools to manage
these testresults.json file.
Using the "store" operation, user can store multiple testresults.json
files as well as the pre-configured directories used to hold those files.
Using the "merge" operation, user can merge multiple testresults.json
files to a target file.
Using the "report" operation, user can view the test result summary
for all available testresults.json files inside a ordinary directory
or a git repository.
Using the "regression-file" operation, user can perform regression
analysis on testresults.json files specified. Using the "regression-dir"
and "regression-git" operations, user can perform regression analysis
on directory and git accordingly.
These resulttool operations expect the testresults.json file to use
the json format below.
{
"<testresult_1>": {
"configuration": {
"<config_name_1>": "<config_value_1>",
"<config_name_2>": "<config_value_2>",
...
"<config_name_n>": "<config_value_n>",
},
"result": {
"<testcase_namespace_1>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
"<testcase_namespace_2>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
...
"<testcase_namespace_n>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
}
},
...
"<testresult_n>": {
"configuration": {
"<config_name_1>": "<config_value_1>",
"<config_name_2>": "<config_value_2>",
...
"<config_name_n>": "<config_value_n>",
},
"result": {
"<testcase_namespace_1>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
"<testcase_namespace_2>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
...
"<testcase_namespace_n>": {
"status": "<PASSED or FAILED or ERROR or SKIPPED>",
"log": "<failure or error logging>"
},
}
},
}
To use these scripts, first source oe environment, then run the
entry point script to look for help.
$ resulttool
To store test result from oeqa automated tests, execute the below
$ resulttool store <source_dir> <git_branch>
To merge multiple testresults.json files, execute the below
$ resulttool merge <base_result_file> <target_result_file>
To report test report, execute the below
$ resulttool report <source_dir>
To perform regression file analysis, execute the below
$ resulttool regression-file <base_result_file> <target_result_file>
To perform regression dir analysis, execute the below
$ resulttool regression-dir <base_result_dir> <target_result_dir>
To perform regression git analysis, execute the below
$ resulttool regression-git <source_dir> <base_branch> <target_branch>
[YOCTO# 13012]
[YOCTO# 12654]
(From OE-Core rev: 78a322d7be402a5b9b5abf26ad35670a8535408a)
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/resulttool')
| -rwxr-xr-x | scripts/resulttool | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/scripts/resulttool b/scripts/resulttool new file mode 100755 index 0000000000..ebb5fc81c9 --- /dev/null +++ b/scripts/resulttool | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | # | ||
| 3 | # test results tool - tool for testresults.json (merge test results, regression analysis) | ||
| 4 | # | ||
| 5 | # To look for help information. | ||
| 6 | # $ resulttool | ||
| 7 | # | ||
| 8 | # To store test result from oeqa automated tests, execute the below | ||
| 9 | # $ resulttool store <source_dir> <git_branch> | ||
| 10 | # | ||
| 11 | # To merge test results, execute the below | ||
| 12 | # $ resulttool merge <base_result_file> <target_result_file> | ||
| 13 | # | ||
| 14 | # To report test report, execute the below | ||
| 15 | # $ resulttool report <source_dir> | ||
| 16 | # | ||
| 17 | # To perform regression file analysis, execute the below | ||
| 18 | # $ resulttool regression-file <base_result_file> <target_result_file> | ||
| 19 | # | ||
| 20 | # Copyright (c) 2019, Intel Corporation. | ||
| 21 | # | ||
| 22 | # This program is free software; you can redistribute it and/or modify it | ||
| 23 | # under the terms and conditions of the GNU General Public License, | ||
| 24 | # version 2, as published by the Free Software Foundation. | ||
| 25 | # | ||
| 26 | # This program is distributed in the hope it will be useful, but WITHOUT | ||
| 27 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 28 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 29 | # more details. | ||
| 30 | # | ||
| 31 | |||
| 32 | import os | ||
| 33 | import sys | ||
| 34 | import argparse | ||
| 35 | import logging | ||
| 36 | script_path = os.path.dirname(os.path.realpath(__file__)) | ||
| 37 | lib_path = script_path + '/lib' | ||
| 38 | sys.path = sys.path + [lib_path] | ||
| 39 | import argparse_oe | ||
| 40 | import scriptutils | ||
| 41 | import resulttool.merge | ||
| 42 | import resulttool.store | ||
| 43 | import resulttool.regression | ||
| 44 | import resulttool.report | ||
| 45 | logger = scriptutils.logger_create('resulttool') | ||
| 46 | |||
| 47 | def _validate_user_input_arguments(args): | ||
| 48 | if hasattr(args, "source_dir"): | ||
| 49 | if not os.path.isdir(args.source_dir): | ||
| 50 | logger.error('source_dir argument need to be a directory : %s' % args.source_dir) | ||
| 51 | return False | ||
| 52 | return True | ||
| 53 | |||
| 54 | def main(): | ||
| 55 | parser = argparse_oe.ArgumentParser(description="OpenEmbedded test results tool.", | ||
| 56 | epilog="Use %(prog)s <subcommand> --help to get help on a specific command") | ||
| 57 | parser.add_argument('-d', '--debug', help='enable debug output', action='store_true') | ||
| 58 | parser.add_argument('-q', '--quiet', help='print only errors', action='store_true') | ||
| 59 | subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') | ||
| 60 | subparsers.required = True | ||
| 61 | subparsers.add_subparser_group('setup', 'setup', 200) | ||
| 62 | resulttool.merge.register_commands(subparsers) | ||
| 63 | resulttool.store.register_commands(subparsers) | ||
| 64 | subparsers.add_subparser_group('analysis', 'analysis', 100) | ||
| 65 | resulttool.regression.register_commands(subparsers) | ||
| 66 | resulttool.report.register_commands(subparsers) | ||
| 67 | |||
| 68 | args = parser.parse_args() | ||
| 69 | if args.debug: | ||
| 70 | logger.setLevel(logging.DEBUG) | ||
| 71 | elif args.quiet: | ||
| 72 | logger.setLevel(logging.ERROR) | ||
| 73 | |||
| 74 | if not _validate_user_input_arguments(args): | ||
| 75 | return -1 | ||
| 76 | |||
| 77 | try: | ||
| 78 | ret = args.func(args, logger) | ||
| 79 | except argparse_oe.ArgumentUsageError as ae: | ||
| 80 | parser.error_subcommand(ae.message, ae.subcommand) | ||
| 81 | return ret | ||
| 82 | |||
| 83 | if __name__ == "__main__": | ||
| 84 | sys.exit(main()) | ||
