mesh/delivery merged: source.main moved to novox/mesh-delivery@71a6a5bf7717
mesh/check pass 22d4cbd14423 on 82180bffd2c6 | unit 22 run, 578 kept | integration 251 run, 425 kept | composition passed on 2 machines
72 lines
3.0 KiB
Go
72 lines
3.0 KiB
Go
package manifest
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"slices"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
func load(t *testing.T) catalogue.Manifest {
|
|
t.Helper()
|
|
raw, err := os.ReadFile("module.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, err := catalogue.ParseManifest(raw)
|
|
if err != nil {
|
|
t.Fatalf("mesh-sdk's manifest reader refuses the manifest: %v", err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// 1297/B2a: the controller's reader (mesh-sdk catalogue, which the controller reads manifests with) takes the
|
|
// manifest; it reads exactly the buckets the assigner opens (the program's list, held equal in its own test), keeps
|
|
// the states it declares (the differences kept read-only, 1906/D5), and holds a credential of its own.
|
|
func TestManifest(t *testing.T) {
|
|
m := load(t)
|
|
if m.Module != "mesh-delivery-assigner" {
|
|
t.Errorf("module = %q", m.Module)
|
|
}
|
|
reads := slices.Clone(m.Reads)
|
|
slices.Sort(reads)
|
|
want := []string{"mesh-build-go.steps", "mesh-controller.assignments", "mesh-controller.builds", "mesh-controller.composed", "mesh-controller.grants",
|
|
"mesh-delivery-builder.builds", "mesh-delivery-indexer.candidates", "mesh-delivery-indexer.manifests",
|
|
"mesh-delivery-indexer.modules", "mesh-delivery-teller.answers", "mesh-delivery-watchman.presence", "node-engine.have"}
|
|
if !reflect.DeepEqual(reads, want) {
|
|
t.Errorf("reads = %v, want exactly %v", reads, want)
|
|
}
|
|
states := map[string]int{}
|
|
for _, s := range m.State {
|
|
states[s.Name] = s.History
|
|
}
|
|
if want := map[string]int{"asks": 5, "compositions": 5, "differences": 64, "puts": 20, "wants": 20}; !reflect.DeepEqual(states, want) {
|
|
t.Errorf("state = %v, want %v", states, want)
|
|
}
|
|
if _, ok := m.OwnSecrets["broker"]; !ok || len(m.OwnSecrets) != 1 {
|
|
t.Errorf("own-secrets = %v, want exactly broker (or no credential is issued)", m.OwnSecrets)
|
|
}
|
|
if m.SecretsOwner != "mesh-delivery-assigner" {
|
|
t.Errorf("secrets-owner = %q", m.SecretsOwner)
|
|
}
|
|
// 1906/D3: it says its conditions on the operator channel; 1622: it puts its compose asks on the Go build seat, as the
|
|
// checker puts its checks.
|
|
if !slices.Equal(m.Uses, []string{"node-build-go", "operator-channel"}) {
|
|
t.Errorf("uses = %v, want exactly node-build-go and operator-channel", m.Uses)
|
|
}
|
|
// ADR 0546: it serves its own tools (put, release, puts) from its bundle through the tool runner (the artifact loads the
|
|
// module), claims no seat (a new seat needs a change of the controller), says each put's step as the event put, and
|
|
// calls the controller's warranted and the bus node's backup holder.
|
|
if len(m.Claims) != 0 || !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts"}) {
|
|
t.Errorf("the assigner claims %v and serves tools %v, want no claim and its three put tools", m.Claims, m.Tools)
|
|
}
|
|
if want := []string{"seat:mesh-controller.warranted", "seat:node-backup.backed-up", "seat:node-backup.now"}; !slices.Equal(slices.Sorted(slices.Values(m.Invokes)), want) {
|
|
t.Errorf("invokes = %v, want %v", m.Invokes, want)
|
|
}
|
|
if !slices.Equal(m.Emits, []string{"put"}) {
|
|
t.Errorf("emits = %v, want put", m.Emits)
|
|
}
|
|
}
|