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
diff --git a/ppa/result.py b/ppa/result.py
index e33c61c..fe47621 100755
--- a/ppa/result.py
+++ b/ppa/result.py
@@ -181,6 +181,9 @@ class Result:
181 subtests = []181 subtests = []
182 result_sum = result_split[1]182 result_sum = result_split[1]
183 for line in re.findall("(.*PASS|.*SKIP|.*FAIL|.*BAD)", result_sum):183 for line in re.findall("(.*PASS|.*SKIP|.*FAIL|.*BAD)", result_sum):
184 if re.match(r"^[0-9]+s\s", line):
185 # Newer autopkgtest logs are prefixed with the timestamp. Ignore it.
186 line = line.split(' ', 1)[1]
184 if name and not line.startswith(name):187 if name and not line.startswith(name):
185 continue188 continue
186 subtests.append(Subtest(line))189 subtests.append(Subtest(line))
diff --git a/tests/test_result.py b/tests/test_result.py
index 33748c1..4063b83 100644
--- a/tests/test_result.py
+++ b/tests/test_result.py
@@ -69,6 +69,86 @@ def test_triggers():
69 assert result.triggers == ['pygobject/3.42.2-2', 'six/1.16.0-4']69 assert result.triggers == ['pygobject/3.42.2-2', 'six/1.16.0-4']
7070
7171
72@pytest.mark.parametrize('log_text, subtest_name, expected', [
73 ('', None, {}),
74 (
75 (
76 "x: @@@@@@@@@@@@@@@@@@@@ summary\n"
77 "test-a PASS\n"
78 "test-b FAIL ignorable-note\n"
79 "test-c NoTaVaLiDsTaTuS\n"
80 ),
81 None,
82 {'test-a': 'PASS', 'test-b': 'FAIL'}
83 ),
84 (
85 (
86 "autopkgtest [21:13:56]: starting date: 2022-11-18\n"
87 "The following packages have unmet dependencies:\n"
88 " builddeps:.../12-autopkgtest-satdep.dsc:i386 : Depends: gcc:i386 but it is not installable\n"
89 "E: Unable to correct problems, you have held broken packages.\n"
90 "chroot FAIL badpkg\n"
91 "blame: apache2\n"
92 "badpkg: Test dependencies are unsatisfiable. A common reason is ...\n"
93 "autopkgtest [21:48:03]: @@@@@@@@@@@@@@@@@@@@ summary\n"
94 "run-test-suite FAIL badpkg\n"
95 "blame: apache2\n"
96 "badpkg: Test dependencies are unsatisfiable. A common reason is...\n"
97 "duplicate-module-load PASS\n"
98 "default-mods PASS\n"
99 "run-htcacheclean PASS\n"
100 "ssl-passphrase PASS\n"
101 "check-http2 PASS\n"
102 "run-chroot FAIL badpkg\n"
103 "blame: apache2\n"
104 ),
105 'run-',
106 {
107 'run-test-suite': 'FAIL',
108 'run-htcacheclean': 'PASS',
109 'run-chroot': 'FAIL',
110 }
111 ),
112 (
113 (
114 "3657s rm: cannot remove '.../mountpoint': Device or resource busy\n"
115 "3661s autopkgtest [03:41:43]: test minimized: -----------------------]\n"
116 "3663s autopkgtest [03:41:45]: test minimized: - - - - - - - - - - results - - - - - - - - - -\n"
117 "3663s minimized FAIL non-zero exit status 1\n"
118 "3663s autopkgtest [03:41:45]: test minimized: - - - - - - - - - - stderr - - - - - - - - - -\n"
119 "3663s rm: cannot remove '.../mountpoint': Device or resource busy\n"
120 "3664s autopkgtest [03:41:46]: @@@@@@@@@@@@@@@@@@@@ summary\n"
121 "3664s default-bootstraps FAIL non-zero exit status 1\n"
122 "3664s minimized FAIL non-zero exit status 1'\n"
123 ),
124 None,
125 {
126 'default-bootstraps': 'FAIL',
127 'minimized': 'FAIL'
128 }
129 ),
130])
131def test_get_subtests(tmp_path, log_text: str, subtest_name: str, expected: dict[str]):
132 """Checks retrieval of Subtest objects from autopkgtest results.
133
134 This test exercises the parser that extracts subtest information out
135 of autopkgtest logs of various formats. It also verifies the
136 parameter to get_subtests() is handled correctly.
137
138 :param fixture tmp_path: Temp dir.
139 :param str log_text: Text to write into the log file.
140 :param str subtest_name: Only retrieve subtests starting with this text.
141 :param dict[str] expected: Dictionary of subtest names to pass/fail status.
142 """
143 f = tmp_path / "result.log.gz"
144 compressed_text = gzip.compress(bytes(log_text, 'utf-8'))
145 f.write_bytes(compressed_text)
146
147 result = Result(f"file://{f}", None, None, None, None)
148 subtests = result.get_subtests(subtest_name)
149 assert {s.desc: s.status for s in subtests} == expected
150
151
72@pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [152@pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [
73 ('x', 'x', 'x', 'x', {})153 ('x', 'x', 'x', 'x', {})
74])154])

Subscribers

People subscribed via source and target branches

to all changes: