test(api/v1alpha1): add runtime and status type coverage#5891
Conversation
Signed-off-by: Harsh <harshmastic@gmail.com>
|
[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.
Code Review
This pull request migrates the v1alpha1 API package tests to the Ginkgo and Gomega frameworks, introducing new test files for CacheRuntime, Dataset helpers, and status DeepCopy functionality. It also refactors existing tests for network modes and dataset operations into table-driven Ginkgo specs. Review feedback identifies opportunities to improve code maintainability by using existing constants instead of hardcoded strings and resolving variable shadowing of the runtime package and the built-in copy function.
| func(runtime interface{ Replicas() int32 }, expected int32) { | ||
| Expect(runtime.Replicas()).To(Equal(expected)) | ||
| }, |
There was a problem hiding this comment.
The variable name runtime shadows the imported k8s.io/apimachinery/pkg/runtime package. This can lead to confusion and prevents access to the package's types or functions within this scope. Consider renaming it to something like rt or runtimeObj.
| func(runtime interface{ Replicas() int32 }, expected int32) { | |
| Expect(runtime.Replicas()).To(Equal(expected)) | |
| }, | |
| func(rt interface{ Replicas() int32 }, expected int32) { | |
| Expect(rt.Replicas()).To(Equal(expected)) | |
| }, |
| Entry("JindoRuntime", &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntime"}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, "JindoRuntime", "JindoRuntimeList"), | ||
| Entry("JuiceFSRuntime", &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntime"}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, "JuiceFSRuntime", "JuiceFSRuntimeList"), | ||
| Entry("ThinRuntime", &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntime"}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, "ThinRuntime", "ThinRuntimeList"), | ||
| Entry("VineyardRuntime", &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntime"}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, "VineyardRuntime", "VineyardRuntimeList"), |
There was a problem hiding this comment.
Use the existing constants like JindoRuntimeKind, JuiceFSRuntimeKind, ThinRuntimeKind, and VineyardRuntimeKind instead of hardcoded strings to improve maintainability and avoid potential typos.
| Entry("JindoRuntime", &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntime"}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, "JindoRuntime", "JindoRuntimeList"), | |
| Entry("JuiceFSRuntime", &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntime"}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, "JuiceFSRuntime", "JuiceFSRuntimeList"), | |
| Entry("ThinRuntime", &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntime"}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, "ThinRuntime", "ThinRuntimeList"), | |
| Entry("VineyardRuntime", &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntime"}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, "VineyardRuntime", "VineyardRuntimeList"), | |
| Entry("JindoRuntime", &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JindoRuntimeKind}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, JindoRuntimeKind, "JindoRuntimeList"), | |
| Entry("JuiceFSRuntime", &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JuiceFSRuntimeKind}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, JuiceFSRuntimeKind, "JuiceFSRuntimeList"), | |
| Entry("ThinRuntime", &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: ThinRuntimeKind}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, ThinRuntimeKind, "ThinRuntimeList"), | |
| Entry("VineyardRuntime", &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: VineyardRuntimeKind}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, VineyardRuntimeKind, "VineyardRuntimeList"), |
| CacheAffinity: &corev1.NodeAffinity{}, | ||
| } | ||
|
|
||
| copy := status.DeepCopy() |
There was a problem hiding this comment.
Pull request overview
Test-only PR that adds Ginkgo/Gomega coverage for runtime and status API helper types under api/v1alpha1. It introduces a Ginkgo test suite entry point for the package and per-type specs for runtime Replicas()/GetStatus(), scheme/GVK registration, and deep-copy/field preservation behavior for the runtime, cache runtime, and operation status structs. Stacked conceptually on #5889, so several of the diffed test files (suite, common, container_network, dataset) overlap with that PR.
Changes:
- Add
Replicas()table tests for Alluxio/GooseFS/Jindo/JuiceFS/Thin/Vineyard runtimes andGetStatus()specs for each, plus scheme-registration table for runtime/list GVKs. - Add
CacheRuntime.GetStatus()and scheme-registration coverage. - Add deep-copy/field-preservation specs for
RuntimeStatus,CacheRuntimeStatus, andOperationStatus.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| api/v1alpha1/suite_test.go | New Ginkgo TestV1alpha1 entry point for the package suite. |
| api/v1alpha1/common_test.go | New specs for MetadataSyncPolicy.AutoSyncEnabled, Dataset.CanbeBound, Dataset.IsExclusiveMode (note: license header is tab-indented). |
| api/v1alpha1/container_network_test.go | Migrates IsHostNetwork test to Ginkgo DescribeTable. |
| api/v1alpha1/dataset_types_test.go | Migrates Dataset operation-ref tests to Ginkgo DescribeTable. |
| api/v1alpha1/runtime_types_test.go | Adds runtime Replicas/GetStatus/scheme-registration tests for six runtimes (EFC omitted). |
| api/v1alpha1/cacheruntime_types_test.go | Adds CacheRuntime.GetStatus and scheme registration test. |
| api/v1alpha1/status_test.go | Adds DeepCopy specs for RuntimeStatus, CacheRuntimeStatus, OperationStatus (uses copy identifier that shadows the builtin). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Entry("AlluxioRuntime", &AlluxioRuntime{Spec: AlluxioRuntimeSpec{Replicas: 1}}, int32(1)), | ||
| Entry("GooseFSRuntime", &GooseFSRuntime{Spec: GooseFSRuntimeSpec{Replicas: 2}}, int32(2)), | ||
| Entry("JindoRuntime", &JindoRuntime{Spec: JindoRuntimeSpec{Replicas: 3}}, int32(3)), | ||
| Entry("JuiceFSRuntime", &JuiceFSRuntime{Spec: JuiceFSRuntimeSpec{Replicas: 4}}, int32(4)), | ||
| Entry("ThinRuntime", &ThinRuntime{Spec: ThinRuntimeSpec{Replicas: 5}}, int32(5)), | ||
| Entry("VineyardRuntime", &VineyardRuntime{Spec: VineyardRuntimeSpec{Replicas: 6}}, int32(6)), |
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ |
| copy := status.DeepCopy() | ||
|
|
||
| Expect(copy).NotTo(BeNil()) | ||
| Expect(copy).NotTo(BeIdenticalTo(status)) | ||
| Expect(copy.WorkerPhase).To(Equal(RuntimePhaseReady)) | ||
| Expect(copy.Conditions).To(HaveLen(1)) | ||
| Expect(copy.Conditions[0].Reason).To(Equal(RuntimeWorkersReadyReason)) | ||
| Expect(copy.MountTime).NotTo(BeNil()) | ||
| Expect(copy.MountTime).NotTo(BeIdenticalTo(status.MountTime)) | ||
| Expect(copy.MountTime.Time).To(Equal(status.MountTime.Time)) | ||
| Expect(copy.Mounts).To(HaveLen(1)) | ||
| Expect(copy.Mounts[0].MountPoint).To(Equal("s3://bucket/data")) | ||
|
|
||
| copy.Mounts[0].MountPoint = "changed" |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5891 +/- ##
=======================================
Coverage 61.65% 61.65%
=======================================
Files 480 480
Lines 32613 32613
=======================================
Hits 20108 20108
Misses 10897 10897
Partials 1608 1608 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Harsh <harshmastic@gmail.com>
03b643a to
a334163
Compare
|
/gemini review |
| @@ -0,0 +1,47 @@ | |||
| /* | |||
| Copyright 2020 The Fluid Authors. | |||
There was a problem hiding this comment.
Code Review
This pull request refactors the v1alpha1 API unit tests to use the Ginkgo and Gomega frameworks, adding coverage for CacheRuntime, Dataset operations, network modes, and status deep-copy helpers. The reviewer suggested improving the EFCRuntime.Replicas test by adding a case for disabled workers and recommended using Kind constants instead of hardcoded strings in test tables for better consistency.
| Entry(EFCRuntimeKind, &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)), | ||
| Entry("GooseFSRuntime", &GooseFSRuntime{Spec: GooseFSRuntimeSpec{Replicas: 2}}, int32(2)), | ||
| Entry("JindoRuntime", &JindoRuntime{Spec: JindoRuntimeSpec{Replicas: 3}}, int32(3)), | ||
| Entry("JuiceFSRuntime", &JuiceFSRuntime{Spec: JuiceFSRuntimeSpec{Replicas: 4}}, int32(4)), | ||
| Entry("ThinRuntime", &ThinRuntime{Spec: ThinRuntimeSpec{Replicas: 5}}, int32(5)), | ||
| Entry("VineyardRuntime", &VineyardRuntime{Spec: VineyardRuntimeSpec{Replicas: 6}}, int32(6)), |
There was a problem hiding this comment.
The EFCRuntime.Replicas() implementation includes specific logic to return 0 if the worker is disabled; this edge case should be covered in the test table. Additionally, use the available Kind constants (e.g., JindoRuntimeKind, JuiceFSRuntimeKind, etc.) for entry names to improve consistency and avoid hardcoded strings.
Entry(EFCRuntimeKind, &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)),
Entry(EFCRuntimeKind+" (disabled)", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2, Worker: EFCCompTemplateSpec{Disabled: true}}}, int32(0)),
Entry("GooseFSRuntime", &GooseFSRuntime{Spec: GooseFSRuntimeSpec{Replicas: 2}}, int32(2)),
Entry(JindoRuntimeKind, &JindoRuntime{Spec: JindoRuntimeSpec{Replicas: 3}}, int32(3)),
Entry(JuiceFSRuntimeKind, &JuiceFSRuntime{Spec: JuiceFSRuntimeSpec{Replicas: 4}}, int32(4)),
Entry(ThinRuntimeKind, &ThinRuntime{Spec: ThinRuntimeSpec{Replicas: 5}}, int32(5)),
Entry(VineyardRuntimeKind, &VineyardRuntime{Spec: VineyardRuntimeSpec{Replicas: 6}}, int32(6)),| Entry("EFCRuntime", &EFCRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: EFCRuntimeKind}}, &EFCRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "EFCRuntimeList"}}, EFCRuntimeKind, "EFCRuntimeList"), | ||
| Entry("GooseFSRuntime", &GooseFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntime"}}, &GooseFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntimeList"}}, "GooseFSRuntime", "GooseFSRuntimeList"), | ||
| Entry("JindoRuntime", &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JindoRuntimeKind}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, JindoRuntimeKind, "JindoRuntimeList"), | ||
| Entry("JuiceFSRuntime", &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JuiceFSRuntimeKind}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, JuiceFSRuntimeKind, "JuiceFSRuntimeList"), | ||
| Entry("ThinRuntime", &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: ThinRuntimeKind}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, ThinRuntimeKind, "ThinRuntimeList"), | ||
| Entry("VineyardRuntime", &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: VineyardRuntimeKind}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, VineyardRuntimeKind, "VineyardRuntimeList"), |
There was a problem hiding this comment.
Use the available Kind constants for the entry names to maintain consistency with the Replicas table and avoid hardcoded strings where possible.
| Entry("EFCRuntime", &EFCRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: EFCRuntimeKind}}, &EFCRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "EFCRuntimeList"}}, EFCRuntimeKind, "EFCRuntimeList"), | |
| Entry("GooseFSRuntime", &GooseFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntime"}}, &GooseFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntimeList"}}, "GooseFSRuntime", "GooseFSRuntimeList"), | |
| Entry("JindoRuntime", &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JindoRuntimeKind}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, JindoRuntimeKind, "JindoRuntimeList"), | |
| Entry("JuiceFSRuntime", &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JuiceFSRuntimeKind}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, JuiceFSRuntimeKind, "JuiceFSRuntimeList"), | |
| Entry("ThinRuntime", &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: ThinRuntimeKind}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, ThinRuntimeKind, "ThinRuntimeList"), | |
| Entry("VineyardRuntime", &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: VineyardRuntimeKind}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, VineyardRuntimeKind, "VineyardRuntimeList"), | |
| Entry(EFCRuntimeKind, &EFCRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: EFCRuntimeKind}}, &EFCRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "EFCRuntimeList"}}, EFCRuntimeKind, "EFCRuntimeList"), | |
| Entry("GooseFSRuntime", &GooseFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntime"}}, &GooseFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntimeList"}}, "GooseFSRuntime", "GooseFSRuntimeList"), | |
| Entry(JindoRuntimeKind, &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JindoRuntimeKind}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, JindoRuntimeKind, "JindoRuntimeList"), | |
| Entry(JuiceFSRuntimeKind, &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JuiceFSRuntimeKind}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, JuiceFSRuntimeKind, "JuiceFSRuntimeList"), | |
| Entry(ThinRuntimeKind, &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: ThinRuntimeKind}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, ThinRuntimeKind, "ThinRuntimeList"), | |
| Entry(VineyardRuntimeKind, &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: VineyardRuntimeKind}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, VineyardRuntimeKind, "VineyardRuntimeList"), |
Signed-off-by: Harsh <harshmastic@gmail.com>
3673d81 to
4c2ad5f
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates and expands the unit tests for the v1alpha1 API package to use the Ginkgo and Gomega frameworks. It introduces new test files for CacheRuntime, MetadataSyncPolicy, and various Runtime types, while refactoring existing tests for IsHostNetwork and Dataset methods into table-driven Ginkgo tests. Additionally, it adds comprehensive DeepCopy verification for status objects. The reviewer suggests strengthening the DeepCopy tests by ensuring nested pointer identities and values are correctly verified, and increasing test coverage for the EFCRuntime.Replicas logic.
| Expect(copied.Mounts).To(HaveLen(1)) | ||
| Expect(copied.Mounts[0].MountPoint).To(Equal("s3://bucket/data")) |
There was a problem hiding this comment.
The DeepCopy test for RuntimeStatus initializes CacheAffinity but does not verify that it is correctly deep-copied. Adding a pointer identity check ensures that the nested object is a new instance and not a shallow copy.
| Expect(copied.Mounts).To(HaveLen(1)) | |
| Expect(copied.Mounts[0].MountPoint).To(Equal("s3://bucket/data")) | |
| Expect(copied.Mounts).To(HaveLen(1)) | |
| Expect(copied.Mounts[0].MountPoint).To(Equal("s3://bucket/data")) | |
| Expect(copied.CacheAffinity).NotTo(BeNil()) | |
| Expect(copied.CacheAffinity).NotTo(BeIdenticalTo(status.CacheAffinity)) |
| Expect(copied.Worker.Phase).To(Equal(RuntimePhasePartialReady)) | ||
| Expect(copied.MountPoints).To(HaveLen(1)) | ||
| Expect(copied.MountPoints[0].Mount.MountPoint).To(Equal("/data/cache")) | ||
| Expect(copied.MountPoints[0].MountTime).NotTo(BeIdenticalTo(status.MountPoints[0].MountTime)) |
There was a problem hiding this comment.
It is recommended to verify the value of MountTime in addition to its pointer identity to ensure data integrity after the deep copy.
| Expect(copied.MountPoints[0].MountTime).NotTo(BeIdenticalTo(status.MountPoints[0].MountTime)) | |
| Expect(copied.MountPoints[0].MountTime).NotTo(BeIdenticalTo(status.MountPoints[0].MountTime)) | |
| Expect(copied.MountPoints[0].MountTime.Time).To(Equal(status.MountPoints[0].MountTime.Time)) |
| Expect(copied.WaitingFor.OperationComplete).NotTo(BeNil()) | ||
| Expect(*copied.WaitingFor.OperationComplete).To(BeTrue()) |
There was a problem hiding this comment.
The DeepCopy test for OperationStatus should verify that nested pointers like WaitingFor.OperationComplete and NodeAffinity are actually deep-copied by checking their pointer identity.
| Expect(copied.WaitingFor.OperationComplete).NotTo(BeNil()) | |
| Expect(*copied.WaitingFor.OperationComplete).To(BeTrue()) | |
| Expect(copied.WaitingFor.OperationComplete).NotTo(BeNil()) | |
| Expect(*copied.WaitingFor.OperationComplete).To(BeTrue()) | |
| Expect(copied.WaitingFor.OperationComplete).NotTo(BeIdenticalTo(status.WaitingFor.OperationComplete)) | |
| Expect(copied.NodeAffinity).NotTo(BeNil()) | |
| Expect(copied.NodeAffinity).NotTo(BeIdenticalTo(status.NodeAffinity)) |
| Expect(runtimeObj.Replicas()).To(Equal(expected)) | ||
| }, | ||
| Entry("AlluxioRuntime", &AlluxioRuntime{Spec: AlluxioRuntimeSpec{Replicas: 1}}, int32(1)), | ||
| Entry("EFCRuntime", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)), |
There was a problem hiding this comment.
The Replicas() method for EFCRuntime contains logic that returns 0 if the runtime is disabled. It would be beneficial to add a test case for this branch to ensure full coverage of the helper method.
| Entry("EFCRuntime", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)), | |
| Entry("EFCRuntime", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)), | |
| Entry("EFCRuntime (disabled)", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2, Worker: EFCCompTemplateSpec{Disabled: true}}}, int32(0)), |
|
/gemini review |
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request migrates and expands the unit tests for the v1alpha1 API package to use the Ginkgo and Gomega testing frameworks. It introduces new test coverage for CacheRuntime, MetadataSyncPolicy, and various Runtime helpers, while refactoring existing tests for Dataset operations and network modes into table-driven Ginkgo tests. Additionally, it adds comprehensive DeepCopy tests for status objects. The reviewer feedback highlights opportunities to improve maintainability by consistently using defined Kind constants instead of hardcoded string literals in the test tables for runtime objects and scheme registration.
| Entry("AlluxioRuntime", &AlluxioRuntime{Spec: AlluxioRuntimeSpec{Replicas: 1}}, int32(1)), | ||
| Entry("EFCRuntime", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2}}, int32(2)), | ||
| Entry("EFCRuntime disabled worker", &EFCRuntime{Spec: EFCRuntimeSpec{Replicas: 2, Worker: EFCCompTemplateSpec{Disabled: true}}}, int32(0)), | ||
| Entry("GooseFSRuntime", &GooseFSRuntime{Spec: GooseFSRuntimeSpec{Replicas: 2}}, int32(2)), | ||
| Entry(JindoRuntimeKind, &JindoRuntime{Spec: JindoRuntimeSpec{Replicas: 3}}, int32(3)), | ||
| Entry(JuiceFSRuntimeKind, &JuiceFSRuntime{Spec: JuiceFSRuntimeSpec{Replicas: 4}}, int32(4)), | ||
| Entry(ThinRuntimeKind, &ThinRuntime{Spec: ThinRuntimeSpec{Replicas: 5}}, int32(5)), | ||
| Entry(VineyardRuntimeKind, &VineyardRuntime{Spec: VineyardRuntimeSpec{Replicas: 6}}, int32(6)), |
There was a problem hiding this comment.
The entry names in this table are inconsistent. Some use string literals (e.g., "AlluxioRuntime", "EFCRuntime") while others use Kind constants (e.g., JindoRuntimeKind, JuiceFSRuntimeKind). For better maintainability and to avoid potential typos, it is recommended to use the defined Kind constants consistently for all entry names where they are available.
| Entry("AlluxioRuntime", &AlluxioRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "AlluxioRuntime"}}, &AlluxioRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "AlluxioRuntimeList"}}, "AlluxioRuntime", "AlluxioRuntimeList"), | ||
| Entry("EFCRuntime", &EFCRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: EFCRuntimeKind}}, &EFCRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "EFCRuntimeList"}}, EFCRuntimeKind, "EFCRuntimeList"), | ||
| Entry("GooseFSRuntime", &GooseFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntime"}}, &GooseFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "GooseFSRuntimeList"}}, "GooseFSRuntime", "GooseFSRuntimeList"), | ||
| Entry(JindoRuntimeKind, &JindoRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JindoRuntimeKind}}, &JindoRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JindoRuntimeList"}}, JindoRuntimeKind, "JindoRuntimeList"), | ||
| Entry(JuiceFSRuntimeKind, &JuiceFSRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: JuiceFSRuntimeKind}}, &JuiceFSRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "JuiceFSRuntimeList"}}, JuiceFSRuntimeKind, "JuiceFSRuntimeList"), | ||
| Entry(ThinRuntimeKind, &ThinRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: ThinRuntimeKind}}, &ThinRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "ThinRuntimeList"}}, ThinRuntimeKind, "ThinRuntimeList"), | ||
| Entry(VineyardRuntimeKind, &VineyardRuntime{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: VineyardRuntimeKind}}, &VineyardRuntimeList{TypeMeta: metav1.TypeMeta{APIVersion: GroupVersion.String(), Kind: "VineyardRuntimeList"}}, VineyardRuntimeKind, "VineyardRuntimeList"), |
There was a problem hiding this comment.
There is an inconsistency in how runtime Kind names are referenced in this registration table. Some entries hardcode the Kind as a string literal (e.g., "AlluxioRuntime", "GooseFSRuntime"), while others correctly use the defined constants (e.g., EFCRuntimeKind, JindoRuntimeKind). Please use the defined Kind constants consistently across all entries to improve maintainability and ensure alignment with the API definitions.
3816c87 to
f75e60b
Compare
|
|
/ok-to-test |



Ⅰ. Describe what this PR does
Add Ginkgo/Gomega coverage for runtime/status API helper types in
api/v1alpha1. This PR is intentionally stacked after #5889 locally to reuse the packagesuite_test.go, but is opened againstmasterfor upstream review.Ⅱ. 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.
Replicas()coverage for Alluxio, GooseFS, Jindo, JuiceFS, Thin, and Vineyard runtime API typesGetStatus()and scheme/GVK registration coverage for runtime and CacheRuntime API objectsⅣ. Describe how to verify it
Run the
api/v1alpha1unit tests and confirm the new Ginkgo specs pass.Ⅴ. Special notes for reviews
Stacked after #5889 conceptually; no dependency on PR2 dataops files, and this diff is test-only.