diff --git a/checks/failurekit/failurekit.go b/checks/failurekit/failurekit.go index e46f8cad7..aa422e9a8 100644 --- a/checks/failurekit/failurekit.go +++ b/checks/failurekit/failurekit.go @@ -5,7 +5,7 @@ // exempt from that, and said so. Every build module, test step or not, must also hold a test that calls // conformance.LeftRunning with its own start sweep, so a step a previous process left running is ended at its start // (issue 1890), and one that calls conformance.Passing, so a step whose network did not answer is said as a transport fault -// (issue 1748). Its manifest asks the capability seat-settle-delay (ADR 0664 §5). +// (issue 1748), and one that calls conformance.StepEnds, so its steps can say a pipeline step's end (design 47 G §24). Its manifest asks the capability seat-settle-delay (ADR 0664 §5). package failurekit import ( @@ -91,6 +91,16 @@ func Judge(root string) ([]Judged, error) { refused = append(refused, fmt.Sprintf("it claims %s, and no test of it calls conformance.LeftRunning "+ "(mesh-build-go buildstep/conformance): run the kit's left-running case with the module's own start sweep (issue 1890)", seat)) } + // Every build module is asked pipeline steps, so every one runs the case that its steps can say a step's end: without a + // SayStep every step ask is refused live ("this build module says no step's end"), as mesh-build-node's was. + ends, err := runsTheKit(dir, "conformance.StepEnds(") + if err != nil { + return nil, err + } + if !ends { + refused = append(refused, fmt.Sprintf("it claims %s, and no test of it calls conformance.StepEnds "+ + "(mesh-delivery-sdk steprun/conformance): run the kit's step-ends case with the module's own steps (design 47 G §24)", seat)) + } // Every build module meets the network (a fetch, a download, an install, a publish), so every one runs the passing case: its // steps say a network that did not answer as a transport fault the bus gives the ask again for (ADR 0664, issue 1748). says, err := runsTheKit(dir, "conformance.Passing(") diff --git a/checks/failurekit/failurekit_test.go b/checks/failurekit/failurekit_test.go index 42049e0ef..f49d3d924 100644 --- a/checks/failurekit/failurekit_test.go +++ b/checks/failurekit/failurekit_test.go @@ -13,7 +13,7 @@ import ( func TestABuildModuleWithATestStepMustRunTheKit(t *testing.T) { root := t.TempDir() const imp = "package main\n\nimport \"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun/conformance\"\n\n" - const sweep = "func TestSweep(t *testing.T) { conformance.LeftRunning(t, nil) }\nfunc TestPassing(t *testing.T) { conformance.Passing(t, nil, nil) }\n" + const sweep = "func TestSweep(t *testing.T) { conformance.LeftRunning(t, nil) }\nfunc TestPassing(t *testing.T) { conformance.Passing(t, nil, nil) }\nfunc TestEnds(t *testing.T) { conformance.StepEnds(t, steprun.AskSteps{}) }\n" kit := imp + "func TestKit(t *testing.T) { conformance.Run(t, conformance.GoTest, nil) }\n" + sweep for path, body := range map[string]string{ "modules/a/module.json": `{"claims":[{"name":"node-build-a"}],"tools":["build_a_fetch","build_a_test"]}`, @@ -30,6 +30,8 @@ func TestABuildModuleWithATestStepMustRunTheKit(t *testing.T) { "modules/h/cmd/h/kit_test.go": imp + "func TestSweep(t *testing.T) { conformance.LeftRunning(t, nil) }\n", "modules/i/module.json": `{"claims":[{"name":"node-build-i"}],"capabilities":["other"],"tools":["build_i_build"]}`, // the whole kit, and no seat-settle-delay "modules/i/cmd/i/kit_test.go": imp + sweep, + "modules/j/module.json": `{"claims":[{"name":"node-build-j"}],"capabilities":["seat-settle-delay"],"tools":["build_j_build"]}`, // the rest of the kit, and no step-ends case + "modules/j/cmd/j/kit_test.go": imp + "func TestSweep(t *testing.T) { conformance.LeftRunning(t, nil) }\nfunc TestPassing(t *testing.T) { conformance.Passing(t, nil, nil) }\n", "modules/e/module.json": `{"claims":[{"name":"node-build-e"}],"tools":["build_e_test"]}`, "modules/e/cmd/e/kit.go": kit, // not a test file } { @@ -45,9 +47,9 @@ func TestABuildModuleWithATestStepMustRunTheKit(t *testing.T) { if err != nil { t.Fatal(err) } - want := map[string]string{"a": "refused", "b": "passes", "c": "exempt", "e": "refused", "f": "refused", "g": "refused", "h": "refused", "i": "refused"} + want := map[string]string{"a": "refused", "b": "passes", "c": "exempt", "e": "refused", "f": "refused", "g": "refused", "h": "refused", "i": "refused", "j": "refused"} if len(got) != len(want) { - t.Fatalf("judged %+v, want a, b, c, e, f, g, h and i", got) + t.Fatalf("judged %+v, want a, b, c, e, f, g, h, i and j", got) } for _, j := range got { is := "passes" diff --git a/modules/mesh-build-go/cmd/mesh-build-go/asks.go b/modules/mesh-build-go/cmd/mesh-build-go/asks.go index 395f9193b..6b9093461 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/asks.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/asks.go @@ -91,7 +91,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskGo, m.Node, m.SayEvent) } - return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskGo, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskGo, Say: say, Callers: m.Callers, Prior: steprun.PriorRuns(m.ReadSteps.Get), Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say, Has: m.Has, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Check(ctx); err != nil { diff --git a/modules/mesh-build-go/cmd/mesh-build-go/kit_test.go b/modules/mesh-build-go/cmd/mesh-build-go/kit_test.go index 8a996b309..7fef9f003 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/kit_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/kit_test.go @@ -56,3 +56,9 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) { } }) } + +// Design 47 G §24 (*Asked on a work queue, ended by an event*): the module's own steps can say a pipeline step's end, or +// every step ask the runner sends it is refused ("this build module says no step's end"), as the first live pipeline met. +func TestTheStepsCanSayAStepsEnd(t *testing.T) { + conformance.StepEnds(t, (&Module{Node: "kitnode"}).askSteps(nil)) +} diff --git a/modules/mesh-build-image/cmd/mesh-build-image/asks.go b/modules/mesh-build-image/cmd/mesh-build-image/asks.go index 7872621cb..761209beb 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/asks.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/asks.go @@ -31,9 +31,20 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps { Fetch: byName["build_image_fetch"], Build: byName["build_image_build"], Copy: byName["build_image_copy"], Release: func(ws string) error { return m.spaces().Release(ws) }, Logf: m.Say, + Node: m.Node, + SayStep: m.sayStep(), } } +// sayStep says a step ask's end on this node's subject of the seat (design 47 G §24): an image has no lint, unit or integration +// step (§328), so none is asked of this seat, but the steps of every build module can say their ends, which the kit holds. +func (m *Module) sayStep() func(sdkstep.StepEnded) error { + if m.SayStep != nil { + return m.SayStep + } + return steprun.SayStepOn(sdkstep.AskImage, m.Node, stdio.SeatPublish) +} + // Puller is the module's pull of its seat's asks, on source (the runtime's seat pull when nil). func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Puller { if source == nil { @@ -69,7 +80,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskImage, m.Node, m.SayEvent) } - return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskImage, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskImage, Say: say, Callers: m.Callers, Prior: steprun.PriorRuns(m.ReadSteps.Get), Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Eligible: m.Eligible, Logf: m.Say, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Check(ctx); err != nil { diff --git a/modules/mesh-build-image/cmd/mesh-build-image/kit_test.go b/modules/mesh-build-image/cmd/mesh-build-image/kit_test.go index 0d3bd0b29..4be8b9158 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/kit_test.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/kit_test.go @@ -44,3 +44,9 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) { } }) } + +// Design 47 G §24 (*Asked on a work queue, ended by an event*): the module's own steps can say a pipeline step's end, or +// every step ask the runner sends it is refused ("this build module says no step's end"), as the first live pipeline met. +func TestTheStepsCanSayAStepsEnd(t *testing.T) { + conformance.StepEnds(t, (&Module{Node: "kitnode"}).askSteps(nil)) +} diff --git a/modules/mesh-build-image/cmd/mesh-build-image/module.go b/modules/mesh-build-image/cmd/mesh-build-image/module.go index e8dca05dc..87b2eca49 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/module.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/module.go @@ -28,6 +28,8 @@ type Module struct { // SayEvent publishes an event of the image build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the // puller's ask-taken, step-progress and step-ended (design 47 G §496, §602). SayEvent func(subject string, body any, id string) error + // SayStep says a step ask's end (steprun.AskSteps.SayStep); the seat's publish on this node when nil (a test's own). + SayStep func(sdkstep.StepEnded) error Node string // RecordAct writes an act in the hand-act log of the seat mesh-hand-acts (§463, §480): a drop writes it first. diff --git a/modules/mesh-build-node/cmd/mesh-build-node/kit_test.go b/modules/mesh-build-node/cmd/mesh-build-node/kit_test.go index c3ed1e426..dfbb88ded 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/kit_test.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/kit_test.go @@ -49,3 +49,9 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) { } }) } + +// Design 47 G §24 (*Asked on a work queue, ended by an event*): the module's own steps can say a pipeline step's end, or +// every step ask the runner sends it is refused ("this build module says no step's end"), as the first live pipeline met. +func TestTheStepsCanSayAStepsEnd(t *testing.T) { + conformance.StepEnds(t, (&Module{Node: "kitnode"}).askSteps(nil)) +}