Skip to content

test(controllers): migrate core pkg/controllers tests to Ginkgo#5679

Open
hxrshxz wants to merge 7 commits intofluid-cloudnative:masterfrom
hxrshxz:lfx/week-1-pkg-controllers-core-tests
Open

test(controllers): migrate core pkg/controllers tests to Ginkgo#5679
hxrshxz wants to merge 7 commits intofluid-cloudnative:masterfrom
hxrshxz:lfx/week-1-pkg-controllers-core-tests

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 5, 2026

I. Describe what this PR does

This PR migrates core pkg/controllers tests to Ginkgo and keeps runtime-specific coverage out of this change to keep review scope focused.

II. Does this pull request fix one issue?

#5676

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

Converted/covered core controller tests in:

  • pkg/controllers/manager_test.go
  • pkg/controllers/operation_controller_test.go
  • pkg/controllers/suite_test.go
  • pkg/controllers/fake_engine_core_test.go

IV. Describe how to verify it

Run:

go test ./pkg/controllers/ 

V. Special notes for reviews
N/A

Copilot AI review requested due to automatic review settings March 5, 2026 17:42
@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 5, 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

@hxrshxz hxrshxz marked this pull request as draft March 5, 2026 17:42
@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 modernizes the testing infrastructure for the core controller logic by adopting the Ginkgo testing framework. This change aims to improve the maintainability, expressiveness, and consistency of the controller tests. By focusing solely on the core pkg/controllers and deferring runtime-specific test migrations, the PR ensures a streamlined review process and lays a solid foundation for future testing improvements.

Highlights

  • Test Framework Migration: Migrated core pkg/controllers tests from the standard Go testing framework to Ginkgo, enhancing test structure and readability.
  • Focused Scope: The migration intentionally excludes runtime-specific test coverage to maintain a focused review scope for this pull request.
  • New Test Files: Introduced new test files for manager, operation_controller, suite, and a fake_engine_core within the pkg/controllers directory to house the Ginkgo-based tests.
Changelog
  • pkg/controllers/fake_engine_core_test.go
    • Added a new file containing a fake engine core implementation for testing.
  • pkg/controllers/manager_test.go
    • Added new Ginkgo-based tests for NewFluidControllerRateLimiter.
    • Added new Ginkgo-based tests for NewFluidControllerClient and NewCacheClientBypassSecrets.
    • Added new Ginkgo-based tests for GetConfigOrDieWithQPSAndBurst.
  • pkg/controllers/operation_controller_test.go
    • Added extensive Ginkgo-based tests for OperationReconciler functionalities, including engine cache management.
    • Added tests for runtime object retrieval and engine implementation determination.
    • Added tests for finalizer handling and owner reference management.
    • Added tests for various scenarios within the ReconcileInternal logic.
  • pkg/controllers/suite_test.go
    • Added the main Ginkgo test suite setup for the controllers package.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the pull request context.
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.

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 5, 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.

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 migrates core pkg/controllers tests to Ginkgo, significantly improving test coverage and readability. The new tests cover various aspects of the controllers, including rate limiting, client creation, engine caching, and reconciliation logic. The use of parameterized tests with DescribeTable is a good practice for reducing test code duplication.

hxrshxz added 4 commits March 5, 2026 23:17
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the lfx/week-1-pkg-controllers-core-tests branch from 4751f6b to 69d2cd0 Compare March 5, 2026 17:47
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.21%. Comparing base (f966f0f) to head (e8b20c0).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5679      +/-   ##
==========================================
+ Coverage   61.04%   61.21%   +0.16%     
==========================================
  Files         444      444              
  Lines       30540    30540              
==========================================
+ Hits        18643    18694      +51     
+ Misses      10360    10306      -54     
- Partials     1537     1540       +3     

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

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

Migrates core pkg/controllers unit tests from the standard testing style to Ginkgo/Gomega while intentionally excluding runtime-specific coverage to keep scope focused.

Changes:

  • Added a Ginkgo suite bootstrap for pkg/controllers.
  • Ported controller/manager and operation controller tests to Ginkgo/Gomega.
  • Introduced a small fake engine implementation to support controller tests.

Reviewed changes

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

File Description
pkg/controllers/suite_test.go Adds Ginkgo suite entrypoint for the controllers package.
pkg/controllers/operation_controller_test.go Adds Ginkgo-based tests for OperationReconciler behaviors and helpers.
pkg/controllers/manager_test.go Adds Ginkgo-based tests for manager helper functions and rate limiter behavior.
pkg/controllers/fake_engine_core_test.go Adds a fake engine implementation used by controller tests.

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

Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the lfx/week-1-pkg-controllers-core-tests branch from 2cc8621 to 13b970e Compare March 6, 2026 16:29
@hxrshxz hxrshxz marked this pull request as ready for review March 6, 2026 16:29
hxrshxz added 2 commits March 6, 2026 22:13
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

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