Hold in a unit table which haves count a module as run inside the node's own composition, so a failed have naming nothing is caught without H8's timing (issue 1126, review round 2)
This commit is contained in:
@@ -779,3 +779,37 @@ func (r fixedReader) Archive(_ context.Context, url, _ string) ([]byte, error) {
|
||||
func (r fixedReader) Served(context.Context, string, string, []string) (map[string]any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// TestAHaveSaysWhetherItsModuleRunsInsideTheNodesOwn feeds takeModuleHave a module's have and reads whether the node
|
||||
// counts the module as run inside its own composition (issue 1126, review round 2): a failed have that names nothing
|
||||
// it runs (NotComposed before the module ever ran) is not, so the next composition does not take the module from its
|
||||
// manifest past its build.
|
||||
func TestAHaveSaysWhetherItsModuleRunsInsideTheNodesOwn(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
have delivery.Have
|
||||
in bool
|
||||
}{
|
||||
{"failed, naming nothing it runs", delivery.Have{Phase: delivery.PhaseFailed, Health: delivery.HealthFailed,
|
||||
Detail: "the node cannot compose it, and keeps running what it ran: no build"}, false},
|
||||
{"failed at a build fingerprint", delivery.Have{FP: "build-0123abcd", Composed: "sha256:" + strings.Repeat("c", 64), Phase: delivery.PhaseFailed,
|
||||
Health: delivery.HealthFailed, Detail: "the node cannot compose it, and keeps running what it ran: no build"}, true},
|
||||
{"running with no fingerprint (mesh-wireguard)", delivery.Have{Phase: delivery.PhaseRunning, Health: delivery.HealthOK}, true},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
c := New(Env{Node: "n1"})
|
||||
key, err := delivery.HaveKey("n1", "web")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
value, err := delivery.EncodeHave(row.have)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.takeModuleHave(agent.Update{Key: key, Value: value})
|
||||
if c.inOwn["web"] != row.in {
|
||||
t.Errorf("web counted inside the node's own composition: %v, want %v", c.inOwn["web"], row.in)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user