A bare alive keeps the last real apply: assert that, not a Current the store no longer holds

This commit is contained in:
2026-10-24 20:54:41 +02:00
parent 72bbdeed35
commit f0815c4f18
+5 -3
View File
@@ -88,7 +88,7 @@ func TestACleanApplyIsRecordedAsOne(t *testing.T) {
}
}
func TestABareAliveDoesNotWipeTheDeclarationThatSaysANodeIsCurrent(t *testing.T) {
func TestABareAliveDoesNotWipeTheLastRealApply(t *testing.T) {
// A node reports it is alive every minute and describes what it applied rarely. If a bare
// alive were written down as a report it would replace the last real apply with an empty one
// — clearing the declaration digest current is measured against — so a node that had just
@@ -107,6 +107,8 @@ func TestABareAliveDoesNotWipeTheDeclarationThatSaysANodeIsCurrent(t *testing.T)
}); err != nil {
t.Fatal(err)
}
// Whether the last real apply is still there: its outcome and the declaration it was about. Whether a node is current is
// read from its haves (cmd/mesh-controller lastReports), not from a report.
currentOf := func(name string) bool {
reports, err := inv.LastReports(ctx)
if err != nil {
@@ -114,14 +116,14 @@ func TestABareAliveDoesNotWipeTheDeclarationThatSaysANodeIsCurrent(t *testing.T)
}
for _, r := range reports {
if r.Node == name {
return r.Current
return r.Outcome == inventory.OutcomeApplied && r.Declared == digest
}
}
t.Fatalf("no report for %s", name)
return false
}
if !currentOf("anchor") {
t.Fatal("a node that applied exactly what it was sent does not read as current")
t.Fatal("the last real apply is not kept")
}
// Now the node says only that it is there, as it does every minute.