diff --git a/internal/agent/supervisor/supervisor_test.go b/internal/agent/supervisor/supervisor_test.go index 8a50c54..8bc5587 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