Skip to content

add test for cache runtime dataload#6116

Open
xliuqq wants to merge 3 commits into
fluid-cloudnative:masterfrom
xliuqq:test
Open

add test for cache runtime dataload#6116
xliuqq wants to merge 3 commits into
fluid-cloudnative:masterfrom
xliuqq:test

Conversation

@xliuqq

@xliuqq xliuqq commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Ⅰ. Describe what this PR does

add test for cache runtime dataload

Ⅱ. Does this pull request fix one issue?

fixes #XXXX

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Signed-off-by: xliuqq <xlzq1992@gmail.com>
@fluid-e2e-bot

fluid-e2e-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

[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 trafalgarzzz for approval by writing /assign @trafalgarzzz 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

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a new test suite dataload_test.go to verify the genDataLoadValue logic of the CacheEngine, covering scenarios such as correct volume/mount wiring, missing DataLoad specs, and empty commands/args. Additionally, it cleans up an unused worker_pod variable in the GHA E2E test script test.sh. The review feedback suggests initializing the test context ctx with a fake recorder in the main BeforeEach block to prevent potential nil pointer panics and simplify individual test cases.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


baseClient = fake.NewFakeClientWithScheme(scheme, runtimeObj, runtimeClass, dataset)
engine = &CacheEngine{Client: baseClient, name: "demo", namespace: "default"}
ctx = cruntime.ReconcileRequestContext{Context: context.Background()}

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

Initializing ctx with a fake recorder in the main BeforeEach block ensures that any unexpected warning or event logged during other test cases won't trigger a nil pointer panic (since ctx.Recorder would otherwise be nil). It also simplifies individual test cases by removing the need to manually construct a testCtx with a fake recorder.

Suggested change
ctx = cruntime.ReconcileRequestContext{Context: context.Background()}
ctx = cruntime.ReconcileRequestContext{
Context: context.Background(),
Recorder: &record.FakeRecorder{},
}

Comment on lines +198 to +200
recorder := &record.FakeRecorder{}
testCtx := cruntime.ReconcileRequestContext{Context: context.Background(), Recorder: recorder}
_, err := engine.genDataLoadValue(testCtx, dataset, runtimeObj, runtimeClass, dataload)

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

Since ctx is now initialized with a fake recorder in the main BeforeEach block, we can reuse ctx directly here instead of creating a local testCtx and recorder.

Suggested change
recorder := &record.FakeRecorder{}
testCtx := cruntime.ReconcileRequestContext{Context: context.Background(), Recorder: recorder}
_, err := engine.genDataLoadValue(testCtx, dataset, runtimeObj, runtimeClass, dataload)
_, err := engine.genDataLoadValue(ctx, dataset, runtimeObj, runtimeClass, dataload)

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@676f47a). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6116   +/-   ##
=========================================
  Coverage          ?   65.08%           
=========================================
  Files             ?      485           
  Lines             ?    33989           
  Branches          ?        0           
=========================================
  Hits              ?    22122           
  Misses            ?    10126           
  Partials          ?     1741           

☔ View full report in Codecov by Harness.
📢 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: xliuqq <xlzq1992@gmail.com>
@cheyang

cheyang commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

/copilot review

@cheyang

cheyang commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

@gemini-code-assist /review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request adds a new unit test suite for genDataLoadValue in pkg/ddc/cache/engine/dataload_test.go and removes an unused local variable worker_pod in test/gha-e2e/curvine/test.sh. The review feedback points out critical issues in the test setup: using an uninitialized &record.FakeRecorder{} directly can cause tests to hang indefinitely, and initializing the engine and context without a recorder risks nil pointer dereferences during event recording.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/ddc/cache/engine/dataload_test.go
Comment thread pkg/ddc/cache/engine/dataload_test.go
Comment thread pkg/ddc/cache/engine/dataload_test.go

Copilot AI left a comment

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.

Pull request overview

This PR adds unit test coverage around CacheEngine.genDataLoadValue to validate DataLoad job wiring (config volumes/mounts/env), and removes unused local variables in a Curvine GHA e2e helper script.

Changes:

  • Add a new Ginkgo test suite for genDataLoadValue, asserting config ConfigMap volume/mount/env correctness and basic error cases.
  • Remove an unused worker_pod variable and its assignment from the Curvine e2e test script.

Reviewed changes

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

File Description
test/gha-e2e/curvine/test.sh Removes unused worker_pod variable/lookup in wait_cache_worker_ready.
pkg/ddc/cache/engine/dataload_test.go Adds Ginkgo tests validating DataLoad value generation (volumes, mounts, env, and error paths).

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

Signed-off-by: xliuqq <xlzq1992@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants