Skip to content

test: let the docker test helper target a remote Docker host#31731

Merged
alii merged 1 commit into
mainfrom
claude/darwin-docker-sidecar-host
Jun 2, 2026
Merged

test: let the docker test helper target a remote Docker host#31731
alii merged 1 commit into
mainfrom
claude/darwin-docker-sidecar-host

Conversation

@alii

@alii alii commented Jun 2, 2026

Copy link
Copy Markdown
Member

What this does

test/docker/index.ts (DockerComposeHelper) hardcoded 127.0.0.1 for both the port-readiness probe and the host it returns from ensure(). This adds a BUN_DOCKER_TEST_HOST env var (default 127.0.0.1) and routes both through it.

Why

The darwin CI runners are moving to an ephemeral-VM model — Tart on Apple Silicon, where each test job runs in a fresh macOS VM and Docker runs in a separate Linux sidecar VM (Apple Silicon can't run accelerated Docker inside a macOS guest, so the daemon lives next door). In that setup the container ports are published on the sidecar's address, not localhost, so the test process needs to connect there.

This is the first, self-contained piece of that migration. On its own it's a no-op for everyone today.

Backward compatible

  • BUN_DOCKER_TEST_HOST unset → 127.0.0.1, exactly as before. Local dev and the current bare-metal agents are unaffected.
  • The sidecar path sets BUN_DOCKER_TEST_HOST=<sidecar-ip> alongside DOCKER_HOST=tcp://<sidecar-ip>:2375 (which points the docker CLI at the same daemon).

Verification

Ran the real ensure("postgres_plain") against an actual Linux Docker sidecar VM (Tart) from a macOS host, with BUN_DOCKER_TEST_HOST + DOCKER_HOST set:

ENSURE_HOST 192.168.64.2
HOST_HONORS_ENV true      # ensure() returns the configured host, not 127.0.0.1
CONNECT_OK true           # a bun SQL connection through that host succeeds

What's next (not in this PR)

The follow-up changes that complete the sidecar model: switching bind-mounted init-scripts/configs to build:/COPY (bind mounts don't cross to a remote daemon; docker build context does — already validated), plus the CI pipeline wiring. This PR is just the host indirection that everything else builds on.

@robobun

robobun commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator
Updated 2:19 PM PT - Jun 2nd, 2026

@alii, your commit b818483 has 1 failures in Build #60002 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 31731

That installs a local version of the PR into your bun-31731 executable, so you can run:

bun-31731 --bun

The darwin CI runners are moving to an ephemeral-VM model (Tart on Apple
Silicon): each test job runs in a fresh macOS VM, and Docker runs in a
separate Linux sidecar VM rather than on the same host as the test process.
In that setup the container ports are published on the sidecar's address, not
localhost.

DockerComposeHelper hardcoded 127.0.0.1 for both the readiness probe and the
returned service host. Route both through a BUN_DOCKER_TEST_HOST env var that
defaults to 127.0.0.1, so the local / bare-metal path is unchanged and the
sidecar path just sets the env (alongside DOCKER_HOST, which points the docker
CLI at the same daemon).

Verified against a real Linux Docker sidecar: with BUN_DOCKER_TEST_HOST set,
ensure() returns the sidecar host and a connection through it succeeds.
@alii alii force-pushed the claude/darwin-docker-sidecar-host branch from b818483 to ac42b46 Compare June 2, 2026 21:19
@alii alii enabled auto-merge (squash) June 2, 2026 21:20
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2b2fbc23-465a-4526-b8fb-3cb43d935881

📥 Commits

Reviewing files that changed from the base of the PR and between b818483 and ac42b46.

📒 Files selected for processing (1)
  • test/docker/index.ts

Walkthrough

DockerComposeHelper adds a testHost getter that reads BUN_DOCKER_TEST_HOST (fallback 127.0.0.1) and uses it for TCP readiness checks (waitForPort) and to populate ServiceInfo.host.

Changes

Docker Test Host Configuration

Layer / File(s) Summary
External Docker host support
test/docker/index.ts
Adds a testHost getter that reads BUN_DOCKER_TEST_HOST or defaults to 127.0.0.1, updates the TCP readiness connection to use this.testHost, and sets ServiceInfo.host to this.testHost in ensure().
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing support for targeting a remote Docker host in the test helper, which is the core purpose of this PR.
Description check ✅ Passed The description includes both required template sections with comprehensive detail: 'What this does' (mapping to 'What does this PR do?') and 'Verification' (mapping to 'How did you verify your code works?'). Additional context is well-organized.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/docker/index.ts (1)

171-191: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Include the target host in the timeout error message.

When debugging remote Docker connectivity (e.g., sidecar VM setup), the error message should identify which host was being probed.

Proposed improvement
-    throw new Error(`Port ${port} did not become ready within ${timeout}ms`);
+    throw new Error(`Port ${port} on ${this.testHost} did not become ready within ${timeout}ms`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/docker/index.ts` around lines 171 - 191, The timeout error thrown from
waitForPort should include the target host being probed; update the thrown Error
in the waitForPort method (use this.testHost) so the message names the host,
port and timeout (e.g. “Port ${port} on ${this.testHost} did not become ready
within ${timeout}ms”) to make debugging remote Docker connectivity easier.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@test/docker/index.ts`:
- Around line 171-191: The timeout error thrown from waitForPort should include
the target host being probed; update the thrown Error in the waitForPort method
(use this.testHost) so the message names the host, port and timeout (e.g. “Port
${port} on ${this.testHost} did not become ready within ${timeout}ms”) to make
debugging remote Docker connectivity easier.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7ef674a9-ac50-44dc-b30e-91105544f984

📥 Commits

Reviewing files that changed from the base of the PR and between f7b9902 and b818483.

📒 Files selected for processing (1)
  • test/docker/index.ts

@alii alii disabled auto-merge June 2, 2026 21:23
@alii alii merged commit 8fe7a60 into main Jun 2, 2026
5 of 36 checks passed
@alii alii deleted the claude/darwin-docker-sidecar-host branch June 2, 2026 21:24
alii added a commit that referenced this pull request Jun 2, 2026
#31732)

## What this does

Converts the four `test/docker` services that bind-mounted local files —
`postgres_plain`, `postgres_auth`, `autobahn`, `squid` — to **build
their own images** (a small Dockerfile that `COPY`s the
init-scripts/config in) instead of `image:` + `volumes:` bind mounts.

## Why

Bind mounts resolve on the **Docker daemon's** filesystem, not the
client's. The darwin CI runners are moving to a **sidecar-Docker model**
(the daemon runs in a separate Linux VM, reached over `DOCKER_HOST` —
Apple Silicon can't run accelerated Docker inside a macOS guest). In
that model the bind-mounted `./init-scripts` / `./config` files don't
exist on the daemon side, so they **silently don't apply** — e.g. the
Postgres init scripts never run and the `bun_sql_test` role is missing,
which then looks like a confusing test failure rather than a setup
problem.

`docker build`'s context, by contrast, **ships to the daemon**, so
baking the files into the image works against both a local daemon and a
remote/sidecar one.

This follows the pattern the repo already uses for its TLS services
(`postgres_tls`, `mysql_tls`, `redis_unified` are all `build:`-based).

## Changes
- New `Dockerfile.postgres-plain`, `Dockerfile.postgres-auth`,
`Dockerfile.autobahn`, `Dockerfile.squid` (each `FROM` the stock image +
`COPY` the scripts/config).
- The four services now use `build:` + a `bun-*:local` image tag; their
`volumes:` bind mounts are removed.

## Compatibility
- **Local dev unchanged in behavior** — `docker compose up` just builds
the image on first run (cached after), then runs identically. Init
scripts/config are baked in rather than mounted.
- Minor DX note: editing a baked config now needs a `docker compose
build` to pick up (same as the existing TLS services).

## Verification
Ran the real compose against an actual Linux Docker sidecar VM (Tart)
over `DOCKER_HOST`:
- `docker compose config` valid; all four images **build** (context
shipped to the remote daemon).
- `postgres_plain` + `postgres_auth` come up **healthy**, and the baked
init scripts run → **`bun_sql_test` role present on both** (the exact
thing that was silently missing with bind mounts).

## Context
Second piece of the darwin Tart-runner migration; pairs with #31731 (the
`BUN_DOCKER_TEST_HOST` host indirection).
alii added a commit that referenced this pull request Jun 5, 2026
…ect using uri' (#31901)

## What
One-line fix in `test/js/sql/sql.test.ts`: the "Connect using uri" test
built its connection string with a hardcoded `@localhost:` instead of
`container.host`.

## Why
Every other test in the file uses `container.host` (which respects
`BUN_DOCKER_TEST_HOST`, added in #31731), so they pass against any
Docker setup — local or remote daemon. This one test only worked when
the daemon is on the same machine. Against a remote daemon it fails
instantly with `PostgresError: Connection closed`, and that single
subtest marks the whole 845-test file as failed even though the other
844 pass.

## How verified
With this change, the full `sql.test.ts` passes (843 pass / 2 todo / 0
fail) against a remote Docker daemon on macOS arm64, and behavior on a
local daemon is unchanged (`container.host` resolves to `127.0.0.1`
there).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants