With no plan left to name a build or a send to keep the plans, a want names what a collection must keep, and the composition is where the provisioner's plans are composed for the assignments mirror (ADR 0539 clauses 1 and 5); the assignments no longer name a node's build, so the controller replaced is the newest earlier build of it.
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// 1945 (dev-r6-controller's finding): the provisioner's plans a composition hands are kept in the shape the
|
|
// assignments mirror reads (inventory.SentProvisioningPlans: each module's plan and what requires it), and a
|
|
// composition that hands none keeps none.
|
|
func TestAComposedNodesProvisionerPlansAreKept(t *testing.T) {
|
|
if plansKept(sendable{}) != nil {
|
|
t.Errorf("a composition that hands nothing kept plans")
|
|
}
|
|
d := sendable{plans: map[string]catalogue.Plan{"umami": {Placement: map[string]string{"dir:state": "/var/lib/umami"}}},
|
|
requiredBy: map[string]string{"umami": "analytics"}}
|
|
var kept map[string]struct {
|
|
Placement map[string]string `json:"placement"`
|
|
RequiredBy string `json:"required-by"`
|
|
}
|
|
if err := json.Unmarshal(plansKept(d), &kept); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if kept["umami"].Placement["dir:state"] != "/var/lib/umami" || kept["umami"].RequiredBy != "analytics" {
|
|
t.Errorf("kept %+v", kept)
|
|
}
|
|
}
|