diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index bcdc9fd5..c91fbc45 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -512,8 +512,10 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { failures int // reads failing before the bus answers cancel bool composes bool - fail error // what each failing read says; JetStream not enabled when nil - slow time.Duration // each failing read takes this long + fail error // what each failing read says; JetStream not enabled when nil + // slow: each failing read lasts until the pass said it runs on, and what it waits on, or its bound (no fixed sleep: on a + // loaded build node a 30 ms read ended with the pass's first tick, and the pass ended before its say, pipeline main.417). + slow bool // again: the refusal says when the node composes again, and a pass is owed (issue 774, 2026-10-31: ace's // route-proxy said only "the vault's own could not be asked ... context deadline exceeded"). again bool @@ -521,15 +523,13 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { "the bus paused for one read": {failures: 1, composes: true}, "the bus paused past every try": {failures: 100, again: true}, "the run ended mid-pass": {failures: 100, cancel: true}, - "the vault did not answer in time": {failures: 100, again: true, slow: 30 * time.Millisecond, + "the vault did not answer in time": {failures: 100, again: true, slow: true, fail: fmt.Errorf("the vault's own could not be asked: no answer from mesh.seat.mesh-vault.call.own.node~n1: %w", context.DeadlineExceeded)}, "a refusal": {failures: 100, fail: errors.New("nats says ${dir:mesh-state}, and nats declares no directory")}, } { - b.mu.Lock() - saidBefore := len(b.said) - b.mu.Unlock() failed := 0 pctx, pcancel := context.WithCancel(ctx) + saidLong, saidOnce := make(chan struct{}), sync.Once{} get := func(gctx context.Context, bucket, key string) ([]byte, error) { if failed < row.failures { failed++ @@ -537,7 +537,12 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { pcancel() return nil, fmt.Errorf("the vault's own could not be asked: %w", context.Canceled) } - time.Sleep(row.slow) + if row.slow { + select { + case <-saidLong: + case <-time.After(5 * time.Second): + } + } if row.fail != nil { return nil, fmt.Errorf("the revisions of %s in %s: %w", key, bucket, row.fail) } @@ -548,6 +553,18 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { return b.kv[bucket+"/"+key], nil } c2, refusals := fresh(get) + var long []string // what this pass said of running on: the shared bus's lines also hold the watching composer's + var longMu sync.Mutex + say := c2.env.Say + c2.env.Say = func(line string) { + say(line) + if strings.Contains(line, "the node's composition has run for ") && strings.Contains(line, " and waits on ") { + longMu.Lock() + long = append(long, line) + longMu.Unlock() + saidOnce.Do(func() { close(saidLong) }) + } + } // What fails is the vault's own, asked for keeper's secret through the same read. c2.holdEntry(t, "keeper", keeperFp, keeperBody) c2.wants["keeper"] = meshwants.WantsByWantNodeModuleValue{Fp: keeperFp, Self: true} @@ -583,16 +600,14 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) { name, (*refusals)[0], c2.owed.Load(), c2.last, row.again) } } - // A pass that runs on says so, and what it waits on (issue 774, 2026-10-31: ace was silent for five minutes). - if row.slow > 0 { - b.mu.Lock() - long := false - for _, line := range b.said[saidBefore:] { - long = long || strings.Contains(line, "the node's composition has run for ") && strings.Contains(line, " and waits on ") - } - b.mu.Unlock() - if !long { - t.Errorf("%s: a pass that ran on said nothing of what it waits on", name) + // A pass that runs on says so, and what it waits on (issue 774, 2026-10-31: ace was silent for five minutes): here the + // vault's own secrets, which its slow read is. + if row.slow { + longMu.Lock() + names := len(long) > 0 && strings.Contains(long[0], "waits on the vault's own secrets") + longMu.Unlock() + if !names { + t.Errorf("%s: a pass that ran on said nothing of what it waits on: %q", name, long) } } }