Skip to content

test(goosefs): migrate suite to Ginkgo v2 and add controller tests#5687

Open
hxrshxz wants to merge 3 commits intofluid-cloudnative:masterfrom
hxrshxz:test/goosefs-controller-ginkgo-migration
Open

test(goosefs): migrate suite to Ginkgo v2 and add controller tests#5687
hxrshxz wants to merge 3 commits intofluid-cloudnative:masterfrom
hxrshxz:test/goosefs-controller-ginkgo-migration

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 10, 2026

Ⅰ. Describe what this PR does

Migrates pkg/controllers/v1alpha1/goosefs from Ginkgo v1 syntax to Ginkgo v2 and adds 10 Ginkgo/Gomega specs covering NewRuntimeReconciler, ControllerName, Reconcile, getRuntime, GetOrCreateEngine, and an envtest CRD CRUD test.

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

  • NewRuntimeReconciler — non-nil reconciler, scheme, engines map, mutex
  • ControllerName — returns "GooseFSRuntimeController"
  • Reconcile (not-found) — empty result, nil error when CR missing
  • Reconcile (exists) — no panic when GooseFSRuntime CR present
  • GetOrCreateEngine — engines map empty on construction, mutex type check
  • RemoveEngine — no panic on delete from empty map
  • getRuntime (error) — error returned when runtime missing
  • getRuntime (success) — correct runtime returned when CR exists
  • GooseFSRuntime CRD via envtest — create/get/delete via k8sClient

Ⅳ. Describe how to verify it

KUBEBUILDER_ASSETS=<local-envtest-path> go test -v -coverprofile=/tmp/goosefs-coverage.out ./pkg/controllers/v1alpha1/goosefs/... -count=1
go tool cover -func=/tmp/goosefs-coverage.out | grep total  # expect ≥76.3%
grep -r "testify" pkg/controllers/v1alpha1/goosefs/ --include="*_test.go"  # expect empty

Ⅴ. Special notes for reviews

N/A

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

fluid-e2e-bot bot commented Mar 10, 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 ronggu for approval by writing /assign @ronggu 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 10, 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 GooseFS controller. It modernizes the existing test suite by upgrading to Ginkgo v2 and introduces a comprehensive set of new tests to ensure the robustness and correctness of key controller functionalities, including runtime reconciliation, engine management, and CRD interactions.

Highlights

  • Ginkgo v2 Migration: Migrated the pkg/controllers/v1alpha1/goosefs test suite from Ginkgo v1 syntax to Ginkgo v2.
  • New Controller Tests: Added 10 new Ginkgo/Gomega test specifications covering NewRuntimeReconciler, ControllerName, Reconcile, getRuntime, GetOrCreateEngine, RemoveEngine, and GooseFSRuntime CRD CRUD operations via envtest.
Changelog
  • pkg/controllers/v1alpha1/goosefs/goosefs_runtime_controller_test.go
    • Added a new test file containing extensive Ginkgo v2 specifications for the GooseFS runtime controller.
  • pkg/controllers/v1alpha1/goosefs/suite_test.go
    • Updated the test suite to be compatible with Ginkgo v2.
    • Removed the os package import as it was no longer needed.
    • Modified the BeforeSuite hook to align with Ginkgo v2's asynchronous setup.
    • Added ErrorIfCRDPathMissing: true to envtest.Environment configuration.
    • Updated copyright year to 2026.
Activity
  • hxrshxz opened this pull request to migrate the GooseFS controller tests to Ginkgo v2 and add new test cases.
  • The PR description details the scope of changes, lists the specific test cases added, and provides clear instructions for verification, including a command to check test coverage.
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

@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 the GooseFS controller test suite to Ginkgo v2 and adds several new tests. The migration in suite_test.go is well-executed. However, I've identified several issues in the newly added test file pkg/controllers/v1alpha1/goosefs/goosefs_runtime_controller_test.go. Some tests are incomplete or do not test the intended functionality, which could lead to a false sense of test coverage. I've provided detailed feedback and code suggestions to address these issues and improve the quality and correctness of the tests.

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 migrates the GooseFS controller test suite under pkg/controllers/v1alpha1/goosefs to Ginkgo v2 and introduces new controller-focused specs (unit-style with fake clients plus an envtest CRUD spec) to improve confidence in the reconciler and runtime helper behaviors.

Changes:

  • Updated suite_test.go from Ginkgo v1-style BeforeSuite(done Done) to Ginkgo v2-style BeforeSuite(func() { ... }) and tightened envtest CRD path handling.
  • Added a new goosefs_runtime_controller_test.go file with Ginkgo/Gomega specs for reconciler construction, controller name, reconcile not-found behavior, runtime lookup, and an envtest CRD CRUD test.

Reviewed changes

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

File Description
pkg/controllers/v1alpha1/goosefs/suite_test.go Migrates suite bootstrapping to Ginkgo v2 and adds stricter envtest configuration.
pkg/controllers/v1alpha1/goosefs/goosefs_runtime_controller_test.go Adds new reconciler/controller tests (fake client + envtest CRUD).

💡 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 10, 2026

/gemini review

1 similar comment
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 10, 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

The pull request successfully migrates the test suite to Ginkgo v2 and introduces a comprehensive set of new controller tests for the GooseFSRuntime. The new tests cover various aspects of the reconciler, including initialization, controller naming, reconciliation logic for existing and non-existent runtimes, engine creation/removal, and CRD CRUD operations via envtest. The migration to Ginkgo v2 syntax is correctly applied across the suite_test.go file. However, one test case lacks a proper assertion, which reduces its effectiveness.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5687      +/-   ##
==========================================
+ 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.

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 successfully migrates the GooseFS controller test suite to Ginkgo v2 and expands test coverage with new, well-written specs. The migration is clean and follows best practices for Ginkgo v2. I have one suggestion to enhance the clarity of a test case by making its assertion more explicit, which will improve maintainability.

hxrshxz added 2 commits March 10, 2026 23:11
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
@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