test: fix the three causes of Main's Test (macOS) failures (#7494)
* test(dbproxy/server): disable dolt event flush so send-metrics cannot race TempDir cleanup Every dolt sql-server this suite stops cleanly forks a detached `dolt send-metrics` child on exit. It outlives the test, rewrites <HOME>/.dolt/eventsData (HOME is a t.TempDir()), and races t.TempDir's RemoveAll: "TempDir RemoveAll cleanup: ... 001/.dolt: directory not empty". main.yml's Test (macOS) job (plain go test) failed on this in about half of the pushes since 2026-10-09; Bazel never did because tools/bazel/test_env.sh exports DOLT_DISABLE_EVENT_FLUSH=1. TestMain now exports it too, guarded by TestSuiteDisablesDoltEventFlush. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(scripts): skip Linux-CI-only rrc and worker-env-sync script tests off Linux TestRRCRunLanes runs .github/scripts/rrc-run-lanes.sh, which uses bash 4's `mapfile` (exit 127 under macOS /bin/bash 3.2). TestWorkerEnvSyncCopyAgainstFixture runs tools/rbe/worker-env-sync-copy, whose GNU `sed -i -E` becomes "-i with backup suffix -E" plus a basic regex under BSD sed, so the pin is never rewritten. Both scripts run only on Linux runners (bazel.yml rrc-seed/rrc-verify, worker-env-autosync.yml); per their owner they stay Linux-only and the tests skip elsewhere with the reason. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0a163ca285
commit
22c0faaaf9
3 changed files with 43 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"regexp"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/doltserver"
|
||||
|
|
@ -118,6 +119,16 @@ func testMainInner(m *testing.M) int {
|
|||
// scripts/test.sh, a second `go test`), are left untouched.
|
||||
doltserver.SweepDeadSuiteRoots(os.TempDir(), suiteRootPrefix)
|
||||
|
||||
// Stop every dolt this suite runs (each inherits the environment) from
|
||||
// forking a detached `dolt send-metrics` child on exit; that child
|
||||
// outlives the test and races t.TempDir's RemoveAll of HOME. See
|
||||
// TestSuiteDisablesDoltEventFlush. tools/bazel/test_env.sh exports the
|
||||
// same for Bazel; this covers plain `go test` (macOS CI, local runs).
|
||||
if err := os.Setenv("DOLT_DISABLE_EVENT_FLUSH", "1"); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "FATAL: set DOLT_DISABLE_EVENT_FLUSH: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Pin TMPDIR under a suite-owned root so every t.TempDir() — including
|
||||
// each server's rootDir, which is its working directory — is nested under
|
||||
// something the sweeps may vouch for.
|
||||
|
|
@ -155,3 +166,18 @@ func TestTempDirLandsUnderSuiteSweepRoot(t *testing.T) {
|
|||
t.Fatalf("t.TempDir() %q is not under suiteTempRoot %q", dir, suiteTempRoot)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSuiteDisablesDoltEventFlush guards the DOLT_DISABLE_EVENT_FLUSH export
|
||||
// in testMainInner. Without it, every `dolt sql-server` this suite stops
|
||||
// cleanly (SIGTERM) forks a detached `dolt send-metrics` child on exit. That
|
||||
// child outlives the test, re-creates and rewrites <HOME>/.dolt/eventsData
|
||||
// (HOME is a t.TempDir()), and races t.TempDir's RemoveAll, which fails the
|
||||
// test with "TempDir RemoveAll cleanup: ... directory not empty". Plain
|
||||
// `go test` on macOS (main.yml's Test (macOS) job) hit it on roughly half the
|
||||
// pushes to main; Bazel never did only because tools/bazel/test_env.sh
|
||||
// exports the same variable.
|
||||
func TestSuiteDisablesDoltEventFlush(t *testing.T) {
|
||||
if !slices.Contains(doltserver.ServerSpawnEnv(), "DOLT_DISABLE_EVENT_FLUSH=1") {
|
||||
t.Fatal("dolt sql-server would be spawned without DOLT_DISABLE_EVENT_FLUSH=1; its detached send-metrics child races t.TempDir cleanup")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
|
@ -355,6 +356,13 @@ func TestBazelRRCLaneCommandsCoverEveryReader(t *testing.T) {
|
|||
// flags after; `test --nobuild`'s exit 1 after a successful analysis
|
||||
// passes, a failed analysis fails, and an empty command list fails.
|
||||
func TestRRCRunLanes(t *testing.T) {
|
||||
// rrc-run-lanes.sh runs only in bazel.yml's rrc-seed and rrc-verify jobs,
|
||||
// on Linux runners. It reads its lane list with `mapfile`, a bash 4
|
||||
// builtin that macOS's /bin/bash 3.2 lacks (exit 127, "mapfile: command
|
||||
// not found"); its owner keeps it Linux-only rather than porting it.
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skipf("rrc-run-lanes.sh is Linux-CI-only (bazel.yml rrc-seed/rrc-verify) and uses bash 4's mapfile; GOOS=%s", runtime.GOOS)
|
||||
}
|
||||
root := sourceRepoRoot(t)
|
||||
script := filepath.Join(root, bazelRRCRunLanes)
|
||||
dir := t.TempDir()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -214,6 +215,14 @@ func TestWorkerEnvAutosyncWorkflowNeverInterpolatesExpressionsInRun(t *testing.T
|
|||
// than writing anything when gascity's platforms/BUILD.bazel carries no
|
||||
// pin to copy.
|
||||
func TestWorkerEnvSyncCopyAgainstFixture(t *testing.T) {
|
||||
// worker-env-sync-copy runs only in worker-env-autosync.yml, on
|
||||
// ubuntu-latest. It edits the pin with GNU `sed -i -E`; BSD sed (macOS)
|
||||
// takes -E as -i's backup suffix, so the {64} interval is read as a
|
||||
// basic regex and never matches, and the pin is left stale. Its owner
|
||||
// keeps it Linux-only rather than porting it.
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skipf("worker-env-sync-copy is Linux-CI-only (worker-env-autosync.yml) and uses GNU sed -i -E; GOOS=%s", runtime.GOOS)
|
||||
}
|
||||
f := newRBEWorkerEnvFixture(t)
|
||||
stalePin := rbeTestPin(rbeTestStaleManifest)
|
||||
beads := f.beads(t, rbeTestStaleManifest, stalePin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue