From f2f6174772d38cd30a2c8864d5471ee3bb87e88d Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Wed, 1 Oct 2025 19:09:24 +0200 Subject: [PATCH 1/2] fix: look for the right key in status_task_batched responses --- src/taskgraph/util/taskcluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taskgraph/util/taskcluster.py b/src/taskgraph/util/taskcluster.py index f534644fe..479547649 100644 --- a/src/taskgraph/util/taskcluster.py +++ b/src/taskgraph/util/taskcluster.py @@ -308,7 +308,7 @@ def pagination_handler(response): { t["taskId"]: t["status"] for t in response.get("statuses", []) - if "namespace" in t and "taskId" in t + if "status" in t and "taskId" in t } ) From 28417fe9f6b4daf7d5c0f5bdcd94cdd1a655d1c0 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Wed, 1 Oct 2025 19:10:11 +0200 Subject: [PATCH 2/2] test: restore test coverage for find_task_id_batched and status_task_batched --- test/test_util_taskcluster.py | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/test_util_taskcluster.py b/test/test_util_taskcluster.py index 4cde503d2..0a8b2482b 100644 --- a/test/test_util_taskcluster.py +++ b/test/test_util_taskcluster.py @@ -190,6 +190,27 @@ def mock_client(service): mock_index.findTask.assert_called_with(index) +def test_find_task_id_batched(monkeypatch, responses, root_url): + monkeypatch.setattr(os, "environ", {"TASKCLUSTER_ROOT_URL": root_url}) + responses.post( + f"{root_url}/api/index/v1/tasks/indexes", + json={ + "tasks": [{"taskId": "abc", "namespace": "index.abc"}], + "continuationToken": "abc", + }, + ) + responses.post( + f"{root_url}/api/index/v1/tasks/indexes", + json={ + "tasks": [{"taskId": "def", "namespace": "index.def"}], + "continuationToken": None, + }, + ) + + result = tc.find_task_id_batched(["index.abc", "index.def"]) + assert result == {"index.abc": "abc", "index.def": "def"} + + def test_get_artifact_from_index(monkeypatch): index = "foo" path = "file.txt" @@ -298,6 +319,40 @@ def mock_client(service): mock_queue.status.assert_called_with(tid) +def test_status_task_batched(monkeypatch, responses, root_url): + monkeypatch.setattr(os, "environ", {"TASKCLUSTER_ROOT_URL": root_url}) + responses.post( + f"{root_url}/api/queue/v1/tasks/status", + json={ + "statuses": [ + { + "taskId": "abc", + "status": {"taskId": "abc", "state": "completed", "runs": []}, + } + ], + "continuationToken": "abc", + }, + ) + responses.post( + f"{root_url}/api/queue/v1/tasks/status", + json={ + "statuses": [ + { + "taskId": "def", + "status": {"taskId": "def", "state": "exception", "runs": []}, + } + ], + "continuationToken": None, + }, + ) + + result = tc.status_task_batched(["abc", "def"]) + assert result == { + "abc": {"taskId": "abc", "state": "completed", "runs": []}, + "def": {"taskId": "def", "state": "exception", "runs": []}, + } + + def test_state_task(monkeypatch): tid = "123"