From dde2bcab1983e2ab3f47909585859184b8c945f9 Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Sun, 27 Sep 2026 09:36:40 +0200 Subject: [PATCH] Stop asserting an ordering the supervisor does not promise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test started a sidecar and an engine, each a shell appending its name to a file, and demanded the sidecar's line come first. The supervisor spawns the sidecar first, but spawning is not sequencing: without WaitForLeaderPort nothing holds the engine back, so two shells race and the scheduler picks the winner. It failed under full-suite load, and lately on its own. The wait that is a real guarantee already has its own test, so the fix is to check what this one is actually for — that both processes run under one shard, that the shard's pid is the engine's rather than the sidecar's, and that their output is distinguishable in a single log tail. Renamed to say so. Co-Authored-By: Claude Opus 5 (1M context) --- internal/agent/supervisor/supervisor_test.go | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/agent/supervisor/supervisor_test.go b/internal/agent/supervisor/supervisor_test.go index 8a50c547..8bc5587a 100644 --- a/internal/agent/supervisor/supervisor_test.go +++ b/internal/agent/supervisor/supervisor_test.go @@ -8,6 +8,7 @@ import ( "net" "os" "path/filepath" + "slices" "strings" "sync/atomic" "syscall" @@ -536,9 +537,9 @@ func TestCorruptStateFileIsCleanedUp(t *testing.T) { // --- multi-process shards (plan §11, phase 4) --- -func TestSidecarRunsBeforeEngine(t *testing.T) { - // The Ray shape: a supporting process starts first and keeps running, then - // the engine starts against it. +func TestASidecarAndAnEngineBothRunUnderOneShard(t *testing.T) { + // The Ray shape: a supporting process runs alongside the engine for the + // shard's lifetime, but the engine is the one whose exit ends the shard. s, _ := newSupervisor(t) dir := t.TempDir() order := filepath.Join(dir, "order") @@ -571,13 +572,20 @@ func TestSidecarRunsBeforeEngine(t *testing.T) { } } // Asserted rather than broken out of: the original fell through on timeout, - // so a slow machine turned the ordering check into a no-op and the failure - // surfaced later as something else. + // so a slow machine turned this into a no-op and the failure surfaced later + // as something else. if len(started) != 2 { t.Fatalf("only %d of 2 processes started: %v", len(started), started) } - if started[0] != "sidecar" || started[1] != "engine" { - t.Fatalf("start order was %v", started) + // Which of the two appended first is deliberately not asserted. The + // supervisor spawns the sidecar first, but spawning is not sequencing: + // nothing here makes the engine wait, so two shells racing to append give + // either order and a test that demanded one would fail for the scheduler's + // reasons rather than the supervisor's. The wait that is a real guarantee + // is WaitForLeaderPort, and TestWaitForLeaderPortBlocksUntilListening is + // where it is checked. + if !slices.Contains(started, "sidecar") || !slices.Contains(started, "engine") { + t.Fatalf("expected both processes to have run, got %v", started) } // The shard's pid is the engine's, not the sidecar's: the engine's exit is