health: remove direct callback and replace with eventbus (#17199)

Pulls out the last callback logic and ensures timers are still running.

The eventbustest package is updated support the absence of events.

Updates #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2025-09-19 14:58:37 -04:00
committed by GitHub
parent d559a21418
commit 009d702adf
5 changed files with 111 additions and 148 deletions

View File

@@ -120,7 +120,12 @@ func Expect(tw *Watcher, filters ...any) error {
// [Expect]. Use [Expect] if other events are allowed.
func ExpectExactly(tw *Watcher, filters ...any) error {
if len(filters) == 0 {
return errors.New("no event filters were provided")
select {
case event := <-tw.events:
return fmt.Errorf("saw event type %s, expected none", reflect.TypeOf(event))
case <-time.After(tw.TimeOut):
return nil
}
}
eventCount := 0
for pos, next := range filters {

View File

@@ -250,7 +250,7 @@ func TestExpectEvents(t *testing.T) {
tw := eventbustest.NewWatcher(t, bus)
// TODO(cmol): When synctest is out of experimental, use that instead:
// https://go.dev/blog/synctest
tw.TimeOut = 10 * time.Millisecond
tw.TimeOut = 100 * time.Millisecond
client := bus.Client("testClient")
defer client.Close()