test(controllers): migrate runtime controller tests to Ginkgo#5680
test(controllers): migrate runtime controller tests to Ginkgo#5680hxrshxz wants to merge 2 commits intofluid-cloudnative:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @hxrshxz. Thanks for your PR. I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing the testing infrastructure for the runtime controller. It migrates existing tests to the Ginkgo/Gomega framework, which provides a more expressive and structured way to write Go tests. This migration, along with the addition of new test cases, significantly improves the unit test coverage for the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Signed-off-by: Harsh <harshmastic@gmail.com>
05acbd3 to
08f12af
Compare
There was a problem hiding this comment.
Code Review
This pull request migrates the runtime controller tests to use the Ginkgo/Gomega framework, significantly expanding test coverage. The changes are well-implemented, with comprehensive test cases for various scenarios, including edge cases and failure modes. The addition of a nil-check in GetRuntimeObjectMeta improves the robustness of the controller. I've left a couple of minor suggestions in the new test file to remove some redundant code. Overall, this is a great contribution to improving the test quality of the project.
There was a problem hiding this comment.
Pull request overview
This PR migrates pkg/controllers/runtime_controller_test.go to the Ginkgo/Gomega BDD testing framework as part of the broader effort to standardize testing across the Fluid project (issue #5676). It also adds a corresponding Ginkgo suite bootstrap file and includes a small production fix to GetRuntimeObjectMeta to handle nil runtime values more defensively.
Changes:
- Added
pkg/controllers/suite_test.go: Ginkgo suite bootstrap for thecontrollerspackage - Added
pkg/controllers/runtime_controller_test.go: Comprehensive Ginkgo-based test coverage forruntime_controller.go(~77.7% coverage) includingNewRuntimeReconciler,ForgetMetrics,ReconcileInternal,ReconcileRuntime,ReconcileRuntimeDeletion, and several helper methods - Modified
pkg/controllers/runtime_controller.go: Added an explicit nil guard inGetRuntimeObjectMetato handlenilruntime interface values safely
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pkg/controllers/suite_test.go |
New Ginkgo suite bootstrap that registers the fail handler and runs all specs under TestControllers |
pkg/controllers/runtime_controller_test.go |
New comprehensive Ginkgo test file exercising all major reconciliation paths with fake clients and a mock RuntimeReconcilerInterface |
pkg/controllers/runtime_controller.go |
Nil check added at the top of GetRuntimeObjectMeta to prevent a panic when ctx.Runtime is a typed nil interface value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5680 +/- ##
=======================================
Coverage 61.21% 61.21%
=======================================
Files 444 444
Lines 30540 30540
=======================================
Hits 18694 18694
Misses 10306 10306
Partials 1540 1540 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Harsh <harshmastic@gmail.com>
e797026 to
f1be066
Compare
|



Ⅰ. Describe what this PR does
Migrate
pkg/controllers/runtime_controller_test.goto Ginkgo/Gomega, add the package suite bootstrap, and expand coverage forpkg/controllers/runtime_controller.goⅡ. Does this pull request fix one issue?
#5676
Ⅲ. List the added test cases
Added unit test coverage for:
NewRuntimeReconcilerForgetMetricsReconcileInternalReconcileRuntimeReconcileRuntimeDeletionruntime_controller.goⅣ. Describe how to verify it
Run:
go test ./pkg/controllers -run TestControllers -count=1go test ./pkg/controllers -run TestControllers -coverprofile=/tmp/runtime_controller_cover.out -coverpkg=./pkg/controllers -count=1Ⅴ. Special notes for reviews
N/A