Skip to content

test(thinruntime): add Ginkgo/Gomega unit tests#5694

Open
hxrshxz wants to merge 3 commits intofluid-cloudnative:masterfrom
hxrshxz:test/thinruntime-ginkgo-tests
Open

test(thinruntime): add Ginkgo/Gomega unit tests#5694
hxrshxz wants to merge 3 commits intofluid-cloudnative:masterfrom
hxrshxz:test/thinruntime-ginkgo-tests

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 16, 2026

Ⅰ. Describe what this PR does

Adds Ginkgo/Gomega unit tests for pkg/controllers/v1alpha1/thinruntime and replaces the empty suite bootstrap with the lightweight test pattern used by nearby controller packages. The package now validates controller helpers and key reconciler paths with measured coverage at 79.2%.

Ⅱ. Does this pull request fix one issue?

#5676

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Added unit tests for getRuntime, GetOrCreateEngine, RemoveEngine, the not-found Reconcile path, ControllerName, ManagedResource, NewRuntimeReconciler, and NewCache.

Ⅳ. Describe how to verify it

Run go test -v -coverprofile=/tmp/fluid-thinruntime.cover ./pkg/controllers/v1alpha1/thinruntime/... -count=1 and confirm the package passes with total coverage above 75%. Optionally run go tool cover -func=/tmp/fluid-thinruntime.cover to inspect the 79.2% coverage breakdown.

Ⅴ. Special notes for reviews

N/A

Copilot AI review requested due to automatic review settings March 16, 2026 13:22
@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zwwhdls for approval by writing /assign @zwwhdls in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 16, 2026

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 significantly enhances the testing infrastructure for the thinruntime and juicefs controllers by introducing new Ginkgo/Gomega unit tests. These tests validate core functionalities, controller helpers, and reconciler paths, while also standardizing the test suite setup for a more lightweight and efficient testing approach across both controller types.

Highlights

  • New Unit Tests for ThinRuntime: Comprehensive Ginkgo/Gomega unit tests were added for the pkg/controllers/v1alpha1/thinruntime package, covering getRuntime, GetOrCreateEngine, RemoveEngine, the not-found Reconcile path, ControllerName, ManagedResource, NewRuntimeReconciler, and NewCache.
  • New Unit Tests for JuiceFSRuntime: New Ginkgo/Gomega unit tests were introduced for the pkg/controllers/v1alpha1/juicefs package, validating getRuntime, GetOrCreateEngine, RemoveEngine, Reconcile (not-found path), ControllerName, ManagedResource, NewRuntimeReconciler, and NewCacheOption.
  • Standardized Test Suite Bootstrap: The empty test suite bootstrapping for both thinruntime and juicefs controllers was replaced with a lightweight test pattern, aligning with practices in other controller packages.
  • Improved Test Coverage: The changes validate controller helpers and key reconciler paths, resulting in a measured test coverage of 79.2% for the thinruntime package.
Changelog
  • pkg/controllers/v1alpha1/juicefs/implement_test.go
    • Added new test file containing Ginkgo/Gomega unit tests for JuiceFSRuntimeReconciler methods like getRuntime, GetOrCreateEngine, and RemoveEngine.
  • pkg/controllers/v1alpha1/juicefs/juicefsruntime_controller_test.go
    • Added new test file containing Ginkgo/Gomega unit tests for JuiceFSRuntimeReconciler helper methods such as ControllerName, ManagedResource, NewRuntimeReconciler, and NewCacheOption.
  • pkg/controllers/v1alpha1/juicefs/suite_test.go
    • Modified the test suite to remove extensive bootstrapping, adopting a lightweight pattern for Ginkgo tests.
  • pkg/controllers/v1alpha1/thinruntime/implement_test.go
    • Added new test file containing Ginkgo/Gomega unit tests for ThinRuntimeReconciler methods like getRuntime, GetOrCreateEngine, and RemoveEngine.
  • pkg/controllers/v1alpha1/thinruntime/suite_test.go
    • Modified the test suite to remove extensive bootstrapping, adopting a lightweight pattern for Ginkgo tests.
    • Updated the copyright year in the file header.
  • pkg/controllers/v1alpha1/thinruntime/thinruntime_controller_test.go
    • Added new test file containing Ginkgo/Gomega unit tests for ThinRuntimeReconciler helper methods such as ControllerName, ManagedResource, NewRuntimeReconciler, and NewCache.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Ginkgo/Gomega unit tests for the thinruntime and juicefs controller packages, replacing the heavyweight envtest-based suite bootstrapping with a lightweight fake-client pattern. Tests cover controller helpers (getRuntime, GetOrCreateEngine, RemoveEngine), reconciler construction, cache options, and the not-found reconcile path.

