Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

test(e2e): wait for simulated shims before startup cleanup (#3115)

kekxyc8b141558847
diff --git a/apps/e2e/README.md b/apps/e2e/README.md
index e85ae879e..5581cb676 100644
--- a/apps/e2e/README.md
+++ b/apps/e2e/README.md
@@ -190,7 +190,7 @@ leave no selection, so correcting `DOCKER_HOST` and retrying works. Keep the
selected Docker context unchanged until teardown;
a newly available Podman socket never changes the selected engine automatically.
-The launcher script tests keep real `/proc` process checks Linux-only and mock process discovery in platform-independent lifecycle tests. Runtime process tests resolve `sleep` through `PATH`, preserving its executable name for multicall coreutils on NixOS; neither `/bin/sleep` nor a renamed sleep applet is required.
+The launcher script tests keep real `/proc` process checks Linux-only and mock process discovery in platform-independent lifecycle tests. Each simulated shim signals readiness before startup cleanup inspects its Linux process identity. Runtime process tests resolve `sleep` through `PATH`, preserving its executable name for multicall coreutils on NixOS; neither `/bin/sleep` nor a renamed sleep applet is required.
Nix is optional: install the same tools with the distro and run the same commands. Host prerequisites remain Docker with Compose v2, `/dev/kvm`, and (for volumes) `/dev/fuse`, `mount-s3` and `user_allow_other` in `/etc/fuse.conf`. The devshell includes `docker-compose`; Ubuntu can use `docker-compose-v2`. The bootstrap instructions below are the legacy Ubuntu system-service path and are no longer used by `make test:e2e:setup`.
diff --git a/tests/scripts/test_e2e_local.py b/tests/scripts/test_e2e_local.py
index 156dc1ab5..cdec7a1cf 100644
--- a/tests/scripts/test_e2e_local.py
+++ b/tests/scripts/test_e2e_local.py
@@ -3,6 +3,7 @@ import importlib.util
import json
import os
from pathlib import Path
+import select
import signal
import shutil
import subprocess
@@ -238,26 +239,31 @@ class LocalE2ETest(unittest.TestCase):
home = self.state / "runtime"
boxes = home / "boxes"
processes = {}
- for name in ("lost", "recoverable", "legacy", "padded", "stale", "garbled"):
- box = boxes / name
- (box / "bin").mkdir(parents=True)
- binary = box / "bin/boxlite-shim"
- binary.symlink_to(sys.executable)
- process = subprocess.Popen(
- [str(binary), "-c", "import time; time.sleep(30)"],
- start_new_session=True)
- processes[name] = process
- starttime = local.process_starttime(process.pid)
- records = {
- "recoverable": f"{process.pid}\n{starttime}\n",
- "legacy": f"{process.pid}\n",
- "padded": f"{process.pid}\n000{starttime}\n",
- "stale": f"{process.pid}\n0\n",
- "garbled": f"{process.pid}\n1_2\n",
- }
- if name in records:
- (box / "shim.pid").write_text(records[name])
try:
+ for name in ("lost", "recoverable", "legacy", "padded", "stale", "garbled"):
+ box = boxes / name
+ (box / "bin").mkdir(parents=True)
+ binary = box / "bin/boxlite-shim"
+ binary.symlink_to(sys.executable)
+ process = subprocess.Popen(
+ [str(binary), "-c", "import os, time; os.write(1, b'R'); time.sleep(30)"],
+ stdout=subprocess.PIPE, start_new_session=True)
+ processes[name] = process
+ with process.stdout as ready:
+ self.assertTrue(select.select([ready], [], [], 5)[0],
+ f"{name} shim timed out before reporting readiness")
+ self.assertEqual(ready.read(1), b"R", f"{name} shim failed to report readiness")
+ starttime = local.process_starttime(process.pid)
+ records = {
+ "recoverable": f"{process.pid}\n{starttime}\n",
+ "legacy": f"{process.pid}\n",
+ "padded": f"{process.pid}\n000{starttime}\n",
+ "stale": f"{process.pid}\n0\n",
+ "garbled": f"{process.pid}\n1_2\n",
+ }
+ if name in records:
+ (box / "shim.pid").write_text(records[name])
+
def check_before_start(*args, **kwargs):
for name, process in processes.items():
if name in ("lost", "stale"):