Skip to content

test(api/v1alpha1): add runtime and status type coverage#5891

Open
hxrshxz wants to merge 10 commits into
fluid-cloudnative:masterfrom
hxrshxz:test/api-v1alpha1-runtimes-ginkgo
Open

test(api/v1alpha1): add runtime and status type coverage#5891
hxrshxz wants to merge 10 commits into
fluid-cloudnative:masterfrom
hxrshxz:test/api-v1alpha1-runtimes-ginkgo

Conversation

@hxrshxz
Copy link
Copy Markdown
Contributor

@hxrshxz hxrshxz commented May 17, 2026

Ⅰ. 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 package suite_test.go, but is opened against master for 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.

  • add Replicas() coverage for Alluxio, GooseFS, Jindo, JuiceFS, Thin, and Vineyard runtime API types
  • add GetStatus() and scheme/GVK registration coverage for runtime and CacheRuntime API objects
  • add lightweight status deepcopy and field-preservation coverage for runtime/cache/operation status structs

Ⅳ. Describe how to verify it

Run the api/v1alpha1 unit 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.

Signed-off-by: Harsh <harshmastic@gmail.com>
Copilot AI review requested due to automatic review settings May 17, 2026 10:52
@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 17, 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
Copy Markdown

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

Comment thread api/v1alpha1/runtime_types_test.go Outdated
Comment on lines +29 to +31
func(runtime interface{ Replicas() int32 }, expected int32) {
Expect(runtime.Replicas()).To(Equal(expected))
},
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 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.

Suggested change
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))
},

Comment thread api/v1alpha1/runtime_types_test.go Outdated
Comment on lines +105 to +108
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"),
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

Use the existing constants like JindoRuntimeKind, JuiceFSRuntimeKind, ThinRuntimeKind, and VineyardRuntimeKind instead of hardcoded strings to improve maintainability and avoid potential typos.

Suggested change
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"),

Comment thread api/v1alpha1/status_test.go Outdated
CacheAffinity: &corev1.NodeAffinity{},
}

copy := status.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 variable name copy shadows the built-in copy function. It is recommended to use a different name like cloned or statusCopy to avoid potential confusion with the built-in function.

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

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 and GetStatus() 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, and OperationStatus.

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.

Comment thread api/v1alpha1/runtime_types_test.go Outdated
Comment on lines +32 to +37
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)),
Comment thread api/v1alpha1/common_test.go Outdated
Comment on lines +5 to +15
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.
*/
Comment thread api/v1alpha1/status_test.go Outdated
Comment on lines +50 to +63
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
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.65%. Comparing base (ed9b7ef) to head (f75e60b).
⚠️ Report is 15 commits behind head on master.

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.
📢 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 hxrshxz force-pushed the test/api-v1alpha1-runtimes-ginkgo branch from 03b643a to a334163 Compare May 17, 2026 11:06
@hxrshxz hxrshxz requested a review from Copilot May 17, 2026 11:52
@hxrshxz
Copy link
Copy Markdown
Contributor Author

hxrshxz commented May 17, 2026

/gemini review

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 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread api/v1alpha1/common_test.go Outdated
@@ -0,0 +1,47 @@
/*
Copyright 2020 The Fluid Authors.
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 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.

Comment thread api/v1alpha1/runtime_types_test.go Outdated
Comment on lines +34 to +39
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)),
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 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)),

Comment thread api/v1alpha1/runtime_types_test.go Outdated
Comment on lines +114 to +119
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"),
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

Use the available Kind constants for the entry names to maintain consistency with the Replicas table and avoid hardcoded strings where possible.

Suggested change
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>
@hxrshxz hxrshxz force-pushed the test/api-v1alpha1-runtimes-ginkgo branch from 3673d81 to 4c2ad5f Compare May 17, 2026 11:55
@hxrshxz
Copy link
Copy Markdown
Contributor Author

hxrshxz commented May 17, 2026

/gemini review

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

Comment on lines +60 to +61
Expect(copied.Mounts).To(HaveLen(1))
Expect(copied.Mounts[0].MountPoint).To(Equal("s3://bucket/data"))
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 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.

Suggested change
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))
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

It is recommended to verify the value of MountTime in addition to its pointer identity to ensure data integrity after the deep copy.

Suggested change
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))

Comment on lines +128 to +129
Expect(copied.WaitingFor.OperationComplete).NotTo(BeNil())
Expect(*copied.WaitingFor.OperationComplete).To(BeTrue())
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 DeepCopy test for OperationStatus should verify that nested pointers like WaitingFor.OperationComplete and NodeAffinity are actually deep-copied by checking their pointer identity.

Suggested change
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)),
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 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.

Suggested change
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)),

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 7 out of 7 changed files in this pull request and generated no new comments.

@hxrshxz
Copy link
Copy Markdown
Contributor Author

hxrshxz commented May 17, 2026

/gemini review

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 7 out of 7 changed files in this pull request and generated no new comments.

hxrshxz added 3 commits May 17, 2026 17:37
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: Harsh <harshmastic@gmail.com>
hxrshxz added 4 commits May 17, 2026 17:38
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>
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 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.

Comment on lines +33 to +40
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)),
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 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.

Comment on lines +114 to +120
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"),
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

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.

@hxrshxz hxrshxz force-pushed the test/api-v1alpha1-runtimes-ginkgo branch from 3816c87 to f75e60b Compare May 17, 2026 12:08
@sonarqubecloud
Copy link
Copy Markdown

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 18, 2026

/ok-to-test

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