node-tools: every wait on the bus in a test waits the shared bound, not a few seconds (issue 1754)

TestAStaleWriteIsRefusedAndWritesNothing gave the watch 5 s to hear a 1 s
key's expire and failed main.505's integration step on a loaded build node;
TestARunnerAtItsStopAnswersNoCallAndItsCallersMeetNoResponders failed its
rerun while it asked 1 s of two round trips and 5 s and 10 s of its waits.
The second of a kind after 3850eb8, so the kind is fixed: meshtest.Bound
(30 s, Until's bound, named once) is what every node-tools test that starts
a bus waits for what the bus carries; Until becomes a deadline of it, so a
try that waits does not multiply it; an upper bound on how long a call or a
wait took is half the bound it tells apart (bus.RequestTimeout, the call's
or the wait's own), at most meshtest.Bound. A wait that hears ends then: no
passing test is longer (per-test durations before and after, equal).

A guard (meshtest waits_test.go) reads every test file that imports
meshtest and refuses a wait whose constant bound is a second or more under
meshtest.Bound; it names 34 such waits at 309069de.

Builds: issue 1754 note 8 (the quick fix), note 9 (1754/AC1 to AC4); principle 11
This commit is contained in:
2026-11-23 19:21:28 +01:00
parent 309069dec1
commit 6a1b4817f8
23 changed files with 309 additions and 72 deletions
+4 -4
View File
@@ -29,7 +29,7 @@ func TestTheBusRefusesAWaitOutsideTheGrant(t *testing.T) {
t.Fatal(err)
}
go s.Start()
if !s.ReadyForConnections(10 * time.Second) {
if !s.ReadyForConnections(mt.Bound) {
t.Fatal("the bus did not come up")
}
t.Cleanup(s.Shutdown)
@@ -38,7 +38,7 @@ func TestTheBusRefusesAWaitOutsideTheGrant(t *testing.T) {
// Every subscription refused: answered after the timeout, never at once, in §16's words.
start := time.Now()
_, ok, refused, err := c.HearFirst(context.Background(), []string{other}, 300*time.Millisecond, nil)
if took := time.Since(start); took < 300*time.Millisecond || took > 3*time.Second {
if took := time.Since(start); took < 300*time.Millisecond || took > mt.Bound { // 1754/AC4: after its timeout, never at once
t.Errorf("a wait refused whole answered after %s, want its timeout of 300ms", took)
}
if ok || err == nil || !strings.Contains(err.Error(), "the bus refused this account a subscription on "+other) ||
@@ -62,7 +62,7 @@ func TestTheBusRefusesAWaitOutsideTheGrant(t *testing.T) {
}
done := make(chan result, 1)
go func() {
h, ok, refused, err := c.HearFirst(context.Background(), []string{other, granted}, 5*time.Second, nil)
h, ok, refused, err := c.HearFirst(context.Background(), []string{other, granted}, mt.Bound, nil)
if !ok && err == nil {
err = errors.New("timed out")
}
@@ -108,7 +108,7 @@ func TestAWaitEndsWhenItsCallerIsGone(t *testing.T) {
if ok || !errors.Is(err, context.Canceled) {
t.Errorf("a cancelled wait answered %v, %v", ok, err)
}
if took := time.Since(start); took > 2*time.Second {
if took := time.Since(start); took > mt.Bound { // 1754/AC4: at the cancel, not at its timeout of a minute
t.Errorf("a cancelled wait ended after %s", took)
}
if after := c.Subscriptions(); after != before {