Skip to content

Commit d482f6a

Browse files
committed
[intermittent commenter] add run counts in intermitent commenter
1 parent 86334f3 commit d482f6a

File tree

4 files changed

+42
-29
lines changed

4 files changed

+42
-29
lines changed

tests/intermittents_commenter/expected_comment.text

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ This is the #1 most frequent failure this week.
55
* mozilla-central: 1
66

77
## Table
8-
| |**debug**|**no_variant**|**opt**|**spi-nw**|
9-
|---|:-:|:-:|:-:|:-:|
10-
|**macosx1015-x86_64/debug**| | | |1|
8+
| |**nb runs**|**debug**|**no_variant**|**opt**|**spi-nw**|
9+
|---|:-:|:-:|:-:|:-:|:-:|
10+
|**macosx1015-x86_64/debug**|22| | | |1|
1111

1212
## For more details, see:
1313
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug=1&startday=2022-05-09&endday=2025-05-10&tree=all

tests/intermittents_commenter/expected_comment_with_5_failures.text

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ This is the #1 most frequent failure this week.
55
* mozilla-central: 5
66

77
## Table
8-
| |**asan**|**debug**|**headless**|**no_variant**|**opt**|**spi-nw**|**swr**|**tsan**|
9-
|---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
10-
|**linux-x86/unknown build**| | |2| | | | | |
11-
|**linux1804-x86_64/debug**| | | | | |1| | |
12-
|**macosx1015-x86_64/debug**| | | | | |1| | |
13-
|**macosx1470-x86_64/debug**| | | | | | |1| |
8+
| |**nb runs**|**asan**|**debug**|**headless**|**no_variant**|**opt**|**spi-nw**|**swr**|**tsan**|
9+
|---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
10+
|**linux-x86/unknown build**|0| | |2| | | | | |
11+
|**linux1804-x86_64/debug**|92| | | | | |1| | |
12+
|**macosx1015-x86_64/debug**|22| | | | | |1| | |
13+
|**macosx1470-x86_64/debug**|0| | | | | | |1| |
1414

1515
## For more details, see:
1616
https://treeherder.mozilla.org/intermittent-failures/bugdetails?bug=1&startday=2022-05-09&endday=2025-05-10&tree=all

treeherder/intermittents_commenter/comment.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ This is the #{{rank}} most frequent failure this week.{% endif %}
2424
* {{repository}}: {{count}}
2525
{% endfor %}
2626
## Table
27-
| |
27+
| |**nb runs**|
2828
{%- for variant in test_variants -%}
2929
**{{variant}}**|
3030
{%- endfor %}
31-
|---|
31+
|---|:-:|
3232
{%- for variant in test_variants -%}
3333
:-:|
3434
{%- endfor %}
3535
{% for platform_and_build, test_by_variant in data_table.items() | sort() -%}
36-
|**{{platform_and_build}}**|
36+
|**{{platform_and_build}}**|{{test_by_variant.get('total_runs', " ")}}|
3737
{%- for variant in test_variants -%}
3838
{{test_by_variant.get(variant, " ")}}|
3939
{%- endfor %}

treeherder/intermittents_commenter/commenter.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class BugRunInfo:
4242

4343
@dataclass
4444
class BugsDetails:
45+
test_name: str = ""
46+
run_count: dict[str, int] = field(default_factory=dict) # {job_name: run_count}
4547
total: int = 0
4648
test_variants: set = field(default_factory=set)
4749
per_repositories: dict[str, int] = field(default_factory=dict) # {repo1: 1, repo2: 2, ...}
@@ -443,18 +445,27 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
443445
all_variants = set()
444446
for bug in bugs:
445447
bug_id = bug["bug__bugzilla_id"]
446-
manifest = self.get_test_manifest(bug["bug__summary"])
447-
task_labels = self.get_task_labels_and_count(manifest, start_day, end_day)
448-
print(task_labels)
448+
all_tests = self.get_tests_from_manifests()
449+
test_name = self.get_test_name(all_tests, bug["bug__summary"])
450+
manifest = None
449451
bug_testrun_matrix = []
450-
if manifest:
451-
testrun_matrix = (
452-
fetch.fetch_testrun_matrix()
453-
if self.testrun_matrix is None
454-
else self.testrun_matrix
455-
)
456-
self.testrun_matrix = testrun_matrix
457-
bug_testrun_matrix = testrun_matrix[manifest]
452+
run_count = 0
453+
if test_name:
454+
manifest = all_tests[test_name][0]
455+
tasks_count = self.get_task_labels_and_count(manifest, start_day, end_day)
456+
job_name = bug["job__signature__job_type_name"]
457+
for task_name, count in tasks_count.items():
458+
if task_name in job_name:
459+
run_count = count
460+
break
461+
if manifest:
462+
testrun_matrix = (
463+
fetch.fetch_testrun_matrix()
464+
if self.testrun_matrix is None
465+
else self.testrun_matrix
466+
)
467+
self.testrun_matrix = testrun_matrix
468+
bug_testrun_matrix = testrun_matrix[manifest]
458469
bug_run_info = self.get_bug_run_info(bug)
459470
all_variants = bug_run_info.variants
460471
if bug_testrun_matrix and bug_run_info.os_name in bug_testrun_matrix:
@@ -470,10 +481,14 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
470481
platform_and_build = f"{bug_run_info.platform}/{bug_run_info.build_type}"
471482
if bug_id not in bug_map:
472483
bug_infos = BugsDetails()
484+
bug_infos.test_name = test_name
473485
bug_infos.total = 1
474486
bug_infos.test_variants |= all_variants
475487
bug_infos.per_repositories[repo] = 1
476-
bug_infos.data_table[platform_and_build] = {test_variant: 1}
488+
bug_infos.data_table[platform_and_build] = {
489+
test_variant: 1,
490+
"total_runs": run_count,
491+
}
477492
bug_map[bug_id] = bug_infos
478493
else:
479494
bug_infos = bug_map[bug_id]
@@ -485,6 +500,7 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
485500
data_table = bug_infos.data_table
486501
platform_and_build_data = data_table.get(platform_and_build, {})
487502
data_table[platform_and_build] = platform_and_build_data
503+
data_table[platform_and_build]["total_runs"] = run_count
488504
data_table[platform_and_build][test_variant] = (
489505
platform_and_build_data.get(test_variant, 0) + 1
490506
)
@@ -556,8 +572,7 @@ def fix_wpt_name(self, test_name):
556572
test_name = test_name.split("?")[0]
557573
return test_name
558574

559-
def get_test_manifest(self, summary):
560-
all_tests = self.get_tests_from_manifests()
575+
def get_test_name(self, all_tests, summary):
561576
tv_strings = [
562577
" TV ",
563578
" TV-nofis ",
@@ -620,7 +635,5 @@ def get_test_manifest(self, summary):
620635
# 3) test has been deleted from the source tree
621636
# 4) sometimes test was deleted but is valid on beta
622637
return None
623-
# matching test- we can access manifest
624-
manifests = all_tests[test_name]
625-
return manifests[0]
638+
return test_name
626639
return None

0 commit comments

Comments
 (0)