Merge ppa-dev-tools:fix-lp2025484-missing-test-name into ppa-dev-tools:main

Proposed by Bryce Harrington
Status: Merged
Merge reported by: Bryce Harrington
Merged at revision: c054b7eb228d4bd91d4cc92842581b76865178ea
Proposed branch: ppa-dev-tools:fix-lp2025484-missing-test-name
Merge into: ppa-dev-tools:main
Diff against target: 105 lines (+83/-0)
2 files modified
ppa/result.py (+3/-0)
tests/test_result.py (+80/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack (community) Approve
PpaDevTools Developers Pending
Canonical Server Pending
Canonical Server Reporter Pending
Review via email: mp+450190@code.launchpad.net

Description of the change

This adds a fix requested by mwhudson today and bdrung earlier to address a change in autopkgtest log file format that was causing some corruption in results shown by ppa tests.

The fix is pretty trivial but I've taken this opportunity to also implement a corresponding test case with some snippets of example log files.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) :
review: Needs Information
Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks for the quick review, response to the question below:

Revision history for this message
Andreas Hasenack (ahasenack) :
review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks Andreas, I decided you were right, and incorporated your suggestion and landed the branch:

stirling: ~/src/PpaDevTools/ppa-dev-tools-bugfix$ git merge --ff-only fix-lp2025484-missing-test-name
Updating 7bef7a0..c56a856
Fast-forward
 ppa/result.py | 3 +++
 tests/test_result.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
stirling: ~/src/PpaDevTools/ppa-dev-tools-bugfix$ git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To git+ssh://git.launchpad.net/ppa-dev-tools
   7bef7a0..c56a856 main -> main

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ppa/result.py b/ppa/result.py
2index e33c61c..fe47621 100755
3--- a/ppa/result.py
4+++ b/ppa/result.py
5@@ -181,6 +181,9 @@ class Result:
6 subtests = []
7 result_sum = result_split[1]
8 for line in re.findall("(.*PASS|.*SKIP|.*FAIL|.*BAD)", result_sum):
9+ if re.match(r"^[0-9]+s\s", line):
10+ # Newer autopkgtest logs are prefixed with the timestamp. Ignore it.
11+ line = line.split(' ', 1)[1]
12 if name and not line.startswith(name):
13 continue
14 subtests.append(Subtest(line))
15diff --git a/tests/test_result.py b/tests/test_result.py
16index 33748c1..4063b83 100644
17--- a/tests/test_result.py
18+++ b/tests/test_result.py
19@@ -69,6 +69,86 @@ def test_triggers():
20 assert result.triggers == ['pygobject/3.42.2-2', 'six/1.16.0-4']
21
22
23+@pytest.mark.parametrize('log_text, subtest_name, expected', [
24+ ('', None, {}),
25+ (
26+ (
27+ "x: @@@@@@@@@@@@@@@@@@@@ summary\n"
28+ "test-a PASS\n"
29+ "test-b FAIL ignorable-note\n"
30+ "test-c NoTaVaLiDsTaTuS\n"
31+ ),
32+ None,
33+ {'test-a': 'PASS', 'test-b': 'FAIL'}
34+ ),
35+ (
36+ (
37+ "autopkgtest [21:13:56]: starting date: 2022-11-18\n"
38+ "The following packages have unmet dependencies:\n"
39+ " builddeps:.../12-autopkgtest-satdep.dsc:i386 : Depends: gcc:i386 but it is not installable\n"
40+ "E: Unable to correct problems, you have held broken packages.\n"
41+ "chroot FAIL badpkg\n"
42+ "blame: apache2\n"
43+ "badpkg: Test dependencies are unsatisfiable. A common reason is ...\n"
44+ "autopkgtest [21:48:03]: @@@@@@@@@@@@@@@@@@@@ summary\n"
45+ "run-test-suite FAIL badpkg\n"
46+ "blame: apache2\n"
47+ "badpkg: Test dependencies are unsatisfiable. A common reason is...\n"
48+ "duplicate-module-load PASS\n"
49+ "default-mods PASS\n"
50+ "run-htcacheclean PASS\n"
51+ "ssl-passphrase PASS\n"
52+ "check-http2 PASS\n"
53+ "run-chroot FAIL badpkg\n"
54+ "blame: apache2\n"
55+ ),
56+ 'run-',
57+ {
58+ 'run-test-suite': 'FAIL',
59+ 'run-htcacheclean': 'PASS',
60+ 'run-chroot': 'FAIL',
61+ }
62+ ),
63+ (
64+ (
65+ "3657s rm: cannot remove '.../mountpoint': Device or resource busy\n"
66+ "3661s autopkgtest [03:41:43]: test minimized: -----------------------]\n"
67+ "3663s autopkgtest [03:41:45]: test minimized: - - - - - - - - - - results - - - - - - - - - -\n"
68+ "3663s minimized FAIL non-zero exit status 1\n"
69+ "3663s autopkgtest [03:41:45]: test minimized: - - - - - - - - - - stderr - - - - - - - - - -\n"
70+ "3663s rm: cannot remove '.../mountpoint': Device or resource busy\n"
71+ "3664s autopkgtest [03:41:46]: @@@@@@@@@@@@@@@@@@@@ summary\n"
72+ "3664s default-bootstraps FAIL non-zero exit status 1\n"
73+ "3664s minimized FAIL non-zero exit status 1'\n"
74+ ),
75+ None,
76+ {
77+ 'default-bootstraps': 'FAIL',
78+ 'minimized': 'FAIL'
79+ }
80+ ),
81+])
82+def test_get_subtests(tmp_path, log_text: str, subtest_name: str, expected: dict[str]):
83+ """Checks retrieval of Subtest objects from autopkgtest results.
84+
85+ This test exercises the parser that extracts subtest information out
86+ of autopkgtest logs of various formats. It also verifies the
87+ parameter to get_subtests() is handled correctly.
88+
89+ :param fixture tmp_path: Temp dir.
90+ :param str log_text: Text to write into the log file.
91+ :param str subtest_name: Only retrieve subtests starting with this text.
92+ :param dict[str] expected: Dictionary of subtest names to pass/fail status.
93+ """
94+ f = tmp_path / "result.log.gz"
95+ compressed_text = gzip.compress(bytes(log_text, 'utf-8'))
96+ f.write_bytes(compressed_text)
97+
98+ result = Result(f"file://{f}", None, None, None, None)
99+ subtests = result.get_subtests(subtest_name)
100+ assert {s.desc: s.status for s in subtests} == expected
101+
102+
103 @pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [
104 ('x', 'x', 'x', 'x', {})
105 ])

Subscribers

People subscribed via source and target branches

to all changes: