Skip to content

Commit 81742f6

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

File tree

4 files changed

+40
-29
lines changed

4 files changed

+40
-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: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BugRunInfo:
4242

4343
@dataclass
4444
class BugsDetails:
45+
run_count: dict[str, int] = field(default_factory=dict) # {job_name: run_count}
4546
total: int = 0
4647
test_variants: set = field(default_factory=set)
4748
per_repositories: dict[str, int] = field(default_factory=dict) # {repo1: 1, repo2: 2, ...}
@@ -443,18 +444,27 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
443444
all_variants = set()
444445
for bug in bugs:
445446
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)
447+
all_tests = self.get_tests_from_manifests()
448+
test_name = self.get_test_name(all_tests, bug["bug__summary"])
449+
manifest = None
449450
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]
451+
run_count = 0
452+
if test_name:
453+
manifest = all_tests[test_name][0]
454+
if manifest:
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+
testrun_matrix = (
462+
fetch.fetch_testrun_matrix()
463+
if self.testrun_matrix is None
464+
else self.testrun_matrix
465+
)
466+
self.testrun_matrix = testrun_matrix
467+
bug_testrun_matrix = testrun_matrix[manifest]
458468
bug_run_info = self.get_bug_run_info(bug)
459469
all_variants = bug_run_info.variants
460470
if bug_testrun_matrix and bug_run_info.os_name in bug_testrun_matrix:
@@ -473,7 +483,10 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
473483
bug_infos.total = 1
474484
bug_infos.test_variants |= all_variants
475485
bug_infos.per_repositories[repo] = 1
476-
bug_infos.data_table[platform_and_build] = {test_variant: 1}
486+
bug_infos.data_table[platform_and_build] = {
487+
test_variant: 1,
488+
"total_runs": run_count,
489+
}
477490
bug_map[bug_id] = bug_infos
478491
else:
479492
bug_infos = bug_map[bug_id]
@@ -485,6 +498,7 @@ def build_bug_map(self, bugs, option_collection_map, start_day, end_day):
485498
data_table = bug_infos.data_table
486499
platform_and_build_data = data_table.get(platform_and_build, {})
487500
data_table[platform_and_build] = platform_and_build_data
501+
data_table[platform_and_build]["total_runs"] = run_count
488502
data_table[platform_and_build][test_variant] = (
489503
platform_and_build_data.get(test_variant, 0) + 1
490504
)
@@ -556,8 +570,7 @@ def fix_wpt_name(self, test_name):
556570
test_name = test_name.split("?")[0]
557571
return test_name
558572

559-
def get_test_manifest(self, summary):
560-
all_tests = self.get_tests_from_manifests()
573+
def get_test_name(self, all_tests, summary):
561574
tv_strings = [
562575
" TV ",
563576
" TV-nofis ",
@@ -620,7 +633,5 @@ def get_test_manifest(self, summary):
620633
# 3) test has been deleted from the source tree
621634
# 4) sometimes test was deleted but is valid on beta
622635
return None
623-
# matching test- we can access manifest
624-
manifests = all_tests[test_name]
625-
return manifests[0]
636+
return test_name
626637
return None

0 commit comments

Comments
 (0)