carlos / platform Public

zdd-5 final review w2: TestTheGenerationsFileFollowsEveryChange waits for a complete publication

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 55de3e4aa91120a817d251c089dcc5c54e69d218 parent 1cc74fe
1 file changed, +11 −7
  • internal/activator/generations_instances_test.go +11 −7
diff --git a/internal/activator/generations_instances_test.go b/internal/activator/generations_instances_test.go
index d543ed240..dcd09b77a 100644
--- a/internal/activator/generations_instances_test.go
+++ b/internal/activator/generations_instances_test.go
@@ -88,13 +88,17 @@ func TestTheGenerationsFileFollowsEveryChange(t *testing.T) {
t.Fatal(err)
}
done()
- g, err = release.ReadGenerations(a.GenerationsFile)
- if err != nil || !slices.Equal(g.Hosts["one.example.com"], []string{"v1"}) {
- t.Fatalf("awake: %+v, %v", g, err)
- }
- if !slices.Equal(g.Paths["one.example.com"], []string{good.StagedPath}) {
- t.Fatalf("awake: paths %v, want the staged %s", g.Paths, good.StagedPath)
- }
+ // The wake goroutine republishes after the request it served has
+ // returned, and a reader that lands between a publication's intent and
+ // its file sees an incomplete one by design (release.ReadGenerations,
+ // plan 4 R19). So wait for a complete publication that names the awake
+ // generation, instead of reading once.
+ var lastErr error
+ waitFor(t, "a complete publication naming the awake generation", func() bool {
+ g, lastErr = release.ReadGenerations(a.GenerationsFile)
+ return lastErr == nil && g != nil && slices.Equal(g.Hosts["one.example.com"], []string{"v1"}) &&
+ slices.Equal(g.Paths["one.example.com"], []string{good.StagedPath})
+ })
a.BounceFor("one.example.com", CauseRestart)
// Four publications: the empty file, the plan before the lease, the
// awake generation, the stop (in either order with the third).