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-03-26 15:38:22 +0000 |
commit | 661fa1335b6832a1d13b13e8ca4354cdef213358 (patch) | |
tree | 9d465a03e55d4906197db32d0d19c181e9ff42dd /meta/lib/oeqa | |
parent | e4c0a8a7cb1b57486952912ba0c4f5b7c582d93d (diff) | |
download | poky-661fa1335b6832a1d13b13e8ca4354cdef213358.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: 39cda3498ec68b91a671ead256231324d74f7d4c)
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/files/testresults/testresults.json | 40 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/resulttooltests.py | 104 |
2 files changed, 144 insertions, 0 deletions
diff --git a/meta/lib/oeqa/files/testresults/testresults.json b/meta/lib/oeqa/files/testresults/testresults.json new file mode 100644 index 0000000000..1a62155618 --- /dev/null +++ b/meta/lib/oeqa/files/testresults/testresults.json | |||
@@ -0,0 +1,40 @@ | |||
1 | { | ||
2 | "runtime_core-image-minimal_qemuarm_20181225195701": { | ||
3 | "configuration": { | ||
4 | "DISTRO": "poky", | ||
5 | "HOST_DISTRO": "ubuntu-16.04", | ||
6 | "IMAGE_BASENAME": "core-image-minimal", | ||
7 | "IMAGE_PKGTYPE": "rpm", | ||
8 | "LAYERS": { | ||
9 | "meta": { | ||
10 | "branch": "master", | ||
11 | "commit": "801745d918e83f976c706f29669779f5b292ade3", | ||
12 | "commit_count": 52782 | ||
13 | }, | ||
14 | "meta-poky": { | ||
15 | "branch": "master", | ||
16 | "commit": "801745d918e83f976c706f29669779f5b292ade3", | ||
17 | "commit_count": 52782 | ||
18 | }, | ||
19 | "meta-yocto-bsp": { | ||
20 | "branch": "master", | ||
21 | "commit": "801745d918e83f976c706f29669779f5b292ade3", | ||
22 | "commit_count": 52782 | ||
23 | } | ||
24 | }, | ||
25 | "MACHINE": "qemuarm", | ||
26 | "STARTTIME": "20181225195701", | ||
27 | "TEST_TYPE": "runtime" | ||
28 | }, | ||
29 | "result": { | ||
30 | "apt.AptRepoTest.test_apt_install_from_repo": { | ||
31 | "log": "Test requires apt to be installed", | ||
32 | "status": "PASSED" | ||
33 | }, | ||
34 | "buildcpio.BuildCpioTest.test_cpio": { | ||
35 | "log": "Test requires autoconf to be installed", | ||
36 | "status": "ERROR" | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } \ No newline at end of file | ||
diff --git a/meta/lib/oeqa/selftest/cases/resulttooltests.py b/meta/lib/oeqa/selftest/cases/resulttooltests.py new file mode 100644 index 0000000000..7bf1ec60c1 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/resulttooltests.py | |||
@@ -0,0 +1,104 @@ | |||
1 | import os | ||
2 | import sys | ||
3 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../') | ||
4 | lib_path = basepath + '/scripts/lib' | ||
5 | sys.path = sys.path + [lib_path] | ||
6 | from resulttool.report import ResultsTextReport | ||
7 | from resulttool.regression import ResultsRegressionSelector, ResultsRegression | ||
8 | from resulttool.merge import ResultsMerge | ||
9 | from resulttool.store import ResultsGitStore | ||
10 | from resulttool.resultsutils import checkout_git_dir | ||
11 | from oeqa.selftest.case import OESelftestTestCase | ||
12 | |||
13 | class ResultToolTests(OESelftestTestCase): | ||
14 | |||
15 | def test_report_can_aggregate_test_result(self): | ||
16 | result_data = {'result': {'test1': {'status': 'PASSED'}, | ||
17 | 'test2': {'status': 'PASSED'}, | ||
18 | 'test3': {'status': 'FAILED'}, | ||
19 | 'test4': {'status': 'ERROR'}, | ||
20 | 'test5': {'status': 'SKIPPED'}}} | ||
21 | report = ResultsTextReport() | ||
22 | result_report = report.get_aggregated_test_result(None, result_data) | ||
23 | self.assertTrue(result_report['passed'] == 2, msg="Passed count not correct:%s" % result_report['passed']) | ||
24 | self.assertTrue(result_report['failed'] == 2, msg="Failed count not correct:%s" % result_report['failed']) | ||
25 | self.assertTrue(result_report['skipped'] == 1, msg="Skipped count not correct:%s" % result_report['skipped']) | ||
26 | |||
27 | def test_regression_can_get_regression_base_target_pair(self): | ||
28 | base_results_data = {'base_result1': {'configuration': {"TEST_TYPE": "oeselftest", | ||
29 | "HOST": "centos-7"}}, | ||
30 | 'base_result2': {'configuration': {"TEST_TYPE": "oeselftest", | ||
31 | "HOST": "centos-7", | ||
32 | "MACHINE": "qemux86-64"}}} | ||
33 | target_results_data = {'target_result1': {'configuration': {"TEST_TYPE": "oeselftest", | ||
34 | "HOST": "centos-7"}}, | ||
35 | 'target_result2': {'configuration': {"TEST_TYPE": "oeselftest", | ||
36 | "HOST": "centos-7", | ||
37 | "MACHINE": "qemux86"}}, | ||
38 | 'target_result3': {'configuration': {"TEST_TYPE": "oeselftest", | ||
39 | "HOST": "centos-7", | ||
40 | "MACHINE": "qemux86-64"}}} | ||
41 | regression = ResultsRegressionSelector() | ||
42 | pair = regression.get_regression_base_target_pair(self.logger, base_results_data, target_results_data) | ||
43 | self.assertTrue('target_result1' in pair['base_result1'], msg="Pair not correct:%s" % pair['base_result1']) | ||
44 | self.assertTrue('target_result3' in pair['base_result2'], msg="Pair not correct:%s" % pair['base_result2']) | ||
45 | |||
46 | def test_regrresion_can_get_regression_result(self): | ||
47 | base_result_data = {'result': {'test1': {'status': 'PASSED'}, | ||
48 | 'test2': {'status': 'PASSED'}, | ||
49 | 'test3': {'status': 'FAILED'}, | ||
50 | 'test4': {'status': 'ERROR'}, | ||
51 | 'test5': {'status': 'SKIPPED'}}} | ||
52 | target_result_data = {'result': {'test1': {'status': 'PASSED'}, | ||
53 | 'test2': {'status': 'FAILED'}, | ||
54 | 'test3': {'status': 'PASSED'}, | ||
55 | 'test4': {'status': 'ERROR'}, | ||
56 | 'test5': {'status': 'SKIPPED'}}} | ||
57 | regression = ResultsRegression() | ||
58 | result = regression.get_regression_result(self.logger, base_result_data, target_result_data) | ||
59 | self.assertTrue(result['test2']['base'] == 'PASSED', | ||
60 | msg="regression not correct:%s" % result['test2']['base']) | ||
61 | self.assertTrue(result['test2']['target'] == 'FAILED', | ||
62 | msg="regression not correct:%s" % result['test2']['target']) | ||
63 | self.assertTrue(result['test3']['base'] == 'FAILED', | ||
64 | msg="regression not correct:%s" % result['test3']['base']) | ||
65 | self.assertTrue(result['test3']['target'] == 'PASSED', | ||
66 | msg="regression not correct:%s" % result['test3']['target']) | ||
67 | |||
68 | def test_merge_can_merged_results(self): | ||
69 | base_results_data = {'base_result1': {}, | ||
70 | 'base_result2': {}} | ||
71 | target_results_data = {'target_result1': {}, | ||
72 | 'target_result2': {}, | ||
73 | 'target_result3': {}} | ||
74 | |||
75 | merge = ResultsMerge() | ||
76 | results = merge.merge_results(base_results_data, target_results_data) | ||
77 | self.assertTrue(len(results.keys()) == 5, msg="merge not correct:%s" % len(results.keys())) | ||
78 | |||
79 | def test_store_can_store_to_new_git_repository(self): | ||
80 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../../') | ||
81 | source_dir = basepath + '/files/testresults' | ||
82 | git_branch = 'qa-cycle-2.7' | ||
83 | store = ResultsGitStore() | ||
84 | output_dir = store.store_to_new(self.logger, source_dir, git_branch) | ||
85 | self.assertTrue(checkout_git_dir(output_dir, git_branch), msg="store to new git repository failed:%s" % | ||
86 | output_dir) | ||
87 | store._remove_temporary_workspace_dir(output_dir) | ||
88 | |||
89 | def test_store_can_store_to_existing(self): | ||
90 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../../') | ||
91 | source_dir = basepath + '/files/testresults' | ||
92 | git_branch = 'qa-cycle-2.6' | ||
93 | store = ResultsGitStore() | ||
94 | output_dir = store.store_to_new(self.logger, source_dir, git_branch) | ||
95 | self.assertTrue(checkout_git_dir(output_dir, git_branch), msg="store to new git repository failed:%s" % | ||
96 | output_dir) | ||
97 | git_branch = 'qa-cycle-2.7' | ||
98 | output_dir = store.store_to_existing_with_new_branch(self.logger, source_dir, output_dir, git_branch) | ||
99 | self.assertTrue(checkout_git_dir(output_dir, git_branch), msg="store to existing git repository failed:%s" % | ||
100 | output_dir) | ||
101 | output_dir = store.store_to_existing(self.logger, source_dir, output_dir, git_branch) | ||
102 | self.assertTrue(checkout_git_dir(output_dir, git_branch), msg="store to existing git repository failed:%s" % | ||
103 | output_dir) | ||
104 | store._remove_temporary_workspace_dir(output_dir) | ||