What would you like to be added:
Comprehensive unit tests for the cmd/vGPUmonitor package to cover critical paths that are currently untested (0-25% coverage). Specifically:
collectPodAndContainerMigInfo: Table-driven tests to verify the decoding and mapping of MIG allocations (hami.io/vgpu-mig-allocations annotations) to container indices.
- NVML Wrapper Functions (
collectGPUInfo, getDeviceCount, collectGPUDeviceMetrics): Using nvmlmock (which is already imported) to simulate host GPU fetching and ensure NVML failures are handled gracefully.
- Edge cases in
collectPodAndContainerInfo (e.g. handling of malformed/empty UUIDs and lister failures).
Why is this needed:
The cmd/vGPUmonitor is a core component for observability that tracks physical GPU usage and container/MIG instance mappings. While recent PRs improved the overall baseline test coverage to ~43%, the complex MIG mapping and hardware-fetching layers remain heavily untested.
Adding tests for these areas ensures that edge cases (like invalid annotations or NVML runtime errors) are handled smoothly without crashing the scrape or silently corrupting metrics in production environments.
Anything else we need to know?:
/kind test
AI assistance disclosure: I used an AI assistant to help identify these specific untested paths and format this issue, but I have verified the coverage gaps manually.
What would you like to be added:
Comprehensive unit tests for the
cmd/vGPUmonitorpackage to cover critical paths that are currently untested (0-25% coverage). Specifically:collectPodAndContainerMigInfo: Table-driven tests to verify the decoding and mapping of MIG allocations (hami.io/vgpu-mig-allocationsannotations) to container indices.collectGPUInfo,getDeviceCount,collectGPUDeviceMetrics): Usingnvmlmock(which is already imported) to simulate host GPU fetching and ensure NVML failures are handled gracefully.collectPodAndContainerInfo(e.g. handling of malformed/empty UUIDs and lister failures).Why is this needed:
The
cmd/vGPUmonitoris a core component for observability that tracks physical GPU usage and container/MIG instance mappings. While recent PRs improved the overall baseline test coverage to ~43%, the complex MIG mapping and hardware-fetching layers remain heavily untested.Adding tests for these areas ensures that edge cases (like invalid annotations or NVML runtime errors) are handled smoothly without crashing the scrape or silently corrupting metrics in production environments.
Anything else we need to know?:
/kind test