Skip to content

[quality] test: add 33 unit tests for pkg/k8s GPU health helpers#19556

Open
clubanderson wants to merge 2 commits into
mainfrom
quality/test-gpu-health-helpers
Open

[quality] test: add 33 unit tests for pkg/k8s GPU health helpers#19556
clubanderson wants to merge 2 commits into
mainfrom
quality/test-gpu-health-helpers

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

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:

Function Tests What's verified
deriveGPUNodeStatus 7 healthy/degraded/unhealthy transitions, critical vs non-critical checks, ≥3 failures threshold, empty input
isStuckPod 6 ContainerStatusUnknown, terminating >5min, terminating <5min (not stuck), pending >10min, pending <10min (not stuck), healthy running
checkOperatorPod 6 Running pod passes, CrashLoopBackOff fails, Pending/ImagePullBackOff fails, pod on wrong node (not-found), nil pods, empty pods
unstructuredNestedMap/Slice 8 Valid paths, deep nesting, missing keys, wrong types, nil input
IsGPUResourceName / SumGPURequested 6 All known vendors, unknown resources, multi-vendor sum, nil/empty inputs

Why this matters:

  • These functions drive the GPU health dashboard — bugs silently misclassify node health
  • deriveGPUNodeStatus has non-obvious critical-check logic that was completely untested
  • isStuckPod determines operator alerts for GPU nodes; wrong thresholds = missed issues
  • unstructuredNestedMap/Slice parse CRD data — nil panics crash handlers

Fixes #19555


Filed by quality agent (ACMM L4/L6 — full mode)

Copilot AI review requested due to automatic review settings June 25, 2026 00:42
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[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 clubanderson for approval. For more information see the 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

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 25, 2026
@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 1c39e98
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a3c884c422e810008dad7be
😎 Deploy Preview https://deploy-preview-19556.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

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

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 deriveGPUNodeStatus covering critical-check failures, non-critical thresholds, and empty input.
  • Add unit tests for isStuckPod and checkOperatorPod covering common stuck/CrashLoopBackOff/Pending/not-found scenarios.
  • Add unit tests for unstructuredNestedMap / unstructuredNestedSlice for valid paths, missing keys, wrong types, and nil input.

Comment on lines +423 to +427
// --- 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>
@kubestellar-hive kubestellar-hive Bot force-pushed the quality/test-gpu-health-helpers branch from a246ea1 to c41d732 Compare June 25, 2026 01:24
@clubanderson clubanderson added hold Blocked — do not touch quality testing and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. dco-signoff: yes Indicates the PR's author has signed the DCO. ai-generated Pull request generated by AI tier/1-lightweight labels Jun 25, 2026
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 25, 2026
@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/1-lightweight labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. hold Blocked — do not touch quality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. testing tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] pkg/k8s GPU health subsystem has zero test coverage — 5 pure helpers untested

2 participants