A module claiming a mesh-scoped seat was granted and issued the seat's subjects on every machine it runs on, so the store's verbs answered from whichever postgres replied first. Where the mesh records the seat's holder, only that (node, module) is now issued it; the module's own tools are untouched everywhere.
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package inventory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/broker"
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
)
|
|
|
|
// novox/hq issue 218: a seat held once for the mesh is granted and issued only to the holder on record;
|
|
// a node seat to every machine's claimant; a mesh seat with no holder on record as derived.
|
|
func TestOnlyTheRecordedHolderHoldsAMeshSeat(t *testing.T) {
|
|
claimed := []broker.Seat{
|
|
{Name: "mesh-store", Scope: catalogue.ScopeMesh},
|
|
{Name: "node-packet-filter", Scope: catalogue.ScopeNode},
|
|
{Name: "unrecorded", Scope: catalogue.ScopeMesh},
|
|
}
|
|
holdings := []catalogue.Held{{Claim: "mesh-store", Scope: catalogue.ScopeMesh, Node: "control", Module: "postgres"}}
|
|
names := func(ss []broker.Seat) (out []string) {
|
|
for _, s := range ss {
|
|
out = append(out, s.Name)
|
|
}
|
|
return
|
|
}
|
|
if got := names(heldHere(claimed, holdings, "control", "postgres")); len(got) != 3 {
|
|
t.Errorf("the holder lost a seat: %v", got)
|
|
}
|
|
got := names(heldHere(claimed, holdings, "other", "postgres"))
|
|
if len(got) != 2 || got[0] != "node-packet-filter" || got[1] != "unrecorded" {
|
|
t.Errorf("a claimant on another machine holds %v; want the node seat and the unrecorded one, not the store", got)
|
|
}
|
|
}
|