Skip to content

test(sensor): cover restorePrev, stamp freshness, failed rollbacks and the writable check - #330

Merged
0x73746F66 merged 1 commit into
mainfrom
fix/290-sensor-update-health-tests
Nov 13, 2026
Merged

0x73746F66 merged 1 commit into
mainfrom
fix/290-sensor-update-health-tests

Conversation

@0x73746F66

Copy link
Copy Markdown
Member

Closes #290

What

New cmd/vulnetix-sensor/updatehealth_rules_test.go (plain testing, reusing installed from updatehealth_test.go).

Items 1 and 3 of the card are largely covered already by the scenario tests in updatehealth_test.go (confirm after report, inside-window, failed unit after one minute, outage deferral and its limit, nothing to restore, TestOnlyOneGuardUpdatesAtATime for lockUpdate). This adds what they do not reach:

  • restorePrev: missing .prev (error, binary untouched), empty .prev (error, binary untouched), good .prev (target rewritten 0755, .prev kept).
  • reconcilePending proof rule: a stamp confirms only for the new version written at or after the swap; an older stamp or the old version's stamp is no verdict and the update stays pending.
  • Nothing pending -> no verdict, whatever the unit and network say.
  • A failed rollback (unit failed, no .prev) still appends the release to Bad (after existing entries), clears Pending, and the reason carries both the unit failure and the rollback error.
  • updateSkipReason with a read-only install directory reports "not writable" (skipped as root).

Item 4 (sweepStaleUpdates Lstat/RemoveAll failures) is left out: the only way to make RemoveAll fail portably is permission tricks that root bypasses, and the existing sweep test already pins the counted removals.

Verified

go test -cover ./cmd/vulnetix-sensor/ passes (57.4% -> 57.5%; the rules were mostly reached through scenarios, these pin them directly). gofmt clean.

@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: test-only (cmd/vulnetix-sensor). Tests write stamps through the package's own healthState type and use t.TempDir(); no duplicated update/rollback logic. No changes needed.

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: no reinvented Vulnetix patterns found. The change stays inside the package it covers, uses stdlib/testify helpers already used by the repo's tests, and adds no new client, auth, config-schema or shared-package duplicate (checked internal/testutils and sibling repos). Rebased onto current main locally: go vet and go test pass for every touched package. The earlier red checks (CodeQL Analyze, Install a release with verified provenance, Lockfile) were GitHub API rate-limit failures, not code failures; this will be re-run on a rebased head before merge.

…d the writable check

The scenario tests already drive reconcilePending through confirm,
window, outage and rollback, and lockUpdate. These add the rules they do
not reach: restorePrev's missing, empty and good .prev; a health stamp
counts only for the new version written at or after the swap; nothing
pending is no verdict; a rollback that cannot restore still adds the
release to the bad list with the reason; and updateSkipReason refuses a
read-only install directory.

Closes #290
@0x73746F66
0x73746F66 force-pushed the fix/290-sensor-update-health-tests branch from 4297a7b to 9869f6e Compare November 13, 2026 11:42
@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66
0x73746F66 merged commit 64cd1ba into main Nov 13, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test cmd/vulnetix-sensor reconcilePending verdicts, restorePrev, lockUpdate

1 participant