R4g+R5 (mesh-controller): the controller asks no build, build-agent and the merge gate go, register by reference (design 47) #448
@@ -5,6 +5,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -31,6 +32,9 @@ func TestARegistrationAtReferencesWritesItsHandActOnlyWhenItWasMade(t *testing.T
|
||||
fp := fpOf('8')
|
||||
b.indexed(t, "sudo", "7", "novox/mesh-catalog", "modules/sudo", "c0ffee0123456789", fp)
|
||||
ref := "artifact-store://sudo/a/blobs/" + shaOf("hand")
|
||||
// The limit of this test: the artifact store is not on its bus, so the check that the store holds the digest is
|
||||
// stood in for (handStoreHolds, tried by TestAReferenceToRegisterAtIsRefusedUnlessTheStoreHoldsIt); everything after
|
||||
// it - the record, the registration, the hand act - runs for real.
|
||||
was := handStoreHolds
|
||||
handStoreHolds = func(context.Context, *inventory.Inventory, string) error { return nil }
|
||||
t.Cleanup(func() { handStoreHolds = was })
|
||||
@@ -58,8 +62,25 @@ func TestARegistrationAtReferencesWritesItsHandActOnlyWhenItWasMade(t *testing.T
|
||||
if err := registerNow(ctx, open, keys, hand, "sudo", "novox/mesh-catalog", "modules/sudo", map[string]string{"a": ref}, given); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recorded, err := inv0(open).Builds(ctx, "sudo", 1)
|
||||
if err != nil || len(recorded) != 1 || recorded[0].On != "hand" || !strings.HasPrefix(recorded[0].ID, "hand-key-") ||
|
||||
recorded[0].Module != "sudo" || len(recorded[0].Made) != 1 || recorded[0].Made[0].Reference != ref {
|
||||
t.Fatalf("the build recorded by hand: %+v %v", recorded, err)
|
||||
}
|
||||
if byID, found, err := inv0(open).BuildByID(ctx, recorded[0].ID); err != nil || !found || byID.Made[0].Reference != ref {
|
||||
t.Fatalf("the record is not read back by its id: %+v %v %v", byID, found, err)
|
||||
}
|
||||
// Recorded as a build, so the store's sweep holds the blob (internal/artifacts/hold.go).
|
||||
if keep, err := inv0(open).KeepSet(ctx); err != nil || len(keep[ref]) == 0 {
|
||||
t.Fatalf("the sweep would let go of the blob registered by hand: %v %v", keep[ref], err)
|
||||
}
|
||||
if shelf, _ := inv0(open).Catalogue(ctx); shelf["sudo"].Version != "7" {
|
||||
t.Fatalf("sudo is registered at version %q, not the manifest's", shelf["sudo"].Version)
|
||||
}
|
||||
got := acts()
|
||||
if len(got) != 1 || got[0].Verb != "register" || got[0].Why != "the builder cannot build it" {
|
||||
t.Fatalf("the hand act of a registration made: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func inv0(open *stores) *inventory.Inventory { return open.inventory }
|
||||
|
||||
Reference in New Issue
Block a user