Merge ppa-dev-tools:testbed-setup-failures-are-bad into ppa-dev-tools:main

Proposed by Bryce Harrington
Status: Merged
Merged at revision: 074f622aa5bbb855dc21081010f599a08338f940
Proposed branch: ppa-dev-tools:testbed-setup-failures-are-bad
Merge into: ppa-dev-tools:main
Diff against target: 122 lines (+30/-14)
3 files modified
ppa/result.py (+4/-4)
scripts/ppa (+0/-1)
tests/test_result.py (+26/-9)
Reviewer Review Type Date Requested Status
Athos Ribeiro (community) Approve
Canonical Server Reporter Pending
PpaDevTools Developers Pending
Review via email: mp+466028@code.launchpad.net

Description of the change

If there is an error setting up the testbed, it'll error out before any subtests are generated. ppa-dev-tools was not correctly checking for or handling this state and required a few different fixups.

Thanks Mitchell for finding and reporting this corner case.

(Hmm, come to think of it I should probably also write test cases to accompany this...)

To post a comment you must log in.
Revision history for this message
Mitchell Dzurick (mitchdz) wrote (last edit ):

Huh I don't see this branch fixing my issue for some reason. Am I installing it wrong?

1. I checked out testbed-setup-failures-are-bad
2. `snapcraft`
3. `snap install ppa-dev-tools_v0.5.0+git43.0c5c395_amd64.snap --dangerous`

It just looks identical to the failure in the bug

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

I ran the following command from the main brainch:

$ ppa tests https://launchpad.net/~mitchdz/+archive/ubuntu/rabbitmq-server-mre-2204/

and got the following results (leaving only relevant bits):

* Results:
  -
    + ✅ rabbitmq-server on focal for amd64 @ 16.05.24 01:43:46 Log️ 🗒️
    + ✅ rabbitmq-server on focal for arm64 @ 12.05.24 03:07:20 Log️ 🗒️
    + ✅ rabbitmq-server on focal for armhf @ 11.05.24 08:01:13 Log️ 🗒️
  - rabbitmq-server/3.8.3-0ubuntu0.1~focal5
    + ✅ rabbitmq-server on focal for i386 @ 11.05.24 13:35:11 Log️ 🗒️
    + ✅ rabbitmq-server on focal for ppc64el @ 14.05.24 23:10:14 Log️ 🗒️
    + ✅ rabbitmq-server on focal for s390x @ 14.05.24 03:20:42 Log️ 🗒️

Then, I ran the same command from the proposed branch and got the following results:

* Results:
  - rabbitmq-server/3.8.3-0ubuntu0.1~focal5
    + ⛔ rabbitmq-server on focal for amd64 @ 16.05.24 01:43:46 Log️ 🗒️
      • testbed BAD ⛔
    + ⛔ rabbitmq-server on focal for arm64 @ 12.05.24 03:07:20 Log️ 🗒️
      • testbed BAD ⛔
    + ⛔ rabbitmq-server on focal for armhf @ 11.05.24 08:01:13 Log️ 🗒️
      • testbed BAD ⛔
    + ✅ rabbitmq-server on focal for i386 @ 11.05.24 13:35:11 Log️ 🗒️
    + ✅ rabbitmq-server on focal for ppc64el @ 14.05.24 23:10:14 Log️ 🗒️
    + ✅ rabbitmq-server on focal for s390x @ 14.05.24 03:20:42 Log️ 🗒️

This works for me.

Mitchell, have you checked the code in your installed snap to make sure it was indeed carrying this patch?

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

As Bryce mentioned, it would be nice to have some tests for this one.

Still, this LGTM. It would also be nice to verify why Mitchell did not get the same results as I did while testing this before merging.

