Put the served test's registrations on the bus's chain, and keep the seat-row test on a verb release 6 keeps (issue 1945)
Assignments and builds live on the bus (ADR 0408), so a fixture written before the chain was attached was not what the serving controller read; and push, which the row test used, went with the plans.
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/novox/mesh-controller/internal/broker"
|
"github.com/novox/mesh-controller/internal/broker"
|
||||||
"github.com/novox/mesh-controller/internal/builderkeys"
|
"github.com/novox/mesh-controller/internal/builderkeys"
|
||||||
|
"github.com/novox/mesh-controller/internal/chain"
|
||||||
"github.com/novox/mesh-controller/internal/identity"
|
"github.com/novox/mesh-controller/internal/identity"
|
||||||
"github.com/novox/mesh-controller/internal/inventory"
|
"github.com/novox/mesh-controller/internal/inventory"
|
||||||
)
|
)
|
||||||
@@ -61,37 +62,6 @@ func aServedMesh(t *testing.T) *servedMesh {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A provider and its consumer (bindings_test.go's store and board), registered from done keys of the catalogue's
|
|
||||||
// repository, so each has a fingerprint of the new form; the store holds the mesh's seat on anchor, the board on
|
|
||||||
// laptop is bound to it.
|
|
||||||
shelf := map[string]catalogue.Manifest{}
|
|
||||||
for _, m := range storeManifests() {
|
|
||||||
shelf[m.Module] = m
|
|
||||||
}
|
|
||||||
for i, module := range []string{"store", "board"} {
|
|
||||||
raw, k, trunk := keyOfManifest(t, shelf[module], fpOf(byte('a'+i)), "c0ffee0123456789")
|
|
||||||
keys := trunkKeys{keyBuckets: keyBuckets{keys: map[string]builderkeys.Key{module: aBuilderKey(module, trunk.FP2, k)},
|
|
||||||
manifests: map[string]string{trunk.Manifest: string(raw)}}, trunk: trunk}
|
|
||||||
if _, _, err := takeInKey(ctx, inv, keys, keyTake{Module: module, Trunk: trunk, Ask: registrationAsk{Merge: trunk.Commit}}); err != nil {
|
|
||||||
t.Fatalf("%s is not registered from its key: %v", module, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if _, err := inv.Assign(ctx, "anchor", "store"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := inv.HoldSeat(ctx, "mesh-store", catalogue.ScopeMesh, "anchor", "store"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if _, err := inv.Assign(ctx, "laptop", "board"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := inv.PinProvision(ctx, "laptop", "postgres-database", "anchor", "store"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The bus, running the user list the controller composes from the store, with the builder and the indexer as the
|
// The bus, running the user list the controller composes from the store, with the builder and the indexer as the
|
||||||
// accounts their own manifests make (each writes its own state).
|
// accounts their own manifests make (each writes its own state).
|
||||||
records, err := inv.BusRecords(ctx)
|
records, err := inv.BusRecords(ctx)
|
||||||
@@ -170,6 +140,51 @@ func aServedMesh(t *testing.T) *servedMesh {
|
|||||||
m := &servedMesh{open: open, controller: connect(controller.Username(), password),
|
m := &servedMesh{open: open, controller: connect(controller.Username(), password),
|
||||||
builder: connect(builder.Username(), "pw"), indexer: connect(indexer.Username(), "pw")}
|
builder: connect(builder.Username(), "pw"), indexer: connect(indexer.Username(), "pw")}
|
||||||
|
|
||||||
|
// The test's own inventory on the bus's chain, as the serving controller's will be: what is registered and assigned
|
||||||
|
// below is in the chain it reads (assignments and builds live on the bus, ADR 0408).
|
||||||
|
chainConn, err := nats.Connect(s.ClientURL(), nats.UserInfo(controller.Username(), password),
|
||||||
|
nats.CustomInboxPrefix("_INBOX."+controller.Username()))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Cleanup(chainConn.Close)
|
||||||
|
c, err := chain.OnTheBus(ctx, chainConn, func(context.Context) error { return nil })
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
inv.UseChain(c)
|
||||||
|
|
||||||
|
// A provider and its consumer (bindings_test.go's store and board), registered from done keys of the catalogue's
|
||||||
|
// repository, so each has a fingerprint of the new form; the store holds the mesh's seat on anchor, the board on
|
||||||
|
// laptop is bound to it.
|
||||||
|
shelf := map[string]catalogue.Manifest{}
|
||||||
|
for _, m := range storeManifests() {
|
||||||
|
shelf[m.Module] = m
|
||||||
|
}
|
||||||
|
for i, module := range []string{"store", "board"} {
|
||||||
|
raw, k, trunk := keyOfManifest(t, shelf[module], fpOf(byte('a'+i)), "c0ffee0123456789")
|
||||||
|
keys := trunkKeys{keyBuckets: keyBuckets{keys: map[string]builderkeys.Key{module: aBuilderKey(module, trunk.FP2, k)},
|
||||||
|
manifests: map[string]string{trunk.Manifest: string(raw)}}, trunk: trunk}
|
||||||
|
if _, _, err := takeInKey(ctx, inv, keys, keyTake{Module: module, Trunk: trunk, Ask: registrationAsk{Merge: trunk.Commit}}); err != nil {
|
||||||
|
t.Fatalf("%s is not registered from its key: %v", module, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := inv.Assign(ctx, "anchor", "store"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := inv.HoldSeat(ctx, "mesh-store", catalogue.ScopeMesh, "anchor", "store"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := inv.Assign(ctx, "laptop", "board"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := inv.PinProvision(ctx, "laptop", "postgres-database", "anchor", "store"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// The builder's and the indexer's buckets as their own parts make them, there before the controller starts (its
|
// The builder's and the indexer's buckets as their own parts make them, there before the controller starts (its
|
||||||
// watch of their keys begins at its start); and the plans' buckets a controller of release 5 left.
|
// watch of their keys begins at its start); and the plans' buckets a controller of release 5 left.
|
||||||
for _, b := range []string{sdkdelivery.BuilderBuildsBucket, sdkdelivery.ModulesBucket, sdkdelivery.ManifestsBucket} {
|
for _, b := range []string{sdkdelivery.BuilderBuildsBucket, sdkdelivery.ModulesBucket, sdkdelivery.ManifestsBucket} {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ func TestTheControllersVerbsInTheRowAreTheBinarys(t *testing.T) {
|
|||||||
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
|
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
old := `[{"name":"push","description":"an older push","input":{"type":"object","properties":{"node":{"type":"string"}}}},
|
old := `[{"name":"assign","description":"an older assign","input":{"type":"object","properties":{"node":{"type":"string"}}}},
|
||||||
{"name":"newer","description":"a verb of a newer build"}]`
|
{"name":"newer","description":"a verb of a newer build"}]`
|
||||||
if _, err := inv.store.Pool().Exec(ctx, `update seat set serves = $1 where name = $2`,
|
if _, err := inv.store.Pool().Exec(ctx, `update seat set serves = $1 where name = $2`,
|
||||||
[]byte(old), catalogue.ControllerSeatName); err != nil {
|
[]byte(old), catalogue.ControllerSeatName); err != nil {
|
||||||
@@ -147,9 +147,10 @@ func TestTheControllersVerbsInTheRowAreTheBinarys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
props, _ := verbs["push"].Input["properties"].(map[string]any)
|
// assign, a verb release 6 keeps (push went with the plans, ADR 0539): the row takes the binary's arguments.
|
||||||
if _, takesWhy := props["why"]; !takesWhy || verbs["push"].Description == "an older push" {
|
props, _ := verbs["assign"].Input["properties"].(map[string]any)
|
||||||
t.Fatalf("push in the row is still the older build's: %+v", verbs["push"])
|
if _, takesModule := props["module"]; !takesModule || verbs["assign"].Description == "an older assign" {
|
||||||
|
t.Fatalf("assign in the row is still the older build's: %+v", verbs["assign"])
|
||||||
}
|
}
|
||||||
if _, kept := verbs["newer"]; !kept {
|
if _, kept := verbs["newer"]; !kept {
|
||||||
t.Fatal("a verb only the row has was dropped")
|
t.Fatal("a verb only the row has was dropped")
|
||||||
|
|||||||
Reference in New Issue
Block a user