Skip to content

test(controller): rewrite envtest suite to run a real Manager - #70

Merged
bittermandel merged 1 commit into
mainfrom
jg/envtest-manager
Apr 30, 2026
Merged

bittermandel merged 1 commit into
mainfrom
jg/envtest-manager

Conversation

@bittermandel

Copy link
Copy Markdown
Contributor

No description provided.

The previous suite started envtest but constructed reconcilers ad-hoc
and called Reconcile() once per test. That skipped watches, requeues,
finalizers, and field-managed updates — so the four scaffold tests for
Project/Branch/Pageserver/Safekeeper were essentially compile checks
(none of them set required spec fields, none of them asserted
post-reconcile state).

Rewrites suite_test.go to start a controller-runtime Manager with all
five reconcilers registered, fakes.StorageController wired into
Project/Branch via the StorageControllerBaseURL injection, and a goroutine
holding mgr.Start. Tests now create CRs through the client and use
Eventually(...) to assert observed state — which is what the Manager
actually drives.

Drops the four scaffold tests (project/branch/pageserver/safekeeper) —
they tested nothing the new Manager-based suite doesn't already exercise,
and downstream tasks (#9 StatefulSets, #11 webhooks, #12 finalizers, etc.)
will write real tests against this foundation.

Rewrites cluster_controller_test as the proof of concept: applies a
Cluster + its bucket-creds and storcon-db Secrets via fixtures, then
Eventually-asserts that the JWT signing Secret, storage-controller
Deployment, and storage-broker Deployment all appear — none of which the
test itself created. Test takes ~6s end-to-end.

internal/controller coverage drops from 45.1% to 16.9% because the
previous number was inflated by tests that asserted nothing. The new
number reflects actual paths exercised through the cluster reconciler;
future tasks restore the rest with real coverage.
@bittermandel
bittermandel merged commit cc8d655 into main Apr 30, 2026
5 checks passed
@bittermandel
bittermandel deleted the jg/envtest-manager branch April 30, 2026 17:20
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.

1 participant