Skip to content

Commit

Permalink
fix: use job name as prefix to integration test tasks instead of hard…
Browse files Browse the repository at this point in the history
…coding 'gecko' (#224)
  • Loading branch information
bhearsum authored Dec 16, 2024
1 parent 00ee798 commit fd3b621
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -173,15 +173,15 @@ 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"],
"task": task_def,
"dependencies": {
"apply": "tc-admin-apply-staging",
},
"attributes": {"integration": "gecko"},
"attributes": {"integration": name_prefix},
}
rewrite_docker_image(taskdesc)
rewrite_private_fetches(taskdesc)
Expand All @@ -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"])
18 changes: 13 additions & 5 deletions taskcluster/test/test_transforms_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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"},
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fd3b621

Please sign in to comment.