Skip to content

Comments

feat: add local integration testing infrastructure (envtest + kind)#54

Draft
ian-flores wants to merge 4 commits intomainfrom
issue-51-integration-tests
Draft

feat: add local integration testing infrastructure (envtest + kind)#54
ian-flores wants to merge 4 commits intomainfrom
issue-51-integration-tests

Conversation

@ian-flores
Copy link
Collaborator

@ian-flores ian-flores commented Jan 27, 2026

Summary

Implements issue #51: a two-tier local integration testing strategy, so developers can validate controller behavior without deploying to staging clusters.

Previously: the only way to test controller behavior against a real Kubernetes API was deploying to internal staging. This adds fast local alternatives.

What This Adds

Tier 1: Envtest (~5s, API-level)

Tests CRD schema validation, resource creation, and reconciliation against a real K8s API server — no kubelet or containers required.

  • Enabled the previously-skipped envtest suite in suite_test.go, fixing CRD paths and registering all required schemes (keycloak, traefik, secrets-store-csi-driver)
  • Added 4 Ginkgo specs covering Site, Connect, Workbench, and PackageManager CRDs (internal/controller/core/site_envtest_test.go)

Tier 2: Kind cluster (minutes, full stack)

Tests full operator Helm deployment and Site CR reconciliation against a real cluster with containers running.

  • Added hack/test-kind.sh — sets up cluster, deploys operator via Helm, creates a Site CR, verifies the controller reconciles it by checking Connect and Workbench child CRs are created, checks operator logs for panics, then cleans up
  • Added Makefile targets: kind-create, kind-delete, kind-load-image, test-kind, test-kind-full, test-integration

CI Integration

  • integration-tests.yml: envtest runs on every PR; kind tests run after merge to main and nightly (too slow for every PR)

Documentation

  • docs/testing.md: prerequisites, usage for all targets, troubleshooting, best practices for writing new tests

Test Plan

  • Envtest suite passes (4 specs, ~5s)
  • All existing unit tests continue to pass
  • make go-test exits cleanly (fixed Go 1.25 covdata issue for packages with no test files)
  • CI workflow runs successfully
  • Kind tests work in CI environment (run post-merge to main and nightly — not on PRs by design)

- 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
Copy link

claude bot commented Jan 27, 2026

Claude finished @ian-flores's task —— View job


Reviewing PR #54

  • Read review guidelines
  • Create pending review
  • Analyze code changes
  • Add inline review comments
  • Submit review

Review submitted with feedback on:

  • Test name/behavior mismatch in site_envtest_test.go
  • Missing cleanup in Site creation test
  • Ineffective validation test
  • Unused helper functions in suite_test.go
  • Unused GO_VERSION env var in workflow

Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Review Summary

Good foundation for integration testing infrastructure. A few items to address:

Test Code Issues

internal/controller/core/site_envtest_test.go

  1. 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).

  2. 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 DeferCleanup or explicit cleanup.

  3. 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

  1. Unused helper functions (lines 104-134): setupSiteControllerForEnvtest() and waitFor() are defined but never called. Remove dead code or add tests that use them.

Workflow Considerations

.github/workflows/integration-tests.yml

  1. The GO_VERSION env var (line 43) is set to '1.22' but unused since go-version-file: go.mod is used instead. Consider removing the unused env var.

Documentation

The docs/testing.md is comprehensive and well-structured.

Security Notes

  • The hack/test-kind.sh script uses appropriate practices (set -euo pipefail, proper quoting)
  • Helm installation uses --wait and 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
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