test(scheduler): add tests for LoadConfig - #2993
magic-peach wants to merge 1 commit into
Conversation
LoadConfig had no test coverage at all despite two distinct error paths, a missing file and invalid YAML, plus the success path that every scheduler component depends on at startup. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
|
@magic-peach: The label(s) DetailsIn response to this:
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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: magic-peach 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds ChangesConfiguration loading validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Merge Risk: ⚪ Minimal · up to This change adds scheduler configuration loader tests without changing production behavior. The added cases cover missing files, invalid YAML, and empty and populated configurations, with no current merge-readiness risk identified. 🚥 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. A rabbit checks each config door Comment |
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. 🚀 New features to boost your workflow:
|
Eshiv-Pandey
left a comment
There was a problem hiding this comment.
imo, this adds coverage for a thin os.ReadFile + yaml.Unmarshal wrapper whose parsing is already covered by Test_LoadConfig in the same file, with no linked issue. idts this pr will survive. don't close it tho.. wait for the maintainers to review this
| } | ||
| } | ||
|
|
||
| func TestLoadConfig(t *testing.T) { |
There was a problem hiding this comment.
There is already a existing Test_LoadConfig func i think it would be very confusing to add a new TestLoadConfig func ,
It would be better if you change the func name and in new function call only error case.
What do you think?
| func TestLoadConfig(t *testing.T) { | ||
| t.Run("file does not exist", func(t *testing.T) { | ||
| _, err := LoadConfig("/nonexistent/path/config.yaml") | ||
| assert.ErrorContains(t, err, "no such file or directory") |
There was a problem hiding this comment.
I think it would be better if we use the existing errors.Is(err, fs.ErrNotExist) instead "no such file or directory" will be better am i correct?.
| } | ||
| } | ||
|
|
||
| func TestLoadConfig(t *testing.T) { |
There was a problem hiding this comment.
did you search for existing LoadConfig tests first?
| func TestLoadConfig(t *testing.T) { | ||
| t.Run("file does not exist", func(t *testing.T) { | ||
| _, err := LoadConfig("/nonexistent/path/config.yaml") | ||
| assert.ErrorContains(t, err, "no such file or directory") |
There was a problem hiding this comment.
why does this break on windows machines?
|
@magic-peach Could we consolidate these into one |
|
Bcs of the inactivity of PR owners, it was closed. It can be re-opened if needed anytime. |
What this PR does / why we need it:
LoadConfig reads and parses the scheduler's YAML config file but had no test
coverage: not for a missing file, not for invalid YAML, not for the success
path every scheduler component depends on at startup. Adds TestLoadConfig
with four subtests: file not found, invalid YAML, an empty file (valid YAML,
zero-value config), and a valid config asserting the parsed nvidia and hygon
fields.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Test-only change, no production code touched. Ran go build, go vet, and the
full pkg/scheduler/config test suite locally, all pass.
Does this PR introduce a user-facing change?
No
This PR was written primarily by Claude Code, an AI coding assistant, under
my direction and review. I have read, tested, and take responsibility for
this change.
Summary by CodeRabbit