[quality] test: add 33 unit tests for pkg/k8s GPU health helpers#19556
[quality] test: add 33 unit tests for pkg/k8s GPU health helpers#19556clubanderson wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
There was a problem hiding this comment.
Pull request overview
Adds a focused unit-test suite for GPU health helper logic in pkg/k8s, improving confidence in node health classification and pod/operator status edge cases that feed the GPU dashboard.
Changes:
- Add unit tests for
deriveGPUNodeStatuscovering critical-check failures, non-critical thresholds, and empty input. - Add unit tests for
isStuckPodandcheckOperatorPodcovering common stuck/CrashLoopBackOff/Pending/not-found scenarios. - Add unit tests for
unstructuredNestedMap/unstructuredNestedSlicefor valid paths, missing keys, wrong types, and nil input.
| // --- Tests for IsGPUResourceName --- | ||
|
|
||
| func TestIsGPUResourceName_Known(t *testing.T) { | ||
| known := []corev1.ResourceName{ | ||
| "nvidia.com/gpu", |
Adds comprehensive unit tests for 5 pure helper functions in the GPU health subsystem that previously had zero test coverage: - deriveGPUNodeStatus: 7 tests covering healthy/degraded/unhealthy transitions - isStuckPod: 6 tests covering all stuck conditions + happy path - checkOperatorPod: 6 tests covering running/crashloop/pending/not-found - unstructuredNestedMap/Slice: 8 tests covering valid paths, missing keys, type mismatches - IsGPUResourceName/SumGPURequested: 6 tests covering known/unknown/multi-vendor Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Copilot <copilot@users.noreply.github.com>
a246ea1 to
c41d732
Compare
Test Improvement
Adds 33 unit tests for 5 pure helper functions in the GPU health subsystem (
pkg/k8s) that previously had zero test coverage.Tests added:
deriveGPUNodeStatusisStuckPodcheckOperatorPodunstructuredNestedMap/SliceIsGPUResourceName/SumGPURequestedWhy this matters:
deriveGPUNodeStatushas non-obvious critical-check logic that was completely untestedisStuckPoddetermines operator alerts for GPU nodes; wrong thresholds = missed issuesunstructuredNestedMap/Sliceparse CRD data — nil panics crash handlersFixes #19555
Filed by quality agent (ACMM L4/L6 — full mode)