Skip to content

test(controllers): migrate runtime controller tests to Ginkgo#5680

Draft
hxrshxz wants to merge 2 commits intofluid-cloudnative:masterfrom
hxrshxz:test/runtime-controller-ginkgo-migration
Draft

test(controllers): migrate runtime controller tests to Ginkgo#5680
hxrshxz wants to merge 2 commits intofluid-cloudnative:masterfrom
hxrshxz:test/runtime-controller-ginkgo-migration

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Mar 6, 2026

Ⅰ. Describe what this PR does

Migrate pkg/controllers/runtime_controller_test.go to Ginkgo/Gomega, add the package suite bootstrap, and expand coverage for pkg/controllers/runtime_controller.go

Ⅱ. Does this pull request fix one issue?

#5676

Ⅲ. List the added test cases

Added unit test coverage for:

  • NewRuntimeReconciler
  • ForgetMetrics
  • ReconcileInternal
  • ReconcileRuntime
  • ReconcileRuntimeDeletion
  • helper methods in runtime_controller.go

Ⅳ. Describe how to verify it

Run:

  • go test ./pkg/controllers -run TestControllers -count=1
  • go test ./pkg/controllers -run TestControllers -coverprofile=/tmp/runtime_controller_cover.out -coverpkg=./pkg/controllers -count=1

Ⅴ. Special notes for reviews

N/A

Copilot AI review requested due to automatic review settings March 6, 2026 19:38
@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 6, 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 6, 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 primarily focuses on enhancing the testing infrastructure for the runtime controller. It migrates existing tests to the Ginkgo/Gomega framework, which provides a more expressive and structured way to write Go tests. This migration, along with the addition of new test cases, significantly improves the unit test coverage for the runtime_controller.go file, ensuring greater reliability and maintainability of the controller logic.

Highlights

  • Test Framework Migration: The pkg/controllers/runtime_controller_test.go file has been migrated to use the Ginkgo/Gomega testing framework, enhancing test readability and structure.
  • Test Coverage Improvement: Unit test coverage for pkg/controllers/runtime_controller.go has been significantly expanded, reaching 77.7%.
  • New Test Cases: New unit tests were added for NewRuntimeReconciler, ForgetMetrics, ReconcileInternal, ReconcileRuntime, ReconcileRuntimeDeletion, and various helper methods.
  • Robustness Improvement: A nil check was introduced in the GetRuntimeObjectMeta function to prevent potential panics when the runtime context is unexpectedly nil.
  • Issue Resolution: This pull request addresses and fixes issue Unify and Modernize Fluid’s Unit Testing Framework and Enhance Testing Coverage #5676.
Changelog
  • pkg/controllers/runtime_controller.go
    • Added a nil check to GetRuntimeObjectMeta to handle cases where ctx.Runtime is nil.
  • pkg/controllers/runtime_controller_test.go
    • Introduced a new test file for RuntimeReconciler using Ginkgo/Gomega.
    • Added tests for GetRuntimeObjectMeta, GetDataset, CheckIfReferenceDatasetIsSupported, AddOwnerAndRequeue, AddFinalizerAndRequeue, ReportDatasetNotReadyCondition, NewRuntimeReconciler, ForgetMetrics, ReconcileInternal, ReconcileRuntime, and ReconcileRuntimeDeletion.
    • Included helper functions for creating test objects and contexts.
  • pkg/controllers/suite_test.go
    • Added a new file to bootstrap the Ginkgo test suite for the controllers package.
Activity
  • The pull request was created by hxrshxz.
  • No additional human activity (comments, reviews, etc.) has been recorded since its creation.
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.

Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the test/runtime-controller-ginkgo-migration branch from 05acbd3 to 08f12af Compare March 6, 2026 19:40
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 runtime controller tests to use the Ginkgo/Gomega framework, significantly expanding test coverage. The changes are well-implemented, with comprehensive test cases for various scenarios, including edge cases and failure modes. The addition of a nil-check in GetRuntimeObjectMeta improves the robustness of the controller. I've left a couple of minor suggestions in the new test file to remove some redundant code. Overall, this is a great contribution to improving the test quality of the project.

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 pkg/controllers/runtime_controller_test.go to the Ginkgo/Gomega BDD testing framework as part of the broader effort to standardize testing across the Fluid project (issue #5676). It also adds a corresponding Ginkgo suite bootstrap file and includes a small production fix to GetRuntimeObjectMeta to handle nil runtime values more defensively.

Changes:

  • Added pkg/controllers/suite_test.go: Ginkgo suite bootstrap for the controllers package
  • Added pkg/controllers/runtime_controller_test.go: Comprehensive Ginkgo-based test coverage for runtime_controller.go (~77.7% coverage) including NewRuntimeReconciler, ForgetMetrics, ReconcileInternal, ReconcileRuntime, ReconcileRuntimeDeletion, and several helper methods
  • Modified pkg/controllers/runtime_controller.go: Added an explicit nil guard in GetRuntimeObjectMeta to handle nil runtime interface values safely

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/controllers/suite_test.go New Ginkgo suite bootstrap that registers the fail handler and runs all specs under TestControllers
pkg/controllers/runtime_controller_test.go New comprehensive Ginkgo test file exercising all major reconciliation paths with fake clients and a mock RuntimeReconcilerInterface
pkg/controllers/runtime_controller.go Nil check added at the top of GetRuntimeObjectMeta to prevent a panic when ctx.Runtime is a typed nil interface value

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

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5680   +/-   ##
=======================================
  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 marked this pull request as draft March 6, 2026 22:51
@hxrshxz hxrshxz marked this pull request as ready for review March 6, 2026 23:07
@hxrshxz hxrshxz marked this pull request as draft March 6, 2026 23:09
Signed-off-by: Harsh <harshmastic@gmail.com>
@hxrshxz hxrshxz force-pushed the test/runtime-controller-ginkgo-migration branch from e797026 to f1be066 Compare March 6, 2026 23:10
@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