The step runner no longer reads the seat list for the callers a build seat's definition lists, refuses an asker it does not name, or gives an ask back until the list says: Puller.Callers, CallersFromDefinitions, SeatListCallers and the seat list reader's start go, since no seat definition names callers and every account may call every verb. The step is still keyed under the asker its subject names, and main's subject still takes only a build, a run and the checker's check and recheck. mesh-delivery-sdk builds again against mesh-sdk without seatdef callers. Builds: design 47 H §752, §764 (every seat contract: the callers lists); lead answers H-A-41, H-A-66, H-A-71 (3) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
75 lines
3.5 KiB
Go
75 lines
3.5 KiB
Go
package steprun
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
|
)
|
|
|
|
// Design 47 H §752, H-A-41: every account may ask every kind, so an ask of any asker its subject names runs, keyed under
|
|
// that asker, and none is given back to be judged; a step on main's subject, which names no asker, is refused (design 47 G
|
|
// §543, A-184: main's subject takes a build, a run and the checker's check and recheck).
|
|
func TestPullTakesEveryAskersKind(t *testing.T) {
|
|
step := testAsk(sdkstep.AskStep)
|
|
step.Check = nil
|
|
step.Step = &sdkstep.StepRun{Pipeline: "p", Step: sdkstep.StepUnit, Module: "m", Artifact: "m:a", Commit: "0123456789abcdef0123456789abcdef01234567",
|
|
Fingerprint: "fp", Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: "0123456789abcdef0123456789abcdef01234567"}}
|
|
build := testAsk(sdkstep.AskDelivery)
|
|
for _, c := range []struct {
|
|
name, subject string
|
|
ask sdkstep.StepAsk
|
|
want string // "" runs it, "refused" refuses it
|
|
}{
|
|
{"the indexer's step", "mesh.seat.node-build-go.accept.check.mesh-catalog", step, ""},
|
|
{"the runner's step", "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner", step, ""},
|
|
{"a step on main's subject", "mesh.seat.node-build-go.accept.check", step, "refused"},
|
|
{"a build on main's subject", "mesh.seat.node-build-go.accept.delivery", build, ""},
|
|
// A-184: until main's subject goes, it also takes the checker's check and recheck asks.
|
|
{"the checker's check on main's subject", "mesh.seat.node-build-go.accept.check", testAsk(sdkstep.AskCheck), ""},
|
|
{"the checker's recheck on main's subject", "mesh.seat.node-build-go.accept.recheck", testAsk(sdkstep.AskRecheck), ""},
|
|
} {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
src, st, sy := NewFakeAsks(), newSteps(), &sayer{}
|
|
raw, _ := sdkstep.EncodeStepAsk(c.ask)
|
|
queue := c.ask.Kind
|
|
if queue == sdkstep.AskStep {
|
|
queue = sdkstep.AskCheck // a step rides the queue check (A-170, A-184)
|
|
}
|
|
src.PublishWithSubject(queue, raw, c.subject)
|
|
_, _, asker, _ := sdkstep.ParseAskSubjectBy(c.subject)
|
|
ran := make(chan struct{}, 1)
|
|
p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 },
|
|
PullWait: 5 * time.Millisecond, Heartbeat: time.Hour, Say: sy.say, ProgressEvery: time.Hour,
|
|
Run: func(context.Context, sdkstep.StepAsk) (any, error) { ran <- struct{}{}; return nil, nil }}
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
go p.Pull(ctx)
|
|
switch c.want {
|
|
case "":
|
|
<-ran
|
|
// §481: the step is keyed under the asker its subject names, main's under its node alone.
|
|
key, _ := sdkstep.AskStepKey(asker, "shanks", c.ask.ID)
|
|
waitFor(t, "the step keyed "+key, func() bool { _, ok := st.get(key); return ok })
|
|
case "refused":
|
|
waitFor(t, "the ask ended", func() bool { acked, _, _ := src.Fates(); return len(acked) == 1 }) // A-489: ended, written, acknowledged
|
|
key, _ := sdkstep.AskStepKey(asker, "shanks", c.ask.ID)
|
|
s, _ := st.get(key)
|
|
if s.State != sdkstep.StepFailed || !strings.Contains(s.Reason, KindOf(c.ask)) || (strings.Contains(c.subject, "mesh-catalog") && !strings.Contains(s.Reason, asker)) {
|
|
t.Fatalf("the step = %+v, want failed naming the kind %s and the asker", s, KindOf(c.ask))
|
|
}
|
|
if end := sy.of("step-ended"); len(end) != 1 || end[0].body["outcome"] != sdkstep.OutcomeFailed {
|
|
t.Fatalf("step-ended = %+v, want failed", end)
|
|
}
|
|
select {
|
|
case <-ran:
|
|
t.Fatal("a refused ask ran")
|
|
default:
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|