carlos / platform Public

Tighten the worker-grace window; own sockets for parallel generation tests

Astra review of ci-speed-activator:

P1: with an 8 s grace the test still allowed +10 s, so a worker waiting
twice its grace (exit at about 17 s) passed; the 60 s test had refused
that. The worker exits between the grace and about 2 s after it (1 s
ticks), so the window is now grace -1 s to +4 s. Checked by mutation:
`>= 2*grace` fails with "exited 18s after the main died".

P3: the newly parallel generation tests shared testRoute's
/tmp/nope.sock and could race on its symlink; they use genTestRoute's
per-test socket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev d9b1b4a61b9519d26753012a958dbf555fa314bf parent 85be21b
2 files changed, +11 −7
  • cmd/moveprobe/main_test.go +5 −1
  • internal/activator/generations_instances_test.go +6 −6
diff --git a/cmd/moveprobe/main_test.go b/cmd/moveprobe/main_test.go
index eabb11d2f..e64ffb336 100644
--- a/cmd/moveprobe/main_test.go
+++ b/cmd/moveprobe/main_test.go
@@ -829,7 +829,11 @@ func TestMoveprobeWorkerOutlivesMain(t *testing.T) {
if alive(r.WorkerPID) {
t.Fatalf("the worker is still alive %s after the main died", gone.Round(time.Second))
}
- if gone < grace-time.Second || gone > grace+10*time.Second {
+ // The worker notices its parent has gone on its next 1 s tick and
+ // leaves on the first tick at or past the grace, so it exits between
+ // the grace and about 2 s after it. 4 s of slack still refuses a worker
+ // that waits twice its grace.
+ if gone < grace-time.Second || gone > grace+4*time.Second {
t.Errorf("the worker exited %s after the main died, want about %s", gone.Round(time.Second), grace)
}
}
diff --git a/internal/activator/generations_instances_test.go b/internal/activator/generations_instances_test.go
index cd7943221..54b852740 100644
--- a/internal/activator/generations_instances_test.go
+++ b/internal/activator/generations_instances_test.go
@@ -84,7 +84,7 @@ func TestTheGenerationsFileFollowsEveryChange(t *testing.T) {
if err != nil || g == nil || len(g.Hosts) != 0 {
t.Fatalf("before any spawn: %+v, %v; want an empty file, written", g, err)
}
- done, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ done, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if err != nil {
t.Fatal(err)
}
@@ -117,7 +117,7 @@ func TestTheGenerationsFileNamesThePlannedBuildBeforeItSpawns(t *testing.T) {
b.gate = make(chan struct{})
woke := make(chan error, 1)
go func() {
- done, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ done, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if err == nil {
done()
}
@@ -165,7 +165,7 @@ func TestAReplannedBuildIsPublishedBeforeItExecs(t *testing.T) {
return WakePlan{Boot: v3, Mode: ModeOverlap}
}
if broken {
- _, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ _, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if !errors.Is(err, errStagedBuildNotPublished) {
t.Fatalf("err = %v, want errStagedBuildNotPublished", err)
}
@@ -180,7 +180,7 @@ func TestAReplannedBuildIsPublishedBeforeItExecs(t *testing.T) {
b.gate = make(chan struct{})
woke := make(chan error, 1)
go func() {
- done, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ done, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if err == nil {
done()
}
@@ -254,7 +254,7 @@ func TestAnUnpublishedBuildIsNeverSpawned(t *testing.T) {
good, next := stagedID(t, dir, "v1"), stagedID(t, dir, "v2")
a, b, evs := planActivator(t, WakePlan{Boot: next, Mode: ModeOverlap, FirstWake: true, Fallback: &good})
a.GenerationsFile = unwritableGenerationsFile(t)
- _, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ _, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if !errors.Is(err, errStagedBuildNotPublished) {
t.Fatalf("err = %v, want errStagedBuildNotPublished", err)
}
@@ -381,7 +381,7 @@ func TestTheGenerationsFileIsUnchangedWithTheFlagOff(t *testing.T) {
if err := a.WakeWorker(alwaysOnWorkerRoute(bot)); err != nil {
t.Fatal(err)
}
- done, err := a.beginRequest(context.Background(), testRoute("one.example.com"))
+ done, err := a.beginRequest(context.Background(), genTestRoute(t, "one.example.com"))
if err != nil {
t.Fatal(err)
}