From 8004bb98f0e7aeb000cb9027dbfaf9d1ab37f61b Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 10:02:46 +0100 Subject: [PATCH] Forge bridge whole test: read performed once the bridge acknowledged the act MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestBridgePerformsWhatIsOwedOnce read performed as soon as the first fill key was purged, while the prune (run inside the write that keeps the act's outcome) was still purging the others; on a loaded build node the count landed mid-prune (main.278, 365, 401, 415: "performed holds 37116 bytes of current values after its prune, want about its target 32768"). Made visible locally by slowing each purge by 20 ms: the old test fails with the same words, the new one passes. The kind is a test acting on the first sign of an act (its owed.ended, one purge) while the act's work goes on. The test now waits for the bridge's acknowledgement of the named act on its durable, which comes only after the outcome is kept and the prune ended: before reading performed after the prune, and before stopping the bridge after the acts said while the forge was away (a stop between outcome and keeping hears the act again, writing performed while the test fills it). Builds: design 47 H2 §812, §807 --- .../integration_test.go | 72 +++++++++++++++---- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go index fb1e081fa..06009b7da 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go @@ -10,6 +10,7 @@ import ( "io" "os" "path/filepath" + "strconv" "strings" "sync" "testing" @@ -495,6 +496,49 @@ func refusedRead(t *testing.T, b *bed, bucket string) { } } +// ackedOf listens, from now on, to the bridge's acknowledgements on its durable of the stream owed; the function it +// answers waits until the bridge acknowledged the act data. The bridge acknowledges an act only once heard returned: +// its outcome said, kept in performed, and the prune that write started ended (bound.go), so what the act changed is +// read whole after it, and the bridge stopped after it, never while the act is still being written. +func ackedOf(t *testing.T, b *bed) func(data []byte) { + t.Helper() + sub, err := b.ctl.SubscribeSync("$JS.ACK." + seat.StreamOwed + ".n1_mesh-delivery-forge-bridge.>") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = sub.Unsubscribe() }) + if err := b.ctl.Flush(); err != nil { + t.Fatal(err) + } + owed, err := b.js.Stream(b.ctx, seat.StreamOwed) + if err != nil { + t.Fatal(err) + } + seen := map[string]bool{} // the acts acknowledged while another was waited for + return func(data []byte) { + t.Helper() + bound := time.Now().Add(20 * time.Second) + for !seen[string(data)] { + m, err := sub.NextMsg(time.Until(bound)) + if err != nil { + t.Fatalf("the bridge did not acknowledge %s on %s within 20 s: %v", data, seat.StreamOwed, err) + } + // $JS.ACK......