Skip to content

Commit dcac151

Browse files
authored
events: Do not use pulse messages from non gecko builds, fixes #180 (#182)
1 parent dd460b2 commit dcac151

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

events/code_coverage_events/workflow.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ async def parse(self, body):
108108
Extract revisions from payload
109109
"""
110110
taskGroupId = body["taskGroupId"]
111+
scheduler = body["schedulerId"]
112+
113+
# Check the scheduler name before loading all tasks in the group
114+
# We are only interested in Mozilla gecko builds
115+
if not scheduler.startswith("gecko-level-"):
116+
logger.info(
117+
"Skipping task, unsupported scheduler",
118+
group_id=taskGroupId,
119+
scheduler=scheduler,
120+
)
121+
return None
111122

112123
build_task = await self.get_build_task_in_group(taskGroupId)
113124
if build_task is None:

events/tests/test_workflow.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ async def test_parse(mock_taskcluster):
4949

5050
hook.triggered_groups.add("already-triggered-group")
5151

52-
assert await hook.parse({"taskGroupId": "already-triggered-group"}) is None
52+
assert (
53+
await hook.parse(
54+
{"schedulerId": "gecko-level-1", "taskGroupId": "already-triggered-group"}
55+
)
56+
is None
57+
)
5358

5459

55-
def run_async_parser(hook, group_id):
60+
def run_async_parser(hook, group_id, scheduler):
5661
"""
5762
Helper to run the asynchronous parser using responses in the same event loop
5863
"""
@@ -65,7 +70,7 @@ async def _check():
6570
json=json.load(f),
6671
status=200,
6772
)
68-
return await hook.parse({"taskGroupId": group_id})
73+
return await hook.parse({"schedulerId": scheduler, "taskGroupId": group_id})
6974

7075
loop = asyncio.new_event_loop()
7176
return loop.run_until_complete(_check())
@@ -75,14 +80,29 @@ def test_wrong_branch(mock_taskcluster):
7580
bus = MessageBus()
7681
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)
7782

78-
assert run_async_parser(hook, "bNq-VIT-Q12o6nXcaUmYNQ") is None
83+
assert run_async_parser(hook, "bNq-VIT-Q12o6nXcaUmYNQ", "gecko-level-1") is None
7984

8085

8186
def test_success(mock_taskcluster):
8287
bus = MessageBus()
8388
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)
8489

85-
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g") == [
90+
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "gecko-level-1") == [
91+
{
92+
"REPOSITORY": "https://hg.mozilla.org/mozilla-central",
93+
"REVISION": "ec3dd3ee2ae4b3a63529a912816a110e925eb2d0",
94+
}
95+
]
96+
97+
98+
def test_scheduler(mock_taskcluster):
99+
bus = MessageBus()
100+
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)
101+
102+
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "-") is None
103+
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "anotherValue") is None
104+
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "aws-Xxxx") is None
105+
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "gecko-level-1") == [
86106
{
87107
"REPOSITORY": "https://hg.mozilla.org/mozilla-central",
88108
"REVISION": "ec3dd3ee2ae4b3a63529a912816a110e925eb2d0",
@@ -94,7 +114,7 @@ def test_success_windows(mock_taskcluster):
94114
bus = MessageBus()
95115
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)
96116

97-
assert run_async_parser(hook, "MibGDsa4Q7uFNzDf7EV6nw") == [
117+
assert run_async_parser(hook, "MibGDsa4Q7uFNzDf7EV6nw", "gecko-level-2") == [
98118
{
99119
"REPOSITORY": "https://hg.mozilla.org/mozilla-central",
100120
"REVISION": "63519bfd42ee379f597c0357af2e712ec3cd9f50",
@@ -106,7 +126,7 @@ def test_success_try(mock_taskcluster):
106126
bus = MessageBus()
107127
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)
108128

109-
assert run_async_parser(hook, "FG3goVnCQfif8ZEOaM_4IA") == [
129+
assert run_async_parser(hook, "FG3goVnCQfif8ZEOaM_4IA", "gecko-level-1") == [
110130
{
111131
"REPOSITORY": "https://hg.mozilla.org/try",
112132
"REVISION": "066cb18ba95a7efe144e729713c429e422d9f95b",

0 commit comments

Comments
 (0)