Skip to content

Commit 9bdcf9d

Browse files
authored
Add descriptive text to intermittent comment when we have available runcount data. (#8835)
1 parent a64a0de commit 9bdcf9d

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

tests/intermittents_commenter/expected_comment.text

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ This is the #1 most frequent failure this week.
99
|---|:-:|:-:|:-:|
1010
|**macosx1015-x86_64/debug**| | |1/22|
1111

12+
* x/y indicates test failures and total runs; only x means number of runs is unknown.
13+
1214
## For more details, see:
1315
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug=1&startday=2022-05-09&endday=2025-05-10&tree=all
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
3 failures were associated with this bug in the last 7 days.
2+
This is the #1 most frequent failure this week.
3+
4+
## Repository breakdown:
5+
* mozilla-central: 3
6+
7+
## Table
8+
| |**a11y_checks+swgl**|**no_variant**|**socketprocess_networking**|**spi-nw**|**swgl**|
9+
|---|:-:|:-:|:-:|:-:|:-:|
10+
|**linux1804-x86_64/debug**| | | |1| |
11+
|**macosx1015-x86_64/debug**| | | |2| |
12+
13+
## For more details, see:
14+
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug=1&startday=2025-01-01&endday=2025-05-10&tree=all

tests/intermittents_commenter/expected_comment_with_5_failures.text

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ This is the #1 most frequent failure this week.
1010
|**linux1804-x86_64/debug**| |1| |2/92| |
1111
|**macosx1015-x86_64/debug**| | | |2/22| |
1212

13+
* x/y indicates test failures and total runs; only x means number of runs is unknown.
14+
1315
## For more details, see:
1416
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug=1&startday=2022-05-09&endday=2025-05-10&tree=all

tests/intermittents_commenter/test_commenter.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,50 @@ def test_intermittents_commenter_with_failures(
9292
assert comment_params[0]["changes"]["comment"]["body"] == expected_comment
9393

9494

95+
@responses.activate
96+
def test_intermittents_commenter_with_no_runcount(
97+
bug_data_with_5_failures,
98+
mock_test_variants_firefoxci_request,
99+
mock_test_manifests_firefoxci_request,
100+
mock_testrun_matrix_firefoxci_request,
101+
mock_summary_groups_request,
102+
):
103+
startday = "2025-01-01"
104+
endday = "2025-05-10"
105+
alt_startday = startday
106+
alt_endday = endday
107+
108+
process = Commenter(weekly_mode=True, dry_run=True)
109+
params = {"include_fields": "product%2C+component%2C+priority%2C+whiteboard%2C+id"}
110+
url = "{}/rest/bug?id={}&include_fields={}".format(
111+
settings.BZ_API_URL, bug_data_with_5_failures["bug_id"], params["include_fields"]
112+
)
113+
114+
content = {
115+
"bugs": [
116+
{
117+
"component": "General",
118+
"priority": "P3",
119+
"product": "Testing",
120+
"whiteboard": "[stockwell infra] [see summary at comment 92]",
121+
"id": bug_data_with_5_failures["bug_id"],
122+
}
123+
],
124+
"faults": [],
125+
}
126+
127+
responses.add(responses.Response(method="GET", url=url, json=content, status=200))
128+
129+
resp = process.fetch_bug_details(bug_data_with_5_failures["bug_id"])
130+
assert resp == content["bugs"]
131+
132+
comment_params = process.generate_bug_changes(startday, endday, alt_startday, alt_endday)
133+
134+
with open("tests/intermittents_commenter/expected_comment_no_runcount.text") as comment:
135+
expected_comment = comment.read()
136+
assert comment_params[0]["changes"]["comment"]["body"] == expected_comment
137+
138+
95139
def test_get_test_variants(mock_test_variants_firefoxci_request):
96140
process = Commenter(weekly_mode=True, dry_run=True)
97141
test_suite = "mochitest-browser-chrome-spi-nw-10"

treeherder/intermittents_commenter/comment.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ This is the #{{rank}} most frequent failure this week.{% endif %}
4646
{%- endif -%}
4747
{%- endfor %}
4848
{% endfor %}
49+
{% if has_runcount -%}
50+
{{"* x/y indicates test failures and total runs; only x means number of runs is unknown.\n"}}
51+
{% endif -%}
4952
## For more details, see:
5053
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug={{bug_id}}&startday={{startday}}&endday={{endday}}&tree=all

treeherder/intermittents_commenter/commenter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class BugRunInfo:
4444
class BugsDetails:
4545
run_count: dict[str, int] = field(default_factory=dict) # {job_name: run_count}
4646
total: int = 0
47+
has_runcount: bool = False
4748
test_variants: set = field(default_factory=set)
4849
per_repositories: dict[str, int] = field(default_factory=dict) # {repo1: 1, repo2: 2, ...}
4950
data_table: dict[str, dict[str, int]] = field(
@@ -148,6 +149,7 @@ def generate_bug_changes(self, startday, endday, alt_startday, alt_endday):
148149
repositories=counts.per_repositories,
149150
test_variants=sorted(list(counts.test_variants)),
150151
data_table=counts.data_table,
152+
has_runcount=bug_map[bug_id].has_runcount,
151153
startday=startday,
152154
endday=endday.split()[0],
153155
weekly_mode=self.weekly_mode,
@@ -485,6 +487,8 @@ def build_bug_map(self, bugs, option_collection_map, days):
485487
bug_infos.data_table[platform_and_build] = {
486488
test_variant: {"count": 1, "runs": run_count},
487489
}
490+
if run_count > 0:
491+
bug_infos.has_runcount = True
488492
bug_map[bug_id] = bug_infos
489493
else:
490494
bug_infos = bug_map[bug_id]
@@ -500,6 +504,8 @@ def build_bug_map(self, bugs, option_collection_map, days):
500504
"count": platform_and_build_data.get(test_variant, {}).get("count", 0) + 1,
501505
"runs": run_count,
502506
}
507+
if run_count > 0:
508+
bug_infos.has_runcount = True
503509

504510
return bug_map
505511

0 commit comments

Comments
 (0)