§819: the delivery SDK's count of transport-fault runs is a row of the again table

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)
This commit is contained in:
2026-11-22 03:31:56 +01:00
parent 81ea73a45f
commit e611103ec9
2 changed files with 13 additions and 29 deletions
@@ -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: <words>` or `publish: <words>`.
// with the why `fetch: <words>` or `publish: <words>`. 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)
}
@@ -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) {