feat: add local integration testing infrastructure (envtest + kind)#54
feat: add local integration testing infrastructure (envtest + kind)#54ian-flores merged 12 commits intomainfrom
Conversation
- Enable envtest suite: remove Skip(), fix CRD paths, add required schemes - Add Ginkgo-based envtest tests for Site, Connect, Workbench, PackageManager CRDs - Add kind integration tests with make targets (test-kind, test-kind-full) - Add GitHub Actions workflow for CI (envtest on PRs, kind on main/nightly) - Add comprehensive testing documentation Closes #51
|
Claude finished @ian-flores's task —— View job Reviewing PR #54
Review submitted with feedback on:
|
There was a problem hiding this comment.
Review Summary
Good foundation for integration testing infrastructure. A few items to address:
Test Code Issues
internal/controller/core/site_envtest_test.go
-
Misleading test name (line 28): Test says "Should create child resources (Connect, Workbench, etc.)" but only verifies the Site CR was created - no child resources are checked. Either rename to match actual behavior or add child resource assertions (requires starting the controller).
-
Missing cleanup (line 67): The first Site test creates resources but doesn't clean them up, unlike other tests that properly delete their resources. Consider adding
DeferCleanupor explicit cleanup. -
Ineffective validation test (line 83): The "Should reject invalid Site specs" test accepts both success and failure outcomes. If validation behavior is defined, assert it; otherwise consider removing this test.
internal/controller/core/suite_test.go
- Unused helper functions (lines 104-134):
setupSiteControllerForEnvtest()andwaitFor()are defined but never called. Remove dead code or add tests that use them.
Workflow Considerations
.github/workflows/integration-tests.yml
- The
GO_VERSIONenv var (line 43) is set to'1.22'but unused sincego-version-file: go.modis used instead. Consider removing the unused env var.
Documentation
The docs/testing.md is comprehensive and well-structured.
Security Notes
- The
hack/test-kind.shscript uses appropriate practices (set -euo pipefail, proper quoting) - Helm installation uses
--waitand proper timeouts - No credential handling concerns identified
- Rename misleading test "Should create child resources" to accurately describe what it tests (Site CR creation and retrieval) - Add DeferCleanup to first Site test to match cleanup pattern of others - Remove ineffective validation test that accepted both success/failure - Remove unused setupSiteControllerForEnvtest and waitFor helpers - Remove unused GO_VERSION env var from integration-tests.yml
go test ./... with -covermode=atomic fails for packages with no test files in Go 1.25 due to covdata removal. Filter to only packages with test files using go list. Also improves kind integration tests: - Add docker-build and kind-load-image as test-kind prerequisites so the operator image is always present before running tests - Add test_reconciliation to verify the controller creates Connect and Workbench child CRs after a Site CR is applied - Add test_operator_logs to detect panics and confirm reconciliation activity in operator logs
|
@claude review this PR |
|
Claude finished @ian-flores's task —— View job Reviewing PR #54
ReviewSolid infrastructure addition. The two-tier strategy is well-designed and the A few remaining observations: Envtest Tests (
|
|
Addressed all findings in 464ef4d:
|
Local dev loop test ✔Ran the persistent kind workflow end-to-end on the current branch: Cluster creation and operator deployment only happen in |
How kind tests handle secrets without AWS credentialsThe kind tests use When the map is empty (as it is in kind tests — nothing pre-populates it),
|
stevenolen
left a comment
There was a problem hiding this comment.
massive, massive fan of this.
a few stray notes:
- thanks for including the comment about secrets manager. ultimately, i think we need to extract the cloud-specific implementation bits, and formalize/document those integrations -- along with some local replacements for first-class kind support.
- notes/additional pr that shows how to actually interact with the products once they are running in kind would be super cool
# [1.15.0](v1.14.0...v1.15.0) (2026-02-24) ### Features * add local integration testing infrastructure (envtest + kind) ([#54](#54)) ([a5b5751](a5b5751))
Summary
Implements #51: a two-tier local integration testing strategy so developers can validate operator behavior without deploying to staging clusters.
Before: the only way to test controller behavior against a real Kubernetes API was deploying to an internal staging cluster.
After: fast local alternatives that work offline, run in CI, and support an iterative dev loop.
What This Adds
Tier 1: Envtest (~5s, no cluster)
Tests CRD schema validation and API storage against a real embedded K8s API server — no kubelet, no containers, no Docker.
suite_test.go, fixing CRD paths and registering all required schemes (keycloak, traefik, secrets-store-csi-driver)internal/controller/core/site_envtest_test.go)Tier 2: Kind cluster (minutes, full stack)
Tests the full operator Helm deployment and Site CR reconciliation end-to-end against a real cluster.
hack/test-kind.sh— deploys operator via Helm, creates a Site CR, verifies Connect and Workbench child CRs are reconciled, checks operator logs for panics, cleans upmake test-kindrunshelm-generatebefore deploying so the chart is always in sync with the current APIPersistent Dev Loop
Instead of creating and destroying a cluster on every run, developers can keep a cluster alive across iterations:
make kind-setupis idempotent — running it after a code change rebuilds the image, reloads it into kind, and does ahelm upgrade, so it doubles as the "reload" step.CI Integration
api/**,internal/**,cmd/**,Dockerfile,Makefile,go.mod/sum,dist/chart/**,hack/test-kind.sh) via acheck-changesjob usingdorny/paths-filterBug Fix
cleanupLegacyHomeAppwas using a direct type assertion (err.(*meta.NoKindMatchError)) that misses wrapped errors, causing reconciliation to abort on any cluster without the secrets-store CSI driver (e.g. kind). Changed toerrors.As.Documentation
README.md: new Testing section surfacing both the one-shot and dev loop workflows as the primary recommended approachdocs/testing.md: full reference — prerequisites, all targets, development loop, troubleshooting, best practicesTest Plan
make go-testexits cleanlymake test-kind)kind-setup→kind-test→ code change →kind-setup→kind-test→kind-teardownSiteSpec, ranmake test-kind, confirmed the new field appeared in the live CRD schema, reverted