2 files changed,
+17
−4
internal/ops/hibernate_verify.go
+6 −0
internal/ops/hibernate_verify_test.go
+11 −4
| index d5e034f0d..fbf5c5382 100644 |
| --- a/internal/ops/hibernate_verify.go |
| +++ b/internal/ops/hibernate_verify.go |
| @@ -126,6 +126,11 @@ var ( |
| t := time.NewTicker(d) |
| return t.C, t.Stop |
| } |
| + // publishTickDone is called once each tick has been handled (published, |
| + // or skipped with nothing new). Production does nothing; a test waits |
| + // on it, since a tick's receipt says nothing about when its handling |
| + // ends. |
| + publishTickDone = func() {} |
| ) |
| |
| // Drill is one run's settings. Cfg names the hibernate bucket; Store is the |
| @@ -195,6 +200,7 @@ func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, n |
| if snap, ok := res.unpublished(); ok { |
| publish(snap) |
| } |
| + publishTickDone() |
| } |
| } |
| }() |
| index 4f4267f55..1ea06165b 100644 |
| --- a/internal/ops/hibernate_verify_test.go |
| +++ b/internal/ops/hibernate_verify_test.go |
| @@ -1107,6 +1107,11 @@ func TestVerifyHibernatingTickWithNothingNewIsQuiet(t *testing.T) { |
| <-release |
| return 1, nil |
| }) |
| + // A tick's receipt says nothing about when its handling ends: wait for |
| + // publishTickDone, so no tick is still being handled when the host's |
| + // verdict lands (that tick would rightly publish it). |
| + handled := make(chan struct{}) |
| + swap(t, &publishTickDone, func() { handled <- struct{}{} }) |
| d := fx.drill() |
| d.PublishEvery = 10 * time.Minute |
| var calls atomic.Int32 |
| @@ -1116,10 +1121,12 @@ func TestVerifyHibernatingTickWithNothingNewIsQuiet(t *testing.T) { |
| close(done) |
| }() |
| <-blocked |
| - ticker.c <- fx.clock.Now() |
| - ticker.c <- fx.clock.Now() // taken only once the first tick was handled |
| - if n := calls.Load(); n != 0 { |
| - t.Fatalf("%d publishes with nothing finished", n) |
| + for range 2 { |
| + ticker.c <- fx.clock.Now() |
| + <-handled |
| + if n := calls.Load(); n != 0 { |
| + t.Fatalf("%d publishes with nothing finished", n) |
| + } |
| } |
| close(release) |
| <-done |