A bare alive keeps the last real apply: assert that, not a Current the store no longer holds
This commit is contained in:
@@ -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
|
// 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
|
// 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
|
// — 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 {
|
}); err != nil {
|
||||||
t.Fatal(err)
|
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 {
|
currentOf := func(name string) bool {
|
||||||
reports, err := inv.LastReports(ctx)
|
reports, err := inv.LastReports(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,14 +116,14 @@ func TestABareAliveDoesNotWipeTheDeclarationThatSaysANodeIsCurrent(t *testing.T)
|
|||||||
}
|
}
|
||||||
for _, r := range reports {
|
for _, r := range reports {
|
||||||
if r.Node == name {
|
if r.Node == name {
|
||||||
return r.Current
|
return r.Outcome == inventory.OutcomeApplied && r.Declared == digest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Fatalf("no report for %s", name)
|
t.Fatalf("no report for %s", name)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !currentOf("anchor") {
|
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.
|
// Now the node says only that it is there, as it does every minute.
|
||||||
|
|||||||
Reference in New Issue
Block a user