diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go index fa91aadb..ae741722 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go @@ -7,14 +7,12 @@ import ( "errors" "fmt" "slices" - "strconv" "sync" "time" nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-sdk/go/keys" ) // The inputs of a composition step (design 47 G ยง354, A-243, A-252): one request per machine, each carrying that machine's input, @@ -28,11 +26,11 @@ const composeCandidateKey = "seat:" + ne.Seat + "." + ne.VerbComposeCandidate func candidateKeyOf(run meshwants.StepRun) (string, error) { switch { case run.Run != "": - return "run-" + run.Run, nil + return nec.RunKey(run.Run) case run.Branch == "" || run.Revision <= 0: return "", errors.New("the step names neither a run on request nor a branch's revision, so no candidate is named") } - return keys.EscapeName(run.Branch) + "." + strconv.FormatInt(run.Revision, 10), nil + return nec.RevisionKey(run.Branch, run.Revision) // built by the seat's client, never by hand (A-226b) } // machinesFor are the machines of a step (A-252): the nodes whose placement of the module names the step's branch (a placement diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go index fee01d44..1499a32b 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) @@ -21,12 +22,21 @@ func TestTheCandidateKeyOfAStep(t *testing.T) { }{ {run: meshwants.StepRun{Run: "r1", Branch: "main"}, want: "run-r1"}, {run: meshwants.StepRun{Branch: "feat/x", Revision: 42}, want: "feat/x.42"}, + {run: meshwants.StepRun{Branch: "main", Revision: 362}, want: "main.362"}, {run: meshwants.StepRun{Branch: "main"}, fail: true}, + {run: meshwants.StepRun{Branch: "main", Revision: 100000000000}, fail: true}, // a number the client's key would read as a heads hash + {run: meshwants.StepRun{Run: "a.b"}, fail: true}, // a run id the client refuses } { got, err := candidateKeyOf(c.run) if (err != nil) != c.fail || got != c.want { t.Errorf("%+v: %q, %v; want %q", c.run, got, err, c.want) } + // A-226b: the node-engine reads every key the step names with the client's one parser. + if !c.fail { + if _, err := nec.ParseCandidateKey(got); err != nil { + t.Errorf("%+v: the key %q is refused by the seat's parser: %v", c.run, got, err) + } + } } }