diff --git a/tst/integration/computer/computer_env_test.py b/tst/integration/computer/computer_env_test.py index 8b1e58cc7..0da7874b3 100644 --- a/tst/integration/computer/computer_env_test.py +++ b/tst/integration/computer/computer_env_test.py @@ -55,6 +55,8 @@ ARCH = {"x86_64": "amd64", "amd64": "amd64", "aarch64": "arm64", "arm64": "arm64"}[platform.machine().lower()] PORT = 18765 +#: The image a container on this machine's network sends a request from, pinned, from the mirror the test images use. +PYTHON = "mirror.gcr.io/library/python:3.12-slim@sha256:423ed6ab25b1921a477529254bfeeabf5855151dc2c3141699a1bfc852199fbf" READ_NOTE = b"""import json, urllib.request def run(input): with urllib.request.urlopen(input["env"]["url"] + "/.well-known/agent-env.json", timeout=10) as response: @@ -279,8 +281,7 @@ def _post_from_a_container(url: str, body: dict) -> int: "headers={'Content-Type': 'application/json'})\n" "try:\n print(urllib.request.urlopen(request, timeout=30).status)\n" "except urllib.error.HTTPError as e:\n print(e.code)\n") - out = docker("run", "--rm", "--network", "host", "public.ecr.aws/docker/library/python:3.12-slim", - "python", "-c", script, url, json.dumps(body)) + out = docker("run", "--rm", "--network", "host", PYTHON, "python", "-c", script, url, json.dumps(body)) return int(out.stdout.decode().strip()) diff --git a/tst/integration/computer/conftest.py b/tst/integration/computer/conftest.py index 64475b975..8af4a3a72 100644 --- a/tst/integration/computer/conftest.py +++ b/tst/integration/computer/conftest.py @@ -179,8 +179,17 @@ def _composed(root: Path, bundle, env_id: str | None = None): patch.undo() +#: How many characters of docker's stderr a failed call's error carries: the last, where docker says what failed. +DOCKER_ERROR_CHARS = 2000 + + def docker(*args: str) -> subprocess.CompletedProcess: - return subprocess.run(["docker", *args], check=True, capture_output=True) + """``docker`` with ``args``; a failure carries docker's own error, which the exception alone doesn't show.""" + try: + return subprocess.run(["docker", *args], check=True, capture_output=True) + except subprocess.CalledProcessError as e: + e.add_note(f"docker's stderr: {e.stderr.decode(errors='replace')[-DOCKER_ERROR_CHARS:]}") + raise @pytest.fixture