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
1diff --git a/ppa/result.py b/ppa/result.py
2index 7488f54..125c134 100755
3--- a/ppa/result.py
4+++ b/ppa/result.py
5@@ -163,12 +163,9 @@ class Result:
6 """
7 regex_triggers = re.compile(r'--env=ADT_TEST_TRIGGERS=(.*?) -- ')
8 header_split = self.log.split(": @@@@@@@@@@@@@@@@@@@@", 1)
9- if len(header_split) < 2:
10- return []
11 m = re.search(regex_triggers, header_split[0])
12 if not m:
13 return []
14-
15 return m.group(1).strip("'").split()
16
17 @lru_cache
18@@ -201,7 +198,8 @@ class Result:
19 """
20 result_split = self.log.split("@@@@@@@@@@@@@@@@@@@@ summary", 1)
21 if len(result_split) < 2:
22- return []
23+ self.error_message = "Failure setting up testbed ⚪"
24+ return [Subtest("testbed setup failure BAD")]
25
26 subtests = []
27 result_sum = result_split[1]
28@@ -235,6 +233,8 @@ class Result:
29 for subtest in self.get_subtests():
30 if subtest.status == 'FAIL':
31 return 'FAIL'
32+ elif subtest.status == 'BAD':
33+ return 'BAD'
34 return 'PASS'
35
36 @property
37diff --git a/scripts/ppa b/scripts/ppa
38index c2f803d..7046f73 100755
39--- a/scripts/ppa
40+++ b/scripts/ppa
41@@ -1057,7 +1057,6 @@ def command_tests(lp: Lp, config: dict[str, str]) -> int:
42 )
43
44 # Results
45- the_ppa.get_autopkgtest_results(releases, architectures, packages)
46 show_results(the_ppa.get_autopkgtest_results(releases, architectures, packages),
47 config.get('show_urls'))
48
49diff --git a/tests/data/results-rabbitmq-server-armhf.log.gz b/tests/data/results-rabbitmq-server-armhf.log.gz
50new file mode 100644
51index 0000000..ad604cf
52Binary files /dev/null and b/tests/data/results-rabbitmq-server-armhf.log.gz differ
53diff --git a/tests/test_result.py b/tests/test_result.py
54index 89a6c8f..b205634 100644
55--- a/tests/test_result.py
56+++ b/tests/test_result.py
57@@ -126,6 +126,7 @@ def test_log(tmp_path):
58
59
60 @pytest.mark.parametrize('filename, expected_triggers', [
61+ ('results-rabbitmq-server-armhf.log.gz', ['rabbitmq-server/3.9.27-0ubuntu0.1~jammy8']),
62 ('results-six-s390x.log.gz', ['pygobject/3.42.2-2', 'six/1.16.0-4']),
63 ('results-chrony-armhf.log.gz', ['dpkg/1.22.6ubuntu5'])
64 ])
65@@ -171,7 +172,7 @@ def test_get_triggers(monkeypatch, triggers, name, expected):
66
67
68 @pytest.mark.parametrize('log_text, subtest_name, expected', [
69- ('', None, {}),
70+ ('', None, {'testbed': 'BAD'}),
71 (
72 (
73 "x: @@@@@@@@@@@@@@@@@@@@ summary\n"
74@@ -300,13 +301,25 @@ def test_status_icon_error(monkeypatch, status, expected_exception):
75
76 @pytest.mark.parametrize('log_text, series, arch, source, expected_dict', [
77 (
78- # Empty/invalid log should return empty triggers & subtests.
79- 'x', 'x', 'x', 'x', {'triggers': [], 'subtests': []}
80+ # Empty/invalid log should return empty triggers
81+ 'x', 'x', 'x', 'x', {'triggers': []}
82 ),
83
84 (
85- # Empty/invalid log counts as an overall test pass.
86- 'x', 'x', 'x', 'x', {'status': 'PASS', 'status_icon': '✅'}
87+ # Empty/invalid log counts as an overall test state BAD.
88+ 'x', 'x', 'x', 'x',
89+ {
90+ 'status': 'BAD',
91+ 'status_icon': '⛔',
92+ 'subtests': [
93+ {
94+ 'desc': 'testbed',
95+ 'line': 'testbed setup failure BAD',
96+ 'status': 'BAD',
97+ 'status_icon': '⛔'
98+ }
99+ ]
100+ }
101 ),
102
103 (
104@@ -493,10 +506,14 @@ def test_get_results(tmp_path,
105
106
107 @pytest.mark.parametrize('data, show_urls, expected_num_lines, expected_in_stdout', [
108- # When there are no results, indicate '(none)'
109- ({}, True, 1, "* Results: (none)\n"),
110- ({'trigger-1': ('a', 'b', 'c', 'x')}, True, 4, "- trigger-1\n + ✅ c on a for b"),
111- ({'t1': ('a', 'b', 'c', 'x'), 't2': ('a', 'b', 'c', 'x')}, True, 7, "- t2"),
112+ (
113+ # When there are no results, indicate '(none)'
114+ {}, True, 1, "* Results: (none)\n"
115+ ),
116+ (
117+ {'trigger-1': ('a', 'b', 'c', 'x')}, True, 6, "- trigger-1\n + ⛔ c on a for b"
118+ ),
119+ ({'t1': ('a', 'b', 'c', 'x'), 't2': ('a', 'b', 'c', 'x')}, True, 11, "- t2"),
120 ])
121 def test_show_results(capfd, tmp_path,
122 data, show_urls, expected_num_lines, expected_in_stdout):

Subscribers

People subscribed via source and target branches

to all changes: