From cb5de6fd31b523e70f7ae43a800952bd024f336d Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:43:38 +0100 Subject: [PATCH] MR1: the recovery module's whole test waits its start by the setup bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The module's start is the test's setup: its two waits on the bus take testbus.SetupBound (half of MESH_TEST_LEVEL_BOUND) and say a starved setup in the one line testbus.Starved writes; its 30 s values go. Builds: design 47 H2 §800; H-A-327, H-A-368 --- .../mesh-recovery/whole_integration_test.go | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/mesh-recovery/cmd/mesh-recovery/whole_integration_test.go b/modules/mesh-recovery/cmd/mesh-recovery/whole_integration_test.go index 0aad2a95a..9e7904dba 100644 --- a/modules/mesh-recovery/cmd/mesh-recovery/whole_integration_test.go +++ b/modules/mesh-recovery/cmd/mesh-recovery/whole_integration_test.go @@ -15,6 +15,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "fmt" "os" "path/filepath" "strings" @@ -258,7 +259,8 @@ func TestRecoveryWhole(t *testing.T) { events <- heard{m.Subject, b} }) var kept []heard - waitEvent := func(t *testing.T, what string, ok func(heard) bool) map[string]any { + // saidWithin waits for an event ok takes, within bound, and ends the test by fail when none came. + saidWithin := func(t *testing.T, what string, bound time.Duration, fail func(string), ok func(heard) bool) map[string]any { t.Helper() for i, h := range kept { if ok(h) { @@ -266,7 +268,7 @@ func TestRecoveryWhole(t *testing.T) { return h.body } } - deadline := time.After(30 * time.Second) + deadline := time.After(bound) for { select { case h := <-events: @@ -275,10 +277,15 @@ func TestRecoveryWhole(t *testing.T) { } kept = append(kept, h) case <-deadline: - t.Fatalf("not said within 30s: %s", what) + fail(fmt.Sprintf("not said within %s: %s", bound, what)) + return nil } } } + waitEvent := func(t *testing.T, what string, ok func(heard) bool) map[string]any { + t.Helper() + return saidWithin(t, what, 30*time.Second, func(words string) { t.Helper(); t.Fatal(words) }, ok) + } endOf := func(t *testing.T, event, act string) map[string]any { t.Helper() return waitEvent(t, event+" of "+act, func(h heard) bool { @@ -347,13 +354,16 @@ func TestRecoveryWhole(t *testing.T) { done := make(chan error, 1) go func() { done <- run(runCtx, func(k string) string { return env[k] }, testLog{t}) }() defer func() { stop(); <-done }() - waitEvent(t, "the start's removal of points past their keep days", func(h heard) bool { + // The module's start is the test's setup: its waits on the bus take the setup bound of the level's bound and say a starved + // setup in its one line, never a value of the test's own (design 47 H2 §800, H-A-327, H-A-368). + setup := testbus.SetupBound(t) + saidWithin(t, "the start's removal of points past their keep days", setup, func(words string) { testbus.Starved(t, words) }, func(h heard) bool { return h.subject == "mesh.seat.mesh-recovery.event."+seat.EventExpiryEnded }) select { case <-listed: - case <-time.After(30 * time.Second): - t.Fatal("the module did not read its seat's definition from the seat list within 30s") + case <-time.After(setup): + testbus.Starved(t, fmt.Sprintf("the module did not read its seat's definition from the seat list within %s", setup)) } var first string