agent: the parts check counts the templates archives a composition was rendered from as fetched (A-481, A-481a)
compose fills Composed.Templates from the resolved manifest's TemplatesDigest; partsDifference adds them to the digests fetched. Builds: design 47 G A-481, A-481a
This commit is contained in:
@@ -364,33 +364,44 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
|
||||
}
|
||||
// A container's digest is the one after its image's @.
|
||||
container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","image-seat":"mesh-artifact-store","image-holder":"n1","module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}, nil); got != "" {
|
||||
t.Fatalf("a container whose digest is in the parts differs: %q", got)
|
||||
}
|
||||
// A-454: an image the manifest pins from outside, by its digest, is no part of the want's parts, and a mesh-built one still is.
|
||||
upstream := json.RawMessage(`{"id":"web.u","type":"container","name":"web-u","image":"registry@` + d2 + `","module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, upstream}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, upstream}, nil); got != "" {
|
||||
t.Fatalf("an upstream image pinned by its digest is a part: %q", got)
|
||||
}
|
||||
// And neither is the registry seat's copy of an upstream image, though it is routed through the seat.
|
||||
mirrored := json.RawMessage(`{"id":"web.m","type":"container","name":"web-m","image":"store:5000/upstream/docker.io/library/registry@` + d1 + `","image-seat":"container-image-registry","image-holder":"n1","module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, mirrored}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, mirrored}, nil); got != "" {
|
||||
t.Fatalf("an upstream copy served through the registry seat is a part: %q", got)
|
||||
}
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}, nil); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) {
|
||||
t.Fatalf("with only an upstream image the mesh-built one is not missing, or the upstream one is named: %q", got)
|
||||
}
|
||||
// A-454a: a mesh-built image whose seat holder is not on record carries no image-seat; its digest is in the parts, so it is fetched.
|
||||
noSeat := json.RawMessage(`{"id":"web.n","type":"container","name":"web-n","image":"store/web@` + d3 + `","module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat}, nil); got != "" {
|
||||
t.Fatalf("a mesh-built image with no image-seat, named by the parts, is not fetched: %q", got)
|
||||
}
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat, upstream}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat, upstream}, nil); got != "" {
|
||||
t.Fatalf("an upstream image beside it is a part: %q", got)
|
||||
}
|
||||
// A-481: a templates archive the composition was rendered from is fetched, one the want's parts do not name is a part
|
||||
// the composition lacks, and the want's digest nothing read stays not fetched.
|
||||
if got := partsDifference(map[string]string{"web:c": d3, "web:files": d1}, []json.RawMessage{container}, []string{d1}); got != "" {
|
||||
t.Fatalf("a templates archive named by the parts and rendered from is fetched: %q", got)
|
||||
}
|
||||
if got := partsDifference(map[string]string{"web:c": d3, "web:files": d1}, []json.RawMessage{container}, nil); !strings.Contains(got, "in the want's parts and not fetched: "+d1) {
|
||||
t.Fatalf("a templates archive nothing read stays not fetched: %q", got)
|
||||
}
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}, []string{d1}); !strings.Contains(got, "fetched and not in the want's parts: "+d1) {
|
||||
t.Fatalf("a templates archive outside the parts differs: %q", got)
|
||||
}
|
||||
// A-432: a runtime of its own runs the tool runner's program, which the module's parts do not name.
|
||||
ownRuntime := json.RawMessage(`{"id":"web.own-runtime","type":"process","name":"web-runtime","source":"store/node-tools","digest":"` + d1 + `","run":["./node-tools"],"module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}); got != "" {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}, nil); got != "" {
|
||||
t.Fatalf("a runtime of its own differs from the module's parts: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user