Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f85199f624 | ||
|
|
13d43a7de0 | ||
|
|
5dfb357333 |
@@ -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), 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).
|
||||
// (issue 1748). Its manifest asks the capability seat-settle-delay (ADR 0664 §5).
|
||||
package failurekit
|
||||
|
||||
import (
|
||||
@@ -91,25 +91,6 @@ 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))
|
||||
}
|
||||
// A-489b: 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
|
||||
}
|
||||
counts, err := runsTheKit(dir, "conformance.RunsCounted(")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !counts {
|
||||
// A-489c
|
||||
refused = append(refused, fmt.Sprintf("it claims %s, and no test of it calls conformance.RunsCounted "+
|
||||
"(mesh-delivery-sdk steprun/conformance): run the kit's case that its puller counts the runs that started, not the bus's deliveries (A-489a)", seat))
|
||||
}
|
||||
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(")
|
||||
|
||||
@@ -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) }\nfunc TestEnds(t *testing.T) { conformance.StepEnds(t, steprun.AskSteps{}) }\nfunc TestCounted(t *testing.T) { conformance.RunsCounted(t, nil) }\n"
|
||||
const sweep = "func TestSweep(t *testing.T) { conformance.LeftRunning(t, nil) }\nfunc TestPassing(t *testing.T) { conformance.Passing(t, nil, nil) }\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,10 +30,6 @@ 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) }\nfunc TestCounted(t *testing.T) { conformance.RunsCounted(t, nil) }\n",
|
||||
"modules/k/module.json": `{"claims":[{"name":"node-build-k"}],"capabilities":["seat-settle-delay"],"tools":["build_k_build"]}`, // no runs-counted case
|
||||
"modules/k/cmd/k/kit_test.go": imp + "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",
|
||||
"modules/e/module.json": `{"claims":[{"name":"node-build-e"}],"tools":["build_e_test"]}`,
|
||||
"modules/e/cmd/e/kit.go": kit, // not a test file
|
||||
} {
|
||||
@@ -49,9 +45,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", "j": "refused", "k": "refused"}
|
||||
want := map[string]string{"a": "refused", "b": "passes", "c": "exempt", "e": "refused", "f": "refused", "g": "refused", "h": "refused", "i": "refused"}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("judged %+v, want a, b, c, e, f, g, h, i, j and k", got)
|
||||
t.Fatalf("judged %+v, want a, b, c, e, f, g, h and i", got)
|
||||
}
|
||||
for _, j := range got {
|
||||
is := "passes"
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
artifactref "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/reference"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/publishconformance"
|
||||
)
|
||||
|
||||
type memObjects map[string][]byte
|
||||
@@ -666,6 +667,22 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) {
|
||||
}
|
||||
}
|
||||
})
|
||||
// Design 47 G A-490: the publish contract's no-parts form, as every publish holder is held to it.
|
||||
t.Run("the publish conformance cases", func(t *testing.T) {
|
||||
publishconformance.Run(t, func(t *testing.T) publishconformance.Bed {
|
||||
b := newBed(true)
|
||||
return publishconformance.Bed{
|
||||
Hold: func(d string) { b.store.has[d] = true },
|
||||
Publish: func(name, version, digest string) publishconformance.Outcome {
|
||||
got, err := b.h.Publish(ArtifactSeat, builder, PublishRequest{Name: name, Version: version, Kind: KindBundle, Digest: digest, Transfer: "t"})
|
||||
o := publishconformance.Outcome{Ended: got.Ended, Lacks: len(got.Missing), Err: err}
|
||||
if len(b.said) > 0 {
|
||||
o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].body.Reason
|
||||
}
|
||||
return o
|
||||
}}
|
||||
})
|
||||
})
|
||||
t.Run("a publish with a version and no parts tags the held digest at the store's size; one not held is not stored", func(t *testing.T) {
|
||||
// Design 47 G A-417, A-73, A-50: the build stored the bundle untagged; the builder's publish of its version with that
|
||||
// digest and no parts tags it and says published, nothing sent; a digest the store holds none of is refused as not
|
||||
|
||||
@@ -291,7 +291,7 @@ func verbTools[PI, PA, PPI, PPA, VI, VA, RI, RA any](seat string, holder func()
|
||||
}
|
||||
return []stdio.Tool{
|
||||
{Name: seat + "." + packageseats.VerbPublish, Input: obj,
|
||||
Description: "Open a transfer of a package's one file (ADR 0611): its name, the builder's version, kind package, its sha256 digest and the file as its one part; answers the part the forge lacks. A version held with that digest answers held and says published.",
|
||||
Description: "Open a transfer of a package's one file (ADR 0611): its name, the builder's version, kind package, its sha256 digest and the file as its one part; answers the part the forge lacks. A version held with that digest answers held and says published; with no part at all (the builder's publish again) nothing moves: held says published, else refused as not stored, naming the digest (design 47 G A-490).",
|
||||
Run: run(func(h *packageseats.Holder, args map[string]any) (any, error) {
|
||||
in, err := as[PI](args)
|
||||
if err != nil {
|
||||
|
||||
@@ -213,7 +213,9 @@ func (h *Holder) answer(transfer string, r parts.Received) Answer {
|
||||
return Answer{Transfer: transfer, Lacks: r.Lacks, Ended: r.Ended}
|
||||
}
|
||||
|
||||
// Publish is `publish` on seat for the proved caller: a package is one file, its digest the file's sha256.
|
||||
// Publish is `publish` on seat for the proved caller: a package is one file, its digest the file's sha256. With its one
|
||||
// part the file travels (design 51 *Publishing*); with none (the builder's publish again, design 47 G A-73, A-417) the
|
||||
// version is said published when the forge holds it under the digest, and refused as not stored otherwise.
|
||||
func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) {
|
||||
if err := checkPublish(seat, p); err != nil {
|
||||
return Answer{}, err
|
||||
@@ -225,12 +227,25 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) {
|
||||
} else if ok {
|
||||
if d != p.Digest {
|
||||
reason := fmt.Sprintf("%s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest)
|
||||
if len(p.Parts) == 0 {
|
||||
// The builder's publish again names nothing the forge holds under that digest: refused as not stored (A-490,
|
||||
// A-490a), the words its republish recognises.
|
||||
reason = "not stored: " + reason
|
||||
return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason))
|
||||
}
|
||||
// A one-part publish of a taken version is refused with an event only, as the registry would (the builder's "version taken").
|
||||
return Answer{Transfer: p.Transfer, Ended: true}, h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)
|
||||
}
|
||||
o := outcomeOf(p, "")
|
||||
o.Reference = Reference(p.Name, p.Version)
|
||||
return Answer{Transfer: p.Transfer, Ended: true}, h.Say(seat, EventPublished, o)
|
||||
}
|
||||
// A publish with a version, a digest and no parts (design 47 G A-73, A-417): what the forge holds under the version has
|
||||
// been said published above; nothing else travels, so the publish is refused as not stored, naming the digest.
|
||||
if len(p.Parts) == 0 {
|
||||
reason := fmt.Sprintf("not stored: the forge holds no %s of %s, so version %s names nothing", p.Digest, p.Name, p.Version)
|
||||
return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason))
|
||||
}
|
||||
// The transfer's name is the caller's own (the seat's contract): none would open the seat's one nameless transfer,
|
||||
// which key() still makes a valid id.
|
||||
if strings.TrimSpace(p.Transfer) == "" {
|
||||
@@ -377,8 +392,8 @@ func checkPublish(seat string, p Publish) error {
|
||||
return fmt.Errorf("publish: %s holds packages, not a %s", seat, p.Kind)
|
||||
case !strings.HasPrefix(p.Digest, "sha256:"):
|
||||
return fmt.Errorf("publish: digest %q is no sha256 digest", p.Digest)
|
||||
case len(p.Parts) != 1 || p.Parts[0].Digest != p.Digest:
|
||||
return errors.New("publish: a package is one file, its one part the package's digest")
|
||||
case len(p.Parts) > 1 || (len(p.Parts) == 1 && p.Parts[0].Digest != p.Digest):
|
||||
return errors.New("publish: a package is one file, its one part the package's digest, or no part at all")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/parts"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/publishconformance"
|
||||
)
|
||||
|
||||
type memObjects map[string][]byte
|
||||
@@ -50,10 +51,21 @@ func (b builder) Recorded(_, _, _ string) (bool, string, error) { return b.ok, "
|
||||
// forge is the forge's package registry: seat -> name@version -> file.
|
||||
type forge struct {
|
||||
files map[string]map[string][]byte
|
||||
digests map[string]string // seat+name@version -> a digest held with no bytes kept
|
||||
removed []string
|
||||
}
|
||||
|
||||
func (f *forge) holdDigest(seat, name, version, d string) {
|
||||
if f.digests == nil {
|
||||
f.digests = map[string]string{}
|
||||
}
|
||||
f.digests[seat+" "+name+"@"+version] = d
|
||||
}
|
||||
|
||||
func (f *forge) Held(seat, name, version string) (string, bool, error) {
|
||||
if d, ok := f.digests[seat+" "+name+"@"+version]; ok {
|
||||
return d, true, nil
|
||||
}
|
||||
b, ok := f.files[seat][name+"@"+version]
|
||||
if !ok {
|
||||
return "", false, nil
|
||||
@@ -150,6 +162,50 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) {
|
||||
}
|
||||
}
|
||||
})
|
||||
// Design 47 G A-490, A-490a: the publish contract's no-parts form, as every publish holder is held to it, per seat.
|
||||
for _, seat := range []string{GoSeat, NpmSeat} {
|
||||
t.Run("the publish conformance cases on "+seat, func(t *testing.T) {
|
||||
publishconformance.Run(t, func(t *testing.T) publishconformance.Bed {
|
||||
b := newBed(true)
|
||||
return publishconformance.Bed{
|
||||
Hold: func(d string) {
|
||||
b.forge.holdDigest(seat, publishconformance.Name, publishconformance.Version, d)
|
||||
},
|
||||
Publish: func(name, version, digest string) publishconformance.Outcome {
|
||||
a, err := b.h.Publish(seat, goBuild, Publish{Transfer: "t", Name: name, Version: version, Kind: KindPackage, Digest: digest})
|
||||
o := publishconformance.Outcome{Ended: a.Ended, Lacks: len(a.Lacks), Err: err}
|
||||
if len(b.said) > 0 {
|
||||
o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].o.Reason
|
||||
}
|
||||
return o
|
||||
}}
|
||||
})
|
||||
})
|
||||
}
|
||||
// Design 47 G A-73, A-417: the builder's publish again names the version and the digest and no parts.
|
||||
t.Run("a publish with a digest and no parts is published when held, refused as not stored when not", func(t *testing.T) {
|
||||
for _, seat := range []string{NpmSeat, GoSeat} {
|
||||
b := newBed(true)
|
||||
none := pub("mesh-sdk", "0.1.0", file)
|
||||
none.Parts = nil
|
||||
a, err := b.h.Publish(seat, goBuild, none)
|
||||
if err == nil || !strings.Contains(err.Error(), "not stored") || !strings.Contains(err.Error(), digest(file)) || !a.Ended {
|
||||
t.Fatalf("%s: a publish of a digest the forge lacks answered %+v, %v; want refused as not stored, naming the digest", seat, a, err)
|
||||
}
|
||||
if len(b.said) != 1 || b.said[0].event != EventRefused || !strings.Contains(b.said[0].o.Reason, digest(file)) || !b.findings["publish-refused mesh-sdk@0.1.0"] {
|
||||
t.Errorf("%s: said %+v, findings %v; want refused with the digest and the finding raised", seat, b.said, b.findings)
|
||||
}
|
||||
b = newBed(true)
|
||||
if _, ok := b.forge.files[seat]; !ok {
|
||||
b.forge.files[seat] = map[string][]byte{}
|
||||
}
|
||||
b.forge.files[seat]["mesh-sdk@0.1.0"] = file
|
||||
a, err = b.h.Publish(seat, goBuild, none)
|
||||
if err != nil || !a.Ended || len(a.Lacks) != 0 || len(b.said) != 1 || b.said[0].event != EventPublished || b.said[0].o.Reference != "mesh-sdk@0.1.0" {
|
||||
t.Errorf("%s: a held digest answered %+v, %v, said %+v; want published", seat, a, err, b.said)
|
||||
}
|
||||
}
|
||||
})
|
||||
// Tools review F4 and running review F2's kind: a seat's incoming is read per seat with the cap its binding
|
||||
// carries; an open transfer is armed with its idle key, re-armed for the rest when it took a chunk since, and
|
||||
// dropped with its chunks when it had none for 24 hours; a cap from the binding refuses a transfer past it.
|
||||
|
||||
@@ -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, 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,
|
||||
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,
|
||||
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 {
|
||||
|
||||
@@ -56,19 +56,3 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A-489b, design 47 G §24: 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))
|
||||
}
|
||||
|
||||
// A-489c (A-489a): the module's puller counts the runs its steps state says started, not the bus's deliveries (an ask given back before
|
||||
// it ran is no run), so the poison rule never ends an ask that never ran.
|
||||
func TestThePullerCountsRunsThatStarted(t *testing.T) {
|
||||
conformance.RunsCounted(t, func(read func(string) (json.RawMessage, error)) *steprun.Puller {
|
||||
m := &Module{Node: "kitnode", Capacity: func() int { return 1 }}
|
||||
m.ReadSteps = StateRead{Get: read}
|
||||
return m.Puller(nil, steprun.NewFakeAsks())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -31,20 +31,9 @@ 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 {
|
||||
@@ -80,7 +69,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, 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,
|
||||
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,
|
||||
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 {
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
@@ -45,19 +44,3 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A-489b, design 47 G §24: 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))
|
||||
}
|
||||
|
||||
// A-489c (A-489a): the module's puller counts the runs its steps state says started, not the bus's deliveries (an ask given back before
|
||||
// it ran is no run), so the poison rule never ends an ask that never ran.
|
||||
func TestThePullerCountsRunsThatStarted(t *testing.T) {
|
||||
conformance.RunsCounted(t, func(read func(string) (json.RawMessage, error)) *steprun.Puller {
|
||||
m := &Module{Node: "kitnode", Capacity: func() int { return 1 }}
|
||||
m.ReadSteps = StateRead{Get: read}
|
||||
return m.Puller(nil, steprun.NewFakeAsks())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ 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.
|
||||
|
||||
@@ -41,22 +41,9 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps {
|
||||
},
|
||||
Release: func(ws string) error { return m.spaces().Release(ws) },
|
||||
Logf: m.Say,
|
||||
Has: m.Has,
|
||||
Lint: m.lintStep,
|
||||
Node: m.Node,
|
||||
SayStep: m.sayStep(),
|
||||
}
|
||||
}
|
||||
|
||||
// sayStep says a pipeline step's end on this node's subject of the seat (design 47 G §24, *Asked on a work queue, ended by an
|
||||
// event*): SayStep when a test sets it, else the runtime's seat publish.
|
||||
func (m *Module) sayStep() func(sdkstep.StepEnded) error {
|
||||
if m.SayStep != nil {
|
||||
return m.SayStep
|
||||
}
|
||||
return steprun.SayStepOn(sdkstep.AskNode, 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 {
|
||||
@@ -92,7 +79,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
|
||||
if m.SayEvent != nil {
|
||||
say = steprun.SayOn(sdkstep.AskNode, m.Node, m.SayEvent)
|
||||
}
|
||||
return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskNode, 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,
|
||||
return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskNode, 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,
|
||||
Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say,
|
||||
Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) {
|
||||
if err := m.Prepare(ctx); err != nil {
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
"git.novox.be/novox/mesh-sdk/go/forgekey"
|
||||
)
|
||||
@@ -227,54 +226,3 @@ func TestTheTestScriptFindsTscAndEsbuildOnItsPath(t *testing.T) {
|
||||
t.Errorf("npm ran with %v, want NODE_OPTIONS naming the TAP reporter and its file", npm.env)
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §328 (*Lint per language*: TypeScript's lint is the type-check) and §24: the pipeline step lint of a TypeScript
|
||||
// artifact runs tsc without emitting over the module's directory; a type error fails it naming the file, a clean package passes,
|
||||
// a tree with no .ts file has nothing to lint, and a tsc that cannot start is an error, not a verdict.
|
||||
func TestTheLintStepIsTheTypeCheck(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
files map[string]string
|
||||
ran forgekey.Ran
|
||||
failed int
|
||||
nothing bool
|
||||
err bool
|
||||
}{
|
||||
{"a type error", map[string]string{"tools/bad.ts": `export const n: number = "text";`}, forgekey.Ran{Status: 2, Stdout: tscTypeError}, 1, false, false},
|
||||
{"a clean package", map[string]string{"index.ts": `export const a = 1;`}, forgekey.Ran{}, 0, false, false},
|
||||
{"no TypeScript", map[string]string{"package.json": `{"name":"x"}`}, forgekey.Ran{}, 0, true, false},
|
||||
{"tsc cannot start", map[string]string{"index.ts": `export const a = 1;`}, forgekey.Ran{Status: 127, Err: "no such file"}, 0, false, true},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
m, f, work := newMachine(t)
|
||||
workspaceWith(t, work, c.files)
|
||||
f.answer["tsc"] = c.ran
|
||||
out, err := m.lintStep(context.Background(), map[string]any{"workspace": "w1", "dir": "."})
|
||||
if (err != nil) != c.err {
|
||||
t.Fatalf("error = %v, want error %v", err, c.err)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
la := out.(steprun.LintAnswer)
|
||||
if len(la.Failed) != c.failed || la.Nothing != c.nothing {
|
||||
t.Fatalf("answer = %+v, want %d failed, nothing %v", la, c.failed, c.nothing)
|
||||
}
|
||||
if c.failed > 0 && !strings.Contains(la.Failed[0].Cause+la.Failed[0].Output, "tools/bad.ts") {
|
||||
t.Errorf("the failure %+v does not name tools/bad.ts", la.Failed[0])
|
||||
}
|
||||
if !c.nothing && !strings.Contains(joined(f.calls[0]), "--noEmit") {
|
||||
t.Errorf("the lint ran %s, want tsc --noEmit", joined(f.calls[0]))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §24: the Node build module's steps carry what a step ask needs (its node, the lint body, the end's publisher and
|
||||
// its own need), so the ask the first live pipeline sent is no longer refused as "says no step's end".
|
||||
func TestTheNodeStepsCarryWhatAStepAskNeeds(t *testing.T) {
|
||||
s := (&Module{Node: "shanks"}).askSteps(nil)
|
||||
if s.Lint == nil || s.Node != "shanks" || s.SayStep == nil || s.Has == nil || !s.Has(sdkstep.NeedNodeBuildNode) || s.Has("other") {
|
||||
t.Errorf("steps = %+v, want Lint, Node, SayStep and Has set", s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -50,19 +49,3 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A-489b, design 47 G §24: 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))
|
||||
}
|
||||
|
||||
// A-489c (A-489a): the module's puller counts the runs its steps state says started, not the bus's deliveries (an ask given back before
|
||||
// it ran is no run), so the poison rule never ends an ask that never ran.
|
||||
func TestThePullerCountsRunsThatStarted(t *testing.T) {
|
||||
conformance.RunsCounted(t, func(read func(string) (json.RawMessage, error)) *steprun.Puller {
|
||||
m := &Module{Node: "kitnode", Capacity: func() int { return 1 }}
|
||||
m.ReadSteps = StateRead{Get: read}
|
||||
return m.Puller(nil, steprun.NewFakeAsks())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
)
|
||||
|
||||
// **The type-check is a TypeScript artifact's pipeline step lint** (design 47 G §328 *Lint per language*: Go's lint is the Go
|
||||
// build module's linter, TypeScript's the type-check; §22: lint is a step the build seats serve; §24: asked on a work queue,
|
||||
// its end said as an event). It takes {"workspace", "dir"} as the lint step of mesh-build-go does and runs tsc over each
|
||||
// TypeScript package of the module's directory (testTargets, the way the unit level finds them), without emitting: a package
|
||||
// with no .ts file has nothing to lint, and nothing at all ends the step `nothing to run`. A failure is the step's, naming
|
||||
// the tsc output as the unit level names it; a tsc that could not start is an error, never a verdict.
|
||||
func (m *Module) lintStep(ctx context.Context, args map[string]any) (any, error) {
|
||||
workspace, _ := args["workspace"].(string)
|
||||
dir, _ := args["dir"].(string)
|
||||
root, mdir, err := m.moduleDirOf(workspace, dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
targets, err := testTargets(mdir, filepath.ToSlash(filepath.Clean(dir)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var failed []Failure
|
||||
linted := false
|
||||
for _, tg := range targets {
|
||||
sources, err := typeScriptFiles(tg.dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(sources) == 0 {
|
||||
continue
|
||||
}
|
||||
linted = true
|
||||
if err := m.provide(root); err != nil {
|
||||
return nil, fmt.Errorf("providing the toolchain's packages to the workspace: %w", err)
|
||||
}
|
||||
r := m.runIn(ctx, root, false, tg.dir, nil, "node", m.typeCheck(tg.dir, sources)...)
|
||||
if r.Err != "" {
|
||||
return nil, fmt.Errorf("type-check could not be run: status %d %s: %s", r.Status, r.Err, firstLine(r.Stderr))
|
||||
}
|
||||
if r.Status != 0 {
|
||||
failed = append(failed, testFailures(tg.where, "type-check", tg.dir, r, "")...)
|
||||
}
|
||||
}
|
||||
return steprun.LintAnswer{Failed: failed, Nothing: !linted}, nil
|
||||
}
|
||||
|
||||
// A-489b: Has says whether this node has a need a package's tests name (sdkstep.AskNeeds): the need node-build-node is this module's own
|
||||
// (a TypeScript package's tests run through it); any other it lacks.
|
||||
func (m *Module) Has(need string) bool { return need == sdkstep.NeedNodeBuildNode }
|
||||
@@ -34,9 +34,6 @@ type Module struct {
|
||||
// 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 pipeline step'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
|
||||
// Recipe is the recipe in force. Reload, when set, reads it again at every check (the lock file the mesh
|
||||
// writes can change under a running module); a failure to read it is a refusal.
|
||||
|
||||
Reference in New Issue
Block a user