Skip to content

test(fluidapp): migrate controller tests to Ginkgo/Gomega#5684

Open
hxrshxz wants to merge 1 commit intofluid-cloudnative:masterfrom
hxrshxz:test/fluidapp-ginkgo-migration
Open

test(fluidapp): migrate controller tests to Ginkgo/Gomega#5684
hxrshxz wants to merge 1 commit intofluid-cloudnative:masterfrom
hxrshxz:test/fluidapp-ginkgo-migration

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 8, 2026

Ⅰ. Describe what this PR does

Migrate unit tests in pkg/controllers/v1alpha1/fluidapp/ from testing.T to Ginkgo/Gomega, adding suite bootstraps, migrating existing table-driven tests, and expanding coverage to 85.2% for the main package.

Ⅱ. 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 suite_test.go bootstraps for fluidapp and dataflowaffinity subpackages
  • Migrated umountFuseSidecars and umountFuseSidecar tests to Ginkgo Describe/Context/It with Gomega matchers; added error-path cases for "not mounted" and "exit code 137"
  • Migrated injectPodNodeLabelsToJob and fillCustomizedNodeAffinity tests to Ginkgo/Gomega
  • Added new unit tests for FluidAppReconciler and DataOpJobReconciler controller lifecycle methods (ControllerName, ManagedResource, NewFluidAppReconciler, Reconcile, internalReconcile)
  • All original test scenarios preserved with behavior parity; no testify imports remain

Ⅳ. Describe how to verify it

go test ./pkg/controllers/v1alpha1/fluidapp/... -v -count=1

Ⅴ. Special notes for reviews

N/A

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

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

@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 refactors the testing infrastructure for the fluidapp controller and its related dataflow affinity components. The primary goal is to modernize the unit testing framework by adopting Ginkgo and Gomega, which provides a more expressive and robust way to write tests. This migration not only improves the maintainability and readability of the tests but also expands test coverage by addressing various edge cases and controller lifecycle methods, ultimately leading to a more reliable and thoroughly tested codebase.

Highlights

  • Testing Framework Migration: The unit tests in pkg/controllers/v1alpha1/fluidapp/ and its subpackages have been migrated from the standard testing.T framework to Ginkgo/Gomega, enhancing test readability and structure.
  • New Test Suites: Dedicated suite_test.go files have been added for both fluidapp and dataflowaffinity subpackages to bootstrap the Ginkgo test suites.
  • Expanded Test Coverage: Existing table-driven tests for functions like umountFuseSidecars, umountFuseSidecar, injectPodNodeLabelsToJob, and fillCustomizedNodeAffinity have been migrated and expanded with new error-path cases and edge scenarios (e.g., 'not mounted' errors, exit code 137, non-existent labels, nil annotations).
  • New Controller Lifecycle Tests: New unit tests have been added for FluidAppReconciler and DataOpJobReconciler controller lifecycle methods, including ControllerName, ManagedResource, NewFluidAppReconciler, Reconcile, and internalReconcile.
  • Test Parity and Cleanup: All original test scenarios have been preserved with behavior parity, and all testify imports have been removed, streamlining the testing dependencies.
Changelog
  • pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/dataflowaffinity_controller_test.go
    • Migrated existing injectPodNodeLabelsToJob tests to Ginkgo/Gomega.
    • Added new Ginkgo/Gomega tests for ControllerName, ManagedResource, and NewDataOpJobReconciler methods.
    • Expanded fillCustomizedNodeAffinity tests with cases for non-existent labels and whitespace handling.
    • Added new test cases for injectPodNodeLabelsToJob covering scenarios like failed pods, pods without node names, and jobs with nil annotations.
  • pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/suite_test.go
    • Added Ginkgo test suite bootstrap.
  • pkg/controllers/v1alpha1/fluidapp/fluidapp_controller_test.go
    • Added new Ginkgo/Gomega tests for FluidAppReconciler methods: ControllerName, ManagedResource, NewFluidAppReconciler, Reconcile, and internalReconcile.
  • pkg/controllers/v1alpha1/fluidapp/implement_test.go
    • Migrated existing umountFuseSidecars tests to Ginkgo/Gomega.
    • Added new Ginkgo/Gomega tests for NewFluidAppReconcilerImplement.
    • Introduced new test cases for umountFuseSidecar to cover scenarios like empty container names, 'not mounted' errors, and exit code 137 during execution.
  • pkg/controllers/v1alpha1/fluidapp/suite_test.go
    • Added Ginkgo test suite bootstrap.
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 8, 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 primarily focuses on migrating existing unit tests from the standard Go testing package to the Ginkgo and Gomega testing framework across several controller packages. Specifically, tests in dataflowaffinity_controller_test.go and implement_test.go were refactored into Describe/Context/It blocks, replacing func Test... with Ginkgo's declarative style and Expect assertions. New suite_test.go files were introduced for both dataflowaffinity and fluidapp packages to set up the Ginkgo test suites. Additionally, a new fluidapp_controller_test.go file was added to include Ginkgo tests for the FluidAppReconciler, covering its core functionalities like ControllerName, ManagedResource, NewFluidAppReconciler, Reconcile scenarios, and internalReconcile logic, including handling fuse sidecars. The changes aim to improve test readability, structure, and maintainability by adopting the Ginkgo/Gomega framework.

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 pkg/controllers/v1alpha1/fluidapp/ controller unit tests from testing.T to the repository’s Ginkgo v2/Gomega BDD style, introducing Ginkgo suite bootstraps and expanding scenario coverage for reconciler and helper behaviors.

Changes:

  • Added Ginkgo/Gomega suite bootstraps for fluidapp and fluidapp/dataflowaffinity.
  • Rewrote existing unit tests in fluidapp and dataflowaffinity packages into Describe/Context/It structure with Gomega assertions.
  • Added additional unit tests for FluidAppReconciler and DataOpJobReconciler controller methods and error paths.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/controllers/v1alpha1/fluidapp/suite_test.go Adds Ginkgo suite bootstrap for the fluidapp package.
pkg/controllers/v1alpha1/fluidapp/implement_test.go Migrates umountFuseSidecars/umountFuseSidecar tests to Ginkgo/Gomega and adds error-path cases.
pkg/controllers/v1alpha1/fluidapp/fluidapp_controller_test.go Adds new unit tests for FluidAppReconciler lifecycle and reconcile paths.
pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/suite_test.go Adds Ginkgo suite bootstrap for the dataflowaffinity subpackage.
pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/dataflowaffinity_controller_test.go Migrates DataOpJobReconciler tests to Ginkgo/Gomega and expands coverage of affinity injection helpers.

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

codecov bot commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.21%. Comparing base (a69c888) to head (fda5492).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5684   +/-   ##
=======================================
  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.
📢 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 hxrshxz force-pushed the test/fluidapp-ginkgo-migration branch from 2b21bb3 to 8130771 Compare March 8, 2026 14:03
…st suite

Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the test/fluidapp-ginkgo-migration branch from 8130771 to fda5492 Compare March 8, 2026 14:04
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 8, 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