From 0e03495757b18b74d301f3991a5cb79e47f0393c Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:03:42 +0100 Subject: [PATCH] Tool runner bus: the per-node state test waits on the watch, not a 5 s poll Under load TestAPerNodeStateIsServedAcrossEveryNodesBucket failed 2 of 30: a bucket made during the watch is taken in on the bus's creation advisory, which a loaded machine delivers after mt.Until's fixed five seconds. The test now waits as the watch hands each change over, bounded only for a watch that never hears. Builds: design 47 H H-A-363 (fix-a-bug-met-twice: a fixed bound a loaded machine overruns) --- node-tools/internal/bus/state_pernode_test.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/node-tools/internal/bus/state_pernode_test.go b/node-tools/internal/bus/state_pernode_test.go index 82baf52..ce6af1a 100644 --- a/node-tools/internal/bus/state_pernode_test.go +++ b/node-tools/internal/bus/state_pernode_test.go @@ -69,6 +69,7 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) { var mu sync.Mutex var current, live []string + heard := make(chan struct{}, 1) stop, err := conn.StateWatch("mesh-provisioner", "mesh-host.composed", "", func(ch bus.StateChange) error { mu.Lock() defer mu.Unlock() @@ -77,6 +78,10 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) { } else { live = append(live, ch.Key) } + select { + case heard <- struct{}{}: + default: + } return nil }) if err != nil { @@ -98,7 +103,10 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) { if _, err := a.Put("a.m1.f5", []byte(`{"v":1}`)); err != nil { t.Fatal(err) } - mt.Until(t, func() error { + // Waited for as the watch hands each change over, not polled within a fixed five seconds: the new bucket is taken + // in on the bus's creation advisory, which a loaded machine delivers later (design 47 H, H-A-363). The bound only + // ends a watch that never hears it. + missing := func() error { mu.Lock() defer mu.Unlock() got := strings.Join(append(append([]string(nil), current...), live...), ",") @@ -108,5 +116,13 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) { } } return nil - }) + } + bound := time.After(30 * time.Second) + for err := missing(); err != nil; err = missing() { + select { + case <-heard: + case <-bound: + t.Fatal(err) + } + } }