Skip to content

test(ddc/goosefs): migrate api_gateway tests to ginkgo#5562

Merged
cheyang merged 2 commits intofluid-cloudnative:masterfrom
hxrshxz:ginkgo/goosefs-api-gateway
Feb 24, 2026
Merged

test(ddc/goosefs): migrate api_gateway tests to ginkgo#5562
cheyang merged 2 commits intofluid-cloudnative:masterfrom
hxrshxz:ginkgo/goosefs-api-gateway

Conversation

@hxrshxz
Copy link
Copy Markdown
Contributor

@hxrshxz hxrshxz commented Jan 28, 2026

Ⅰ. Describe what this PR does

Migrate unit tests in pkg/ddc/goosefs/api_gateway_test.go to use Ginkgo/Gomega framework.

Ⅱ. Does this pull request fix one issue?

part of #5407

Ⅲ. List the added test cases

No new test cases. Migrated existing tests to Ginkgo/Gomega.

Ⅳ. Describe how to verify it

go test -v ./pkg/ddc/goosefs/... -count=1

Ⅴ. Special notes for reviews

N/A

Signed-off-by: Harsh <harshmastic@gmail.com>
Copilot AI review requested due to automatic review settings January 28, 2026 08:51
@gemini-code-assist
Copy link
Copy Markdown
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 unit testing infrastructure for the api_gateway component within the GooseFS DDC package. By transitioning to the Ginkgo/Gomega framework, the tests become more structured, readable, and maintainable, aligning with BDD principles. This change improves the overall quality and future extensibility of the test suite without introducing new test cases or altering existing functionality.

Highlights

  • Test Framework Migration: Migrated unit tests in pkg/ddc/goosefs/api_gateway_test.go from the standard Go testing package to the Ginkgo/Gomega behavior-driven development (BDD) testing framework.
  • Test Structure Refactoring: Refactored existing test functions (TestGetAPIGatewayStatus and TestQueryAPIGatewayEndpoint) into Ginkgo Describe and DescribeTable blocks for improved readability and organization.
  • Assertion Modernization: Replaced traditional reflect.DeepEqual and t.Errorf assertions with Gomega's expressive Expect matchers, enhancing test clarity and conciseness.

🧠 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
Copy Markdown

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
Copy Markdown
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 API gateway tests to use the Ginkgo/Gomega framework, which improves the test structure and readability. I've included a couple of minor suggestions to further enhance the clarity and consistency of the new test code.

Comment on lines +64 to 70
type testCase struct {
name string
engineName string
engineNamespace string
port int32
wantEndpoint string
}{
"test GetAPIGatewayStatus case 1": {
engineName: "fluid",
engineNamespace: "default",
port: 8080,
wantEndpoint: fmt.Sprintf(endpointFormat, "fluid", "default", 8080),
},
"test GetAPIGatewayStatus case 2": {
engineName: "demo",
engineNamespace: common.NamespaceFluidSystem,
port: 80,
wantEndpoint: fmt.Sprintf(endpointFormat, "demo", common.NamespaceFluidSystem, 80),
},
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The name field in the testCase struct is defined but never used. The test descriptions are provided in the Entry functions. You can remove this field to simplify the struct. This will also require removing it from the testCase literals below.

        type testCase struct {
                engineName      string
                engineNamespace string
                port            int32
                wantEndpoint    string
        }


Expect(err).NotTo(HaveOccurred())
expectedStatus := &datav1alpha1.APIGatewayStatus{
Endpoint: fmt.Sprintf(endpointFormat, tc.engineName, tc.engineNamespace, tc.port),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve consistency with the queryAPIGatewayEndpoint test and avoid re-calculating the endpoint string, you can use the wantEndpoint field from the testCase struct.

                                        Endpoint: tc.wantEndpoint,

Copy link
Copy Markdown
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 unit tests in pkg/ddc/goosefs/api_gateway_test.go from standard Go testing with testify to the Ginkgo/Gomega BDD-style testing framework. This is part of a larger initiative (issue #5407) to modernize and unify Fluid's testing framework across the codebase.

Changes:

  • Replaced standard Go testing imports with Ginkgo v2 and Gomega
  • Converted two test functions (TestGetAPIGatewayStatus and TestQueryAPIGatewayEndpoint) to Ginkgo's Describe/DescribeTable/Entry pattern
  • Refactored test cases from map-based iteration to table-driven tests using Ginkgo's DescribeTable

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

Comment thread pkg/ddc/goosefs/api_gateway_test.go Outdated
testCases := map[string]struct {

type testCase struct {
name string
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The name field in the testCase struct is defined but never used in the test functions. Consider removing this field to keep the struct definition clean and avoid confusion.

Copilot uses AI. Check for mistakes.
engineName string
engineNamespace string
port int32
wantEndpoint string
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The wantEndpoint field in the testCase struct is not used in the GetAPIGatewayStatus test (lines 72-103). It's only referenced in the queryAPIGatewayEndpoint test. Consider either removing this field from the testCase struct and computing the expected endpoint inline, or splitting into two separate structs for each test if they have different field requirements.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.07%. Comparing base (2a4f24d) to head (e14c3d2).
⚠️ Report is 87 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5562      +/-   ##
==========================================
+ Coverage   58.33%   59.07%   +0.74%     
==========================================
  Files         444      444              
  Lines       30431    30431              
==========================================
+ Hits        17751    17978     +227     
+ Misses      11188    10947     -241     
- Partials     1492     1506      +14     

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

Signed-off-by: Harsh <harshmastic@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Feb 24, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheyang

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@cheyang cheyang merged commit 56549d5 into fluid-cloudnative:master Feb 24, 2026
18 checks passed
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.

3 participants