Skip to content

test(jindocache): migrate transform_test.go to Ginkgo/Gomega#5629

Draft
hxrshxz wants to merge 1 commit intofluid-cloudnative:masterfrom
hxrshxz:test/migrate-jindocache-transform-test
Draft

test(jindocache): migrate transform_test.go to Ginkgo/Gomega#5629
hxrshxz wants to merge 1 commit intofluid-cloudnative:masterfrom
hxrshxz:test/migrate-jindocache-transform-test

Conversation

@hxrshxz
Copy link
Contributor

@hxrshxz hxrshxz commented Jan 29, 2026

Ⅰ. Describe what this PR does

Migrates pkg/ddc/jindocache/transform_test.go from standard Go testing to the Ginkgo/Gomega framework.
Converts 17 Go test functions to Ginkgo Describe/DescribeTable format, preserves existing Ginkgo transformTolerations tests, and reduces the file from 1702 to 1317 lines (~23% reduction).
All test logic and coverage are preserved.

Ⅱ. Does this pull request fix one issue?

part of #5407

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

No new test cases added. All existing tests were migrated to Ginkgo/Gomega format.

Ⅳ. Describe how to verify it

go build ./...
ginkgo -v ./pkg/ddc/jindocache/

- Convert 17 Go test functions to Ginkgo Describe/DescribeTable format
- Preserve existing Ginkgo transformTolerations tests
- 1317 lines (reduced from 1702 lines, ~23% reduction)
- All 53 Ginkgo specs pass
- TestDestroyWorker failure in shutdown_test.go is pre-existing

Signed-off-by: Harsh <harshmastic@gmail.com>
Copilot AI review requested due to automatic review settings January 29, 2026 03:06
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Jan 29, 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 yangyuliufeng for approval by writing /assign @yangyuliufeng 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 Jan 29, 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.

@sonarqubecloud
Copy link

@hxrshxz hxrshxz marked this pull request as draft January 29, 2026 03:08
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 pkg/ddc/jindocache/transform_test.go from standard testing-style unit tests to Ginkgo/Gomega BDD-style specs.

Changes:

  • Replaces multiple Test* functions with a consolidated Describe tree and several DescribeTable-based specs.
  • Refactors assertions from t.Errorf / manual checks into Expect(...)-style assertions.
  • Restructures test setup/fixtures using BeforeEach and per-spec initialization.

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

Comment on lines +989 to +993
err := engine.transformMasterVolumes(testRuntime, jindoValue)
if err != nil {
GinkgoWriter.Println(err)
}
Expect(len(jindoValue.Master.VolumeMounts)).To(Equal(expect))
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

transformMasterVolumes returns an error when a VolumeMount doesn't have a matching Volume. This spec prints the error but still passes based on length, which can mask real failures; additionally, the "non-matching" entry currently expects 0 mounts even though an error should be returned. Assert the expected error/non-error per entry (and avoid just logging errors).

Copilot uses AI. Check for mistakes.
dataset *datav1alpha1.Dataset
jindoValue *Jindo
)
var _ = Describe("JindoCacheEngine Transform", func() {
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

This file defines Ginkgo specs (Describe/It) but does not include a Test... entrypoint that calls RunSpecs, so go test will compile this file but never execute these specs. Add a *_suite_test.go (or a Test... function in this file) in package jindocache that registers the fail handler and calls RunSpecs (and import testing).

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +195
resources := corev1.ResourceRequirements{}
resources.Limits = make(corev1.ResourceList)
resources.Limits[corev1.ResourceMemory] = resource.MustParse("2Gi")

Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

resources is declared and populated but never used, which will fail compilation due to Go's unused local variable rules. Remove it or wire it into the test data so it actually affects the runtime/value under test.

Suggested change
resources := corev1.ResourceRequirements{}
resources.Limits = make(corev1.ResourceList)
resources.Limits[corev1.ResourceMemory] = resource.MustParse("2Gi")

Copilot uses AI. Check for mistakes.
Comment on lines +426 to +430
if test.jindoValue.Master.Port.Rpc != test.expect && err != nil {
Fail("expected port allocation to match")
}
}
})
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The failure condition here is inverted: the spec only fails when the port mismatches AND err != nil. This can let failures slip through (e.g., port mismatch with nil err, or err with matching port). Assert err separately and fail on any port mismatch (use Gomega expectations for clearer output).

Suggested change
if test.jindoValue.Master.Port.Rpc != test.expect && err != nil {
Fail("expected port allocation to match")
}
}
})
Expect(err).NotTo(HaveOccurred())
Expect(test.jindoValue.Master.Port.Rpc).To(Equal(test.expect))
}
})
})

Copilot uses AI. Check for mistakes.
Comment on lines +435 to +436
_ = os.Setenv("USE_DEFAULT_MEM_LIMIT", "true")
quotas := []resource.Quantity{resource.MustParse("200Gi"), resource.MustParse("10Gi")}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

This spec sets USE_DEFAULT_MEM_LIMIT globally and does not restore it, which can leak into other tests and cause order-dependent failures. Capture the previous value and restore it with DeferCleanup (or os.Unsetenv as appropriate) after the spec.

Copilot uses AI. Check for mistakes.
s.AddKnownTypes(datav1alpha1.GroupVersion, &datav1alpha1.DatasetList{})
_ = corev1.AddToScheme(s)
client := fake.NewFakeClientWithScheme(s, runtimeObjs...)
runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jinocache")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Typo in the runtime type passed to BuildRuntimeInfo: this uses "jinocache" while other specs in this file use "jindocache". If runtimeType influences label/config naming, this can make the test exercise a different code path than production. Use the consistent runtime type string.

Suggested change
runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jinocache")
runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jindocache")

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

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.22%. Comparing base (2a85fb5) to head (b255716).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5629   +/-   ##
=======================================
  Coverage   59.22%   59.22%           
=======================================
  Files         444      444           
  Lines       30431    30431           
=======================================
  Hits        18024    18024           
  Misses      10912    10912           
  Partials     1495     1495           

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

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