Skip to content

Commit f542db5

Browse files
committed
split me up: collection of fixes that will hopefully fix integration tests
1 parent 0da8901 commit f542db5

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

taskcluster/fxci_config_taskgraph/transforms/firefoxci_artifact.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import json
66
import os
7+
import re
78
from collections import defaultdict
89
from copy import deepcopy
910

@@ -26,6 +27,7 @@ def make_firefoxci_artifact_tasks(config, tasks):
2627
include_attrs = task.pop("include-attrs", {})
2728
exclude_attrs = task.pop("exclude-attrs", {})
2829
include_deps = task.pop("include-deps", [])
30+
mirror_public_artifacts = [re.compile(r) for r in task.pop("mirror-public-artifacts", [])]
2931
for decision_index_path in task.pop("decision-index-paths"):
3032
for _, task_def in find_tasks(
3133
decision_index_path,
@@ -36,14 +38,10 @@ def make_firefoxci_artifact_tasks(config, tasks):
3638
# Add docker images
3739
if "image" in task_def["payload"]:
3840
image = task_def["payload"]["image"]
39-
if not isinstance(image, dict) or "taskId" not in image:
40-
continue
41-
42-
task_id = image["taskId"]
43-
if task_id in tasks_to_create:
44-
continue
45-
46-
tasks_to_create[task_id] = [image["path"]]
41+
if isinstance(image, dict) and "taskId" in image:
42+
task_id = image["taskId"]
43+
if task_id not in tasks_to_create:
44+
tasks_to_create[task_id] = [image["path"]]
4745

4846
# Add private artifacts
4947
if "MOZ_FETCHES" in task_def["payload"].get("env", {}):
@@ -52,7 +50,8 @@ def make_firefoxci_artifact_tasks(config, tasks):
5250
)
5351
for fetch in fetches:
5452
if fetch["artifact"].startswith("public"):
55-
continue
53+
if not any([pat.match(task_def["metadata"]["name"]) for pat in mirror_public_artifacts]):
54+
continue
5655

5756
task_id = fetch["task"]
5857
tasks_to_create[task_id].append(fetch["artifact"])

