Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-7244 test: fix the two flakes that turned main red (#8258)
Bohan Jiang2c25c20da5de
diff --git a/server/internal/daemon/workdir_race_test.go b/server/internal/daemon/workdir_race_test.goindex 31ab640e3c..fa5f08fc24 100644--- a/server/internal/daemon/workdir_race_test.go+++ b/server/internal/daemon/workdir_race_test.go@@ -662,6 +662,17 @@ func (t *prepareLeaseCountingTransport) RoundTrip(req *http.Request) (*http.Respreturn t.base.RoundTrip(req)}+// prepareBudgetForBlockedStart is the prepare deadline the blocked-/start test+// arms. It has to outlast everything runTask does before it calls /start — the+// isolated execution environment, its sidecars, and the task temp dir are all+// real filesystem work — because a deadline that expires during preparation+// never reaches the /start this test is about. That preparation costs ~15ms on+// an idle developer machine but an order of magnitude more on a loaded CI+// runner under -race, which is why the original 150ms turned main red+// (MUL-7244). Two seconds keeps ~20x headroom over the observed CI cost while+// still bounding the test at roughly the budget itself.+const prepareBudgetForBlockedStart = 2 * time.Second+func TestRunTask_PrepareTimeoutStopsLeaseDuringBlockedStartTask(t *testing.T) {oldRefresh := taskPrepareLeaseRefresholdTimeout := taskPrepareLeaseTimeout@@ -712,7 +723,7 @@ func TestRunTask_PrepareTimeoutStopsLeaseDuringBlockedStartTask(t *testing.T) {workspaces: make(map[string]*workspaceState),runtimeIndex: map[string]Runtime{"rt-1": {ID: "rt-1", Provider: "claude"}},activeEnvRoots: make(map[string]int),- taskPrepareTimeout: 150 * time.Millisecond,+ taskPrepareTimeout: prepareBudgetForBlockedStart,cfg: Config{WorkspacesRoot: workspacesRoot,Agents: map[string]AgentEntry{@@ -735,13 +746,19 @@ func TestRunTask_PrepareTimeoutStopsLeaseDuringBlockedStartTask(t *testing.T) {if !errors.Is(err, errTaskPrepareTimeout) {t.Fatalf("runTask error = %v, want task prepare timeout", err)}- if elapsed := time.Since(startedAt); elapsed > time.Second {+ if elapsed := time.Since(startedAt); elapsed > prepareBudgetForBlockedStart+time.Second {t.Fatalf("runTask took %s, want prepare deadline to stop blocked /start", elapsed)}+ // Wait for the handler rather than sampling it: runTask returns as soon as+ // the deadline cancels the in-flight RoundTrip, which can beat httptest+ // scheduling the handler goroutine that closes startEntered. The wait only+ // slows the failing path — when /start was reached the channel is already+ // closed, and when it was not the budget above was too small to survive+ // preparation on this machine.select {case <-startEntered:- default:- t.Fatal("runTask did not reach /start")+ case <-time.After(2 * time.Second):+ t.Fatalf("runTask did not reach /start: the %s prepare budget expired during preparation", prepareBudgetForBlockedStart)}releaseStartOnce.Do(func() { close(releaseStart) })if got := leaseCalls.Load(); got == 0 {diff --git a/server/pkg/agent/omp_test.go b/server/pkg/agent/omp_test.goindex 5fcd299e27..82014a9eef 100644--- a/server/pkg/agent/omp_test.go+++ b/server/pkg/agent/omp_test.go@@ -85,8 +85,17 @@ func TestOmpExecuteDefaultsToOmpBinary(t *testing.T) {fakeDir := t.TempDir()fakePath := filepath.Join(fakeDir, "omp")+ // Real omp reads the piped prompt to EOF before emitting events, so the+ // fake has to drain stdin too: one that exits without reading closes the+ // read end while the backend is still writing, and the EPIPE surfaces as+ // "omp prompt write failed: broken pipe" (MUL-7244). It must drain with a+ // shell builtin, not `cat` — PATH is replaced with fakeDir below so the+ // backend has to resolve "omp" by name, which leaves no external command+ // on PATH for the fixture to call. A `cat` drain here fails silently with+ // "cat: not found" and the script runs straight through to its exit,+ // reopening the very race the drain was added to close.script := "#!/bin/sh\n" +- "cat > /dev/null\n" ++ "while IFS= read -r _; do :; done\n" +"printf '%s\\n' '{\"type\":\"agent_start\"}'\n" +"printf '%s\\n' '{\"type\":\"turn_end\",\"message\":{\"role\":\"assistant\",\"model\":\"test\",\"usage\":{\"input\":1,\"output\":1}}}'\n" +"exit 0\n"