test(kunlun): raise vdevice.go coverage up to 95% - #2176
Conversation
Add unit tests for the KunlunVDevices methods that previously had no direct coverage: InitKunlunVDevice, trimMemory, MutateAdmission, CheckHealth, NodeCleanUp, GetNodeDevices, PatchAnnotations, LockNode, ReleaseNodeLock, CheckType, GenerateResourceRequests, ScoreNode, AddResourceUsage, GetResourceNames, and FitVXPU. LockNode/ReleaseNodeLock/CheckHealth/NodeCleanUp tests use a fake Kubernetes clientset (client.KubeClient = fake.NewClientset()), following the same pattern already used in the hygon and biren device test suites. Signed-off-by: Aditya Raut <araut7798@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds comprehensive unit tests for Kunlun virtual device initialization, admission mutation, node state handling, annotations, locking, resource accounting, scoring, and VXPU fitting. Admission mutation also initializes nil resource request maps before writing memory requests. ChangesKunlun virtual device tests
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/device/kunlun/vdevice_test.go`:
- Around line 43-55: Strengthen Test_InitKunlunVDevice by reasserting after the
second InitKunlunVDevice call that device.InRequestDevices[XPUDevice],
device.SupportDevices[XPUDevice], and util.HandshakeAnnos[XPUDevice] still equal
their expected values. Keep the existing non-nil assertion and initial
registration checks unchanged.
- Around line 109-122: Guard Resources.Requests before writing the trimmed
KunlunResourceVMemory value in MutateAdmission. Initialize the request resource
list when it is nil, then perform the existing assignment; preserve current
behavior when Requests is already populated.
- Around line 288-328: Initialize Kunlun configuration before constructing
resource-name fixtures in both Test_KunlunVDevices_LockNode and
Test_KunlunVDevices_ReleaseNodeLock. In pkg/device/kunlun/vdevice_test.go lines
288-328 and 330-378, move InitKunlunVDevice(testVConfig()) to the start of each
test function before its tests literal, and remove the per-subtest
initialization from each t.Run closure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f4c2c7a-b547-4aad-95e7-455ffdc1bae8
📒 Files selected for processing (1)
pkg/device/kunlun/vdevice_test.go
|
could you resolve these comments? |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
every other test passes on its own, these 2 dont?
$ go test ./pkg/device/kunlun/ -run '^Test_KunlunVDevices_LockNode$' -count=1
--- FAIL: Test_KunlunVDevices_LockNode/container_requesting_xpu_locks_node
vdevice_test.go:325: assertion failed: false (ok bool) != true (test.hasLock bool)
also no ai disclosure in the description, see https://github.com/Project-HAMi/HAMi/blob/master/CONTRIBUTING.md#ai-assistance-notice
Signed-off-by: Aditya Raut <araut7798@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adity1raut, archlitchi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Summary by CodeRabbit