A5 assigner-validate: the tool assigner_validate reads the pipeline's candidate from the runner's show and calls the seat mesh-wants' verb validate, which the process answers, recording the hand act before it joins or starts <pipeline>.validate
Builds: design 47 H2 H-A-684 (1) (2), H-A-702, H-A-727, H-A-739
This commit is contained in:
@@ -104,9 +104,9 @@ func (c *compositionSteps) drop(r *compositionRuns, record func(meshhandactsclie
|
||||
return answer, err
|
||||
}
|
||||
|
||||
// compositionVerbs are the process's handlers of the seat mesh-wants' verbs compositions and compositions-drop.
|
||||
func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshhandactsclient.Request) error) map[string]process.SeatHandler {
|
||||
return map[string]process.SeatHandler{
|
||||
// compositionVerbs are the process's handlers of the seat mesh-wants' verbs compositions, compositions-drop and validate.
|
||||
func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshhandactsclient.Request) error, validate *compositionRun) map[string]process.SeatHandler {
|
||||
verbs := map[string]process.SeatHandler{
|
||||
meshwants.VerbCompositions: func(_ string, raw json.RawMessage) (any, error) {
|
||||
var in meshwants.CompositionsInput
|
||||
if len(raw) > 0 {
|
||||
@@ -124,6 +124,17 @@ func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshh
|
||||
return c.drop(r, record, caller, in)
|
||||
},
|
||||
}
|
||||
if validate != nil {
|
||||
// The seat's verb validate (design 47 H2 H-A-727): the tool assigner_validate reaches the process, which keeps the runs.
|
||||
verbs[meshwants.VerbValidate] = func(caller string, raw json.RawMessage) (any, error) {
|
||||
var in meshwants.ValidateInput
|
||||
if err := json.Unmarshal(raw, &in); err != nil {
|
||||
return nil, fmt.Errorf("the arguments are not JSON: %w", err)
|
||||
}
|
||||
return validate.validateOnRequest(validate.own, record, caller, in)
|
||||
}
|
||||
}
|
||||
return verbs
|
||||
}
|
||||
|
||||
// compositionsTools are the module's tools of §728's names, each calling its verb (A-469f).
|
||||
|
||||
+2
-2
@@ -45,14 +45,14 @@ func TestTheCompositionRunsAreReadAndDroppedByTheirVerbs(t *testing.T) {
|
||||
})
|
||||
var recorded []meshhandactsclient.Request
|
||||
record := func(q meshhandactsclient.Request) error { recorded = append(recorded, q); return nil }
|
||||
verbs := compositionVerbs(r, c, record)
|
||||
verbs := compositionVerbs(r, c, record, nil)
|
||||
out, err := verbs[meshwants.VerbCompositions]("op", json.RawMessage(`{"machine":"n2"}`))
|
||||
read, _ := out.(meshwants.CompositionsAnswer)
|
||||
if err != nil || len(read.Runs) != 1 || read.Runs[0].Key != runKeyOf("main.3", "n2") || read.Runs[0].Ask != "run-n2" || len(read.Runs[0].Readers) != 3 ||
|
||||
read.Fill.Store != "composition-runs" || read.Fill.Cap != 16<<20 || read.Fill.Bytes == 0 {
|
||||
t.Fatalf("compositions = %+v %v", out, err)
|
||||
}
|
||||
refuse := compositionVerbs(r, c, func(meshhandactsclient.Request) error { return errors.New("no holder") })
|
||||
refuse := compositionVerbs(r, c, func(meshhandactsclient.Request) error { return errors.New("no holder") }, nil)
|
||||
if _, err := refuse[meshwants.VerbCompositionsDrop]("op", json.RawMessage(`{"candidate":"main.3","machine":"n2","why":"stuck"}`)); err == nil ||
|
||||
!strings.Contains(err.Error(), "nothing was dropped") || len(drops) != 0 {
|
||||
t.Fatalf("a drop not recorded: %v, drops %v", err, drops)
|
||||
|
||||
@@ -724,7 +724,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
||||
_, err := meshhandactsclient.Recorder{Ask: bus.Call}.Record(q)
|
||||
return err
|
||||
}
|
||||
verbs := compositionVerbs(runs, steps, record)
|
||||
verbs := compositionVerbs(runs, steps, record, run)
|
||||
maps.Copy(verbs, dropVerb(steps)) // the seat's act drop (§778, H-A-404)
|
||||
if p.graph != nil {
|
||||
maps.Copy(verbs, keepNowVerb(ctx, p)) // the keeping by hand (§813 (2), H-A-417)
|
||||
|
||||
@@ -409,6 +409,7 @@ func serveTools() error {
|
||||
tools = append(tools, wants.tools()...)
|
||||
keeper := &inputKeeper{vals: stateobjects.ForState(buckets.InputsState), now: time.Now, logf: func(string, ...any) {}}
|
||||
tools = append(tools, inputsRead(keeper), inputsDrop(keeper, stdio.Ask))
|
||||
tools = append(tools, validateTools(stdio.Ask)...) // judge a pipeline's candidate on request, through the seat mesh-wants' verb validate (H-A-727)
|
||||
tools = append(tools, compositionsTools(stdio.Ask)...) // the composition runs' read and drop, through their verbs (§728)
|
||||
tools = append(tools, viewTools(os.Getenv, keptSource, time.Now)...)
|
||||
// What each node's engine reads, as the assigner uses it: its own state engine-reads (design 47 H-A-104).
|
||||
|
||||
@@ -13,13 +13,16 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
|
||||
"mesh-delivery-assigner/internal/buckets"
|
||||
@@ -512,3 +515,190 @@ func (r *compositionRun) seatList(ctx context.Context, ask string) ([]json.RawMe
|
||||
}
|
||||
return list, a.Digest, nil
|
||||
}
|
||||
|
||||
// validateTool is the tool that judges a pipeline's candidate on request (design 47 H2 H-A-684, H-A-702, H-A-727).
|
||||
const validateTool = "assigner_validate"
|
||||
|
||||
// showKey is the seat mesh-pipeline-runner's verb show, which names a pipeline's candidate (H-A-684 (1), H-A-739).
|
||||
const showKey = "seat:" + mpr.Seat + "." + mpr.VerbShow
|
||||
|
||||
// validateVerbKey is the seat mesh-wants' verb validate, answered by the assigner's process, which keeps the runs (H-A-727).
|
||||
const validateVerbKey = "seat:" + meshwants.Seat + "." + meshwants.VerbValidate
|
||||
|
||||
// validateOnRequest is the process's answer of the seat mesh-wants' verb validate: it reads the pipeline's candidate from the runner's
|
||||
// `show` (H-A-739), answers at once, starting nothing, a pipeline the runner does not know and a candidate the indexer does not
|
||||
// hold; for a run that has ended it answers its verdict, narrowed by the module; otherwise it records the hand act through the seat
|
||||
// mesh-hand-acts with its why (H-A-702) and joins or starts the run `<pipeline>.validate` as the step does (H-A-684 (1), H-A-727),
|
||||
// and answers the run as it stands.
|
||||
func (r *compositionRun) validateOnRequest(ctx context.Context, record func(meshhandactsclient.Request) error, caller string, in meshwants.ValidateInput) (meshwants.ValidateAnswer, error) {
|
||||
why, pipeline := strings.TrimSpace(in.Why), strings.TrimSpace(in.Pipeline)
|
||||
if pipeline == "" || why == "" {
|
||||
return meshwants.ValidateAnswer{}, errors.New("name the pipeline and why its candidate is judged")
|
||||
}
|
||||
couldNot := func(words string) (meshwants.ValidateAnswer, error) {
|
||||
return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: words}, nil
|
||||
}
|
||||
body, said, err := r.callRead(withReadsClock(ctx), showKey, mpr.ShowInput{Pipeline: pipeline, Bound: 4096})
|
||||
if err != nil {
|
||||
return couldNot("the runner's show of " + pipeline + " is not read: " + err.Error())
|
||||
}
|
||||
if body == nil {
|
||||
return couldNot("the runner knows no pipeline " + pipeline + ": " + said)
|
||||
}
|
||||
var shown mpr.ShowAnswer
|
||||
if err := json.Unmarshal(body, &shown); err != nil || shown.Pipeline.Pipeline == "" {
|
||||
return couldNot("the runner's show of " + pipeline + " names no pipeline")
|
||||
}
|
||||
p := shown.Pipeline
|
||||
step := meshwants.StepRun{Pipeline: pipeline, Branch: p.Branch, Revision: p.Revision, Run: p.Run, Source: p.Source, Module: strings.TrimSpace(in.Module),
|
||||
Step: meshwants.StepRunStepValidate}
|
||||
candidate, err := candidateKeyOf(step)
|
||||
if err != nil {
|
||||
return couldNot("the pipeline " + pipeline + " names no candidate: " + err.Error())
|
||||
}
|
||||
if in.Candidate != "" && in.Candidate != candidate {
|
||||
return couldNot(fmt.Sprintf("the candidate %s is not the pipeline %s's, %s", in.Candidate, pipeline, candidate))
|
||||
}
|
||||
if _, err := r.revision(withReadsClock(ctx), step); err != nil {
|
||||
return couldNot(fmt.Sprintf("the indexer holds no candidate %s of the pipeline %s: %v", candidate, pipeline, err))
|
||||
}
|
||||
key, err := validateKeyOf(step)
|
||||
if err != nil {
|
||||
return couldNot(err.Error())
|
||||
}
|
||||
run, _, ok, err := r.runs.read(key)
|
||||
if err != nil {
|
||||
return meshwants.ValidateAnswer{}, err
|
||||
}
|
||||
if !ok || run.Ended == nil {
|
||||
if err := record(meshhandactsclient.Request{What: meshwants.VerbValidate + " " + key, Why: why + " (" + caller + ")", Cause: "validate"}); err != nil {
|
||||
return meshwants.ValidateAnswer{}, fmt.Errorf("the hand act was not recorded, so no run was started: %w", err)
|
||||
}
|
||||
now := r.now().UTC()
|
||||
reader := readerOf("validate."+buildstep.NewID(), step)
|
||||
reader.Ended = &now // a reader of a hand act owes no step end; the run's later steps join it
|
||||
j, err := r.runs.joinAt(key, reader, candidate, "", buildstep.NewID())
|
||||
if err != nil {
|
||||
return meshwants.ValidateAnswer{}, fmt.Errorf("the validate run %s is not joined: %w", key, err)
|
||||
}
|
||||
if j.started {
|
||||
go r.startValidate(r.own, key, j.run, step)
|
||||
}
|
||||
if run, _, ok, err = r.runs.read(key); err != nil || !ok {
|
||||
run = j.run
|
||||
}
|
||||
}
|
||||
run.Key = key
|
||||
return validateAnswerOf(run, step.Module)
|
||||
}
|
||||
|
||||
// validateAnswerOf is the validate run as it stands: running with its start, or its end: passed, failed `cycle` naming the
|
||||
// cycle, failed `manifest-refused` with every problem per manifest (those the case before holds too marked), or could not run with
|
||||
// why; the problems narrowed to module when one is named (H-A-684 (1)).
|
||||
func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.ValidateAnswer, error) {
|
||||
out := meshwants.ValidateAnswer{Run: &run}
|
||||
if run.Ended == nil {
|
||||
out.Outcome, out.Started = meshwants.ValidateAnswerOutcomeRunning, run.Started
|
||||
return out, nil
|
||||
}
|
||||
if run.Outcome != meshwants.CompositionRunOutcomePassed {
|
||||
out.Outcome, out.Why = meshwants.ValidateAnswerOutcomeCouldNotRun, run.Said
|
||||
return out, nil
|
||||
}
|
||||
var v validateVerdict
|
||||
if raw, err := json.Marshal(run.Verdict); err != nil || json.Unmarshal(raw, &v) != nil {
|
||||
out.Outcome, out.Why = meshwants.ValidateAnswerOutcomeCouldNotRun, "the validate run's verdict does not read"
|
||||
return out, nil
|
||||
}
|
||||
if len(v.Cycle) > 0 {
|
||||
out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonCycle
|
||||
for _, a := range v.Cycle {
|
||||
out.Cycle = append(out.Cycle, string(a))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
counted := false
|
||||
for _, name := range slices.Sorted(maps.Keys(v.Change.Manifests)) {
|
||||
read := v.Change.Manifests[name]
|
||||
if read.Accepted || read.Refused == "" || (module != "" && name != module) {
|
||||
continue
|
||||
}
|
||||
held := map[string]bool{}
|
||||
for _, p := range strings.Split(v.Before.Manifests[name].Refused, "\n") {
|
||||
held[p] = true
|
||||
}
|
||||
for _, p := range strings.Split(read.Refused, "\n") {
|
||||
if p != "" {
|
||||
out.Problems = append(out.Problems, meshwants.ValidateAnswerProblemsItem{Module: name, Problem: p, Before: held[p]})
|
||||
counted = counted || !held[p]
|
||||
}
|
||||
}
|
||||
}
|
||||
out.Outcome = meshwants.ValidateAnswerOutcomePassed
|
||||
if counted {
|
||||
out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonManifestRefused
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// validateTools is the module's tool assigner_validate: it reads the pipeline's candidate from the seat mesh-pipeline-runner's `show`
|
||||
// (answering a pipeline the runner does not know, starting nothing), then calls the seat mesh-wants' verb validate, which the
|
||||
// process answers; it writes no state and answers what the verb answers (H-A-727).
|
||||
func validateTools(ask func(string, any) (json.RawMessage, error)) []stdio.Tool {
|
||||
return []stdio.Tool{{Name: validateTool, Description: "Judge a manifest on request (design 47 H2 H-A-684, H-A-702): the manifest validator's verdict " +
|
||||
"on a pipeline's candidate, a delivering pipeline's or a run on request's, the one revision's manifests together. It joins or starts the " +
|
||||
"validate run `<pipeline>.validate` as the step does, so the pipeline's own validate step joins it, recorded as a hand act with why, " +
|
||||
"and answers at once the run as it stands: running, passed, failed (cycle, or manifest-refused with every problem per manifest, those " +
|
||||
"the case before holds too marked) or could-not-run. A pipeline the runner does not know, or a candidate the indexer does not hold, " +
|
||||
"is answered so and starts nothing; a run on request's later steps run until its cancel.",
|
||||
Input: schema(map[string]string{"pipeline": "the pipeline's key as the runner names it", "module": "narrows the answer to one module's manifest", "why": "why the candidate is judged, kept in the hand act"},
|
||||
[]string{"pipeline", "why"}),
|
||||
Run: func(args map[string]any) (any, error) {
|
||||
pipeline, why := strings.TrimSpace(arg(args, "pipeline")), strings.TrimSpace(arg(args, "why"))
|
||||
if pipeline == "" || why == "" {
|
||||
return nil, errors.New("name the pipeline and why its candidate is judged")
|
||||
}
|
||||
body, said, err := unwrapAnswer(ask(showKey, mpr.ShowInput{Pipeline: pipeline, Bound: 4096}))
|
||||
if err != nil || body == nil {
|
||||
return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the runner knows no pipeline " + pipeline + ": " + orWords(said, err)}, nil
|
||||
}
|
||||
var shown mpr.ShowAnswer
|
||||
if err := json.Unmarshal(body, &shown); err != nil || shown.Pipeline.Pipeline == "" {
|
||||
return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the runner's show of " + pipeline + " names no pipeline"}, nil
|
||||
}
|
||||
p := shown.Pipeline
|
||||
candidate, err := candidateKeyOf(meshwants.StepRun{Branch: p.Branch, Revision: p.Revision, Run: p.Run})
|
||||
if err != nil {
|
||||
return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the pipeline " + pipeline + " names no candidate: " + err.Error()}, nil
|
||||
}
|
||||
raw, err := ask(validateVerbKey, meshwants.ValidateInput{Pipeline: pipeline, Candidate: candidate, Module: strings.TrimSpace(arg(args, "module")), Why: why})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out any
|
||||
if err := json.Unmarshal(raw, &out); err != nil {
|
||||
return nil, fmt.Errorf("validate answered what is not JSON: %w", err)
|
||||
}
|
||||
return out, nil
|
||||
}}}
|
||||
}
|
||||
|
||||
// unwrapAnswer reads a verb's answer as a tool call gave it: the body of a good answer, else the holder's words; err when the call
|
||||
// failed.
|
||||
func unwrapAnswer(raw json.RawMessage, err error) (json.RawMessage, string, error) {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
body, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return nil, said, nil
|
||||
}
|
||||
return body, "", nil
|
||||
}
|
||||
|
||||
func orWords(said string, err error) string {
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return said
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer"
|
||||
@@ -64,9 +66,24 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
}
|
||||
return b
|
||||
}
|
||||
// The runner's show of each pipeline it knows (H-A-739): a delivering pipeline's, a run on request's, and one whose candidate the
|
||||
// indexer holds not.
|
||||
shown := map[string]mpr.Pipeline{
|
||||
"main.12": {Pipeline: "main.12", Branch: "main", Revision: 12, Source: 12},
|
||||
"main.run.r1": {Pipeline: "main.run.r1", Branch: "main", Revision: 7, Run: "r1"},
|
||||
"main.50": {Pipeline: "main.50", Branch: "main", Revision: 50, Source: 50},
|
||||
}
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case showKey:
|
||||
var in mpr.ShowInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
p, ok := shown[in.Pipeline]
|
||||
if !ok {
|
||||
return json.Marshal(map[string]string{"error": "no pipeline " + in.Pipeline})
|
||||
}
|
||||
return json.Marshal(mpr.ShowAnswer{Pipeline: p})
|
||||
case mcc.RevisionVerb:
|
||||
var in meshcatalog.RevisionInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
@@ -276,12 +293,99 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
key, _ := validateKeyOf(step("web", 14))
|
||||
run := runs.awaitEach(ctx, []string{key}, nil)[key]
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if run.Ended == nil || run.Outcome != meshwants.CompositionRunOutcomePassed || len(asks) != 5 || asks[4].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.36" {
|
||||
t.Errorf("the validate run its starting step left ended %v %s %q with %d validator asks, want it put after the publish and passed", run.Ended, run.Outcome, run.Said, len(asks))
|
||||
}
|
||||
mu.Unlock()
|
||||
if len(held) < 2 || !strings.HasPrefix(held[len(held)-2], waitOnPublish+"git.novox.be/novox/mesh-sdk/go (") ||
|
||||
!strings.HasPrefix(held[len(held)-1], waitOnBuildNode+" (") || !strings.HasSuffix(held[len(held)-1], ".held.put)") {
|
||||
t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held)
|
||||
}
|
||||
|
||||
// H2 H-A-684, H-A-702, H-A-727, H-A-739 (A5): the verb validate, which the tool assigner_validate calls, joins or starts the run.
|
||||
var acts []meshhandactsclient.Request
|
||||
record := func(q meshhandactsclient.Request) error { acts = append(acts, q); return nil }
|
||||
onRequest := func(pipeline, module, why string) meshwants.ValidateAnswer {
|
||||
t.Helper()
|
||||
a, err := r.validateOnRequest(ctx, record, "op@shanks", meshwants.ValidateInput{Pipeline: pipeline, Module: module, Why: why})
|
||||
if err != nil {
|
||||
t.Fatalf("validate of %s: %v", pipeline, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
if _, err := r.validateOnRequest(ctx, record, "op", meshwants.ValidateInput{Pipeline: "main.12"}); err == nil || len(acts) != 0 {
|
||||
t.Errorf("a call with no why is not refused (%v), or recorded %d hand acts", err, len(acts))
|
||||
}
|
||||
mu.Lock()
|
||||
asked := len(asks)
|
||||
mu.Unlock()
|
||||
if a := onRequest("main.12", "", "judge the fix before its merge"); a.Outcome != meshwants.ValidateAnswerOutcomeRunning || a.Started == nil || len(acts) != 1 ||
|
||||
!strings.Contains(acts[0].What, "main.12"+validateKeySuffix) || !strings.Contains(acts[0].Why, "judge the fix before its merge (op@shanks)") {
|
||||
t.Errorf("a pipeline with no validate run answered %+v after %d hand acts %+v", a, len(acts), acts)
|
||||
}
|
||||
// The pipeline's own validate step joins that run: no second manifest validator is asked.
|
||||
if o := r.validate(ctx, "ask-web-12", meshwants.StepRun{Step: meshwants.StepRunStepValidate, Pipeline: "main.12", Branch: "main", Module: "web", Revision: 12, Source: 12}); o.Outcome != meshwants.StepEndedOutcomeFailed || len(asks) != asked+1 {
|
||||
t.Errorf("the step after the call ended %+v with %d validator asks, want one for the call and the step", o, len(asks)-asked)
|
||||
}
|
||||
// On an ended run it starts nothing, records none and answers its verdict, narrowed by the module.
|
||||
got := onRequest("main.12", "web", "again")
|
||||
if got.Outcome != meshwants.ValidateAnswerOutcomeFailed || got.Reason != meshwants.ValidateAnswerReasonManifestRefused || len(acts) != 1 || len(asks) != asked+1 ||
|
||||
len(got.Problems) != 2 || got.Problems[0].Module != "web" || got.Problems[0].Before || got.Problems[1].Problem != "an inherited problem" || !got.Problems[1].Before {
|
||||
t.Errorf("an ended run answered %+v after %d hand acts and %d asks", got, len(acts), len(asks)-asked)
|
||||
}
|
||||
// An unknown pipeline and a candidate the indexer does not hold are answered so, and start nothing.
|
||||
for _, pipeline := range []string{"main.99", "main.50"} {
|
||||
if a := onRequest(pipeline, "", "why"); a.Outcome != meshwants.ValidateAnswerOutcomeCouldNotRun || a.Why == "" || len(acts) != 1 || len(asks) != asked+1 {
|
||||
t.Errorf("%s answered %+v after %d hand acts, %d asks", pipeline, a, len(acts), len(asks)-asked)
|
||||
}
|
||||
}
|
||||
// H-A-739: a run on request's candidate (run-r1) is judged at the revision show names, 7.
|
||||
if a := onRequest("main.run.r1", "", "judge the run's members"); a.Outcome != meshwants.ValidateAnswerOutcomeRunning || len(acts) != 2 {
|
||||
t.Errorf("a run on request answered %+v after %d hand acts", a, len(acts))
|
||||
}
|
||||
if run, _, ok, _ := runs.read("main.run.r1" + validateKeySuffix); !ok || run.Candidate != "run-r1" {
|
||||
t.Errorf("the run on request's validate run is %+v (kept %v), want its candidate run-r1", run, ok)
|
||||
}
|
||||
}
|
||||
|
||||
// H-A-684 (1), H-A-727, H-A-739: the tool reads the runner's show for the candidate and calls the seat mesh-wants' verb validate with
|
||||
// it, answering what the verb answers; a pipeline the runner does not know is answered so with no verb called, and a call with no
|
||||
// why is refused.
|
||||
func TestTheToolValidateReadsTheCandidateAndCallsTheVerb(t *testing.T) {
|
||||
var verbs []meshwants.ValidateInput
|
||||
ask := func(key string, body any) (json.RawMessage, error) {
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case showKey:
|
||||
var in mpr.ShowInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
if in.Pipeline == "main.12" {
|
||||
return json.Marshal(mpr.ShowAnswer{Pipeline: mpr.Pipeline{Pipeline: "main.12", Branch: "main", Revision: 12}})
|
||||
}
|
||||
return json.Marshal(map[string]string{"error": "no pipeline " + in.Pipeline})
|
||||
case validateVerbKey:
|
||||
var in meshwants.ValidateInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
verbs = append(verbs, in)
|
||||
return json.Marshal(meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomePassed})
|
||||
}
|
||||
return nil, errors.New("no such verb " + key)
|
||||
}
|
||||
tool := validateTools(ask)[0]
|
||||
if d := strings.ToLower(tool.Description); tool.Name != validateTool || !strings.Contains(d, "judge a manifest on request") || !strings.Contains(d, "the manifest validator's verdict") ||
|
||||
!strings.Contains(d, "validate") {
|
||||
t.Errorf("the tool %s says %q", tool.Name, tool.Description)
|
||||
}
|
||||
out, err := tool.Run(map[string]any{"pipeline": "main.12", "module": "web", "why": "before the merge"})
|
||||
if b, _ := json.Marshal(out); err != nil || !strings.Contains(string(b), `"outcome":"passed"`) || len(verbs) != 1 ||
|
||||
verbs[0] != (meshwants.ValidateInput{Pipeline: "main.12", Candidate: "main.12", Module: "web", Why: "before the merge"}) {
|
||||
t.Errorf("a known pipeline answered %s, %v and called the verb with %+v", out, err, verbs)
|
||||
}
|
||||
out, err = tool.Run(map[string]any{"pipeline": "main.99", "why": "why"})
|
||||
if a, _ := out.(meshwants.ValidateAnswer); err != nil || a.Outcome != meshwants.ValidateAnswerOutcomeCouldNotRun || len(verbs) != 1 {
|
||||
t.Errorf("an unknown pipeline answered %+v, %v and called the verb %d times", out, err, len(verbs))
|
||||
}
|
||||
if _, err := tool.Run(map[string]any{"pipeline": "main.12"}); err == nil || len(verbs) != 1 {
|
||||
t.Errorf("a call with no why answered %v and called the verb", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestManifest(t *testing.T) {
|
||||
// which lists and asks again what each node's engine reads.
|
||||
if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assigner_inputs_drop", "assigner_compositions", "assigner_compositions_drop", "assignments", "seat-holders", "wants", "asks",
|
||||
"assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies",
|
||||
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before"}) {
|
||||
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before", "assigner_validate"}) {
|
||||
t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5), assigner_why (design 47 G A-439) and assigner_assignment_drop after assigner_want_drop (design 47 H2 H-A-509)", m.Tools)
|
||||
}
|
||||
if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs {
|
||||
@@ -164,6 +164,7 @@ func TestManifest(t *testing.T) {
|
||||
"seat:mesh-conditions.conditions", // design 47 G §706: the conditions read at each judging of an outside wait
|
||||
"seat:mesh-delivery.source", // §507: the branches the gate keeps a source revision of, before the first registrations
|
||||
"seat:mesh-hand-acts.hand-act", "seat:mesh-hand-acts.hand-acts", "seat:mesh-hand-acts.warranted", // ADR 0565 §9, §11: the seat alone
|
||||
"seat:mesh-pipeline-runner.show", // design 47 H2 H-A-684 (1), H-A-739: the candidate of the pipeline assigner_validate judges
|
||||
"seat:node-backup.backed-up", "seat:node-backup.now",
|
||||
"seat:node-build-go.accept.check", // A-231
|
||||
"seat:node-build-go.answer", // A-254, H-A-412: a composition run's answer over the inline bound, read through the build seat's verb answer
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
"seat:mesh-hand-acts.hand-act",
|
||||
"seat:mesh-hand-acts.hand-acts",
|
||||
"seat:mesh-hand-acts.warranted",
|
||||
"seat:mesh-pipeline-runner.show",
|
||||
"seat:node-backup.backed-up",
|
||||
"seat:node-backup.now",
|
||||
"seat:node-build-go.answer",
|
||||
@@ -140,7 +141,8 @@
|
||||
"assigner_asks",
|
||||
"assigner_ask_drop",
|
||||
"assigner_keep_now",
|
||||
"assigner_validate_before"
|
||||
"assigner_validate_before",
|
||||
"assigner_validate"
|
||||
],
|
||||
"state": [
|
||||
{ "name": "assignments", "history": 64, "max-mib": 8 },
|
||||
|
||||
Reference in New Issue
Block a user