Conversation
There was a problem hiding this comment.
Pull request overview
Adds an envtest-based integration test suite for the Kubernetes controller to validate end-to-end behavior (pod lifecycle → deployment record posting) in a realistic API server environment, plus minimal plumbing to make the controller’s poster mockable.
Changes:
- Introduces
internal/controller/controller_integration_test.gowith envtest setup and multiple controller integration scenarios (deployment lifecycle, init containers, namespace filtering). - Refactors the controller’s
apiClientfield behind a small interface to enable test-time mocking. - Updates
make testand GitHub Actions workflow to install/usesetup-envtestand setKUBEBUILDER_ASSETSfor envtest.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/controller/controller_integration_test.go | New envtest integration tests and helper utilities for controller verification. |
| internal/controller/controller.go | Makes the deployment record poster mockable via an interface. |
| go.mod | Adds controller-runtime (envtest) and testify dependencies. |
| go.sum | Updates sums for newly added/updated dependencies. |
| Makefile | Runs tests with KUBEBUILDER_ASSETS populated via setup-envtest. |
| .github/workflows/build.yml | Installs setup-envtest in CI before running make test. |
Comments suppressed due to low confidence (1)
internal/controller/controller_integration_test.go:108
cache.WaitForCacheSync(ctx.Done(), ...)does not have its own timeout; with a non-cancelledctxthis can block forever and hang the test suite. Consider using acontext.WithTimeout(or a time-bounded channel) specifically for cache sync and fail the test if it doesn’t sync in time.
go func() {
_ = ctrl.Run(ctx, 1)
}()
if !cache.WaitForCacheSync(ctx.Done(), ctrl.podInformer.HasSynced) {
t.Fatal("timed out waiting for informer cache to sync")
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tingx2wang
approved these changes
Feb 27, 2026
malancas
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds integration testing to the controller using https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest
The integration test: