runner: test-runs is answered by the process, its fill said against test-runs-cap-mib (A-470g, A-470i)
The bundle said test-runs' fill against the bucket's 64 MiB ceiling, a cap that refuses nothing; the process, which holds test-runs-cap-mib and judges it, now answers the verb test-runs, its fill's cap being that setting, and runner_test_runs calls the verb. Builds: design 47 G §728, §725 (the cap); A-469d, A-470g, A-470i
This commit is contained in:
@@ -46,8 +46,8 @@ func as[T any](args map[string]any) (T, error) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
// Tools are the runner's read verbs over its states pipelines, kept and test-runs.
|
||||
func Tools(r pipeline.Reads, testRuns ...pipeline.RunsRead) []stdio.Tool {
|
||||
// Tools are the runner's read verbs over its states pipelines and kept; test-runs is the process's (A-470i).
|
||||
func Tools(r pipeline.Reads) []stdio.Tool {
|
||||
runs := map[string]func(map[string]any) (any, error){
|
||||
seat.VerbShow: func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.ShowInput](a)
|
||||
@@ -79,15 +79,6 @@ func Tools(r pipeline.Reads, testRuns ...pipeline.RunsRead) []stdio.Tool {
|
||||
return r.KeptResults(in)
|
||||
},
|
||||
}
|
||||
for _, t := range testRuns {
|
||||
runs[seat.VerbTestRuns] = func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.TestRunsInput](a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t.TestRuns(in)
|
||||
}
|
||||
}
|
||||
var out []stdio.Tool
|
||||
for _, v := range seat.Verbs() {
|
||||
if run, ok := runs[v]; ok {
|
||||
@@ -157,8 +148,7 @@ func main() {
|
||||
func(n string) (buscalls.Fill, error) { return busstate.ObjectsOf(n).Fill() },
|
||||
func(n string) (*stdio.LogInfo, error) { return stdio.Log(n).Info() }, time.Now)
|
||||
r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill}
|
||||
runs := RunsRead(stdio.State(testRunsState), stdio.State(testRunsState).Info, busstate.ObjectsOf(testRunsObjects))
|
||||
tools := append(Tools(r, runs), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...)
|
||||
tools := append(Tools(r), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...)
|
||||
tools = append(tools, UnloggedTools(stdio.State(seat.StatePipelines), stdio.Log(seat.StateStepLog), meshhandactsclient.Recorder{Ask: stdio.Ask},
|
||||
func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] "+f+"\n", a...) })...)
|
||||
tools = append(tools, CancelTool(r.List, stdio.Ask), RerunTool(stdio.Ask))
|
||||
|
||||
@@ -7,42 +7,14 @@ import (
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/busstate"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
|
||||
"mesh-delivery-pipeline/internal/pipeline"
|
||||
)
|
||||
|
||||
// testRunsState is the runner's state of its test runs (§725), and testRunsObjects its own object store (A-469e).
|
||||
const testRunsState = "test-runs"
|
||||
|
||||
var testRunsObjects = catalogue.StateObjectsName(testRunsState)
|
||||
|
||||
// RunsRead is the verb test-runs' reader over the runner's state test-runs and its object store, through the bundle's calls.
|
||||
func RunsRead(state stdio.KeptState, info func() (*stdio.StateInfo, error), objects busstate.Objects) pipeline.RunsRead {
|
||||
return pipeline.RunsRead{Runs: kept{state},
|
||||
Object: func(name string) ([]byte, error) {
|
||||
o, err := objects.Get(name)
|
||||
if err != nil && strings.Contains(err.Error(), "not found") {
|
||||
return nil, pipeline.ErrNoRun
|
||||
}
|
||||
return o.Data, err
|
||||
},
|
||||
Fill: func() (seat.Fill, error) {
|
||||
i, err := info()
|
||||
if err != nil {
|
||||
return seat.Fill{}, err
|
||||
}
|
||||
return seat.Fill{Store: testRunsState, Bytes: int64(i.Bytes), Cap: i.MaxBytes}, nil
|
||||
}}
|
||||
}
|
||||
|
||||
// TestRunsTools are runner_test_runs and runner_test_runs_drop (design 47 G §728; A-469f, A-469u): each calls its seat verb
|
||||
// over the bus, test-runs answered by this bundle and test-runs-drop by the runner's process (A-469g).
|
||||
// over the bus, both answered by the runner's process, which holds test-runs-cap-mib (A-469g, A-470i).
|
||||
func TestRunsTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.Tool {
|
||||
return []stdio.Tool{
|
||||
{Name: Prefix + "_test_runs",
|
||||
Description: "The pipeline runner's test runs, one per candidate, level and tested packages (the state test-runs): each with its packages read from its output object, its ask, node, readers, outcome and counts, and the state's fill against its cap; filtered by a candidate, a level, a digest or a module, or none.",
|
||||
Description: "The pipeline runner's test runs, one per candidate, level and tested packages (the state test-runs): each with its packages read from its output object, its ask, node, readers, outcome and counts, and the state's fill against its cap setting test-runs-cap-mib; filtered by a candidate, a level, a digest or a module, or none.",
|
||||
Input: map[string]any{"type": "object", "properties": map[string]any{
|
||||
"candidate": map[string]any{"type": "string"}, "level": map[string]any{"type": "string"},
|
||||
"digest": map[string]any{"type": "string"}, "module": map[string]any{"type": "string"}}},
|
||||
|
||||
@@ -238,7 +238,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
// The test runs (§724, §725): one run per candidate, level and digest, kept in the state test-runs with its clock.
|
||||
runDrop := pipeline.BoundDrop(dropAsk(calls, cred.Module), armDropBound(ctx, bounds), dropAnswered(ctx, deleteBound(ctx, bounds), rv.Findings))
|
||||
runsKV, _, err := openTestRuns(ctx, js, cred, getenv, starter, hearer, runDrop, logger.Printf)
|
||||
runsKV, runObjs, err := openTestRuns(ctx, js, cred, getenv, starter, hearer, runDrop, logger.Printf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -297,7 +297,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// mesh-wants), never on EVENTS: bound here, or no step of any pipeline is ever heard ending (G-1 §24).
|
||||
logger.Printf("the kept seat events heard: %d streams bound", hub.StartKept(ctx, js, cred))
|
||||
// The seat's write verbs are answered here, by the process that holds the pipelines (A-107).
|
||||
stopVerbs, err := answerVerbs(calls, seats, writeVerbs(hearer, starter, func(branch string) (pipeline.Half, bool) { return rv.Catalog.View(branch) }, calls))
|
||||
verbs := writeVerbs(hearer, starter, func(branch string) (pipeline.Half, bool) { return rv.Catalog.View(branch) }, calls)
|
||||
verbs.Runs = pipeline.RunsRead{Runs: runsKept{ctx: ctx, kv: runsKV}, Object: runObjs.Get, Fill: starter.TestRunsFill}
|
||||
stopVerbs, err := answerVerbs(calls, seats, verbs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -112,6 +112,31 @@ func (t testRunsKV) Keys() ([]string, error) {
|
||||
return all, err
|
||||
}
|
||||
|
||||
// runsKept is the state test-runs as the verb test-runs reads it (A-470i): its keys, and each key's value as written.
|
||||
type runsKept struct {
|
||||
ctx context.Context
|
||||
kv jetstream.KeyValue
|
||||
}
|
||||
|
||||
func (r runsKept) Keys() ([]string, error) {
|
||||
ks, err := r.kv.Keys(r.ctx)
|
||||
if errors.Is(err, jetstream.ErrNoKeysFound) {
|
||||
return nil, nil
|
||||
}
|
||||
return ks, err
|
||||
}
|
||||
|
||||
func (r runsKept) Value(key string) (json.RawMessage, error) {
|
||||
e, err := r.kv.Get(r.ctx, key)
|
||||
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return e.Value(), nil
|
||||
}
|
||||
|
||||
// runObjects is the state test-runs' own object store, `test-runs-objects`, made with the state (A-469e), opened when
|
||||
// first used.
|
||||
type runObjects struct {
|
||||
|
||||
@@ -38,7 +38,8 @@ func answerVerbs(conn *process.Conn, seats *seatlist.Part, v pipeline.Verbs) (fu
|
||||
return conn.AnswerSeat(seat.Seat, seatlist.Definition(seats.Reader, seat.Seat), writeHandlers(v))
|
||||
}
|
||||
|
||||
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, and ask-again.
|
||||
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, and ask-again; and
|
||||
// the test runs' verbs test-runs and test-runs-drop (A-469g, A-470i).
|
||||
func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
||||
return map[string]process.SeatHandler{
|
||||
seat.VerbRun: verbOf(func(c string, in seat.RunInput) (any, error) { return v.Run(c, in) }),
|
||||
@@ -50,6 +51,8 @@ func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
||||
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
|
||||
// §728, A-469g: a test run's drop is answered by the process, the only writer of pipelines and test-runs.
|
||||
seat.VerbTestRunsDrop: verbOf(func(c string, in seat.TestRunsDropInput) (any, error) { return v.TestRunsDrop(c, in) }),
|
||||
// A-470i: test-runs too, since the process holds test-runs-cap-mib, the cap its fill is said against.
|
||||
seat.VerbTestRuns: verbOf(func(_ string, in seat.TestRunsInput) (any, error) { return v.Runs.TestRuns(in) }),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestEveryWriteVerbIsServed(t *testing.T) {
|
||||
got = append(got, v)
|
||||
}
|
||||
slices.Sort(got)
|
||||
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRunsDrop}
|
||||
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRuns, seat.VerbTestRunsDrop}
|
||||
slices.Sort(want)
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("the process answers %v, want %v", got, want)
|
||||
|
||||
@@ -208,22 +208,34 @@ func (e *fullErr) Error() string {
|
||||
return fmt.Sprintf("the state %s holds %d of its %d bytes, so no test run is asked (test-runs-cap-mib)", e.fill.Store, e.fill.Bytes, e.fill.Cap)
|
||||
}
|
||||
|
||||
// TestRunsFill is test-runs' fill against its cap setting test-runs-cap-mib, the cap that refuses a new run (A-469d, A-470i),
|
||||
// never the manifest's ceiling.
|
||||
func (s *Starter) TestRunsFill() (seat.Fill, error) {
|
||||
if s.RunsFill == nil {
|
||||
return seat.Fill{}, errors.New("the runner reads no fill of test-runs")
|
||||
}
|
||||
f, err := s.RunsFill()
|
||||
if err != nil {
|
||||
return seat.Fill{}, err
|
||||
}
|
||||
f.Cap = s.Runs.CapBytes
|
||||
if f.Cap <= 0 {
|
||||
f.Cap = DefaultRunSettings.CapBytes
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// atCap is the error of test-runs at its cap setting, nil below it or when its fill is not read (said).
|
||||
func (s *Starter) atCap() error {
|
||||
if s.RunsFill == nil {
|
||||
return nil
|
||||
}
|
||||
f, err := s.RunsFill()
|
||||
f, err := s.TestRunsFill()
|
||||
if err != nil {
|
||||
s.logf("the fill of test-runs is not read, so its cap is not judged: %v", err)
|
||||
return nil
|
||||
}
|
||||
cap := s.Runs.CapBytes
|
||||
if cap <= 0 {
|
||||
cap = DefaultRunSettings.CapBytes
|
||||
}
|
||||
if f.Bytes >= cap {
|
||||
f.Cap = cap
|
||||
if f.Bytes >= f.Cap {
|
||||
return &fullErr{fill: f}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -390,11 +390,15 @@ func TestTheTestRunsAreReadAndDroppedByTheirVerbs(t *testing.T) {
|
||||
for k, e := range f.runs {
|
||||
put(t, pipes, k, e.r)
|
||||
}
|
||||
read := RunsRead{Runs: pipes, Object: f.objects.Get, Fill: func() (seat.Fill, error) { return seat.Fill{Store: "test-runs", Bytes: 9, Cap: 16 << 20}, nil }}
|
||||
// The fill is said against the cap setting that refuses, never the bucket's 64 MiB ceiling (A-470g, A-470i).
|
||||
f.s.Runs.CapBytes, f.fill = 1<<20, 9
|
||||
bucket := f.s.RunsFill
|
||||
f.s.RunsFill = func() (seat.Fill, error) { fl, err := bucket(); fl.Cap = 64 << 20; return fl, err }
|
||||
read := RunsRead{Runs: pipes, Object: f.objects.Get, Fill: f.s.TestRunsFill}
|
||||
a, err := read.TestRuns(seat.TestRunsInput{Level: "unit", Module: "app"})
|
||||
if err != nil || len(a.Runs) != 1 || len(a.Runs[0].Packages) != 1 || a.Runs[0].Packages[0] != (seat.TestRunPackage{Package: "app/x", Digest: "d1"}) ||
|
||||
a.Runs[0].Key != unit.Shared[0].Run || len(a.Runs[0].Readers) != 2 || a.Fill.Cap != 16<<20 {
|
||||
t.Fatalf("test-runs = %+v, %v; want the unit run with its package and readers, and the fill", a, err)
|
||||
a.Runs[0].Key != unit.Shared[0].Run || len(a.Runs[0].Readers) != 2 || a.Fill.Cap != 1<<20 || a.Fill.Bytes != 9 {
|
||||
t.Fatalf("test-runs = %+v, %v; want the unit run with its package and readers, and the fill against the cap setting", a, err)
|
||||
}
|
||||
delete(f.objects, unit.Shared[0].Run) // gone, whatever step-outputs' age: the run answers without its packages
|
||||
if a, _ := read.TestRuns(seat.TestRunsInput{Level: "unit"}); len(a.Runs) != 1 || a.Runs[0].Gone != Gone || len(a.Runs[0].Packages) != 0 {
|
||||
|
||||
@@ -27,6 +27,8 @@ type Verbs struct {
|
||||
Candidate func(group, branch string, revision int64) (Half, error)
|
||||
// Acts records a hand act before the verb does it (rerun, accept, cancel); a nil Acts refuses the verb, nothing recorded.
|
||||
Acts views.HandActs
|
||||
// Runs answers the read verb test-runs, answered by the process that holds test-runs-cap-mib (A-470i).
|
||||
Runs RunsRead
|
||||
}
|
||||
|
||||
func (v Verbs) now() time.Time { return v.Hearer.now() }
|
||||
|
||||
Reference in New Issue
Block a user