test: keep the sim's task-end check; strict read for publish order
Opus review of #526 (READY AFTER FIXES): - P1: stop() waits for stream tasks at most 5 s of virtual time after cancel, so a task that ignores its client going fails again (in the bubble a bare wg.Wait let it run out MaxHold instantly and pass). - P3: TestReleaseBuildPublishedBeforeExec reads the generations file once (pinnedNow), so a write still in flight at StartRelease fails instead of being waited out. Follow-ups left on #526: cap sweep passes in the worker test, move the remaining deadAddr/listenLater tests to owned listeners, race pin note.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+26
−2
internal/activator/rootfsrelease_test.go+15 −1internal/edge/heldstream_sim_test.go+11 −1
diff --git a/internal/activator/rootfsrelease_test.go b/internal/activator/rootfsrelease_test.go| index 847067577..2a39a13cb 100644 |
| --- a/internal/activator/rootfsrelease_test.go |
| +++ b/internal/activator/rootfsrelease_test.go |
| @@ -710,6 +710,18 @@ func pinned(t *testing.T, a *Service, host, v string) bool { |
| return pinnedSettled(t, a, host, v) |
| } |
| +// pinnedNow is pinned without the retry: one read, and a half-written file |
| +// fails. For a check whose point is ordering (the file is complete before |
| +// something else happens), where waiting for the write would hide the bug. |
| +func pinnedNow(t *testing.T, a *Service, host, v string) bool { |
| + t.Helper() |
| + g, err := release.ReadGenerations(a.GenerationsFile) |
| + if err != nil { |
| + t.Fatalf("the generations file: %v", err) |
| + } |
| + return g != nil && slices.Contains(g.Hosts[host], v) |
| +} |
| + |
| // shrinkRelease shrinks the lease lead, the recheck and the retries. Not |
| // parallel: they are package vars. |
| func shrinkRelease(t *testing.T, lead, recheck time.Duration) { |
| @@ -786,7 +798,9 @@ func TestReleaseBuildPublishedBeforeExec(t *testing.T) { |
| r := newReleaseRig(t) |
| sawPin, sawRecord := false, false |
| r.b.onStart = func() { |
| - sawPin = pinned(t, r.a, r.rt.Host, "v2") |
| + // Strict: the file must already be complete when the release |
| + // starts, so a write still in flight is a failure, not a wait. |
| + sawPin = pinnedNow(t, r.a, r.rt.Host, "v2") |
| sawRecord = r.record() != nil |
| } |
| r.b.unit.done("1", "0", "success") |
diff --git a/internal/edge/heldstream_sim_test.go b/internal/edge/heldstream_sim_test.go| index 628471b38..ff5992b4d 100644 |
| --- a/internal/edge/heldstream_sim_test.go |
| +++ b/internal/edge/heldstream_sim_test.go |
| @@ -347,7 +347,17 @@ func heldStreamLifecycleSim(t *testing.T) { |
| close(stopDrive) |
| <-driveDone |
| cancel() |
| - wg.Wait() |
| + // Bounded, in virtual time: a stream task that ignores its |
| + // client going would otherwise run out MaxHold instantly |
| + // inside the bubble and pass. |
| + waited := make(chan struct{}) |
| + go func() { wg.Wait(); close(waited) }() |
| + select { |
| + case <-waited: |
| + case <-time.After(5 * time.Second): |
| + t.Errorf("seed %d: stream tasks did not end within 5s of cancel", seed) |
| + <-waited |
| + } |
| }) |
| } |
| defer stop() |