Skip to content

test: cover vineyard engine with Ginkgo#5822

Merged
fluid-e2e-bot[bot] merged 2 commits intofluid-cloudnative:masterfrom
hxrshxz:test/vineyard-engine-ginkgo
May 3, 2026
Merged

test: cover vineyard engine with Ginkgo#5822
fluid-e2e-bot[bot] merged 2 commits intofluid-cloudnative:masterfrom
hxrshxz:test/vineyard-engine-ginkgo

Conversation

@hxrshxz
Copy link
Copy Markdown
Contributor

@hxrshxz hxrshxz commented May 2, 2026

Ⅰ. Describe what this PR does

Add Ginkgo v2 + Gomega coverage for Vineyard engine build and precheck behavior in pkg/ddc/vineyard.

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

Added package-scoped specs covering successful Build, nil runtime, wrong runtime type, runtime info lookup failure, and Precheck found/not-found behavior.

Ⅳ. Describe how to verify it

  • make fmt
  • go test -coverprofile=/tmp/fluid-requested-package.cover ./pkg/ddc/vineyard/... -count=1
  • go tool cover -func=/tmp/fluid-requested-package.cover -> total 76.3%
  • rg 'testify' pkg/ddc/vineyard/engine_test.go

Ⅴ. Special notes for reviews

N/A

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

fluid-e2e-bot Bot commented May 2, 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

This pull request refactors the VineyardEngine tests by migrating from the standard testing package to Ginkgo and Gomega. It introduces structured test cases for the Build and Precheck functions, improves setup modularity with helper functions, and adds constants for test data. Feedback suggests renaming the test name constant for better context, using more descriptive Ginkgo labels, and extending test coverage to include the GetDataOperationValueFile function.

Comment thread pkg/ddc/vineyard/engine_test.go Outdated
Name: "fluid",
const (
engineTestNamespace = "fluid"
engineTestName = "hbase"
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 constant engineTestName is set to "hbase", which is misleading for tests within the vineyard package. Using a more relevant name like "vineyard" would improve code clarity and maintainability. Note that updating this constant will require corresponding updates to the expected error strings in the test cases (e.g., lines 59, 72, and 85).

Suggested change
engineTestName = "hbase"
engineTestName = "vineyard"

Comment thread pkg/ddc/vineyard/engine_test.go Outdated
engineTestID = "testId"
)

var _ = Describe("VineyardEngine", Label("pkg.ddc.vineyard.engine_test.go"), func() {
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 label pkg.ddc.vineyard.engine_test.go is redundant because Ginkgo's output already includes the file path for every spec. It is better to use descriptive labels that categorize the tests (e.g., "vineyard", "engine") to facilitate filtering.

Suggested change
var _ = Describe("VineyardEngine", Label("pkg.ddc.vineyard.engine_test.go"), func() {
var _ = Describe("VineyardEngine", Label("vineyard"), func() {

Comment thread pkg/ddc/vineyard/engine_test.go Outdated
engineTestID = "testId"
)

var _ = Describe("VineyardEngine", Label("pkg.ddc.vineyard.engine_test.go"), func() {
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

While this pull request significantly improves coverage for engine.go, the GetDataOperationValueFile function in operator.go remains untested. Consider adding test cases for this function to ensure comprehensive coverage of the vineyard engine's core logic.

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

Adds Ginkgo v2/Gomega unit test coverage for the Vineyard engine’s Build and Precheck behaviors in pkg/ddc/vineyard, aligning this package with the ongoing test framework modernization and coverage goals from #5676.

Changes:

  • Migrates engine_test.go from a single testing.T test to Ginkgo v2 specs.
  • Adds spec coverage for Build success and common failure modes (nil runtime, wrong runtime type, runtime info lookup failure).
  • Adds spec coverage for Precheck found/not-found behavior.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.94%. Comparing base (5bc2c17) to head (5beb8d9).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5822      +/-   ##
==========================================
+ Coverage   58.89%   58.94%   +0.04%     
==========================================
  Files         479      479              
  Lines       32443    32443              
==========================================
+ Hits        19107    19122      +15     
+ Misses      11784    11772      -12     
+ Partials     1552     1549       -3     

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

hxrshxz commented May 2, 2026

/gemini review

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 2, 2026

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

This pull request refactors the unit tests for the Vineyard engine by migrating from the standard Go testing package to the Ginkgo and Gomega frameworks. The changes include more comprehensive test coverage for the Build and Precheck functions, covering various success and error scenarios, and the introduction of helper functions for test setup. Feedback was provided regarding the initialization of ReconcileRequestContext in the test helpers, specifically recommending the inclusion of Context and Recorder fields to avoid potential nil pointer dereferences and ensuring consistent use of constants.

Comment on lines +117 to +128
func newEngineTestContext(fakeClient client.Client, runtime client.Object) cruntime.ReconcileRequestContext {
return cruntime.ReconcileRequestContext{
NamespacedName: types.NamespacedName{
Name: engineTestName,
Namespace: engineTestNamespace,
},
Client: fakeClient,
Log: fake.NullLogger(),
RuntimeType: "vineyard",
Runtime: runtime,
}
testObjs := []runtime.Object{}
testObjs = append(testObjs, namespace.DeepCopy())
}
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 ReconcileRequestContext is initialized without the Context and Recorder fields. While the current tests for Build and Precheck do not appear to use these fields, they are fundamental parts of the request context. Missing them could lead to nil pointer dereferences if the code under test is updated to emit events or use the context for API calls. It is recommended to initialize them with context.TODO() and a fake recorder (e.g., record.NewFakeRecorder(1)). Additionally, consider using the engineTestName constant for the RuntimeType field to maintain consistency.

Suggested change
func newEngineTestContext(fakeClient client.Client, runtime client.Object) cruntime.ReconcileRequestContext {
return cruntime.ReconcileRequestContext{
NamespacedName: types.NamespacedName{
Name: engineTestName,
Namespace: engineTestNamespace,
},
Client: fakeClient,
Log: fake.NullLogger(),
RuntimeType: "vineyard",
Runtime: runtime,
}
testObjs := []runtime.Object{}
testObjs = append(testObjs, namespace.DeepCopy())
}
func newEngineTestContext(fakeClient client.Client, runtime client.Object) cruntime.ReconcileRequestContext {
return cruntime.ReconcileRequestContext{
NamespacedName: types.NamespacedName{
Name: engineTestName,
Namespace: engineTestNamespace,
},
Client: fakeClient,
Log: fake.NullLogger(),
RuntimeType: engineTestName,
Runtime: runtime,
}
}

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

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


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

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 May 3, 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

@fluid-e2e-bot fluid-e2e-bot Bot merged commit c4234dd into fluid-cloudnative:master May 3, 2026
21 of 22 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