G4 late-running: a late running moves a record's end only from a machine present at it, a record says its end count, a mover-added is counted and a higher pipeline end reopens the record
On fa345c83's RanAfterEnd: a running from a machine away at the end, or a repeated one, moves nothing; a first running from a present machine moves ended and delivery-time and says record-ended again with ends one higher (an id of its own). The record head gains ends and pipeline-ends (the end operation's fields); a pipeline-ended of a count above 1 and higher than pipeline-ends reopens the record; the gate consumes mover-added and counts the mover in the record its pipeline key names. Builds: design 47 H2 H-A-585, H-A-597, H-A-609 (2), H-A-617, H-A-645, H-A-648, H-A-728
This commit is contained in:
@@ -63,6 +63,7 @@ var stepFamilies = []stepFamily{
|
||||
// runner's pipeline-started, pipeline-ended, wait-held and wait-ended on <branch>.<source>, the assigner's wanted on
|
||||
// <node>.<module> and pipeline-wanted on <branch>.<source>, and the node-engine seat's running on <node>.<module>.
|
||||
seatFamily(runner.EventPipelineStarted, 2, false, decodePipelineStarted),
|
||||
seatFamily(runner.EventMoverAdded, 2, false, decodeMoverAdded),
|
||||
seatFamily(runner.EventPipelineEnded, 2, false, decodePipelineEnded),
|
||||
seatFamily(runner.EventWaitHeld, 2, false, decodeWait),
|
||||
seatFamily(runner.EventWaitEnded, 2, false, decodeWait),
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestItClaimsTheDeliverySeatAndFollowsWhatItHandles(t *testing.T) {
|
||||
}
|
||||
// The names move (milestone 47/G): the families heard from another module are its manifest's consumes, and no Go
|
||||
// source of the gate names those modules.
|
||||
if !slices.Contains(m.Consumes, owedEndedEvent) || owedEndedEvent == "" || len(stepFamilies) != 8 {
|
||||
if !slices.Contains(m.Consumes, owedEndedEvent) || owedEndedEvent == "" || len(stepFamilies) != 9 {
|
||||
t.Fatalf("owed.ended is %q and the step families %+v, not the manifest's consumes %v", owedEndedEvent, stepFamilies, m.Consumes)
|
||||
}
|
||||
for _, f := range stepFamilies {
|
||||
|
||||
@@ -99,6 +99,11 @@ type Record struct {
|
||||
// entry of its own, joined when read, never on the head entry (design 47 H2 §809, H-A-455 (1)).
|
||||
Acts map[string]RecordAct `json:"acts,omitempty"`
|
||||
Ended *RecordEnded `json:"ended,omitempty"`
|
||||
// Ends is the record's end count, one higher at each end and said by record-ended; PipelineEnds the highest
|
||||
// pipeline-ended end count the record heard: a pipeline-ended of a higher count reopens it. Both absent read as 0, and a
|
||||
// reopening empties neither (design 47 H2 H-A-728, H-A-597, H-A-609 (2), H-A-617).
|
||||
Ends int `json:"ends,omitempty"`
|
||||
PipelineEnds int `json:"pipeline-ends,omitempty"`
|
||||
// Recovery marks the merge its author named a recovery by the seat's verb recovery (design 47 G §81, A-23).
|
||||
Recovery *RecordRecovery `json:"recovery,omitempty"`
|
||||
// MoverCount is the count of its movers, each with an entry of its own (design 47 H2 §809); Entries and Outcomes above
|
||||
|
||||
@@ -8,6 +8,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -150,8 +151,10 @@ func (rs *Records) end(r *Record, why, by string) error {
|
||||
body["delivery-time"], body["class"] = took.String(), class
|
||||
}
|
||||
}
|
||||
// The end count one higher, and the highest pipeline end count the record heard (H-A-728).
|
||||
body["ends"], body["pipeline-ends"] = r.Ends+1, r.PipelineEnds
|
||||
next := *r
|
||||
next.Ended = &e
|
||||
next.Ended, next.Ends = &e, r.Ends+1
|
||||
if took > 0 {
|
||||
next.DeliveryTime, next.Class = took.String(), class
|
||||
}
|
||||
@@ -159,7 +162,7 @@ func (rs *Records) end(r *Record, why, by string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Ended, r.Sequence = &e, seq
|
||||
r.Ended, r.Sequence, r.Ends = &e, seq, r.Ends+1
|
||||
if took > 0 {
|
||||
r.DeliveryTime, r.Class = took.String(), class
|
||||
}
|
||||
@@ -172,49 +175,78 @@ func (rs *Records) end(r *Record, why, by string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RanAfterEnd writes a record's end again from a running of one of its movers kept after the record ended (H-A-585): when
|
||||
// that running is later than the record's ended, ended takes its time and, for a record that ended with every mover running,
|
||||
// delivery-time runs to it, with the class its movers' entries kept when they opened (H2 §810, H-A-394 (3)). record-ended is
|
||||
// not said a second time; the journal says the record, the module, the machine and both times. Applied says the running was
|
||||
// applied now; one applied before and not later than the end (its end written from it already) changes and says nothing.
|
||||
// RanAfterEnd writes a record's end again from a running of one of its movers kept after the record ended (H-A-585, H-A-597,
|
||||
// H-A-617): when that running is the first of its mover's version from a machine present at the end and later than the
|
||||
// record's ended, ended takes its time and, for a record that ended with every mover running, delivery-time runs to it, with
|
||||
// the class its movers' entries kept when they opened (H2 §810, H-A-394 (3)); the end count goes one higher and
|
||||
// record-ended is said again with it. A running from a machine that was away at the end (a machine back, ADR 0603 §7), or
|
||||
// a repeated one, marks the mover's entry (the caller applied it) and changes neither time nor count. The journal says the
|
||||
// record, the module, the machine and both times when the time moved. Applied says the running was applied now; one applied
|
||||
// before and not later than the end (its end written from it already) changes and says nothing.
|
||||
func (rs *Records) RanAfterEnd(r *Record, o RecordOutcome, applied bool) error {
|
||||
if r.Ended == nil {
|
||||
return nil
|
||||
}
|
||||
for _, a := range r.Ended.Away {
|
||||
if a.Node == o.Node {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
was := r.Ended.At
|
||||
if !applied && !o.At.After(was) {
|
||||
if !o.At.After(was) {
|
||||
return nil
|
||||
}
|
||||
if o.At.After(was) {
|
||||
e := *r.Ended
|
||||
e.At = o.At
|
||||
body := map[string]any{"ended": e}
|
||||
next := *r
|
||||
next.Ended = &e
|
||||
var took time.Duration
|
||||
class := r.Class
|
||||
if e.Why == WhyAllRun {
|
||||
var kept string
|
||||
if took, kept = timesAtEnd(r); took > 0 {
|
||||
class = firstOf(class, kept)
|
||||
body["delivery-time"], body["class"] = took.String(), class
|
||||
next.DeliveryTime, next.Class = took.String(), class
|
||||
}
|
||||
e := *r.Ended
|
||||
e.At = o.At
|
||||
ends := r.Ends + 1
|
||||
body := map[string]any{"ended": e, "ends": ends}
|
||||
next := *r
|
||||
next.Ended, next.Ends = &e, ends
|
||||
var took time.Duration
|
||||
class := r.Class
|
||||
if e.Why == WhyAllRun {
|
||||
var kept string
|
||||
if took, kept = timesAtEnd(r); took > 0 {
|
||||
class = firstOf(class, kept)
|
||||
body["delivery-time"], body["class"] = took.String(), class
|
||||
next.DeliveryTime, next.Class = took.String(), class
|
||||
}
|
||||
seq, err := rs.write(r, r.Instance, OpEnd, body, next.head())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Ended, r.Sequence = &e, seq
|
||||
if took > 0 {
|
||||
r.DeliveryTime, r.Class = took.String(), class
|
||||
}
|
||||
rs.keep(r)
|
||||
}
|
||||
seq, err := rs.write(r, r.Instance, OpEnd, body, next.head())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Ended, r.Sequence, r.Ends = &e, seq, ends
|
||||
if took > 0 {
|
||||
r.DeliveryTime, r.Class = took.String(), class
|
||||
}
|
||||
rs.keep(r)
|
||||
if rs.Logf != nil {
|
||||
rs.Logf("[mesh-delivery] the record %s took the running of %s on %s at %s, after it ended at %s; it ends at %s, its delivery time %q",
|
||||
rs.Logf("[mesh-delivery] the record %s took the running of %s on %s at %s, after it ended at %s; it ends at %s, its delivery time %q, end %d",
|
||||
r.Instance, o.Module, o.Node, o.At.UTC().Format(time.RFC3339Nano), was.UTC().Format(time.RFC3339Nano),
|
||||
r.Ended.At.UTC().Format(time.RFC3339Nano), r.DeliveryTime)
|
||||
r.Ended.At.UTC().Format(time.RFC3339Nano), r.DeliveryTime, ends)
|
||||
}
|
||||
return rs.sayEnded(r)
|
||||
}
|
||||
|
||||
// Reopen reopens an ended record whose pipeline ended again with a higher end count (H-A-609 (2), H-A-728): its `ended` is
|
||||
// emptied and pipeline-ends takes the count, its own end count staying; the next end says ends one higher.
|
||||
func (rs *Records) Reopen(r *Record, pipelineEnds int) error {
|
||||
if r.Ended == nil {
|
||||
return nil
|
||||
}
|
||||
next := *r
|
||||
next.Ended, next.PipelineEnds = nil, pipelineEnds
|
||||
seq, err := rs.write(r, r.Instance, OpEnd, map[string]any{"ended": nil, "pipeline-ends": pipelineEnds}, next.head())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
was := r.Ended.At
|
||||
r.Ended, r.PipelineEnds, r.Sequence = nil, pipelineEnds, seq
|
||||
rs.keep(r)
|
||||
if rs.Logf != nil {
|
||||
rs.Logf("[mesh-delivery] the record %s, ended at %s, is open again: its pipeline ended again, end %d", r.Instance,
|
||||
was.UTC().Format(time.RFC3339Nano), pipelineEnds)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -224,10 +256,16 @@ func (rs *Records) sayEnded(r *Record) error {
|
||||
return nil
|
||||
}
|
||||
at := r.Ended.At
|
||||
e := meshdelivery.RecordEndedEvent{Record: r.Instance, Milestone: r.Milestone, Branch: r.Branch, Source: r.Source, Call: r.Call, At: &at}
|
||||
e := meshdelivery.RecordEndedEvent{Record: r.Instance, Milestone: r.Milestone, Branch: r.Branch, Source: r.Source, Call: r.Call, At: &at,
|
||||
Ends: int64(r.Ends)}
|
||||
for _, a := range r.Ended.Away {
|
||||
since := a.Since
|
||||
e.Away = append(e.Away, meshdelivery.RecordEndedEventAwayItem{Node: a.Node, Since: &since})
|
||||
}
|
||||
return rs.say(meshdelivery.SubjectRecordEnded, e, "record-ended."+r.Instance)
|
||||
// Each end is said under an id of its own, so an end said again is kept once and the next end is said (H-A-597, H-A-617).
|
||||
id := "record-ended." + r.Instance
|
||||
if r.Ends > 1 {
|
||||
id += "." + strconv.Itoa(r.Ends)
|
||||
}
|
||||
return rs.say(meshdelivery.SubjectRecordEnded, e, id)
|
||||
}
|
||||
|
||||
@@ -55,6 +55,28 @@ func decodePipelineStarted(body json.RawMessage, _ time.Time) ([]StepOutcome, er
|
||||
return nil, namesSource(p.Branch, p.Source, p.Run)
|
||||
}
|
||||
|
||||
// decodeMoverAdded reads a mover-added with the contract's decoder, and refuses one naming none or two of from, caller and
|
||||
// take-in (design 47 H2 H-A-645).
|
||||
func decodeMoverAdded(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
|
||||
m, _, err := runner.DecodeMoverAddedEvent(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
named := 0
|
||||
for _, given := range []bool{m.From != "", m.Caller != "", m.TakeIn != 0} {
|
||||
if given {
|
||||
named++
|
||||
}
|
||||
}
|
||||
if named != 1 {
|
||||
return nil, fmt.Errorf("a mover-added names exactly one of from, caller and take-in, and this names %d", named)
|
||||
}
|
||||
if m.Module == "" || m.Pipeline == "" {
|
||||
return nil, fmt.Errorf("a mover-added names no module or pipeline")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func decodePipelineEnded(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
|
||||
var p runner.PipelineEndedEvent
|
||||
if err := strictly(body, &p); err != nil {
|
||||
@@ -134,6 +156,12 @@ func (h *Holder) Follow(event string, body json.RawMessage) error {
|
||||
return nil
|
||||
}
|
||||
return h.pipelineStarted(p)
|
||||
case runner.EventMoverAdded:
|
||||
var m runner.MoverAddedEvent
|
||||
if err := json.Unmarshal(body, &m); err != nil {
|
||||
return nil
|
||||
}
|
||||
return h.moverAdded(m)
|
||||
case runner.EventPipelineEnded:
|
||||
var p runner.PipelineEndedEvent
|
||||
if err := json.Unmarshal(body, &p); err != nil || p.Run != "" {
|
||||
@@ -193,11 +221,45 @@ func (h *Holder) pipelineStarted(p runner.PipelineStartedEvent) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Holder) pipelineEnded(p runner.PipelineEndedEvent) error {
|
||||
r, err := h.openRecord(p.Branch, p.Source)
|
||||
if err != nil || r == nil {
|
||||
// moverAdded counts a mover added to a pipeline in the record that pipeline's key names, as wantWritten finds it (G §144,
|
||||
// design 47 H2 H-A-609 (2), H-A-645): a mover carried into a pipeline whose record ended is counted there too, and the
|
||||
// pipeline's next end with a higher end count reopens the record.
|
||||
func (h *Holder) moverAdded(m runner.MoverAddedEvent) error {
|
||||
milestone, _, _ := strings.Cut(m.Pipeline, ".published.")
|
||||
r, err := h.Records.ByMilestone(milestone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("the record of the pipeline %s cannot be read: %w", m.Pipeline, err)
|
||||
}
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
if err := h.Records.AddEntry(r, RecordEntry{Module: m.Module, Fingerprint: m.Fingerprint}); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.Records.SetMover(r, m.Module, m.Fingerprint, m.Pipeline, "")
|
||||
}
|
||||
|
||||
func (h *Holder) pipelineEnded(p runner.PipelineEndedEvent) error {
|
||||
r, err := h.Records.ByKey(p.Branch, p.Source)
|
||||
if err != nil {
|
||||
return fmt.Errorf("the record of %s at %d cannot be read: %w", p.Branch, p.Source, err)
|
||||
}
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
count := int(p.EndCount)
|
||||
if r.Ended != nil {
|
||||
// A pipeline that ended again, with an end count higher than the record heard, reopens its record; its first end
|
||||
// reopens nothing (H-A-609 (2), H-A-728).
|
||||
if count < 2 || count <= r.PipelineEnds {
|
||||
return nil
|
||||
}
|
||||
if err := h.Records.Reopen(r, count); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if count > r.PipelineEnds {
|
||||
r.PipelineEnds = count
|
||||
}
|
||||
at := h.Now().UTC()
|
||||
if p.Ended != nil {
|
||||
at = p.Ended.UTC()
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
)
|
||||
@@ -188,9 +189,9 @@ func TestWhatIsHeardWhileAnEventIsWrittenWaitsUntilItIsApplied(t *testing.T) {
|
||||
r, err := h.Records.ByKey("main", 1)
|
||||
ran := time.Date(2026, 11, 20, 3, 6, 0, 0, time.UTC)
|
||||
if err != nil || r == nil || r.Ended == nil || !r.Ended.At.Equal(ran) || r.Ended.Why != WhyAllRun || r.DeliveryTime != "6m0s" ||
|
||||
r.Class != catalogue.ClassCore || said.ended != 1 {
|
||||
t.Fatalf("the record ended %+v keeping the delivery time %q and the class %q, said %d times (%v); want ended at the "+
|
||||
"running, 6m0s and core, said once", r.Ended, r.DeliveryTime, r.Class, said.ended, err)
|
||||
r.Class != catalogue.ClassCore || said.ended != 2 || r.Ends != 2 {
|
||||
t.Fatalf("the record ended %+v keeping the delivery time %q and the class %q, end %d, said %d times (%v); want ended at the "+
|
||||
"running, 6m0s and core, said at its end and again at the late running (H-A-597)", r.Ended, r.DeliveryTime, r.Class, r.Ends, said.ended, err)
|
||||
}
|
||||
if o := r.Outcomes[OutcomeKey("app", "f", "ace", StepRunning)]; o.Outcome != OutcomeRunning {
|
||||
t.Fatalf("the running after the end is %+v", o)
|
||||
@@ -207,8 +208,8 @@ func TestWhatIsHeardWhileAnEventIsWrittenWaitsUntilItIsApplied(t *testing.T) {
|
||||
}
|
||||
// The ledger holds what memory does.
|
||||
back, err := h.Records.Read(r.Instance)
|
||||
if err != nil || back.Ended == nil || !back.Ended.At.Equal(ran) || back.DeliveryTime != "6m0s" || back.Class != catalogue.ClassCore {
|
||||
t.Fatalf("the ledger keeps %+v, %q, %q (%v)", back.Ended, back.DeliveryTime, back.Class, err)
|
||||
if err != nil || back.Ended == nil || !back.Ended.At.Equal(ran) || back.DeliveryTime != "6m0s" || back.Class != catalogue.ClassCore || back.Ends != 2 {
|
||||
t.Fatalf("the ledger keeps %+v, %q, %q, end %d (%v)", back.Ended, back.DeliveryTime, back.Class, back.Ends, err)
|
||||
}
|
||||
}},
|
||||
} {
|
||||
@@ -281,6 +282,111 @@ func TestWhatIsHeardWhileAnEventIsWrittenWaitsUntilItIsApplied(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-597, H-A-609 (2), H-A-617, H-A-645, H-A-728: a first end says ends 1; a late running from a machine present
|
||||
// at the end moves the end and says record-ended again with ends 2, one from a machine that was away and a repeated one
|
||||
// move nothing; a pipeline-ended of a first end, or of a count not higher than the record heard, reopens nothing and a
|
||||
// higher one reopens it, its next end saying ends one higher; a mover-added counts its mover in the record its pipeline
|
||||
// names, and one naming none or two of from, caller and take-in is refused.
|
||||
func TestARecordsEndCountIsSaidAtEachEndAndAHigherPipelineEndReopensIt(t *testing.T) {
|
||||
now := time.Date(2026, 11, 20, 3, 0, 0, 0, time.UTC)
|
||||
var said []meshdelivery.RecordEndedEvent
|
||||
var ids []string
|
||||
h := &Holder{Now: func() time.Time { return now }}
|
||||
h.Records = &Records{Ledger: newLedgerFake(t), Now: h.Now, Say: func(subject string, body any, id string) error {
|
||||
if e, ok := body.(meshdelivery.RecordEndedEvent); ok {
|
||||
said, ids = append(said, e), append(ids, id)
|
||||
}
|
||||
return nil
|
||||
}}
|
||||
if _, _, err := h.Records.Open(opening("main", 1, map[string]string{"novox/app@5": strings.Repeat("a", 40)})); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := h.Records.Kept(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, _ := h.Records.ByKey("main", 1)
|
||||
c := &StepConsumer{Records: h.Records, Families: stepFamilies, Now: h.Now, Taken: h.TakenIn, Follow: h.Follow}
|
||||
hear(t, c, "mesh-pipeline-runner.pipeline-started.main.1", "",
|
||||
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","call":"0000000000000001","movers":[{"module":"app","commit":"c","fingerprint":"f","repository":"novox/app","tier":1}]}`)
|
||||
for _, node := range []string{"ace", "g14"} {
|
||||
hear(t, c, "mesh-wants.wanted.x.app", "", `{"v":1,"node":"`+node+`","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":12}`)
|
||||
}
|
||||
if err := h.Records.NodeAway(r, "g14", now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
running := func(node string) {
|
||||
hear(t, c, "node-engine.running."+node+".app", node, `{"v":1,"at":"2026-11-20T03:05:00Z","module":"app","node":"`+node+`","fingerprint":"f","healthy":true}`)
|
||||
}
|
||||
pipelineWanted := func() {
|
||||
hear(t, c, "mesh-wants.pipeline-wanted.main.1", "", `{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"running"}`)
|
||||
}
|
||||
pipelineEnded := func(count int) {
|
||||
hear(t, c, "mesh-pipeline-runner.pipeline-ended.main.1", "", fmt.Sprintf(
|
||||
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"passed","end-count":%d,"movers":[]}`, count))
|
||||
}
|
||||
// The first end, with ace not heard running yet and g14 away: ends 1.
|
||||
now = now.Add(time.Minute)
|
||||
pipelineWanted()
|
||||
if r.Ended == nil || r.Ends != 1 || len(said) != 1 || said[0].Ends != 1 || ids[0] != "record-ended."+r.Instance {
|
||||
t.Fatalf("the record ended %+v at end %d, said %+v under %v: want the first end, ends 1", r.Ended, r.Ends, said, ids)
|
||||
}
|
||||
endedAt := r.Ended.At
|
||||
// A running from the machine that was away at the end moves nothing; a late one from ace, present at the end, moves it.
|
||||
now = now.Add(time.Minute)
|
||||
running("g14")
|
||||
if !r.Ended.At.Equal(endedAt) || r.Ends != 1 || len(said) != 1 {
|
||||
t.Fatalf("a machine back moved the end to %v, end %d, said %d times", r.Ended.At, r.Ends, len(said))
|
||||
}
|
||||
now = now.Add(time.Minute)
|
||||
running("ace")
|
||||
if !r.Ended.At.Equal(now) || r.Ends != 2 || len(said) != 2 || said[1].Ends != 2 || ids[1] != "record-ended."+r.Instance+".2" {
|
||||
t.Fatalf("a late running left the end at %v, end %d, said %+v under %v: want it moved, ends 2, said again under an id of its own", r.Ended.At, r.Ends, said, ids)
|
||||
}
|
||||
now = now.Add(time.Minute)
|
||||
running("ace")
|
||||
if r.Ends != 2 || len(said) != 2 {
|
||||
t.Fatalf("a repeated running changed the end to %d, said %d times", r.Ends, len(said))
|
||||
}
|
||||
back, err := h.Records.Read(r.Instance)
|
||||
if err != nil || back.Ends != 2 || back.PipelineEnds != 0 {
|
||||
t.Fatalf("the ledger keeps end %d and pipeline end %d (%v): the late running leaves the pipeline's count unchanged", back.Ends, back.PipelineEnds, err)
|
||||
}
|
||||
// A pipeline's first end, and a count not higher than the record heard, reopen nothing; a higher one reopens it.
|
||||
pipelineEnded(1)
|
||||
if r.Ended == nil {
|
||||
t.Fatal("a first pipeline end reopened the record")
|
||||
}
|
||||
pipelineEnded(2)
|
||||
if r.Ended != nil || r.PipelineEnds != 2 || r.Ends != 2 {
|
||||
t.Fatalf("a pipeline ended again left the record ended %+v, pipeline end %d, end %d: want it open, both counts kept", r.Ended, r.PipelineEnds, r.Ends)
|
||||
}
|
||||
pipelineWanted()
|
||||
if r.Ended == nil || r.Ends != 3 || len(said) != 3 || said[2].Ends != 3 || ids[2] != "record-ended."+r.Instance+".3" {
|
||||
t.Fatalf("the reopened record ended %+v at end %d, said %+v: want ends 3", r.Ended, r.Ends, said)
|
||||
}
|
||||
pipelineEnded(2)
|
||||
if r.Ended == nil || r.Ends != 3 {
|
||||
t.Fatalf("a pipeline end not higher than the record heard reopened it: %+v, end %d", r.Ended, r.Ends)
|
||||
}
|
||||
if back, err = h.Records.Read(r.Instance); err != nil || back.Ended == nil || back.Ends != 3 || back.PipelineEnds != 2 {
|
||||
t.Fatalf("the ledger keeps %+v, end %d, pipeline end %d (%v)", back.Ended, back.Ends, back.PipelineEnds, err)
|
||||
}
|
||||
// A mover-added counts its mover in the record its pipeline's key names; one naming none or two of its sources is refused.
|
||||
hear(t, c, "mesh-pipeline-runner.mover-added.main.1", "", `{"v":1,"pipeline":"main.1","revision":4,"module":"extra","fingerprint":"x","from":"main.1.again.1"}`)
|
||||
for _, bad := range []string{
|
||||
`{"v":1,"pipeline":"main.1","revision":4,"module":"never","fingerprint":"y"}`,
|
||||
`{"v":1,"pipeline":"main.1","revision":4,"module":"never","fingerprint":"y","from":"a","take-in":3}`,
|
||||
} {
|
||||
hear(t, c, "mesh-pipeline-runner.mover-added.main.1", "", bad)
|
||||
}
|
||||
if _, ok := r.Entries[EntryKey("extra", "x", "")]; !ok {
|
||||
t.Errorf("a mover-added counted no mover: %v", r.Entries)
|
||||
}
|
||||
if _, ok := r.Entries[EntryKey("never", "y", "")]; ok {
|
||||
t.Errorf("a mover-added naming none or two of its sources counted a mover: %v", r.Entries)
|
||||
}
|
||||
}
|
||||
|
||||
// GATE-5/AC (design 47 H §738, §751; H-A-75, H-A-89 (3), (4)): a pipeline-ended not passed ends the record failed naming
|
||||
// the pipeline's why, and pipeline-wanted tier-late ends it failed naming the movers and machines not running.
|
||||
func TestARecordEndsFailedOnAPipelineNotPassedOrATierLate(t *testing.T) {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"mesh-delivery-forge-bridge.forge.*.*.*.head-moved",
|
||||
"mesh-delivery-indexer.take-in.taken",
|
||||
"mesh-pipeline-runner.pipeline-started.*.*",
|
||||
"mesh-pipeline-runner.mover-added.*.*",
|
||||
"mesh-pipeline-runner.pipeline-ended.*.*",
|
||||
"mesh-pipeline-runner.wait-held.*.*",
|
||||
"mesh-pipeline-runner.wait-ended.*.*",
|
||||
@@ -120,6 +121,12 @@
|
||||
},
|
||||
"phases": {
|
||||
"type": "object"
|
||||
},
|
||||
"ends": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pipeline-ends": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"operations": [
|
||||
@@ -193,7 +200,9 @@
|
||||
"fields": [
|
||||
"ended",
|
||||
"delivery-time",
|
||||
"class"
|
||||
"class",
|
||||
"ends",
|
||||
"pipeline-ends"
|
||||
],
|
||||
"sequence": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user