P10 show-stands-bounded: show and stands take a bound (default the setting answer-bound, 32 KB), answer capped, total and next, show says moved when its record was written between pages
stands takes pipeline and module, orders its waits by since, pipeline, module, step and artifact, and pages by a cursor holding the last wait; a cursor the runner did not give is refused saying a page is read again from the start; the process and the tools program read the setting; one journal line per caller of a capped answer to a call naming no bound and no next. Builds: design 47 H2 H-A-709 (2), H-A-708 (3) (the runner's description), H-A-717 (DQ-57)
This commit is contained in:
@@ -25,6 +25,15 @@ type kept struct{ s stdio.KeptState }
|
||||
|
||||
func (k kept) Keys() ([]string, error) { return k.s.Keys() }
|
||||
|
||||
// Revision is the revision of key's record, for the cursor of show (design 47 H2 H-A-709 (2)).
|
||||
func (k kept) Revision(key string) (uint64, error) {
|
||||
e, err := k.s.Get(key)
|
||||
if err != nil || e == nil {
|
||||
return 0, err
|
||||
}
|
||||
return e.Revision, nil
|
||||
}
|
||||
|
||||
func (k kept) Value(key string) (json.RawMessage, error) {
|
||||
e, err := k.s.Get(key)
|
||||
if err != nil || e == nil {
|
||||
@@ -54,7 +63,11 @@ func Tools(r pipeline.Reads) []stdio.Tool {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.Show(in)
|
||||
ans, err := r.Show(in)
|
||||
if err == nil && ans.Capped && in.Bound == 0 && in.Next == "" && r.SaidCapped != nil {
|
||||
r.SaidCapped(stdio.CallerOf(a), seat.VerbShow, ans.Total)
|
||||
}
|
||||
return ans, err
|
||||
},
|
||||
seat.VerbList: func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.ListInput](a)
|
||||
@@ -63,7 +76,17 @@ func Tools(r pipeline.Reads) []stdio.Tool {
|
||||
}
|
||||
return r.List(in)
|
||||
},
|
||||
seat.VerbStands: func(map[string]any) (any, error) { return r.Stands() },
|
||||
seat.VerbStands: func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.StandsInput](a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ans, err := r.Stands(in)
|
||||
if err == nil && ans.Capped && in.Bound == 0 && in.Next == "" && r.SaidCapped != nil {
|
||||
r.SaidCapped(stdio.CallerOf(a), seat.VerbStands, ans.Total)
|
||||
}
|
||||
return ans, err
|
||||
},
|
||||
seat.VerbWhyCarried: func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.WhyCarriedInput](a)
|
||||
if err != nil {
|
||||
@@ -174,9 +197,24 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
answerBound, err := pipeline.AnswerBound(stdio.Setting)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
var saidMu sync.Mutex
|
||||
said := map[string]bool{}
|
||||
fill := StoresFill(func(n string) (*stdio.StateInfo, error) { return stdio.State(n).Info() },
|
||||
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, StalledBound: stalledBound}
|
||||
r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill, StalledBound: stalledBound, AnswerBound: answerBound,
|
||||
SaidCapped: func(caller, verb string, total int64) {
|
||||
saidMu.Lock()
|
||||
defer saidMu.Unlock()
|
||||
if !said[caller] {
|
||||
said[caller] = true
|
||||
fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] %s answered %s a capped page of %d, as it named no bound and no next: it reads the rest from next, or names a bound up to %d (H-A-709 (2))\n", verb, caller, total, pipeline.MaxAnswer)
|
||||
}
|
||||
}}
|
||||
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...) })...)
|
||||
|
||||
@@ -16,13 +16,14 @@ func ShowTools(r pipeline.Reads) []stdio.Tool {
|
||||
return []stdio.Tool{
|
||||
{Name: Prefix + "_show",
|
||||
Description: "One pipeline in parts: its record with the steps the filters hold (a mover, a step kind, a step's " +
|
||||
"outcome), at most 768 KB with capped, the filters' total and next, the cursor of the next page.",
|
||||
"outcome), at most the bound's bytes (default the setting answer-bound, 32 KB) with capped, the filters' total and next, the cursor of the next page, moved when the record was written between two pages.",
|
||||
Input: map[string]any{"type": "object", "properties": map[string]any{
|
||||
"pipeline": map[string]any{"type": "string", "description": "the pipeline's key"},
|
||||
"mover": map[string]any{"type": "string", "description": "only this mover's steps"},
|
||||
"step": map[string]any{"type": "string", "description": "only the steps of this kind (build, lint, unit, integration, validate, composition, review, approval)"},
|
||||
"state": map[string]any{"type": "string", "description": "only the steps whose outcome is this (passed, failed, running, could not run, ...)"},
|
||||
"next": map[string]any{"type": "string", "description": "the cursor the previous page answered"},
|
||||
"bound": map[string]any{"type": "number", "description": "the most bytes the answer holds, 4096 to 786432; absent, the setting answer-bound"},
|
||||
}, "required": []string{"pipeline"}},
|
||||
Run: func(a map[string]any) (any, error) {
|
||||
in, err := as[seat.ShowInput](a)
|
||||
|
||||
@@ -180,6 +180,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return err
|
||||
}
|
||||
hearer.StalledBound = stalledBound // the held step's wait is timed by it (H-A-738 (2))
|
||||
// design 47 H2 H-A-709 (2), §781: the answer bound, read as the tools program reads it; a value outside its range stops the start.
|
||||
answerBound, err := pipeline.AnswerBound(stdio.Setting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Printf("reads: show and stands answer at most %d bytes unless a call names a bound (%s)", answerBound, pipeline.AnswerBoundSetting)
|
||||
logger.Printf("health: a running pipeline with nothing open and nothing newly placed, or a step whose ask is untaken, is named after %s (%s)", stalledBound, pipeline.StalledBoundSetting)
|
||||
// Its asking half (§22, §24): a pipeline's steps are placed from the module's registration and each build seat is asked
|
||||
// for its step.
|
||||
|
||||
@@ -31,6 +31,67 @@ type Reads struct {
|
||||
Fill func() ([]seat.Fill, error)
|
||||
// StalledBound is the runner's setting stalled-bound, the bound of a held step's wait (H-A-599, H-A-738 (2)).
|
||||
StalledBound time.Duration
|
||||
// AnswerBound is the runner's setting answer-bound, the most bytes show and stands answer when a call names no bound;
|
||||
// zero reads as DefaultAnswerBound (design 47 H2 H-A-709 (2)).
|
||||
AnswerBound int64
|
||||
// SaidCapped says, for the journal, that a caller named no bound and no next and was answered a capped page of verb with
|
||||
// total rows or waits in all; the caller of it says it once per caller (design 47 H2 H-A-709 (2)).
|
||||
SaidCapped func(caller, verb string, total int64)
|
||||
}
|
||||
|
||||
// Revised is a Kept that tells the revision of a key's record: the cursor of show holds it (design 47 H2 H-A-709 (2)).
|
||||
type Revised interface {
|
||||
Revision(key string) (uint64, error)
|
||||
}
|
||||
|
||||
// DefaultAnswerBound is the setting answer-bound's default, AnswerBoundSetting its name (design 47 H2 H-A-709 (2), §781): the
|
||||
// runner's process and its tools program read it alike. MinAnswer is the least a call's bound may name.
|
||||
const (
|
||||
DefaultAnswerBound = 32768
|
||||
AnswerBoundSetting = "answer-bound"
|
||||
MinAnswer = 4096
|
||||
)
|
||||
|
||||
// AnswerBound is the setting answer-bound as the runner's process and its tools program read it through setting (the runtime's
|
||||
// word for a setting): a whole number of bytes from MinAnswer to MaxAnswer, DefaultAnswerBound when none is set.
|
||||
func AnswerBound(setting func(key string) (string, bool)) (int64, error) {
|
||||
v, ok := setting(AnswerBoundSetting)
|
||||
if !ok || strings.TrimSpace(v) == "" {
|
||||
return DefaultAnswerBound, nil
|
||||
}
|
||||
n, err := strconv.ParseInt(strings.TrimSpace(v), 10, 64)
|
||||
if err != nil || n < MinAnswer || n > MaxAnswer {
|
||||
return 0, fmt.Errorf("the setting %s is %q: it is a whole number of bytes from %d to %d", AnswerBoundSetting, v, MinAnswer, MaxAnswer)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// cappedReserve is what a capped answer adds to its size: its capped flag and its cursor, so the bound holds the answer whole.
|
||||
const cappedReserve = 96
|
||||
|
||||
// bound is the most bytes an answer holds: the call's, else the setting's, else the default; one outside MinAnswer to MaxAnswer
|
||||
// is refused.
|
||||
func (r Reads) bound(asked int64) (int, error) {
|
||||
b := asked
|
||||
if b == 0 {
|
||||
b = r.AnswerBound
|
||||
}
|
||||
if b == 0 {
|
||||
b = DefaultAnswerBound
|
||||
}
|
||||
if b < MinAnswer || b > MaxAnswer {
|
||||
return 0, fmt.Errorf("the bound %d is outside %d to %d bytes: nothing was answered", b, MinAnswer, MaxAnswer)
|
||||
}
|
||||
return int(b), nil
|
||||
}
|
||||
|
||||
// revisionOf is the revision of key's record in the state pipelines, zero when the state tells none.
|
||||
func (r Reads) revisionOf(key string) uint64 {
|
||||
if rv, ok := r.Pipelines.(Revised); ok {
|
||||
n, _ := rv.Revision(key)
|
||||
return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// fills is the stores' fill, or an error saying it could not be read: an answer never leaves it out unsaid.
|
||||
@@ -63,10 +124,15 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) {
|
||||
if err != nil {
|
||||
return seat.ShowAnswer{}, err
|
||||
}
|
||||
from, err := pageFrom(in.Next)
|
||||
bound, err := r.bound(in.Bound)
|
||||
if err != nil {
|
||||
return seat.ShowAnswer{}, err
|
||||
}
|
||||
from, cursorRev, err := pageFrom(in.Next)
|
||||
if err != nil {
|
||||
return seat.ShowAnswer{}, err
|
||||
}
|
||||
rev := r.revisionOf(in.Pipeline)
|
||||
// Named, a mover is answered by its steps alone (H-A-187): one mover's of a pipeline of a hundred movers.
|
||||
m := strings.TrimSpace(in.Mover)
|
||||
if m != "" && !Moves(p, m) {
|
||||
@@ -79,12 +145,12 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) {
|
||||
moverCount, stepCount := int64(len(p.Movers)), int64(len(p.Steps))
|
||||
p.Steps, p.Movers, p.Unlogged = []seat.StepResult{}, []seat.Mover{}, nil // the page's mover rows name each mover (design 47 H2 H-A-709 (1))
|
||||
p.MoverCount, p.StepCount = moverCount, stepCount
|
||||
a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(rows)), Movers: []seat.MoverRow{}}
|
||||
size := sizeOf(a)
|
||||
a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(rows)), Movers: []seat.MoverRow{}, Moved: in.Next != "" && cursorRev != rev}
|
||||
size := sizeOf(a) + cappedReserve
|
||||
for i := from; i < len(rows); i++ {
|
||||
n := sizeOf(rows[i]) + 1
|
||||
if size+n > MaxAnswer && len(a.Movers) > 0 {
|
||||
a.Capped, a.Next = true, pageCursor(i)
|
||||
if size+n > bound && len(a.Movers) > 0 {
|
||||
a.Capped, a.Next = true, pageCursor(i, rev)
|
||||
break
|
||||
}
|
||||
size += n
|
||||
@@ -103,8 +169,8 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) {
|
||||
all := p.Movers
|
||||
p.Steps, p.Movers, p.Unlogged = []seat.StepResult{}, []seat.Mover{}, nil
|
||||
p.MoverCount, p.StepCount = int64(len(all)), int64(p0steps)
|
||||
a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(held))}
|
||||
size := sizeOf(a)
|
||||
a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(held)), Moved: in.Next != "" && cursorRev != rev}
|
||||
size := sizeOf(a) + cappedReserve
|
||||
named := map[string]bool{}
|
||||
for i := from; i < len(held); i++ {
|
||||
n := sizeOf(held[i]) + 1
|
||||
@@ -116,8 +182,8 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if size+n > MaxAnswer && len(a.Pipeline.Steps) > 0 {
|
||||
a.Capped, a.Next = true, pageCursor(i)
|
||||
if size+n > bound && len(a.Pipeline.Steps) > 0 {
|
||||
a.Capped, a.Next = true, pageCursor(i, rev)
|
||||
break
|
||||
}
|
||||
size += n
|
||||
@@ -131,25 +197,35 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// pageCursor is the opaque cursor of a page starting at the i-th step the filters hold (§779): the caller hands it back.
|
||||
func pageCursor(i int) string {
|
||||
return base64.RawURLEncoding.EncodeToString([]byte("step:" + strconv.Itoa(i)))
|
||||
// pageCursor is the opaque cursor of a page starting at the i-th row or step the filters hold, in the record at revision rev
|
||||
// (design 47 H2 §779, H-A-709 (2)): the caller hands it back.
|
||||
func pageCursor(i int, rev uint64) string {
|
||||
return base64.RawURLEncoding.EncodeToString([]byte("page:" + strconv.Itoa(i) + ":" + strconv.FormatUint(rev, 10)))
|
||||
}
|
||||
|
||||
// pageFrom is the step a cursor starts at, 0 for none; a cursor this reader did not give is refused.
|
||||
func pageFrom(next string) (int, error) {
|
||||
// errCursor refuses a cursor the runner cannot read as its own, saying that a page is read again from the start (H-A-717 DQ-57).
|
||||
func errCursor(next string) error {
|
||||
return fmt.Errorf("the cursor %q is not one this runner answered: a page is read again from the start, with no next", next)
|
||||
}
|
||||
|
||||
// pageFrom is the place a cursor starts at, 0 for none, and the revision of the record it was given at; a cursor this reader
|
||||
// did not give is refused.
|
||||
func pageFrom(next string) (int, uint64, error) {
|
||||
if next = strings.TrimSpace(next); next == "" {
|
||||
return 0, nil
|
||||
return 0, 0, nil
|
||||
}
|
||||
raw, err := base64.RawURLEncoding.DecodeString(next)
|
||||
if err == nil {
|
||||
if n, ok := strings.CutPrefix(string(raw), "step:"); ok {
|
||||
if i, err := strconv.Atoi(n); err == nil && i >= 0 {
|
||||
return i, nil
|
||||
if n, ok := strings.CutPrefix(string(raw), "page:"); ok {
|
||||
at, rv, _ := strings.Cut(n, ":")
|
||||
i, e1 := strconv.Atoi(at)
|
||||
r, e2 := strconv.ParseUint(rv, 10, 64)
|
||||
if e1 == nil && e2 == nil && i >= 0 {
|
||||
return i, r, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("the cursor %q is not one show answered", next)
|
||||
return 0, 0, errCursor(next)
|
||||
}
|
||||
|
||||
// sizeOf is v's size as JSON.
|
||||
@@ -331,13 +407,32 @@ func stepCounts(steps []seat.StepResult) map[string]int64 {
|
||||
}
|
||||
|
||||
// Stands is every step that has started and not ended, with what it waits on and since when (§75, §83): the watchman
|
||||
// seeds its open waits from it.
|
||||
func (r Reads) Stands() (seat.StandsAnswer, error) {
|
||||
all, err := r.pipelines()
|
||||
// seeds its open waits from it. It answers the waits of the pipeline and the module it names, in the order of their since,
|
||||
// then their pipeline, module, step and artifact, at most the bound's bytes with capped, the filters' total and a next that
|
||||
// holds the last wait answered: the next page answers the waits after it, so a wait standing across both pages is answered
|
||||
// once, one ended between them is gone, and one held since comes later (design 47 H2 H-A-709 (2)).
|
||||
func (r Reads) Stands(in seat.StandsInput) (seat.StandsAnswer, error) {
|
||||
bound, err := r.bound(in.Bound)
|
||||
if err != nil {
|
||||
return seat.StandsAnswer{}, err
|
||||
}
|
||||
out := []seat.Wait{}
|
||||
after, err := standsFrom(in.Next)
|
||||
if err != nil {
|
||||
return seat.StandsAnswer{}, err
|
||||
}
|
||||
var all []seat.Pipeline
|
||||
if in.Pipeline != "" {
|
||||
p, ok, err := r.pipeline(in.Pipeline)
|
||||
if err != nil {
|
||||
return seat.StandsAnswer{}, err
|
||||
}
|
||||
if ok {
|
||||
all = []seat.Pipeline{p}
|
||||
}
|
||||
} else if all, err = r.pipelines(); err != nil {
|
||||
return seat.StandsAnswer{}, err
|
||||
}
|
||||
var held []seat.Wait
|
||||
for _, p := range all {
|
||||
for _, s := range p.Steps {
|
||||
if s.Ended != nil || s.Started == nil {
|
||||
@@ -347,17 +442,63 @@ func (r Reads) Stands() (seat.StandsAnswer, error) {
|
||||
continue
|
||||
}
|
||||
m, _ := MoverOf(p, s.Module)
|
||||
if in.Module != "" && m.Module != in.Module {
|
||||
continue
|
||||
}
|
||||
w := seat.Wait{Pipeline: p.Pipeline, Module: m.Module, Branch: p.Branch, Commit: m.Commit,
|
||||
Run: p.Run, Source: p.Source, Revision: p.Revision, Fingerprint: m.Fingerprint, Step: s.Step,
|
||||
Artifact: s.Artifact, On: s.On, Since: *s.Started, V: 1, Ask: askOfWait(s), Shared: sharedOfWait(s)}
|
||||
if s.On == seat.WaitOnRevisionView && s.HeldAt != nil { // the held step's wait is timed from its hold (H-A-599, H-A-738 (2))
|
||||
w.Bound, w.ClockFrom = boundOf(r.StalledBound), s.HeldAt
|
||||
}
|
||||
out = append(out, w)
|
||||
held = append(held, w)
|
||||
}
|
||||
}
|
||||
sort.SliceStable(out, func(i, j int) bool { return out[i].Since.Before(out[j].Since) })
|
||||
return seat.StandsAnswer{Stands: out}, nil
|
||||
sort.SliceStable(held, func(i, j int) bool { return waitLess(held[i], held[j]) })
|
||||
a := seat.StandsAnswer{Stands: []seat.Wait{}, Total: int64(len(held))}
|
||||
size := sizeOf(a) + cappedReserve
|
||||
for _, w := range held {
|
||||
if after != nil && !waitLess(*after, w) {
|
||||
continue
|
||||
}
|
||||
n := sizeOf(w) + 1
|
||||
if size+n > bound && len(a.Stands) > 0 {
|
||||
a.Capped, a.Next = true, standsCursor(a.Stands[len(a.Stands)-1])
|
||||
break
|
||||
}
|
||||
size += n
|
||||
a.Stands = append(a.Stands, w)
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// waitLess orders waits by their since, then their pipeline, module, step and artifact (design 47 H2 H-A-709 (2)).
|
||||
func waitLess(a, b seat.Wait) bool {
|
||||
if !a.Since.Equal(b.Since) {
|
||||
return a.Since.Before(b.Since)
|
||||
}
|
||||
return strings.Join([]string{a.Pipeline, a.Module, a.Step, a.Artifact}, "\x00") < strings.Join([]string{b.Pipeline, b.Module, b.Step, b.Artifact}, "\x00")
|
||||
}
|
||||
|
||||
// standsCursor is the cursor after wait w: its place in the order, by the fields the order reads.
|
||||
func standsCursor(w seat.Wait) string {
|
||||
return base64.RawURLEncoding.EncodeToString([]byte(strings.Join([]string{"wait", strconv.FormatInt(w.Since.UnixNano(), 10), w.Pipeline, w.Module, w.Step, w.Artifact}, "\x00")))
|
||||
}
|
||||
|
||||
// standsFrom is the wait a cursor follows, nil for none; one this reader did not give is refused.
|
||||
func standsFrom(next string) (*seat.Wait, error) {
|
||||
if next = strings.TrimSpace(next); next == "" {
|
||||
return nil, nil
|
||||
}
|
||||
raw, err := base64.RawURLEncoding.DecodeString(next)
|
||||
if err == nil {
|
||||
if f := strings.Split(string(raw), "\x00"); len(f) == 6 && f[0] == "wait" {
|
||||
if ns, err := strconv.ParseInt(f[1], 10, 64); err == nil {
|
||||
return &seat.Wait{Since: time.Unix(0, ns), Pipeline: f[2], Module: f[3], Step: f[4], Artifact: f[5]}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, errCursor(next)
|
||||
}
|
||||
|
||||
// WhyCarried is where a step's result was carried from (§25, §83): the pipeline it names.
|
||||
|
||||
@@ -14,6 +14,14 @@ import (
|
||||
|
||||
type memKept map[string]json.RawMessage
|
||||
|
||||
// revKept is a memKept that tells every record's revision as the number rev points to (H-A-709 (2)).
|
||||
type revKept struct {
|
||||
memKept
|
||||
rev *uint64
|
||||
}
|
||||
|
||||
func (k revKept) Revision(string) (uint64, error) { return *k.rev, nil }
|
||||
|
||||
func (m memKept) Keys() ([]string, error) {
|
||||
var out []string
|
||||
for k := range m {
|
||||
@@ -188,7 +196,7 @@ func TestReads(t *testing.T) {
|
||||
return fmt.Sprint(len(a.Rows), " ", a.Rows[0].Pipeline, " ", a.Rows[19].Pipeline), err
|
||||
}, "20 main.24 main.5"},
|
||||
{"stands names a waiting step and since when", func() (string, error) {
|
||||
a, err := r.Stands()
|
||||
a, err := r.Stands(seat.StandsInput{})
|
||||
var s []string
|
||||
for _, w := range a.Stands {
|
||||
s = append(s, w.Pipeline+" "+w.Step+" "+w.On+" "+w.Since.Format("15:04"))
|
||||
@@ -276,7 +284,7 @@ func TestStandsAndStepStartedNameWhatAReadingStepWaitsOn(t *testing.T) {
|
||||
}
|
||||
pipes := memKept{}
|
||||
put(t, pipes, p.Pipeline, f.pipeline(p))
|
||||
a, err := Reads{Pipelines: pipes, Kept: memKept{}}.Stands()
|
||||
a, err := Reads{Pipelines: pipes, Kept: memKept{}}.Stands(seat.StandsInput{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -318,7 +326,7 @@ func TestStandsAndStepStartedNameWhatAReadingStepWaitsOn(t *testing.T) {
|
||||
}
|
||||
pipes := memKept{}
|
||||
put(t, pipes, p.Pipeline, pl)
|
||||
a, err := Reads{Pipelines: pipes, Kept: memKept{}, StalledBound: time.Minute}.Stands()
|
||||
a, err := Reads{Pipelines: pipes, Kept: memKept{}, StalledBound: time.Minute}.Stands(seat.StandsInput{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -381,7 +389,7 @@ func TestAPipelineIsReadInParts(t *testing.T) {
|
||||
big := Reads{Pipelines: record(1000), Kept: memKept{}}
|
||||
seen, pages, next := 0, 0, ""
|
||||
for {
|
||||
a, err := big.Show(seat.ShowInput{Pipeline: "main.9", State: seat.StepResultOutcomePassed, Next: next})
|
||||
a, err := big.Show(seat.ShowInput{Pipeline: "main.9", State: seat.StepResultOutcomePassed, Next: next, Bound: MaxAnswer})
|
||||
raw, _ := json.Marshal(a)
|
||||
if err != nil || len(raw) > MaxAnswer || a.Total != 5900 {
|
||||
t.Fatalf("page %d: %d bytes, total %d, %v", pages, len(raw), a.Total, err)
|
||||
@@ -396,13 +404,72 @@ func TestAPipelineIsReadInParts(t *testing.T) {
|
||||
t.Fatalf("pages %d read %d steps, want every one of 5900 over more than one page", pages, seen)
|
||||
}
|
||||
// Design 47 H2 H-A-376: naming no mover and no filter, show answers 1,000 movers' rows in one answer and no step.
|
||||
if a, err := big.Show(seat.ShowInput{Pipeline: "main.9"}); err != nil || len(a.Movers) != 1000 || len(a.Pipeline.Steps) != 0 || a.Capped ||
|
||||
if a, err := big.Show(seat.ShowInput{Pipeline: "main.9", Bound: MaxAnswer}); err != nil || len(a.Movers) != 1000 || len(a.Pipeline.Steps) != 0 || a.Capped ||
|
||||
a.Movers[3].Outcome != seat.MoverRowOutcomeFailed || a.Movers[3].Failed == nil || a.Movers[3].Failed.Step != seat.StepResultStepUnit {
|
||||
t.Fatalf("the movers' rows: %d rows, %d steps, capped %v, %v", len(a.Movers), len(a.Pipeline.Steps), a.Capped, err)
|
||||
}
|
||||
if _, err := big.Show(seat.ShowInput{Pipeline: "main.9", Next: "not-a-cursor"}); err == nil {
|
||||
t.Fatal("a cursor show never answered is refused")
|
||||
}
|
||||
// design 47 H2 H-A-709 (2), H-A-717 (DQ-57) (AC-P10): a call naming no bound is answered at the setting's 32,768 bytes and
|
||||
// capped with a next that reads the rest; a bound outside 4,096 to 786,432 and a cursor of no page are refused.
|
||||
def, err := big.Show(seat.ShowInput{Pipeline: "main.9", State: seat.StepResultOutcomePassed})
|
||||
if raw, _ := json.Marshal(def); err != nil || !def.Capped || def.Next == "" || len(raw) > DefaultAnswerBound || def.Moved {
|
||||
t.Errorf("show at the default bound: %d bytes, capped %v, next %q, moved %v, %v", len(raw), def.Capped, def.Next, def.Moved, err)
|
||||
}
|
||||
if few, _ := (Reads{Pipelines: record(1000), Kept: memKept{}, AnswerBound: 8192}).Show(seat.ShowInput{Pipeline: "main.9", State: seat.StepResultOutcomePassed}); len(few.Pipeline.Steps) >= len(def.Pipeline.Steps) {
|
||||
t.Errorf("the setting 8192 answered %d steps, want fewer than the default's %d", len(few.Pipeline.Steps), len(def.Pipeline.Steps))
|
||||
}
|
||||
for _, in := range []seat.ShowInput{{Pipeline: "main.9", Bound: 100}, {Pipeline: "main.9", Bound: MaxAnswer + 1}, {Pipeline: "main.9", Next: "step:3"}} {
|
||||
if _, err := big.Show(in); err == nil || (in.Next != "" && !strings.Contains(err.Error(), "read again from the start")) {
|
||||
t.Errorf("show %+v = %v, want refused", in, err)
|
||||
}
|
||||
}
|
||||
// A record written between two pages: the second answers from the place and says moved.
|
||||
rev := uint64(3)
|
||||
moving := Reads{Pipelines: revKept{record(129), &rev}, Kept: memKept{}}
|
||||
first, _ := moving.Show(seat.ShowInput{Pipeline: "main.9", Step: seat.StepResultStepUnit, Bound: MinAnswer})
|
||||
same, _ := moving.Show(seat.ShowInput{Pipeline: "main.9", Step: seat.StepResultStepUnit, Bound: MinAnswer, Next: first.Next})
|
||||
rev = 4
|
||||
later, _ := moving.Show(seat.ShowInput{Pipeline: "main.9", Step: seat.StepResultStepUnit, Bound: MinAnswer, Next: first.Next})
|
||||
if !first.Capped || first.Moved || same.Moved || !later.Moved || len(later.Pipeline.Steps) == 0 || later.Pipeline.Steps[0].Module != same.Pipeline.Steps[0].Module {
|
||||
t.Errorf("pages: first capped %v moved %v, same revision moved %v, a record written between: moved %v", first.Capped, first.Moved, same.Moved, later.Moved)
|
||||
}
|
||||
// stands pages its waits in the order of their since, each once, by pipeline and module when it names them.
|
||||
waits := memKept{}
|
||||
for _, key := range []string{"main.9", "main.10"} {
|
||||
wp := seat.Pipeline{Pipeline: key, Branch: "main", Source: 9, Outcome: seat.PipelineOutcomeRunning, Started: &t0}
|
||||
for i := 0; i < 40; i++ {
|
||||
at := t0.Add(time.Duration(i) * time.Minute)
|
||||
m := fmt.Sprintf("module-%02d", i)
|
||||
wp.Movers = append(wp.Movers, seat.Mover{Module: m})
|
||||
wp.Steps = append(wp.Steps, seat.StepResult{Module: m, Step: seat.StepResultStepApproval, Artifact: m + ":program", Outcome: seat.StepResultOutcomeWaiting, Started: &at, On: seat.WaitOnPerson})
|
||||
}
|
||||
put(t, waits, key, wp)
|
||||
}
|
||||
var standing []string
|
||||
for next, pages := "", 0; ; pages++ {
|
||||
a, err := (Reads{Pipelines: waits, Kept: memKept{}}).Stands(seat.StandsInput{Bound: MinAnswer, Next: next})
|
||||
if err != nil || a.Total != 80 || (a.Capped && a.Next == "") || pages > 80 {
|
||||
t.Fatalf("stands page %d: total %d, capped %v, %v", pages, a.Total, a.Capped, err)
|
||||
}
|
||||
if raw, _ := json.Marshal(a); len(raw) > MinAnswer {
|
||||
t.Errorf("a stands page of %d bytes at bound %d", len(raw), MinAnswer)
|
||||
}
|
||||
for _, w := range a.Stands {
|
||||
standing = append(standing, w.Pipeline+" "+w.Module)
|
||||
}
|
||||
if !a.Capped {
|
||||
break
|
||||
}
|
||||
next = a.Next
|
||||
}
|
||||
if len(standing) != 80 || standing[0] != "main.10 module-00" || standing[1] != "main.9 module-00" {
|
||||
t.Errorf("stands pages answered %d waits, the first %v, want 80 in the order of since, then pipeline", len(standing), standing[:2])
|
||||
}
|
||||
if a, err := (Reads{Pipelines: waits, Kept: memKept{}}).Stands(seat.StandsInput{Pipeline: "main.9", Module: "module-07"}); err != nil || len(a.Stands) != 1 || a.Total != 1 || a.Capped {
|
||||
t.Errorf("stands of one pipeline and module = %+v (%v), want its one wait", a, err)
|
||||
}
|
||||
m, err := big.Movers("main.9")
|
||||
raw, _ := json.Marshal(m)
|
||||
if err != nil || len(raw) >= MaxAnswer || len(m.Movers) != 1000 {
|
||||
|
||||
@@ -234,7 +234,7 @@ func runSettingsOf(raw []byte) bool {
|
||||
// program alike, from the words the node-engine composes: no file of its own.
|
||||
// design 47 H2 §775: the kept-call form's pace, read by mesh-sdk at the process's and the bundle's start; §777:
|
||||
// ask-silent-bound goes.
|
||||
words := map[string]string{"stalled-bound": "5m", "kept-call-pace-first": "1s", "kept-call-pace-max": "30s"}
|
||||
words := map[string]string{"stalled-bound": "5m", "answer-bound": "32768", "kept-call-pace-first": "1s", "kept-call-pace-max": "30s"}
|
||||
for key, def := range words {
|
||||
if m.Config[key]["type"] != "string" || m.Config[key]["default"] != def || m.Config[key]["runtime"] != true {
|
||||
return false
|
||||
|
||||
@@ -169,10 +169,17 @@
|
||||
},
|
||||
"ask-unanswered-bound": {
|
||||
"type": "string",
|
||||
"description": "how long an ask the runner puts on a seat, but a test run's, may go without its holder's first word (an ask-taken, a step progress or the step's end) before it is asked once more, and as long again before its step ends could not run, a Go duration such as 10m (design 47 H H-A-235, H-A-238).",
|
||||
"description": "how long an ask the runner puts on a seat, but a test run's, may go without its holder's first word (an ask-taken, a step progress or the step's end) before it is asked once more, and as long again before its step ends could not run, a Go duration such as 10m (design 47 H H-A-235, H-A-238). The assigner's setting reads-bound is kept below it, so a run's step ends with the assigner's words; one set above it has the runner's bound end the step with its own (design 47 H2 H-A-708 (3)).",
|
||||
"trusted": false,
|
||||
"default": "10m"
|
||||
},
|
||||
"answer-bound": {
|
||||
"type": "string",
|
||||
"description": "the most bytes the runner's show and stands answer when a call names no bound, a whole number from 4096 to 786432; a longer answer is capped, answers next and is read from it (design 47 H2 H-A-709 (2), section 781).",
|
||||
"trusted": false,
|
||||
"runtime": true,
|
||||
"default": "32768"
|
||||
},
|
||||
"stalled-bound": {
|
||||
"type": "string",
|
||||
"description": "how long a running pipeline may have nothing open and nothing newly placed, or a step's ask stay untaken, before the runner's health names it, a Go duration such as 5m (design 47 H2 sections 778, 790).",
|
||||
|
||||
Reference in New Issue
Block a user