ci-box: /tmp back in memory; installer tests find a home with xattrs
Moving /tmp to the machine's disk (eb26406) doubled every lane: thintest 35 to 78 s, directlive 88 to 168 s, headless 260 to 309 s. The tests sync small files and databases thousands of times. /tmp is a tmpfs again. The one thing that needed the disk is the installer, which marks what it wrote with a user extended attribute, and a tmpfs refuses those before Linux 6.6. Its test fixture now puts the home under the user's own home where the temporary directory refuses the attribute.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2 files changed,
+27
−22
internal/runner/setup/install_test.go+23 −1scripts/ci-box.py+4 −21
Intent
diff --git a/internal/runner/setup/install_test.go b/internal/runner/setup/install_test.go| index 4d4e042e..0553dfd0 100644 |
| --- a/internal/runner/setup/install_test.go |
| +++ b/internal/runner/setup/install_test.go |
| @@ -12,11 +12,33 @@ import ( |
| "amadan.net/oficina/equipo/internal/release" |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| + "golang.org/x/sys/unix" |
| ) |
| -func installFixture(t *testing.T) (InstallOptions, installHost, *int) { |
| +// installHome is a home directory on a filesystem that keeps user |
| +// extended attributes: the installer marks what it wrote with one. A |
| +// tmpfs refuses them before Linux 6.6, so where the test's temporary |
| +// directory is one, the home goes under the user's own home instead. |
| +func installHome(t *testing.T) string { |
| t.Helper() |
| home := t.TempDir() |
| + if unix.Setxattr(home, "user.equipo.test", []byte("1"), 0) == nil { |
| + return home |
| + } |
| + base, err := os.UserHomeDir() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if home, err = os.MkdirTemp(base, "equipo-install-test-"); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { os.RemoveAll(home) }) |
| + return home |
| +} |
| + |
| +func installFixture(t *testing.T) (InstallOptions, installHost, *int) { |
| + t.Helper() |
| + home := installHome(t) |
| binary := []byte("fixture runner bytes") |
| m := release.InstallManifest{Version: "fixture-16", Target: "linux/amd64", RunnerSHA256: fmt.Sprintf("%x", sha256.Sum256(binary)), NamespaceArgs: provider.NamespaceArguments(), Release: release.BuildManifest()} |
| m.Release.Binaries = []release.BinaryDigest{{Name: "equipo-tool-proxy", Version: m.Release.LauncherVersion, SHA256: fmt.Sprintf("%x", sha256.Sum256([]byte("fixture tool proxy")))}} |
diff --git a/scripts/ci-box.py b/scripts/ci-box.py| index c0e8c96a..ecd93397 100755 |
| --- a/scripts/ci-box.py |
| +++ b/scripts/ci-box.py |
| @@ -35,7 +35,6 @@ import lzma |
| import os |
| import platform |
| import shutil |
| -import signal |
| import subprocess |
| import sys |
| import tarfile |
| @@ -334,13 +333,10 @@ def run(command): |
| for path in (gocache, gomodcache): |
| os.makedirs(path, exist_ok=True) |
| tool = engine() |
| - # /tmp on disk, not a tmpfs: the installer tests set user extended |
| - # attributes, which a tmpfs refuses before Linux 6.6. |
| - os.makedirs(os.path.join(box_dir(), "tmp"), exist_ok=True) |
| - scratch = tempfile.mkdtemp(dir=os.path.join(box_dir(), "tmp")) |
| - os.chmod(scratch, 0o1777) |
| + # /tmp in memory. The tests sync small files and databases thousands |
| + # of times; on the machine's disk that doubled every lane's time. |
| args = [tool, "run", "--rm", "--privileged", "--cgroupns=private", |
| - "-v", scratch + ":/tmp", |
| + "--tmpfs", "/tmp:exec,mode=1777", |
| "-v", ROOT + ":" + WORK, "-w", WORK, |
| "-v", gocache + ":" + GOCACHE, "-v", gomodcache + ":" + GOMODCACHE, |
| "-v", os.path.join(tools_dir(), "bin") + ":" + TRY_BIN + ":ro"] |
| @@ -375,20 +371,7 @@ def run(command): |
| for name in sorted(env): |
| args += ["-e", name + "=" + env[name]] |
| args += [pins()["image"], WORK + "/scripts/ci-box-enter.sh"] + command |
| - child = subprocess.Popen(args) |
| - for number in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP): |
| - signal.signal(number, lambda n, _frame: child.send_signal(n)) |
| - status = child.wait() |
| - # The job's scratch goes with the command. Inside, files may belong to |
| - # the engine's other users, so the box removes them. |
| - subprocess.call([tool, "run", "--rm", "-v", scratch + ":/scratch", pins()["image"], |
| - "find", "/scratch", "-mindepth", "1", "-delete"], |
| - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| - try: |
| - os.rmdir(scratch) |
| - except OSError: |
| - pass |
| - return status if status >= 0 else 128 - status |
| + os.execvp(args[0], args) |
| # The Go caches. |