Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tst/integration/computer/computer_env_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())


Expand Down
11 changes: 10 additions & 1 deletion tst/integration/computer/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading