Skip to content

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Jan 28, 2026

Summary

Ⅰ. Migrate pkg/ddc/juicefs/health_check_test.go from standard Go testing to Ginkgo/Gomega framework
Ⅱ. Convert table-driven tests to individual It() blocks with BeforeEach setup
Ⅲ. Replace all t.Errorf assertions with Gomega matchers (Expect/To/Equal/BeEquivalentTo)
Ⅳ. Update imports to use Ginkgo v2 and Gomega
Ⅴ. Part of #5407

Changes

  • Removed testing package, added Ginkgo/Gomega imports
  • Converted 2 test functions (TestCheckRuntimeHealthy, TestCheckFuseHealthy) to Describe blocks
  • Extracted setup logic to BeforeEach blocks for proper test isolation
  • Converted all assertions to Gomega style matchers
  • Fixed type comparison using BeEquivalentTo for CacheStates map
  • All tests passing: 80/80 specs ✅

Testing

go test ./pkg/ddc/juicefs -count=1 -v
# Result: SUCCESS! -- 80 Passed | 0 Failed

Signed-off-by: Harsh <harshmastic@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hxrshxz, 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 JuiceFS health check logic by migrating existing tests to the Ginkgo/Gomega framework. This change improves the clarity, structure, and maintainability of the test suite, making it easier to understand test intent and outcomes.

Highlights

  • Testing Framework Migration: The pkg/ddc/juicefs/health_check_test.go file has been migrated from standard Go testing to the Ginkgo/Gomega BDD testing framework.
  • Test Structure Refactoring: Original table-driven tests have been converted into individual It() blocks, utilizing BeforeEach for setup to ensure better test isolation and readability.
  • Assertion Style Update: All t.Errorf assertions have been replaced with Gomega matchers (e.g., Expect().To(Equal())), enhancing the expressiveness of test expectations.
  • Dependency Updates: Imports were updated to include Ginkgo v2 and Gomega, and reflect and testing packages were removed.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 Jan 28, 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 successfully migrates the tests in pkg/ddc/juicefs/health_check_test.go to use the Ginkgo/Gomega framework, which improves test readability and structure. The conversion from table-driven tests to individual It blocks with BeforeEach setup is well-executed. I have one suggestion to improve consistency in the test setup code.

Comment on lines 294 to 321
engines = []JuiceFSEngine{
{
Client: fakeClient,
Log: fake.NullLogger(),
namespace: "fluid",
name: "hbase",
runtime: &datav1alpha1.JuiceFSRuntime{
ObjectMeta: metav1.ObjectMeta{
Name: "hbase",
Namespace: "fluid",
},
},
Recorder: record.NewFakeRecorder(1),
},
{
Client: fakeClient,
Log: fake.NullLogger(),
namespace: "fluid",
name: "spark",
runtime: &datav1alpha1.JuiceFSRuntime{
ObjectMeta: metav1.ObjectMeta{
Name: "spark",
Namespace: "fluid",
},
},
Recorder: record.NewFakeRecorder(1),
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and to reduce redundancy, consider reusing the juicefsruntimeInputs slice when initializing the engines, similar to how it's done in the CheckRuntimeHealthy test suite. This makes the test setup cleaner and easier to maintain.

engines = []JuiceFSEngine{
			{
				Client:    fakeClient,
				Log:       fake.NullLogger(),
				namespace: "fluid",
				name:      "hbase",
				runtime:   &juicefsruntimeInputs[0],
				Recorder:  record.NewFakeRecorder(1),
			},
			{
				Client:    fakeClient,
				Log:       fake.NullLogger(),
				namespace: "fluid",
				name:      "spark",
				runtime:   &juicefsruntimeInputs[1],
				Recorder:  record.NewFakeRecorder(1),
			},
		}

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.30%. Comparing base (77d4cb2) to head (e0a6a2b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5531   +/-   ##
=======================================
  Coverage   61.30%   61.30%           
=======================================
  Files         444      444           
  Lines       30540    30540           
=======================================
  Hits        18723    18723           
  Misses      10275    10275           
  Partials     1542     1542           

☔ 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
Copy link
Contributor Author

hxrshxz commented Jan 28, 2026

/gemini review

1 similar comment
@hxrshxz
Copy link
Contributor Author

hxrshxz commented Jan 28, 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

This pull request successfully migrates the tests in pkg/ddc/juicefs/health_check_test.go from the standard Go testing framework to Ginkgo and Gomega. The refactoring improves test structure and readability by using Describe/It blocks and BeforeEach for setup. The logic of the original table-driven tests is preserved. I've suggested one improvement to make a test assertion more robust by avoiding reliance on the order of items returned from a list call, which can be flaky.

Comment on lines 210 to 220
var datasets datav1alpha1.DatasetList
err = fakeClient.List(context.TODO(), &datasets)
Expect(err).NotTo(HaveOccurred())
Expect(datasets.Items[0].Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(datasets.Items[0].Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(datasets.Items[0].Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Relying on client.List and then accessing datasets.Items[0] can lead to flaky tests, as the order of items returned by the fake client's List method is not guaranteed. It's more robust to fetch the specific Dataset object by its name and namespace using client.Get.

Suggested change
var datasets datav1alpha1.DatasetList
err = fakeClient.List(context.TODO(), &datasets)
Expect(err).NotTo(HaveOccurred())
Expect(datasets.Items[0].Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(datasets.Items[0].Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(datasets.Items[0].Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))
var dataset datav1alpha1.Dataset
err = fakeClient.Get(context.TODO(), client.ObjectKey{Name: "hbase", Namespace: "fluid"}, &dataset)
Expect(err).NotTo(HaveOccurred())
Expect(dataset.Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(dataset.Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(dataset.Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))

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 tests in pkg/ddc/juicefs/health_check_test.go from the standard Go testing framework to Ginkgo/Gomega. The conversion from table-driven tests to individual It blocks with BeforeEach setup improves test readability and isolation. The assertions are correctly updated to use Gomega matchers.

I've added one suggestion to improve the robustness of a test by fetching a resource directly by name instead of relying on its index in a list, which can be unstable.

Comment on lines 210 to 220
var datasets datav1alpha1.DatasetList
err = fakeClient.List(context.TODO(), &datasets)
Expect(err).NotTo(HaveOccurred())
Expect(datasets.Items[0].Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(datasets.Items[0].Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(datasets.Items[0].Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Relying on the order of items from fakeClient.List can make tests brittle, as the order is not guaranteed. It's more robust to fetch the specific Dataset object by name to ensure assertions are made against the correct object.

Also, it's a good practice to use context.Background() instead of context.TODO() in tests when a specific context isn't required.

Suggested change
var datasets datav1alpha1.DatasetList
err = fakeClient.List(context.TODO(), &datasets)
Expect(err).NotTo(HaveOccurred())
Expect(datasets.Items[0].Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(datasets.Items[0].Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(datasets.Items[0].Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))
var hbaseDataset datav1alpha1.Dataset
err = fakeClient.Get(context.Background(), client.ObjectKey{Name: "hbase", Namespace: "fluid"}, &hbaseDataset)
Expect(err).NotTo(HaveOccurred())
Expect(hbaseDataset.Status.Phase).To(Equal(datav1alpha1.BoundDatasetPhase))
Expect(hbaseDataset.Status.CacheStates).To(BeEquivalentTo(map[common.CacheStateName]string{
common.Cached: "true",
}))
Expect(hbaseDataset.Status.HCFSStatus).To(Equal(&datav1alpha1.HCFSStatus{
Endpoint: "test Endpoint",
UnderlayerFileSystemVersion: "Underlayer HCFS Compatible Version",
}))

Signed-off-by: Harsh <harshmastic@gmail.com>
Copilot AI review requested due to automatic review settings January 28, 2026 13:45
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 test file pkg/ddc/juicefs/health_check_test.go from the standard Go testing framework to Ginkgo v2 and Gomega, aligning with the project's goal (issue #5407) to standardize testing practices and improve test readability and maintainability.

Changes:

  • Migrated two test functions (TestCheckRuntimeHealthy and TestCheckFuseHealthy) to Ginkgo-style Describe blocks with BDD-style test organization
  • Replaced standard Go testing assertions with Gomega matchers for more expressive test expectations
  • Updated package declaration in juicefs_suite_test.go from juicefs_test to juicefs for consistency with other test files in the package

Reviewed changes

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

File Description
pkg/ddc/juicefs/juicefs_suite_test.go Changed package declaration from juicefs_test to juicefs to align with codebase conventions
pkg/ddc/juicefs/health_check_test.go Migrated test functions to Ginkgo/Gomega framework, converted table-driven tests to individual It blocks with BeforeEach setup, replaced all assertions with Gomega matchers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…alth-check

# Conflicts:
#	pkg/ddc/juicefs/health_check_test.go
@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Feb 9, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 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.

1 participant