Changes:

  • Added unit tests for thinruntime and juicefs controller packages covering key reconciler methods and helpers
  • Simplified suite_test.go in both packages by removing envtest bootstrapping in favor of a lightweight fake.NullLogger() setup
  • Added new test files implement_test.go and *_controller_test.go in both packages

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/controllers/v1alpha1/thinruntime/thinruntime_controller_test.go New tests for ControllerName, ManagedResource, NewRuntimeReconciler, NewCache
pkg/controllers/v1alpha1/thinruntime/suite_test.go Simplified suite bootstrap, removed envtest dependency
pkg/controllers/v1alpha1/thinruntime/implement_test.go New tests for getRuntime, GetOrCreateEngine, RemoveEngine, Reconcile
pkg/controllers/v1alpha1/juicefs/suite_test.go Simplified suite bootstrap, removed envtest dependency
pkg/controllers/v1alpha1/juicefs/juicefsruntime_controller_test.go New tests for ControllerName, ManagedResource, NewRuntimeReconciler, NewCacheOption
pkg/controllers/v1alpha1/juicefs/implement_test.go New tests for getRuntime, GetOrCreateEngine, RemoveEngine, Reconcile

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

@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 16, 2026

/gemini review

1 similar comment
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 16, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive set of Ginkgo/Gomega unit tests for the thinruntime controller, significantly improving test coverage. The changes also include a valuable refactoring of the test suite setup for both thinruntime and juicefs controllers, replacing the heavier envtest environment with a more lightweight fake client pattern. The new tests are well-structured and cover important controller logic. I've pointed out a minor code duplication in test helpers that could be refactored for better maintainability. Overall, this is a great contribution to improving the test quality of the project.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds valuable unit tests for the thinruntime controller using Ginkgo/Gomega, significantly improving test coverage. The refactoring to a lightweight test pattern by removing envtest is a good simplification for the test suite. I've noticed this pattern has also been applied to the juicefs controller tests, which brings nice consistency. My review includes a couple of suggestions to further improve maintainability and test completeness.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds valuable unit tests for the thinruntime controller and refactors the test suite setup for both thinruntime and juicefs to a simpler, more lightweight pattern. The new tests significantly improve coverage for key controller logic.

My main feedback is regarding the significant code duplication in the newly added test files. Both implement_test.go and ..._controller_test.go files for thinruntime and juicefs are nearly identical. I've left a specific comment with suggestions on how to refactor this into shared test helpers, which would improve the maintainability and extensibility of the test suite.

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.22%. Comparing base (a69c888) to head (c60d0d3).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5694      +/-   ##
==========================================
+ Coverage   61.21%   61.22%   +0.01%     
==========================================
  Files         444      444              
  Lines       30540    30557      +17     
==========================================
+ Hits        18694    18710      +16     
- Misses      10306    10307       +1     
  Partials     1540     1540              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 18, 2026

/gemini review

1 similar comment
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 18, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces unit tests for the thinruntime controller and refactors the testing pattern for it and other controllers like efc and juicefs. The move to a more lightweight approach using fake clients instead of envtest is a great improvement for test speed and simplicity.

The new tests are well-structured and cover key functionalities of the reconcilers.

I've added one comment regarding significant code duplication across the new test files. Refactoring this into a shared testing package would improve maintainability.

Overall, this is a solid contribution that improves the test quality of the controllers.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves test coverage by adding Ginkgo/Gomega unit tests for the thinruntime, efc, and juicefs controllers. The refactoring to a more lightweight test pattern by removing envtest is a welcome improvement for test execution speed. The new tests cover key reconciler paths and helper functions effectively. I have one suggestion to further improve maintainability by reducing code duplication in the test helpers.

@hxrshxz hxrshxz force-pushed the test/thinruntime-ginkgo-tests branch from ac1732f to 0f11364 Compare March 18, 2026 11:01
hxrshxz added 3 commits March 18, 2026 17:34
- Update suite_test.go to Ginkgo v2 (remove deprecated Done channel)
- Add implement_test.go: getRuntime, GetOrCreateEngine, RemoveEngine
- Add juicefsruntime_controller_test.go: ControllerName, ManagedResource,
  NewRuntimeReconciler, NewCacheOption
- Coverage: 79.1% (gate >75% PASS)

Signed-off-by: Harsh <harshmastic@gmail.com>
Remove the duplicate assertion that tested against the unexported
constant; use the string literal form only as suggested by code review.

Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the test/thinruntime-ginkgo-tests branch from 0f11364 to c60d0d3 Compare March 18, 2026 12:05
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants