Grants: make a pulled-by-kind seat's per-queue workers where the bus lacks them (H-A-468 (3))
"Main's workers are held already" held only while the controller made them: the Node build module's install queue, added since, never had its plain worker, so the module pulled nothing. The account consumers now name each queue's plain worker beside its named one; a held one is left as it is. Builds: design 47 H H-A-468 (third addendum)
This commit is contained in:
@@ -2265,7 +2265,8 @@ func TestGrants(t *testing.T) {
|
||||
|
||||
// H-A-468 (design 47 H2): a seat with an accept that is not pulled by kind gets its one shared worker, SeatQueue's, made by
|
||||
// the grants part where the bus lacks it (its holders bind it, never make it); a seat pulled by kind gets none (its
|
||||
// per-queue workers are its holders' seat traffic's); a worker the bus holds is left as it is, and no pass deletes it.
|
||||
// per-queue workers are its holders' seat traffic's, made too where the bus lacks them: H-A-468, third addendum); a
|
||||
// worker the bus holds is left as it is, and no pass deletes it.
|
||||
t.Run("a seat's shared worker is made where the bus lacks it", func(t *testing.T) {
|
||||
raw, err := os.ReadFile("module.json")
|
||||
if err != nil {
|
||||
@@ -2274,6 +2275,10 @@ func TestGrants(t *testing.T) {
|
||||
b := fixture()
|
||||
b.manifestOf("mesh-grants", string(raw))
|
||||
b.assign("a", "mesh-grants")
|
||||
// H-A-468 (third addendum): a holder of a seat pulled by kind, on a bus that holds one queue's plain worker and lacks
|
||||
// the other's (live, the Node build module's install queue had none and pulled nothing).
|
||||
b.manifestOf("go-builder", `{"module":"go-builder","version":"1","own-secrets":{"broker":"/var/lib/gb/broker"},"claims":[{"name":"node-build-go"}]}`)
|
||||
b.assign("a", "go-builder")
|
||||
b.loaded = shadowOf(t, b)
|
||||
p := partOn(b)
|
||||
p.Create, p.Consumers = b, b
|
||||
@@ -2282,8 +2287,19 @@ func TestGrants(t *testing.T) {
|
||||
"node-build-go": {Seat: "node-build-go", PulledByKind: true, Accepts: []seatdef.Message{{Name: "check"}}},
|
||||
"mesh-wants": {Seat: "mesh-wants", Accepts: []seatdef.Message{{Name: "step"}}},
|
||||
}
|
||||
b.consumers = map[string][]map[string]any{"SEAT_MESH_WANTS": {{"name": "SEAT_MESH_WANTS_worker", "filters": []string{"mesh.seat.mesh-wants.accept.>"}, "max_deliver": 9}}}
|
||||
b.consumers = map[string][]map[string]any{"SEAT_MESH_WANTS": {{"name": "SEAT_MESH_WANTS_worker", "filters": []string{"mesh.seat.mesh-wants.accept.>"}, "max_deliver": 9}},
|
||||
"SEAT_NODE_BUILD_GO": {{"name": "SEAT_NODE_BUILD_GO_CHECK_worker", "filters": []string{"mesh.seat.node-build-go.accept.check"}, "max_deliver": 9}}}
|
||||
res := p.Compose()
|
||||
if !slices.Contains(res.Consumers.Created, "SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_DELIVERY_worker") ||
|
||||
!slices.Contains(res.Consumers.Created, "SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_RECHECK_worker") ||
|
||||
slices.Contains(res.Consumers.Created, "SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker") {
|
||||
t.Errorf("a pulled-by-kind seat's per-queue workers: created %v, want each queue's the bus lacks, the held check worker not", res.Consumers.Created)
|
||||
}
|
||||
for _, c := range b.consumers["SEAT_NODE_BUILD_GO"] {
|
||||
if c["name"] == "SEAT_NODE_BUILD_GO_CHECK_worker" && c["max_deliver"] != 9 {
|
||||
t.Errorf("the held check worker was changed: %v", c)
|
||||
}
|
||||
}
|
||||
var made map[string]any
|
||||
for _, c := range b.consumers["SEAT_MESH_BUILDS"] {
|
||||
if c["name"] == "SEAT_MESH_BUILDS_worker" {
|
||||
@@ -2301,7 +2317,7 @@ func TestGrants(t *testing.T) {
|
||||
t.Errorf("the wants seat's held worker was changed: %v", b.consumers["SEAT_MESH_WANTS"])
|
||||
}
|
||||
p.Compose()
|
||||
if len(b.consumers["SEAT_MESH_BUILDS"]) != 1 || len(b.consumers["SEAT_MESH_WANTS"]) != 1 {
|
||||
if len(b.consumers["SEAT_MESH_BUILDS"]) != 1 || len(b.consumers["SEAT_MESH_WANTS"]) != 1 || len(b.consumers["SEAT_NODE_BUILD_GO"]) != 3 {
|
||||
t.Errorf("a pass changed the seats' workers: %v", b.consumers)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -286,13 +286,21 @@ func AccountConsumers(users []Principal) []ModuleConsumer {
|
||||
out = append(out, mc)
|
||||
}
|
||||
}
|
||||
// A build seat's named workers (design 47 G §544, A-413): the seat traffic of each composed holder names them, and the part makes
|
||||
// them, never only names them in a membership. Main's workers are held already; only the named ones are made here.
|
||||
// A build seat's workers (design 47 G §544, A-413; H2 H-A-468, third addendum): the seat traffic of each composed holder
|
||||
// names them, each queue's plain worker (SEAT_<SEAT>_<QUEUE>_worker) and its named one, and the part makes them where the
|
||||
// bus lacks them, never only names them in a membership. "Main's workers are held already" held only while the
|
||||
// controller made them: a queue added since had none.
|
||||
made := map[string]bool{}
|
||||
for _, p := range users {
|
||||
byKind := map[string]bool{}
|
||||
for _, s := range p.Holds {
|
||||
if s.PulledByKind {
|
||||
byKind[seatStreamName(s.Name)] = true
|
||||
}
|
||||
}
|
||||
_, cs := SeatTrafficObjects([]Principal{p})
|
||||
for _, c := range cs {
|
||||
if !strings.HasSuffix(c.Name, "_named_worker") || made[c.Stream+"."+c.Name] {
|
||||
if !(byKind[c.Stream] || strings.HasSuffix(c.Name, "_named_worker")) || made[c.Stream+"."+c.Name] {
|
||||
continue
|
||||
}
|
||||
made[c.Stream+"."+c.Name] = true
|
||||
|
||||
@@ -62,14 +62,18 @@ func TestNamedAsks(t *testing.T) {
|
||||
t.Errorf("the work queue's consumers: %d, want 4 (a main and a named worker for each of two queues)", len(consumers))
|
||||
}
|
||||
// A-413: the part makes the named workers (AccountConsumers), never only names them in a membership.
|
||||
named := 0
|
||||
// H-A-468 (third addendum): and each queue's plain worker, which a queue added since the controller ended had none of.
|
||||
named, plain := 0, 0
|
||||
for _, mc := range AccountConsumers([]Principal{{Kind: KindModule, Node: "one", Module: "go-module", Holds: []Seat{held}}}) {
|
||||
if strings.HasSuffix(mc.Consumer.Name, "_named_worker") {
|
||||
switch {
|
||||
case strings.HasSuffix(mc.Consumer.Name, "_named_worker"):
|
||||
named++
|
||||
case mc.Consumer.Name == "SEAT_NODE_BUILD_GO_CHECK_worker" || mc.Consumer.Name == "SEAT_NODE_BUILD_GO_DELIVERY_worker":
|
||||
plain++
|
||||
}
|
||||
}
|
||||
if named != 2 {
|
||||
t.Errorf("account consumers hold %d named workers, want 2", named)
|
||||
if named != 2 || plain != 2 {
|
||||
t.Errorf("account consumers hold %d named and %d plain workers, want 2 and 2", named, plain)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user