taskcluster/fxci_config_taskgraph/transforms/integration_test.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,17 @@ def rewrite_mirrored_dependencies(
210210
prefix: str,
211211
dependencies: dict[str, str],
212212
tasks: dict[str, Any],
213-
patterns: list[re.Pattern],
213+
include_deps: list[str],
214+
artifact_tasks,
214215
):
215216
"""Re-write dependencies and fetches of tasks that are being re-run in the
216217
staging instance that are also being re-run in the staging instance. Without
217218
this, the downstream tasks will attempt to refer to firefoxci task ids that
218219
do not exist in the staging cluster, and task submission will fail.
219220
"""
221+
patterns = [re.compile(p) for p in include_deps]
220222
modified_deps = set()
223+
mirrored_deps = set()
221224
# First, update any dependencies that are also being run as part of this integration test
222225
for upstream_task_id in dependencies:
223226
if upstream_task_id in tasks:
@@ -227,6 +230,15 @@ def rewrite_mirrored_dependencies(
227230
upstream_task_label = f"{prefix}-{name}"
228231
taskdesc["dependencies"][upstream_task_label] = upstream_task_label
229232

233+
artifact_task_label = f"firefoxci-artifact-{prefix}-{upstream_task_id}"
234+
# TODO: shouldn't add docker images here; they get added already elsewhere
235+
if artifact_task_label in artifact_tasks:
236+
fetched_artifacts = artifact_tasks[artifact_task_label].task["payload"]["env"]["FETCH_FIREFOXCI_ARTIFACTS"]
237+
if "image.tar.zst" in fetched_artifacts:
238+
continue
239+
mirrored_deps.add(upstream_task_id)
240+
taskdesc["dependencies"][artifact_task_label] = artifact_task_label
241+
230242
# Second, update any fetches that point to dependencies that are also being run as part
231243
# of this integration test
232244
updated_fetches = []
@@ -241,6 +253,9 @@ def rewrite_mirrored_dependencies(
241253
fetch_task_label = tasks[fetch_task_id]["metadata"]["name"]
242254
fetch["task"] = f"<{prefix}-{fetch_task_label}>"
243255

256+
if fetch_task_id in mirrored_deps:
257+
fetch["task"] = f"<firefoxci-artifact-{prefix}-{fetch_task_id}>"
258+
244259
updated_fetches.append(fetch)
245260

246261
taskdesc["task"]["payload"]["env"]["MOZ_FETCHES"] = {
@@ -253,6 +268,8 @@ def make_integration_test_description(
253268
name_prefix: str,
254269
tasks: dict[str, Any],
255270
include_deps: list[str],
271+
should_patch_root_url: bool,
272+
artifact_tasks,
256273
):
257274
"""Schedule a task on the staging Taskcluster instance.
258275
@@ -274,30 +291,6 @@ def make_integration_test_description(
274291
if "treeherder" in task_def["extra"]:
275292
del task_def["extra"]["treeherder"]
276293

277-
include_patterns = [re.compile(p) for p in include_deps]
278-
# Tasks may only have 1 root url set, which is primarily used to decide
279-
# where to find `MOZ_FETCHES`. When we're including dependencies, we peek
280-
# at upstream tasks to figure out what this should be set to. If any
281-
# upstream task is present that doesn't match an include pattern, its
282-
# dependencies must be pulled from the firefox ci cluster, and we must
283-
# patch the root. If a task matches an include pattern, its dependencies
284-
# will be in the staging cluster, and we must not patch the root.
285-
# If we have a mix of tasks, we cannot proceed.
286-
matches = set()
287-
for upstream_task_id in orig_dependencies:
288-
if upstream_task_id in tasks:
289-
name = tasks[upstream_task_id]["metadata"]["name"]
290-
matches.add(any([pat.match(name) for pat in include_patterns]))
291-
292-
should_patch_root_url = True
293-
if len(matches) == 2:
294-
raise Exception(
295-
f"task '{task_def['metadata']['name']}' has both mirrored and unmirrored dependencies; it will not work correctly"
296-
)
297-
elif len(matches) == 1:
298-
if matches.pop() is True:
299-
should_patch_root_url = False
300-
301294
if should_patch_root_url:
302295
patch_root_url(task_def)
303296
rewrite_mounts(task_def)
@@ -328,7 +321,7 @@ def make_integration_test_description(
328321
rewrite_docker_image(taskdesc)
329322
rewrite_private_fetches(taskdesc)
330323
rewrite_mirrored_dependencies(
331-
taskdesc, name_prefix, orig_dependencies, tasks, include_patterns
324+
taskdesc, name_prefix, orig_dependencies, tasks, include_deps, artifact_tasks,
332325
)
333326
return taskdesc
334327

@@ -341,10 +334,12 @@ def schedule_tasks_at_index(config, tasks):
341334
if os.environ["TASKCLUSTER_ROOT_URL"] != STAGING_ROOT_URL:
342335
return
343336

337+
artifact_tasks = {k: v for k, v in config.kind_dependencies_tasks.items() if k.startswith("firefoxci-artifact")}
344338
for task in tasks:
345339
include_attrs = task.pop("include-attrs", {})
346340
exclude_attrs = task.pop("exclude-attrs", {})
347341
include_deps = task.pop("include-deps", [])
342+
patch_root_url = task.pop("patch-root-url", True)
348343
for decision_index_path in task.pop("decision-index-paths"):
349344
found_tasks = find_tasks(
350345
decision_index_path,
@@ -356,5 +351,5 @@ def schedule_tasks_at_index(config, tasks):
356351
# task_def is copied to avoid modifying the version in `tasks`, which
357352
# may be used to modify parts of the new task description
358353
yield make_integration_test_description(
359-
copy.deepcopy(task_def), task["name"], found_tasks, include_deps
354+
copy.deepcopy(task_def), task["name"], found_tasks, include_deps, patch_root_url, artifact_tasks
360355
)

taskcluster/kinds/firefoxci-artifact/kind.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ tasks:
6060
# expire, which causes us to try to mirror expired docker image tasks
6161
# into the staging cluster
6262
- ^(?!(Decision|Action|PR action|build-docker-image|fetch)).*
63+
mirror-public-artifacts:
64+
- ^toolchain.*

taskcluster/kinds/integration-test/kind.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ tasks:
4242
# expire, which causes us to try to mirror expired docker image tasks
4343
# into the staging cluster
4444
- ^(?!(Decision|Action|PR action|build-docker-image|fetch)).*
45+
patch-root-url: false

taskcluster/test/test_transforms_integration_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def run_include_deps_test(run_test, *args, **kwargs):
379379
"taskId": "ghi",
380380
"path": "public/image.tar.zst",
381381
},
382-
"command": ["run-task", "build-a-thing"],
382+
"command": ["run-task", "build-a-thing", "foo"],
383383
},
384384
"tags": {},
385385
},
@@ -394,7 +394,7 @@ def run_include_deps_test(run_test, *args, **kwargs):
394394
"taskId": "jkl",
395395
"path": "public/image.tar.zst",
396396
},
397-
"command": ["run-task", "test-a-thing"],
397+
"command": ["run-task", "test-a-thing", "foo"],
398398
"env": {
399399
"MOZ_FETCHES": json.dumps(
400400
[
@@ -420,7 +420,7 @@ def run_include_deps_test(run_test, *args, **kwargs):
420420
"taskId": "mno",
421421
"path": "public/image.tar.zst",
422422
},
423-
"command": ["run-task", "sign-a-thing"],
423+
"command": ["run-task", "sign-a-thing", "foo"],
424424
"env": {
425425
"MOZ_FETCHES": json.dumps(
426426
[
@@ -502,11 +502,11 @@ def test_include_some_deps(run_test):
502502
"taskId": task_id,
503503
"path": artifact,
504504
},
505-
"command": ["run-task", "foo"],
505+
"command": ["run-task", "foo", "bar"],
506506
},
507507
},
508508
},
509-
include_deps=["^sign", "^test"],
509+
include_deps=["^(?!(build))"],
510510
name="gecko",
511511
)
512512
expected = set(["gecko-foo", "gecko-test-thing", "gecko-sign-thing"])
@@ -521,6 +521,8 @@ def test_include_some_deps(run_test):
521521
in sign_task["task"]["payload"]["env"]["MOZ_FETCHES"]["task-reference"]
522522
)
523523
assert "TASKCLUSTER_ROOT_URL" in test_task["task"]["payload"]["command"][2]
524+
assert "TASKCLUSTER_ROOT_URL" not in sign_task["task"]["payload"]["command"][2]
525+
assert "TASKCLUSTER_ROOT_URL" not in foo_task["task"]["payload"]["command"][2]
524526

525527

526528
def test_no_deps(run_test):

0 commit comments

Comments
 (0)