test(jindocache): migrate transform_test.go to Ginkgo/Gomega#5629
test(jindocache): migrate transform_test.go to Ginkgo/Gomega#5629hxrshxz wants to merge 1 commit intofluid-cloudnative:masterfrom
Conversation
- 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>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
There was a problem hiding this comment.
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 consolidatedDescribetree and severalDescribeTable-based specs. - Refactors assertions from
t.Errorf/ manual checks intoExpect(...)-style assertions. - Restructures test setup/fixtures using
BeforeEachand per-spec initialization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| err := engine.transformMasterVolumes(testRuntime, jindoValue) | ||
| if err != nil { | ||
| GinkgoWriter.Println(err) | ||
| } | ||
| Expect(len(jindoValue.Master.VolumeMounts)).To(Equal(expect)) |
There was a problem hiding this comment.
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).
| dataset *datav1alpha1.Dataset | ||
| jindoValue *Jindo | ||
| ) | ||
| var _ = Describe("JindoCacheEngine Transform", func() { |
There was a problem hiding this comment.
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).
| resources := corev1.ResourceRequirements{} | ||
| resources.Limits = make(corev1.ResourceList) | ||
| resources.Limits[corev1.ResourceMemory] = resource.MustParse("2Gi") | ||
|
|
There was a problem hiding this comment.
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.
| resources := corev1.ResourceRequirements{} | |
| resources.Limits = make(corev1.ResourceList) | |
| resources.Limits[corev1.ResourceMemory] = resource.MustParse("2Gi") |
| if test.jindoValue.Master.Port.Rpc != test.expect && err != nil { | ||
| Fail("expected port allocation to match") | ||
| } | ||
| } | ||
| }) |
There was a problem hiding this comment.
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).
| 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)) | |
| } | |
| }) | |
| }) |
| _ = os.Setenv("USE_DEFAULT_MEM_LIMIT", "true") | ||
| quotas := []resource.Quantity{resource.MustParse("200Gi"), resource.MustParse("10Gi")} |
There was a problem hiding this comment.
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.
| s.AddKnownTypes(datav1alpha1.GroupVersion, &datav1alpha1.DatasetList{}) | ||
| _ = corev1.AddToScheme(s) | ||
| client := fake.NewFakeClientWithScheme(s, runtimeObjs...) | ||
| runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jinocache") |
There was a problem hiding this comment.
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.
| runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jinocache") | |
| runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "jindocache") |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|



Ⅰ. Describe what this PR does
Migrates
pkg/ddc/jindocache/transform_test.gofrom standard Go testing to the Ginkgo/Gomega framework.Converts 17 Go test functions to Ginkgo
Describe/DescribeTableformat, preserves existing GinkgotransformTolerationstests, 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