Skip to content
Open
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
9 changes: 8 additions & 1 deletion tst/integration/store/local_parallel_deploy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"""

import contextlib
import fcntl
import json
import socket
import subprocess
import tempfile
import time
import uuid
from pathlib import Path
Expand All @@ -34,6 +36,9 @@
pytestmark = [pytest.mark.integration, pytest.mark.int_test_slow]

_TST_DATA = Path(__file__).resolve().parents[2] / "data"
# Test workers share one Docker daemon, and two builds naming the same tag at once can fail with
# "image ... already exists", so the bootstrap builds take turns.
_BUILD_LOCK = Path(tempfile.gettempdir()) / "agentenv-test-bootstrap-builds.lock"


def _free_port() -> int:
Expand Down Expand Up @@ -115,7 +120,9 @@ def _seed_bootstrap_envs():
from agent_env.env.envs.service_db import ServiceDBEnv

def build(dockerfile: Path, context: Path, tag: str) -> DockerImageArtifact:
result = _docker("build", "-f", str(dockerfile), "-t", tag, str(context))
with open(_BUILD_LOCK, "w") as lock:
fcntl.flock(lock, fcntl.LOCK_EX)
result = _docker("build", "-f", str(dockerfile), "-t", tag, str(context))
assert result.returncode == 0, f"build {tag} failed: {result.stderr[-2000:]}"
return DockerImageArtifact.put(id=tag, description="bootstrap", image_name=tag)

Expand Down
Loading