From e611103ec98fbfe7ac9c16389b6a6b8653fe5b41 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 03:31:56 +0100 Subject: [PATCH] =?UTF-8?q?=C2=A7819:=20the=20delivery=20SDK's=20count=20o?= =?UTF-8?q?f=20transport-fault=20runs=20is=20a=20row=20of=20the=20again=20?= =?UTF-8?q?table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test that a transport fault counts the runs that started, not the bus's deliveries, is folded into the again-delays table as its second run, so the SDK's unit tests fall by one instead of rising. Builds: design 47 H2 §819 (H-A-453 (4): a module's count never rises in a change) --- .../mesh-delivery-sdk/steprun/again_test.go | 15 +++++++++-- .../steprun/pull_poison_test.go | 27 ------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/again_test.go b/modules/mesh-delivery-sdk/steprun/again_test.go index 89133b165..cf8e2125f 100644 --- a/modules/mesh-delivery-sdk/steprun/again_test.go +++ b/modules/mesh-delivery-sdk/steprun/again_test.go @@ -12,7 +12,9 @@ import ( // Design 47 H2 §799: a fetch met by a forge's 401 or a connection fault, and a publish met by no responders or a bundle // that exited, end their run `again` after again-delays' delay, with no seat call; a third run's fault ends the step failed -// with the why `fetch: ` or `publish: `. +// with the why `fetch: ` or `publish: `. ADR 0664 §1 with the bus's count above the runs that started: an ask +// given back twice before its first run (the bus says delivered 3, the step key 1 run began) meets its fault in run 2, +// given again after again-delays' second, 60 s, not 3. func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { delay, err := AgainDelays("") if err != nil || delay(1) != 15*time.Second || delay(2) != time.Minute || delay(3) != time.Minute { @@ -46,8 +48,14 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { if !sdkstep.IsPassing(tc.err) || !strings.HasPrefix(tc.err.Error(), tc.why) { t.Fatalf("%v: want a transport fault opening with %q", tc.err, tc.why) } - for _, prior := range []int{0, 2} { // its first run ends again after 15 s; its third ends the step failed + // Its first run ends again after 15 s; its second, delivered three times, again after 60 s; its third ends the step failed. + for _, run := range []struct { + prior int + delivered uint64 + }{{0, 0}, {1, 3}, {2, 0}} { + prior := run.prior src, st := NewFakeAsks(), newSteps() + src.Delivered = run.delivered a := testAsk(sdkstep.AskDelivery) _ = src.PublishAsk(a) p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 }, @@ -65,6 +73,9 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { if prior == 0 && (s.State != sdkstep.StepAgain || len(delays) != 1 || delays[0] != 15*time.Second) { t.Errorf("the first run: step %+v, delays %v, want again after 15s", s, delays) } + if prior == 1 && (s.State != sdkstep.StepAgain || s.Run != 2 || len(delays) != 1 || delays[0] != time.Minute) { + t.Errorf("the second run, delivered %d times: step %+v, delays %v, want again in run 2 after 60s", run.delivered, s, delays) + } if prior == 2 && (s.State != sdkstep.StepFailed || !strings.HasPrefix(s.Reason, tc.why)) { t.Errorf("the third run: step %+v, want failed with the why %q", s, tc.why) } diff --git a/modules/mesh-delivery-sdk/steprun/pull_poison_test.go b/modules/mesh-delivery-sdk/steprun/pull_poison_test.go index 4af6d6aa7..bc650445f 100644 --- a/modules/mesh-delivery-sdk/steprun/pull_poison_test.go +++ b/modules/mesh-delivery-sdk/steprun/pull_poison_test.go @@ -246,33 +246,6 @@ func TestAnEndedPipelineStepIsSaidAndAcknowledged(t *testing.T) { } } -// ADR 0664 §1 with the bus's count above the runs that started: the ask was given back twice before its first run, so the -// bus says delivered 3 while the step key says 1 run began; a transport fault is run 2 (given again after again-delays' -// second, 60 s, design 47 H2 §799), not 3. -func TestATransportFaultCountsRunsThatStartedNotDeliveries(t *testing.T) { - src, st := NewFakeAsks(), newSteps() - src.Delivered = 3 - a := testAsk(sdkstep.AskDelivery) - _ = src.PublishAsk(a) - p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 }, PullWait: 10 * time.Millisecond, - Prior: func(string) int { return 1 }, - Run: func(context.Context, sdkstep.StepAsk) (any, error) { - return nil, &sdkstep.Passing{Err: errors.New("lookup proxy: i/o timeout")} - }} - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - go p.Pull(ctx) - waitFor(t, "the ask given again", func() bool { src.mu.Lock(); defer src.mu.Unlock(); return len(src.Delayed) == 1 }) - key, _ := sdkstep.AskStepKey("", "shanks", a.ID) - s, _ := st.get(key) - src.mu.Lock() - delays := append([]time.Duration(nil), src.Delays...) - src.mu.Unlock() - if s.State != sdkstep.StepAgain || s.Run != 2 || len(delays) != 1 || delays[0] != time.Minute { - t.Errorf("step %+v, delays %v, want again in run 2 after 60s", s, delays) - } -} - // Puller.Prior over a steps state's read: the Run of the step the key holds, 0 for an absent key, a failed read or what is no // step, and nil for no read. func TestPriorRunsReadsTheRunOfTheStepAKeyHolds(t *testing.T) {