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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"taskcluster-taskgraph>=11,<17",
"taskcluster-taskgraph>=16.2.1,<17",
]

[project.urls]
Expand Down
6 changes: 3 additions & 3 deletions src/mozilla_taskgraph/transforms/replicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
from textwrap import dedent

from requests.exceptions import HTTPError
from taskcluster.exceptions import TaskclusterRestFailure
from taskgraph.transforms.base import TransformSequence
from taskgraph.util.attributes import attrmatch
from taskgraph.util.schema import Schema
Expand Down Expand Up @@ -102,8 +102,8 @@ def resolve_targets(config, tasks):
# we have a decision task, add all tasks from task-graph.json
result = get_artifact(task_id, "public/task-graph.json").values()
task_defs.extend(result)
except HTTPError as e:
if e.response.status_code != 404:
except TaskclusterRestFailure as e:
if e.status_code != 404:
raise

# we have a regular task, just yield its definition and move on
Expand Down
14 changes: 7 additions & 7 deletions test/actions/test_release_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

import pytest
import taskcluster_urls as liburl
from taskgraph.util.taskcluster import get_artifact_url

from mozilla_taskgraph.actions import enable_action

from ..conftest import make_graph, make_task
from ..conftest import (
make_graph,
make_task,
)


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -49,23 +51,21 @@ def inner(previous_graphs=None):
# Only the parameters from the first previous graph is downloaded.
responses.add(
method="GET",
url=get_artifact_url(
list(previous_graphs.keys())[0], "public/parameters.yml"
),
url=f"{tc_url}/api/queue/v1/task/{list(previous_graphs.keys())[0]}/artifacts/public%2Fparameters.yml",
json=parameters,
)

tid = count(0)
for decision_id, full_task_graph in previous_graphs.items():
responses.add(
method="GET",
url=get_artifact_url(decision_id, "public/full-task-graph.json"),
url=f"{tc_url}/api/queue/v1/task/{decision_id}/artifacts/public%2Ffull-task-graph.json",
json=full_task_graph.to_json(),
)
label_to_taskid = {label: int(next(tid)) for label in full_task_graph.tasks}
responses.add(
method="GET",
url=get_artifact_url(decision_id, "public/label-to-taskid.json"),
url=f"{tc_url}/api/queue/v1/task/{decision_id}/artifacts/public%2Flabel-to-taskid.json",
json=label_to_taskid,
)

Expand Down
8 changes: 8 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

import pytest
Expand All @@ -23,6 +24,13 @@ def set_taskcluster_url(session_mocker):
"os.environ", {"TASKCLUSTER_ROOT_URL": liburl.test_root_url()}
)

# The Taskcluster Proxy URL is cleared to ensure the test environment
# uses the root url instead of the proxy url as with the current
# implementation of get_artifact we default to using
# the proxy url if it is present in the environment
if "TASKCLUSTER_PROXY_URL" in os.environ:
del os.environ["TASKCLUSTER_PROXY_URL"]


@pytest.fixture
def responses():
Expand Down
5 changes: 0 additions & 5 deletions test/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ def test_payload_builders(graph_config):
does_not_raise(),
id="shipit_valid",
),
pytest.param(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an accidental removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No as we update graph config schema to allow extra parameters not defined in the schema, somewhere in taskgraph 12 and I just updating this to ensure this test doesn't fail once we swap over to 16.2. So this test just became redundant so I though it would be best to remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{"shipit": {"product": "foo", "extra": "bar"}},
pytest.raises(Exception),
id="shipit_invalid",
),
),
)
def test_graph_config(make_graph_config, extra_config, expectation):
Expand Down
24 changes: 13 additions & 11 deletions test/transforms/test_replicate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from itertools import count
from pprint import pprint
from unittest.mock import Mock

import pytest
from requests import HTTPError
from taskcluster.exceptions import TaskclusterRestFailure
from taskgraph.util.templates import merge

from mozilla_taskgraph.transforms.replicate import transforms as replicate_transforms
Expand Down Expand Up @@ -139,11 +138,12 @@ def test_requests_error(responses, run_replicate):
},
}
responses.get(
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public/task-graph.json",
body=HTTPError("Artifact not found!", response=Mock(status_code=403)),
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public%2Ftask-graph.json",
json={"message": "Forbidden"},
status=403,
)

with pytest.raises(HTTPError):
with pytest.raises(TaskclusterRestFailure):
run_replicate(task)


Expand All @@ -162,8 +162,9 @@ def test_task_id(responses, run_replicate):
expected = get_expected(prefix, task_def)[0]

responses.get(
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public/task-graph.json",
body=HTTPError("Artifact not found!", response=Mock(status_code=404)),
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public%2Ftask-graph.json",
json={"message": "Artifact not found"},
status=404,
)
responses.get(f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}", json=task_def)

Expand All @@ -187,8 +188,9 @@ def test_index_path(responses, run_replicate):
f"{TC_ROOT_URL}/api/index/v1/task/{index_path}", json={"taskId": task_id}
)
responses.get(
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public/task-graph.json",
body=HTTPError("Artifact not found!", response=Mock(status_code=404)),
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public%2Ftask-graph.json",
json={"message": "Artifact not found"},
status=404,
)
responses.get(f"{TC_ROOT_URL}/api/queue/v1/task/{index_path}", json=task_def)

Expand All @@ -213,7 +215,7 @@ def test_decision_task(responses, run_replicate):

counter = count()
responses.get(
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public/task-graph.json",
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public%2Ftask-graph.json",
json={next(counter): task_def for task_def in task_defs},
)
result = run_replicate(task)
Expand Down Expand Up @@ -268,7 +270,7 @@ def test_filtered_out(responses, run_replicate, target_def):

counter = count()
responses.get(
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public/task-graph.json",
f"{TC_ROOT_URL}/api/queue/v1/task/{task_id}/artifacts/public%2Ftask-graph.json",
json={next(counter): task_def for task_def in task_defs},
)
result = run_replicate(task)
Expand Down
Loading