Stop asserting an ordering the supervisor does not promise

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) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5 committed 2026-09-27 09:36:40 +02:00
1 parent 16ec585411
commit dde2bcab19
1 file changed
+15 -7
+15 -7
View File
@@ -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