Skip to content

Do not use pulse messages from non gecko builds #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions events/code_coverage_events/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ async def parse(self, body):
Extract revisions from payload
"""
taskGroupId = body["taskGroupId"]
scheduler = body["schedulerId"]

# Check the scheduler name before loading all tasks in the group
# We are only interested in Mozilla gecko builds
if not scheduler.startswith("gecko-level-"):
logger.info(
"Skipping task, unsupported scheduler",
group_id=taskGroupId,
scheduler=scheduler,
)
return None

build_task = await self.get_build_task_in_group(taskGroupId)
if build_task is None:
Expand Down
34 changes: 27 additions & 7 deletions events/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ async def test_parse(mock_taskcluster):

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

assert await hook.parse({"taskGroupId": "already-triggered-group"}) is None
assert (
await hook.parse(
{"schedulerId": "gecko-level-1", "taskGroupId": "already-triggered-group"}
)
is None
)


def run_async_parser(hook, group_id):
def run_async_parser(hook, group_id, scheduler):
"""
Helper to run the asynchronous parser using responses in the same event loop
"""
Expand All @@ -65,7 +70,7 @@ async def _check():
json=json.load(f),
status=200,
)
return await hook.parse({"taskGroupId": group_id})
return await hook.parse({"schedulerId": scheduler, "taskGroupId": group_id})

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

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


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

assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g") == [
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "gecko-level-1") == [
{
"REPOSITORY": "https://hg.mozilla.org/mozilla-central",
"REVISION": "ec3dd3ee2ae4b3a63529a912816a110e925eb2d0",
}
]


def test_scheduler(mock_taskcluster):
bus = MessageBus()
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)

assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "-") is None
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "anotherValue") is None
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "aws-Xxxx") is None
assert run_async_parser(hook, "RS0UwZahQ_qAcdZzEb_Y9g", "gecko-level-1") == [
{
"REPOSITORY": "https://hg.mozilla.org/mozilla-central",
"REVISION": "ec3dd3ee2ae4b3a63529a912816a110e925eb2d0",
Expand All @@ -94,7 +114,7 @@ def test_success_windows(mock_taskcluster):
bus = MessageBus()
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)

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

assert run_async_parser(hook, "FG3goVnCQfif8ZEOaM_4IA") == [
assert run_async_parser(hook, "FG3goVnCQfif8ZEOaM_4IA", "gecko-level-1") == [
{
"REPOSITORY": "https://hg.mozilla.org/try",
"REVISION": "066cb18ba95a7efe144e729713c429e422d9f95b",
Expand Down