The node-engine composes nothing of a package artifact (H-A-466)
A package is a build input published to a registry, never placed on a machine, and no registry seat the engine reads numbers it: asking its digest failed the whole build, so a module declaring a package (the indexer, the forge bridge) was wanted and held. The engine now leaves package artifacts out of what it resolves (lookUp), holds (partsMissing), builds (buildOf) and takes in (takein.Manifest, takein.Built, and the manifest handed to Resolve), and so does the candidate compose, which shares partsOf. Builds: design 47 H2 H-A-466
This commit is contained in:
@@ -14,6 +14,9 @@ import (
|
||||
|
||||
"github.com/novox/mesh-host/internal/agent"
|
||||
"github.com/novox/mesh-host/internal/nodegrant"
|
||||
"github.com/novox/mesh-host/internal/takein"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
@@ -36,15 +39,26 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
}}}
|
||||
entry := meshcatalog.CatalogEntry{Module: "mail", Fp: fp, Manifest: manifest, Artifacts: []meshcatalog.Artifact{
|
||||
{Ref: "mail:server", Kind: "upstream"}, {Ref: "mail:files", Kind: "archive"}, {Ref: "mail:web", Kind: "image"}}}
|
||||
// H-A-466: a build with a bundle and a package resolves the bundle's digest alone; no digest is asked of the package, a build
|
||||
// input never placed, and nothing is held for it.
|
||||
fpPkg := meshcatalogclient.SourcePrefix2 + strings.Repeat("b", 64)
|
||||
withPackage := meshcatalog.CatalogEntry{Module: "mail", Fp: fpPkg, Manifest: map[string]any{"module": "mail", "version": "1",
|
||||
"build": map[string]any{"artifacts": []any{
|
||||
map[string]any{"name": "tools", "kind": "bundle", "language": "go", "from": "tools"},
|
||||
map[string]any{"name": "mailapi", "kind": "package", "language": "go", "from": "api"},
|
||||
}}}, Artifacts: []meshcatalog.Artifact{{Ref: "mail:tools", Kind: "bundle", Language: "go"},
|
||||
{Ref: "mail:mailapi", Kind: "package", Language: "go", Package: &meshcatalog.ArtifactPackage{Name: "git.example/mail/api"}}}}
|
||||
// The seats hold mail/files and mail/web; versions newest first.
|
||||
held := map[string]string{
|
||||
"oci-artifact-registry.mail/files": `{"name":"mail/files","versions":[{"name":"mail/files","kind":"archive","digest":"` + d("2") + `","version":"1.3.0"},{"name":"mail/files","kind":"archive","digest":"` + d("1") + `","version":"1.2.3"}]}`,
|
||||
"container-image-registry.mail/web": `{"name":"mail/web","versions":[{"name":"mail/web","kind":"image","digest":"` + d("3") + `","version":"1.2.3"}]}`,
|
||||
"container-image-registry.mail/other": `{"name":"mail/other","versions":[]}`,
|
||||
"oci-artifact-registry.mail/tools": `{"name":"mail/tools","versions":[{"name":"mail/tools","kind":"bundle","digest":"` + d("4") + `","version":"1.2.3"}]}`,
|
||||
}
|
||||
for name, row := range map[string]struct {
|
||||
want meshwants.WantsByWantNodeModuleValue
|
||||
down string // a seat whose call fails
|
||||
entry *meshcatalog.CatalogEntry // the build's entry, the one above when nil
|
||||
down string // a seat whose call fails
|
||||
parts map[string]string
|
||||
missing string // a word the reason holds
|
||||
said []string
|
||||
@@ -55,6 +69,8 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
missing: "2.0.0", said: []string{"mail at version 2.0.0", "oci-artifact-registry", "container-image-registry"}},
|
||||
"a seat that does not answer": {want: meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: "1.2.3", Self: true}, down: "container-image-registry",
|
||||
missing: "mail:web", said: []string{"mail at version 1.2.3: the seat container-image-registry"}},
|
||||
"a package artifact": {want: meshwants.WantsByWantNodeModuleValue{Fp: fpPkg, Version: "1.2.3", Self: true}, entry: &withPackage,
|
||||
parts: map[string]string{"mail:tools": d("4")}},
|
||||
} {
|
||||
var mu sync.Mutex
|
||||
var said []string
|
||||
@@ -77,11 +93,15 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
||||
return nil, errors.New("not asked")
|
||||
})
|
||||
entry := entry
|
||||
if row.entry != nil {
|
||||
entry = *row.entry
|
||||
}
|
||||
c := New(env)
|
||||
c.wants["mail"] = row.want
|
||||
c.keptEnt[fp] = keptEntry{entry: entry}
|
||||
c.keptEnt[entry.Fp] = keptEntry{entry: entry}
|
||||
parts, missing := c.partsOf("mail", entry, row.want)
|
||||
b := c.buildOf("mail", fp)
|
||||
b := c.buildOf("mail", entry.Fp)
|
||||
if row.missing != "" {
|
||||
if parts != nil || b != nil || !strings.Contains(missing, row.missing) {
|
||||
t.Errorf("%s: parts %v, build %v, missing %q: want the module held whole, naming %s", name, parts, b, missing, row.missing)
|
||||
@@ -97,16 +117,28 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
if missing != "" || len(parts) != len(row.parts) {
|
||||
t.Fatalf("%s: parts %v, missing %q", name, parts, missing)
|
||||
t.Fatalf("%s: parts %v, missing %q (said %q)", name, parts, missing, said)
|
||||
}
|
||||
if held := c.entryHolds()["mail"]; held != "" {
|
||||
t.Errorf("%s: the module is held: %s", name, held)
|
||||
}
|
||||
for ref, digest := range row.parts {
|
||||
if parts[ref] != digest {
|
||||
t.Errorf("%s: %s at %s, want %s", name, ref, parts[ref], digest)
|
||||
}
|
||||
}
|
||||
if b == nil || len(b.Artifacts) != 3 {
|
||||
if b == nil || len(b.Artifacts) != len(row.parts) {
|
||||
t.Fatalf("%s: build %+v", name, b)
|
||||
}
|
||||
// The take-in of the build's manifest passes: no package is counted as missing or waited on (H-A-466).
|
||||
raw, _ := json.Marshal(entry.Manifest)
|
||||
m, err := catalogue.Decode(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
if _, err := takein.Manifest(context.Background(), m, *b, nil); err != nil {
|
||||
t.Errorf("%s: the take-in refused the build: %v", name, err)
|
||||
}
|
||||
for _, a := range b.Artifacts {
|
||||
if a.Digest != row.parts["mail:"+a.Name] || a.Reference != referenceOf("mail", a.Name, a.Digest) {
|
||||
t.Errorf("%s: artifact %+v", name, a)
|
||||
|
||||
Reference in New Issue
Block a user