diff --git a/internal/link/heard_test.go b/internal/link/heard_test.go index 3223374d..999957d6 100644 --- a/internal/link/heard_test.go +++ b/internal/link/heard_test.go @@ -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.