Skip to content

tighten k8s tests - #191

Merged
atkrad merged 1 commit into
mainfrom
tighten-k8s-tests
Oct 13, 2026
Merged

atkrad merged 1 commit into
mainfrom
tighten-k8s-tests

Conversation

@atkrad

@atkrad atkrad commented Oct 13, 2026

Copy link
Copy Markdown
Member

Summary

Pod, component, and certificate helpers now have tests for the failures a caller can see: a missing object, an API error, a bad name, and a certificate that should be replaced. Job creation reports leftover objects when a rollback delete fails. Selector checks assert the selector string in the test. Watch tests run in parallel.

Production behavior is unchanged.

Testing principles covered:

  • Failure paths: invalid input, API errors, cancellation, cleanup failure, version bounds, and certificate expiry
  • Parallel tests: t.Parallel on the watch cases
  • Assertions: ErrorIs for sentinels and context.Canceled, ErrorContains where the message is the contract
  • Tables: selector cases keep the assertion in the test, with a name for each case
  • Determinism: GetAvailableComponents walks a map, so the test checks membership

Test plan

  • Unit tests added/updated
  • go test -race -shuffle=on -count=1 ./internal/k8s/ passed, then passed again on a second shuffle
  • golangci-lint run ./internal/k8s/ passed, and the pre-commit hook passed
  • Scenario under scenarios/ (if behavior changes)
  • Manual smoke (command + expected result), if user-facing

Remaining

GetAvailableComponents returns names in map iteration order. The test checks membership.

A running pod with no container statuses counts as ready. The ready-count test includes that pod.

The fake client ignores field selectors. Tests for running pods check that the list request asks for status.phase=Running.

Labels

  • kind/chore
  • skip-changelog (internal tests)

Checklist

  • Title is short and imperative (matches commit style)
  • Docs / CLI help left unchanged (no user-facing behavior change)
  • No secrets or local-only paths in the diff

- cover pod queries, certificate reuse, and job cleanup failures
- reject bad selectors before listing, and name version parse cases
@atkrad atkrad added kind/chore Cleanup, deps, CI, or refactor with no user-facing change skip-changelog Exclude this PR from release notes labels Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@atkrad
atkrad merged commit fd4208e into main Oct 13, 2026
17 checks passed
@atkrad
atkrad deleted the tighten-k8s-tests branch October 13, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore Cleanup, deps, CI, or refactor with no user-facing change skip-changelog Exclude this PR from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant