hub v0.181.0 (not deployed): root files are 'behind' only when the files differ (R-1392, decision 304); Go 1.27.4 (R-1391)
gates / gates (push) Successful in 1m55s
gates / gates (push) Successful in 1m55s
This commit is contained in:
1 parent
561a4d98e9
commit
83316fc986
15 files changed
+442
-11
No files matched your search
@@ -14,19 +14,36 @@ func TestBundleCell(t *testing.T) {
|
||||
cur := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"}}}`)
|
||||
old := sys(`{"system":{"config_bundle":{"version":"none"}}}`)
|
||||
drift := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"},"facts":{"host":{"config_bundle":{"version":"0.143.0","drift":["/usr/local/sbin/felhom-pbs-apply"]}}}}}`)
|
||||
if c := bundleCell(cur, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "" || c.Text != "0.143.0" {
|
||||
if c := bundleCell(cur, "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Class != "" || c.Text != "0.143.0" {
|
||||
t.Fatalf("current: %+v", c)
|
||||
}
|
||||
if c := bundleCell(old, "0.143.0", "new", now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" || c.Text != "none" {
|
||||
if c := bundleCell(old, "0.143.0", "new", false, now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" || c.Text != "none" {
|
||||
t.Fatalf("behind 1 h: %+v", c)
|
||||
}
|
||||
if c := bundleCell(old, "0.143.0", "new", now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "bad" {
|
||||
if c := bundleCell(old, "0.143.0", "new", false, now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "bad" {
|
||||
t.Fatalf("behind 8 days: %+v", c)
|
||||
}
|
||||
if c := bundleCell(drift, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "warn" || c.Title == "" {
|
||||
if c := bundleCell(drift, "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Class != "warn" || c.Title == "" {
|
||||
t.Fatalf("drift: %+v", c)
|
||||
}
|
||||
if c := bundleCell(sys(`{}`), "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Text != "unknown" {
|
||||
if c := bundleCell(sys(`{}`), "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Text != "unknown" {
|
||||
t.Fatalf("no stanza: %+v", c)
|
||||
}
|
||||
}
|
||||
|
||||
// R-1392 (`09` §3 decision 304): the same files under an older label are not "behind" — no colour, also after the
|
||||
// alarm's wait; a bundle whose files differ stays amber; drift is still amber.
|
||||
func TestBundleCell_R1392(t *testing.T) {
|
||||
now := time.Date(2026, 11, 14, 10, 0, 0, 0, time.UTC)
|
||||
box := sysfacts.Parse(`{"system":{"config_bundle":{"version":"0.172.1","bundle_sha256":"old"}}}`)
|
||||
if c := bundleCell(box, "0.173.0", "new", true, now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "" || c.Text != "0.172.1" || c.Title == "" {
|
||||
t.Fatalf("same files, new label: %+v", c)
|
||||
}
|
||||
if c := bundleCell(box, "0.173.0", "new", false, now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" {
|
||||
t.Fatalf("different files: %+v", c)
|
||||
}
|
||||
drift := sysfacts.Parse(`{"system":{"config_bundle":{"version":"0.172.1","bundle_sha256":"old"},"facts":{"host":{"config_bundle":{"version":"0.172.1","drift":["/etc/sudoers.d/felhom-agent"]}}}}}`)
|
||||
if c := bundleCell(drift, "0.173.0", "new", true, time.Time{}, 7*24*time.Hour, now); c.Class != "warn" {
|
||||
t.Fatalf("drift under the same files: %+v", c)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user