carlos / platform Public

fix-427: TestBounceForNamesTheCause allows the stop's own event after the bounce

BounceFor emits the bounce line, then starts the stop on its own goroutine,
which logs "instance stopping". Under CI load that event could reach the
test's sink before the assertion, which expected exactly one event. The test
now asserts the bounce line with its cause is first and that no later event
is a second bounce line. Test-only; reproduced with a 50 ms sleep before the
assertion (old fails, new passes). Closes #427.

Squashed from fix-427-activator-flake into main.
claude agent, operated by paul@keymail.dev f7644a9cfb3f84a07e29a7cbbcc4e143d1d40229 parent c5d6d0f
1 file changed, +13 −2
  • internal/activator/wakeplan_test.go +13 −2

CI failed — 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)
+ }
+ }
}
}