Skip to content
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
8 changes: 0 additions & 8 deletions libmozevent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from libmozevent.taskcluster import TaskclusterConfig

taskcluster_config = TaskclusterConfig()
14 changes: 8 additions & 6 deletions libmozevent/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from datetime import datetime, timedelta

import structlog
from taskcluster.helper import TaskclusterConfig
from taskcluster.utils import slugId, stringDate

from libmozevent import taskcluster_config

logger = structlog.get_logger(__name__)

GROUP_MD = """
Expand All @@ -26,11 +25,14 @@ class Monitoring(object):
every X seconds
"""

def __init__(self, queue_name, emails, period):
assert isinstance(queue_name, str)
assert isinstance(period, int)
def __init__(
self,
taskcluster_config: TaskclusterConfig,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix #17, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so

queue_name: str,
emails: list,
period: int,
):
assert period > 0
assert isinstance(emails, list)
assert len(emails) > 0
self.queue_name = queue_name
self.period = period
Expand Down
131 changes: 0 additions & 131 deletions libmozevent/taskcluster.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Logbook
python-hglib
pytoml
structlog
taskcluster
taskcluster>=24.0.0
12 changes: 5 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import hglib
import pytest
import responses
from taskcluster.helper import TaskclusterConfig
from taskcluster.utils import stringDate

from libmozevent import taskcluster_config
from libmozevent.mercurial import Repository
from libmozevent.phabricator import PhabricatorActions

Expand Down Expand Up @@ -367,10 +367,8 @@ def mock_taskcluster():
"""
Mock Tasklcuster authentication
"""
taskcluster_config.options = {"rootUrl": "http://taskcluster.test"}
tc = TaskclusterConfig("http://taskcluster.test")
tc.auth()
tc.options["maxRetries"] = 1

responses.add(
responses.GET,
"https://queue.taskcluster.net/v1/task-group/aGroup/list",
json={"taskGroupId": "aGroup", "tasks": []},
)
return tc
10 changes: 5 additions & 5 deletions tests/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@pytest.mark.asyncio
async def test_monitoring(QueueMock, NotifyMock, mock_taskcluster):
bus = MessageBus()
monitoring = Monitoring("testqueue", ["pinco@pallino"], 1)
monitoring = Monitoring(mock_taskcluster, "testqueue", ["pinco@pallino"], 1)
monitoring.register(bus)
await bus.send("testqueue", ("Group1", "Hook1", "Task-invalid"))
await bus.send("testqueue", ("Group1", "Hook1", "Task-pending"))
Expand Down Expand Up @@ -123,7 +123,7 @@ async def test_monitoring(QueueMock, NotifyMock, mock_taskcluster):
@pytest.mark.asyncio
async def test_report_all_completed(QueueMock, NotifyMock, mock_taskcluster):
bus = MessageBus()
monitoring = Monitoring("testqueue", ["pinco@pallino"], 1)
monitoring = Monitoring(mock_taskcluster, "testqueue", ["pinco@pallino"], 1)
monitoring.register(bus)
await bus.send("testqueue", ("Group1", "Hook1", "Task1-completed"))
await bus.send("testqueue", ("Group1", "Hook1", "Task2-completed"))
Expand All @@ -146,7 +146,7 @@ async def test_monitoring_whiteline_between_failed_and_hook(
QueueMock, NotifyMock, mock_taskcluster
):
bus = MessageBus()
monitoring = Monitoring("testqueue", ["pinco@pallino"], 1)
monitoring = Monitoring(mock_taskcluster, "testqueue", ["pinco@pallino"], 1)
monitoring.register(bus)
await bus.send("testqueue", ("Group1", "Hook1", "Task-failed"))
await bus.send("testqueue", ("Group1", "Hook2", "Task-failed"))
Expand Down Expand Up @@ -218,7 +218,7 @@ async def test_monitoring_whiteline_between_failed_and_hook(
@pytest.mark.asyncio
async def test_monitoring_retry_exceptions(QueueMock, NotifyMock, mock_taskcluster):
bus = MessageBus()
monitoring = Monitoring("testqueue", ["pinco@pallino"], 1)
monitoring = Monitoring(mock_taskcluster, "testqueue", ["pinco@pallino"], 1)
monitoring.register(bus)
await bus.send("testqueue", ("Group1", "Hook1", "Task-exception-retry:2"))
await bus.send("testqueue", ("Group1", "Hook2", "Task-exception-retry:0"))
Expand Down Expand Up @@ -254,7 +254,7 @@ async def test_monitoring_retry_exceptions(QueueMock, NotifyMock, mock_taskclust
@pytest.mark.asyncio
async def test_monitoring_restartable(QueueMock, IndexMock, mock_taskcluster):
bus = MessageBus()
monitoring = Monitoring("testqueue", ["pinco@pallino"], 1)
monitoring = Monitoring(mock_taskcluster, "testqueue", ["pinco@pallino"], 1)
monitoring.register(bus)

monitoring.index = IndexMock
Expand Down