From fd3b621ac336bc63bc610b3cf806946271ab7a86 Mon Sep 17 00:00:00 2001 From: "Ben Hearsum (he/him)" Date: Mon, 16 Dec 2024 10:01:35 -0500 Subject: [PATCH] fix: use job name as prefix to integration test tasks instead of hardcoding 'gecko' (#224) --- .../transforms/integration_test.py | 8 ++++---- .../test/test_transforms_integration_test.py | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/taskcluster/fxci_config_taskgraph/transforms/integration_test.py b/taskcluster/fxci_config_taskgraph/transforms/integration_test.py index 8957ee57..34f72146 100644 --- a/taskcluster/fxci_config_taskgraph/transforms/integration_test.py +++ b/taskcluster/fxci_config_taskgraph/transforms/integration_test.py @@ -144,7 +144,7 @@ def rewrite_private_fetches(taskdesc: dict[str, Any]) -> None: payload["env"]["MOZ_FETCHES"] = {"task-reference": json.dumps(fetches)} -def make_integration_test_description(task_def: dict[str, Any]): +def make_integration_test_description(task_def: dict[str, Any], name_prefix: str): """Schedule a task on the staging Taskcluster instance. Typically task_def will come from the firefox-ci instance and will be @@ -173,7 +173,7 @@ def make_integration_test_description(task_def: dict[str, Any]): if key in task_def: task_def[key] = task_def[key].replace("3", "1") - task_def["metadata"]["name"] = f"gecko-{task_def['metadata']['name']}" + task_def["metadata"]["name"] = f"{name_prefix}-{task_def['metadata']['name']}" taskdesc = { "label": task_def["metadata"]["name"], "description": task_def["metadata"]["description"], @@ -181,7 +181,7 @@ def make_integration_test_description(task_def: dict[str, Any]): "dependencies": { "apply": "tc-admin-apply-staging", }, - "attributes": {"integration": "gecko"}, + "attributes": {"integration": name_prefix}, } rewrite_docker_image(taskdesc) rewrite_private_fetches(taskdesc) @@ -199,4 +199,4 @@ def schedule_tasks_at_index(config, tasks): for task in tasks: for decision_index_path in task.pop("decision-index-paths"): for task_def in find_tasks(decision_index_path): - yield make_integration_test_description(task_def) + yield make_integration_test_description(task_def, task["name"]) diff --git a/taskcluster/test/test_transforms_integration_test.py b/taskcluster/test/test_transforms_integration_test.py index 5f40316f..14eb66aa 100644 --- a/taskcluster/test/test_transforms_integration_test.py +++ b/taskcluster/test/test_transforms_integration_test.py @@ -47,7 +47,11 @@ def run_test(monkeypatch, run_transform, responses): json={"taskId": decision_task_id}, ) - def inner(task: dict[str, Any]) -> dict[str, Any] | None: + # `name` may seem like an awkard identifier here, but outside of tests + # this comes from the keys in a `kind`. `task_label` is not really + # an ideal default, but it's the best option we have here, and this value + # is irrelevant to many tests anyways. + def inner(task: dict[str, Any], name: str = task_label) -> dict[str, Any] | None: find_tasks.cache_clear() task = merge(deepcopy(base_task), task) @@ -59,7 +63,9 @@ def inner(task: dict[str, Any]) -> dict[str, Any] | None: json=task_graph, ) - result = run_transform(transforms, {"decision-index-paths": [index]}) + result = run_transform( + transforms, {"decision-index-paths": [index], "name": name} + ) if not result: return None @@ -109,7 +115,7 @@ def test_android_hw_skipped(run_test): def test_basic(run_test): - result = run_test({"attributes": {"unittest_variant": "os-integration"}}) + result = run_test({"attributes": {"unittest_variant": "os-integration"}}, "gecko") assert result == { "attributes": {"integration": "gecko"}, "dependencies": {"apply": "tc-admin-apply-staging"}, @@ -133,7 +139,8 @@ def test_docker_image(run_test): { "attributes": {"unittest_variant": "os-integration"}, "task": {"payload": {"image": {"taskId": "def"}}}, - } + }, + "gecko", ) assert result["dependencies"] == { "apply": "tc-admin-apply-staging", @@ -225,7 +232,8 @@ def test_private_artifact(run_test): "env": {"MOZ_FETCHES": '[{"task": "def", "artifact": "foo.txt"}]'}, } }, - } + }, + "gecko", ) assert result["dependencies"] == { "apply": "tc-admin-apply-staging",