carlos / platform Public

activator test: TestBounceForNamesTheCause allows the stop's own event after the bounce (#427)

BounceFor emits the bounce line, then starts the stop on its own
goroutine, which logs "instance stopping". Under CI load that second
event can land before the test reads its sink, and the test asserted
exactly one event. It now asserts the bounce line with the cause comes
first and that no later event is a second bounce line.

Reproduced deterministically with a 50 ms sleep before the assertion
(old: FAIL with [instance restarting (config change) instance stopping];
new: pass). Test-only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 63a9a99da15be9b079a3683348c27b08fa00dd6c parent 5634538
1 file changed, +13 −2
  • internal/activator/wakeplan_test.go +13 −2

CI passed — run details

diff --git a/internal/activator/wakeplan_test.go b/internal/activator/wakeplan_test.go
index 675eb3498..b0c767c4e 100644
--- a/internal/activator/wakeplan_test.go
+++ b/internal/activator/wakeplan_test.go
@@ -1217,9 +1217,20 @@ func TestBounceForNamesTheCause(t *testing.T) {
}
sink.mu.Lock()
defer sink.mu.Unlock()
+ // BounceFor words its event before it starts the stop, so the bounce
+ // line is always first. The stop runs on its own goroutine and may log
+ // "instance stopping" before this check reads the sink (#427), so later
+ // events are allowed, but none may be a second bounce line.
want := fmt.Sprintf(rolloutwords.EventBounceInstance, rolloutwords.Cause(string(CauseConfig)))
- if len(sink.msgs) != 1 || sink.msgs[0] != want {
- t.Fatalf("events = %v, want %q", sink.msgs, want)
+ if len(sink.msgs) == 0 || sink.msgs[0] != want {
+ t.Fatalf("events = %v, want %q first", sink.msgs, want)
+ }
+ for _, msg := range sink.msgs[1:] {
+ for _, cause := range []Cause{CauseRelease, CauseInstall, CauseRetry, CauseConfig, CauseRestart} {
+ if msg == bounceText(false, cause) || msg == bounceText(true, cause) {
+ t.Fatalf("events = %v: a second bounce line %q", sink.msgs, msg)
+ }
+ }
}
}