Skip to content

test(jindo): migrate controller tests to Ginkgo/Gomega#5688

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

test(jindo): migrate controller tests to Ginkgo/Gomega#5688
hxrshxz wants to merge 3 commits intofluid-cloudnative:masterfrom
hxrshxz:test/jindo-controller-ginkgo-migration

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 10, 2026

Ⅰ. Describe what this PR does

Migrate pkg/controllers/v1alpha1/jindo/ unit tests to Ginkgo v2/Gomega, fix the broken suite bootstrap (Ginkgo v1 Unknown Decorator error), and add full test coverage for implement.go and jindoruntime_controller.go.

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

New test file controller_test.go:

  • NewRuntimeReconciler — verifies non-nil Scheme, engines map, mutex, and embedded RuntimeReconciler
  • ControllerName — verifies constant value JindoRuntimeController
  • ManagedResource — verifies returned JindoRuntime has correct Kind and APIVersion TypeMeta
  • Reconcile (not-found path) — verifies ctrl.Result{}, nil when runtime is absent
  • Reconcile (invalid DNS name) — verifies error returned for runtime name starting with a digit

New test file implement_test.go:

  • getRuntime (found) — verifies correct JindoRuntime is returned from fake client
  • getRuntime (not-found) — verifies error is returned
  • GetOrCreateEngine (create) — verifies new engine is created and non-nil
  • GetOrCreateEngine (cached) — verifies second call returns same engine instance
  • GetOrCreateEngine (unknown impl) — verifies error for unregistered engine impl
  • RemoveEngine (removes) — verifies engine map is empty after removal
  • RemoveEngine (no-op) — verifies no panic when engine not present

Updated suite_test.go:

  • Removed Ginkgo v1 BeforeSuite(func(done Done){...}, 60) pattern (caused Unknown Decorator panic)
  • Replaced with minimal Ginkgo v2 bootstrap (no envtest dependency needed for unit tests)

Ⅳ. Describe how to verify it

go build ./pkg/controllers/v1alpha1/jindo/...
go test -v -cover ./pkg/controllers/v1alpha1/jindo/...
# Expected: 13/13 specs pass, coverage: 86.0%

Ⅴ. Special notes for reviews

N/A

Migrate pkg/controllers/v1alpha1/jindo/ unit tests to Ginkgo v2/Gomega.
Fix broken suite bootstrap (Ginkgo v1 Unknown Decorator error) and add
full coverage for implement.go and jindoruntime_controller.go (86.0%).

13/13 specs pass.
Copilot AI review requested due to automatic review settings March 10, 2026 17:58
@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 upgrades the testing infrastructure for the Jindo controller. By migrating to Ginkgo v2/Gomega and expanding test coverage, it improves the robustness and maintainability of the controller's core logic, making future development and refactoring safer and more efficient.

Highlights

  • Test Framework Migration: Migrated existing unit tests in pkg/controllers/v1alpha1/jindo/ to Ginkgo v2 and Gomega, enhancing the testing framework.
  • Test Suite Bootstrap Fix: Resolved the broken test suite bootstrap, specifically addressing the Ginkgo v1 "Unknown Decorator" error.
  • Expanded Test Coverage: Added comprehensive test coverage for implement.go and jindoruntime_controller.go, ensuring greater code reliability.
Changelog
  • pkg/controllers/v1alpha1/jindo/controller_test.go
    • Added a new test file to house Ginkgo/Gomega tests for the JindoRuntime controller.
  • pkg/controllers/v1alpha1/jindo/implement_test.go
    • Added a new test file containing Ginkgo/Gomega tests for the JindoRuntime implementation logic.
  • pkg/controllers/v1alpha1/jindo/suite_test.go
    • Updated the copyright year from 2020 to 2026.
    • Removed the Ginkgo v1 BeforeSuite pattern and related envtest dependencies, replacing it with a minimal Ginkgo v2 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.

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 Jindo controller unit tests to Ginkgo v2/Gomega, removing the old envtest-based suite bootstrap and adding new unit coverage for controller/implement logic.

Changes:

  • Replaced the Ginkgo v1 suite bootstrap with a minimal Ginkgo v2 RunSpecs entrypoint.
  • Added new Ginkgo v2/Gomega unit tests for controller behavior and engine/runtime helpers.
  • Expanded coverage for not-found and error paths (e.g., engine impl selection, runtime retrieval).

Reviewed changes

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

File Description
pkg/controllers/v1alpha1/jindo/suite_test.go Simplifies test suite bootstrap for Ginkgo v2 and removes envtest setup.
pkg/controllers/v1alpha1/jindo/implement_test.go Adds unit tests for getRuntime, GetOrCreateEngine, and RemoveEngine.
pkg/controllers/v1alpha1/jindo/controller_test.go Adds unit tests for reconciler construction, managed resource metadata, and reconcile paths.

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

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 Jindo controller unit tests to Ginkgo/Gomega, improving test structure and coverage. The changes are well-executed, particularly the cleanup of suite_test.go. My feedback focuses on improving the new test files (controller_test.go and implement_test.go) by reducing code duplication and consolidating redundant test cases for better maintainability.

- Replace silent _ = datav1alpha1.AddToScheme(s) with
  Expect(datav1alpha1.AddToScheme(s)).NotTo(HaveOccurred()) in all
  It blocks across controller_test.go and implement_test.go so
  scheme-registration failures surface immediately rather than
  producing misleading test behaviour.
- Change r.mutex.Lock()/Expect/r.mutex.Unlock() sequence in
  RemoveEngine test to use defer r.mutex.Unlock() so the lock is
  always released even when an Expect assertion fails.
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 10, 2026

/gemini review

@hxrshxz
Copy link
Contributor Author

hxrshxz commented Mar 10, 2026

/gemini review

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

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

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

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 Jindo controller unit tests to Ginkgo v2/Gomega, resolving the Unknown Decorator error and significantly expanding test coverage for implement.go and jindoruntime_controller.go. The new tests are well-structured and cover various scenarios, enhancing the overall reliability and maintainability of the codebase. One minor improvement could be made to ensure consistency and precision in APIVersion assertions.

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 Jindo controller tests to Ginkgo v2/Gomega, addressing the Unknown Decorator error and significantly enhancing test coverage for implement.go and jindoruntime_controller.go. The newly added test files, controller_test.go and implement_test.go, are well-structured and cover essential functionalities, including runtime creation, controller naming, managed resource type meta, and various Reconcile, getRuntime, GetOrCreateEngine, and RemoveEngine scenarios. The changes in suite_test.go correctly remove the outdated Ginkgo v1 setup and envtest dependencies, streamlining the testing environment. Overall, the changes improve the robustness and maintainability of the Jindo controller's test suite.

@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