zdd-5 final review w2: TestTheGenerationsFileFollowsEveryChange waits for a complete publication
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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). |