test: add unit tests for LinkDevice scoring - #2411
Conversation
Signed-off-by: aaka24 <yaarsuperstar44@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: aaka24 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 |
📝 WalkthroughWalkthroughAdded table-driven unit tests for metax device scoring and collection string formatting. The tests cover UUIDs, link zones, pairwise score accumulation, empty collections, and device output. ChangesMetax scoring tests
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 1
🤖 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/metax/score_test.go`:
- Around line 166-181: Update the test table’s non-empty case to provide the
exact expected device string, then change the assertions in the t.Run block to
compare result with expected for every case. Retain the existing
bracketed-output validation only if needed, while ensuring mismatched device
order or formatting causes the test to fail.
🪄 Autofix
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: 2abd77bb-2953-4241-8c6e-91f343654c83
📒 Files selected for processing (1)
pkg/device/metax/score_test.go
Signed-off-by: aaka24 <yaarsuperstar44@gmail.com>
65fc778 to
a287714
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
please sync with master to pass the CI |
|
Thanks for the contribution. These tests cover simple LinkDevice summation and the current formatting of String(). The latter is not a public compatibility contract, so pinning its exact text adds maintenance cost without protecting user behavior. There is no linked defect or reproducible regression, and the current unit-test check is still failing after the requested sync. We are closing this PR. Please choose a maintainer-confirmed issue with an observable failure for the next contribution. |
|
I understand the concerns regarding testing the I'll keep this feedback in mind for future contributions and will focus on issues with observable failures that have maintainer confirmation. Thanks again for the review and guidance. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds unit tests for the metax device link scoring logic in
pkg/device/metax/score.go.The scoring functions (
LinkDevice.score(),LinkDevices.Score(), andLinkDevices.String()) previously had no dedicated test coverage.This change adds table-driven tests covering normal cases and edge cases
without modifying any production code.
Changes (test-only,
pkg/device/metax/score_test.go):Added tests for
LinkDevice.score():linkZonevalueslinkZonevalueslinkZonevaluesAdded tests for
LinkDevices.Score():Added tests for
LinkDevices.String():This improves coverage of metax topology scoring behavior and helps
prevent regressions in scheduler extender link scoring logic.
Which issue(s) this PR fixes:
Fixes #2410
Special notes for your reviewer:
CI failure appears unrelated to this PR. The failing package is pkg/scheduler, while this PR only adds unit tests for pkg/device/metax/score.go. The new metax tests pass locally with go test ./pkg/device/metax/....
Validation performed locally:
go test ./pkg/device/metax/... -run TestLinkDevice -v— passgofmt -l pkg/device/metax/score_test.go— cleango vet ./pkg/device/metax/...— passThis PR only adds unit tests and does not change production behavior.
The failure logs point to the scheduler package (
pkg/scheduler), specifically around thetest-pod-nodefailpath. No scheduler files or production code are changed in this PR.Does this PR introduce a user-facing change?:
No.
Summary by CodeRabbit