review: Approve

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 7488f54..125c134 100755
--- a/ppa/result.py
+++ b/ppa/result.py
@@ -163,12 +163,9 @@ class Result:
163 """163 """
164 regex_triggers = re.compile(r'--env=ADT_TEST_TRIGGERS=(.*?) -- ')164 regex_triggers = re.compile(r'--env=ADT_TEST_TRIGGERS=(.*?) -- ')
165 header_split = self.log.split(": @@@@@@@@@@@@@@@@@@@@", 1)165 header_split = self.log.split(": @@@@@@@@@@@@@@@@@@@@", 1)
166 if len(header_split) < 2:
167 return []
168 m = re.search(regex_triggers, header_split[0])166 m = re.search(regex_triggers, header_split[0])
169 if not m:167 if not m:
170 return []168 return []
171
172 return m.group(1).strip("'").split()169 return m.group(1).strip("'").split()
173170
174 @lru_cache171 @lru_cache
@@ -201,7 +198,8 @@ class Result:
201 """198 """
202 result_split = self.log.split("@@@@@@@@@@@@@@@@@@@@ summary", 1)199 result_split = self.log.split("@@@@@@@@@@@@@@@@@@@@ summary", 1)
203 if len(result_split) < 2:200 if len(result_split) < 2:
204 return []201 self.error_message = "Failure setting up testbed ⚪"
202 return [Subtest("testbed setup failure BAD")]
205203
206 subtests = []204 subtests = []
207 result_sum = result_split[1]205 result_sum = result_split[1]
@@ -235,6 +233,8 @@ class Result:
235 for subtest in self.get_subtests():233 for subtest in self.get_subtests():
236 if subtest.status == 'FAIL':234 if subtest.status == 'FAIL':
237 return 'FAIL'235 return 'FAIL'
236 elif subtest.status == 'BAD':
237 return 'BAD'
238 return 'PASS'238 return 'PASS'
239239
240 @property240 @property
diff --git a/scripts/ppa b/scripts/ppa
index c2f803d..7046f73 100755
--- a/scripts/ppa
+++ b/scripts/ppa
@@ -1057,7 +1057,6 @@ def command_tests(lp: Lp, config: dict[str, str]) -> int:
1057 )1057 )
10581058
1059 # Results1059 # Results
1060 the_ppa.get_autopkgtest_results(releases, architectures, packages)
1061 show_results(the_ppa.get_autopkgtest_results(releases, architectures, packages),1060 show_results(the_ppa.get_autopkgtest_results(releases, architectures, packages),
1062 config.get('show_urls'))1061 config.get('show_urls'))
10631062
diff --git a/tests/data/results-rabbitmq-server-armhf.log.gz b/tests/data/results-rabbitmq-server-armhf.log.gz
1064new file mode 1006441063new file mode 100644
index 0000000..ad604cf
1065Binary files /dev/null and b/tests/data/results-rabbitmq-server-armhf.log.gz differ1064Binary files /dev/null and b/tests/data/results-rabbitmq-server-armhf.log.gz differ
diff --git a/tests/test_result.py b/tests/test_result.py
index 89a6c8f..b205634 100644
--- a/tests/test_result.py
+++ b/tests/test_result.py
@@ -126,6 +126,7 @@ def test_log(tmp_path):
126126
127127
128@pytest.mark.parametrize('filename, expected_triggers', [128@pytest.mark.parametrize('filename, expected_triggers', [
129 ('results-rabbitmq-server-armhf.log.gz', ['rabbitmq-server/3.9.27-0ubuntu0.1~jammy8']),
129 ('results-six-s390x.log.gz', ['pygobject/3.42.2-2', 'six/1.16.0-4']),130 ('results-six-s390x.log.gz', ['pygobject/3.42.2-2', 'six/1.16.0-4']),
130 ('results-chrony-armhf.log.gz', ['dpkg/1.22.6ubuntu5'])131 ('results-chrony-armhf.log.gz', ['dpkg/1.22.6ubuntu5'])
131])132])
@@ -171,7 +172,7 @@ def test_get_triggers(monkeypatch, triggers, name, expected):
171172
172173
173@pytest.mark.parametrize('log_text, subtest_name, expected', [174@pytest.mark.parametrize('log_text, subtest_name, expected', [
174 ('', None, {}),175 ('', None, {'testbed': 'BAD'}),
175 (176 (
176 (177 (
177 "x: @@@@@@@@@@@@@@@@@@@@ summary\n"178 "x: @@@@@@@@@@@@@@@@@@@@ summary\n"
@@ -300,13 +301,25 @@ def test_status_icon_error(monkeypatch, status, expected_exception):
300301
301@pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [302@pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [
302 (303 (
303 # Empty/invalid log should return empty triggers & subtests.304 # Empty/invalid log should return empty triggers
304 'x', 'x', 'x', 'x', {'triggers': [], 'subtests': []}305 'x', 'x', 'x', 'x', {'triggers': []}
305 ),306 ),
306307
307 (308 (
308 # Empty/invalid log counts as an overall test pass.309 # Empty/invalid log counts as an overall test state BAD.
309 'x', 'x', 'x', 'x', {'status': 'PASS', 'status_icon': '✅'}310 'x', 'x', 'x', 'x',
311 {
312 'status': 'BAD',
313 'status_icon': '⛔',
314 'subtests': [
315 {
316 'desc': 'testbed',
317 'line': 'testbed setup failure BAD',
318 'status': 'BAD',
319 'status_icon': '⛔'
320 }
321 ]
322 }
310 ),323 ),
311324
312 (325 (
@@ -493,10 +506,14 @@ def test_get_results(tmp_path,
493506
494507
495@pytest.mark.parametrize('data, show_urls, expected_num_lines, expected_in_stdout', [508@pytest.mark.parametrize('data, show_urls, expected_num_lines, expected_in_stdout', [
496 # When there are no results, indicate '(none)'509 (
497 ({}, True, 1, "* Results: (none)\n"),510 # When there are no results, indicate '(none)'
498 ({'trigger-1': ('a', 'b', 'c', 'x')}, True, 4, "- trigger-1\n + ✅ c on a for b"),511 {}, True, 1, "* Results: (none)\n"
499 ({'t1': ('a', 'b', 'c', 'x'), 't2': ('a', 'b', 'c', 'x')}, True, 7, "- t2"),512 ),
513 (
514 {'trigger-1': ('a', 'b', 'c', 'x')}, True, 6, "- trigger-1\n + ⛔ c on a for b"
515 ),
516 ({'t1': ('a', 'b', 'c', 'x'), 't2': ('a', 'b', 'c', 'x')}, True, 11, "- t2"),
500])517])
501def test_show_results(capfd, tmp_path,518def test_show_results(capfd, tmp_path,
502 data, show_urls, expected_num_lines, expected_in_stdout):519 data, show_urls, expected_num_lines, expected_in_stdout):

Subscribers

People subscribed via source and target branches

to all changes: