Add unit tests for the gpuop-cfg config validators - #2908
abrarshivani wants to merge 1 commit into
Conversation
Cover the remaining gaps in cmd/gpuop-cfg/validate: the operand walk in clusterpolicy.validateImages, the deployment and env-var branches in csv.validateImages, both ManifestGet outcomes in validateImage, and the CLI Before/Action closures that were previously never invoked. The registry client is constructed inline with no injection seam, so the tests drive it through regclient's ocidir scheme against an OCI layout written into t.TempDir(). That exercises the validator's own control flow without a socket. The registry transport itself stays untested. Each of the eleven operands resolves at its own tag, so an error naming a tag names the operand whose field produced it. Dropping an operand's block, duplicating another over it, or reading the wrong spec field all fail the corresponding case. clusterpolicy 26.7% -> 100%, csv 55.4% -> 100%. Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Enterprise Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughExpanded cluster policy and CSV validation tests. The tests cover malformed inputs, missing image configuration, OCI image resolution, operand validation, image tags, environment variables, optional GDS configuration, cancelled contexts, and missing ClusterPolicy data. Command tests write temporary inputs and run Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This change only expands automated test coverage for existing validation logic and does not modify any production behavior, so it carries no direct risk to runtime behavior, data integrity, or security. Repository inspection did not surface any defects in the new tests themselves, so the change appears safe to merge pending normal CI verification. Comment |
Closes the remaining coverage gaps in
cmd/gpuop-cfg/validate. Tests only — no production changes.Coverage
validatevalidate/clusterpolicyvalidate/csvcmd/gpuop-cfgstays at 0%:mainends inlog.Exit, so its error path can't be covered in-process.What's now covered
clusterpolicy.validateImages, which had never returnednilin a testcsv.validateImagesManifestGetoutcomes invalidateImageBefore/Actionclosures,validateFlagsandrun, none previously invokedApproach
validateImagebuilds its registry client inline, so the tests drive it through regclient'socidirscheme against an OCI layout int.TempDir()— hermetic, no networkPre-existing issues these tests ran into
Not fixed here, since this is tests-only. Flagging them rather than losing them:
csv.validateImagesindexesDeploymentSpecs[0]/Containers[0]unguarded, sogpuop-cfg validate csvon empty stdin dies with a stack trace instead of an error-ubuntu22.04appended unconditionally, so a digest-pinned image becomes an invalid reference and can never validate%v, not%w, so causes are flattened and assertions have to match on message textNote for whoever fixes the digest issue:
TestValidateImages_DriverImageOSTagAppendedand its GDS counterpart assert the suffix is appended. They pin current behaviour and will need updating — they aren't an endorsement of it.Happy to split any of the above into separate issues or PRs if useful.