MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / TestTransformValidatorComponent

Function TestTransformValidatorComponent

controllers/transforms_test.go:2459–2764  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2457}
2458
2459func TestTransformValidatorComponent(t *testing.T) {
2460 testCases := []struct {
2461 description string
2462 pod Pod
2463 cpSpec *gpuv1.ClusterPolicySpec
2464 component string
2465 expectedPod Pod
2466 errorExpected bool
2467 }{
2468 {
2469 description: "no validation init container is a no-op",
2470 pod: NewPod(),
2471 cpSpec: nil,
2472 component: "driver",
2473 expectedPod: NewPod(),
2474 },
2475 {
2476 description: "invalid component",
2477 pod: NewPod().WithInitContainer(corev1.Container{Name: "invalid-validation"}),
2478 cpSpec: &gpuv1.ClusterPolicySpec{
2479 Validator: gpuv1.ValidatorSpec{},
2480 },
2481 component: "invalid",
2482 expectedPod: NewPod(),
2483 errorExpected: true,
2484 },
2485 {
2486 description: "cuda validation",
2487 pod: NewPod().
2488 WithInitContainer(corev1.Container{Name: "cuda-validation"}).
2489 WithRuntimeClassName("nvidia"),
2490 cpSpec: &gpuv1.ClusterPolicySpec{
2491 Validator: gpuv1.ValidatorSpec{
2492 Repository: "nvcr.io/nvidia/cloud-native",
2493 Image: "gpu-operator-validator",
2494 Version: "v1.0.0",
2495 ImagePullPolicy: "IfNotPresent",
2496 ImagePullSecrets: []string{"pull-secret1", "pull-secret2"},
2497 CUDA: gpuv1.CUDAValidatorSpec{
2498 Env: []gpuv1.EnvVar{{Name: "foo", Value: "bar"}},
2499 },
2500 },
2501 },
2502 component: "cuda",
2503 expectedPod: NewPod().WithInitContainer(corev1.Container{
2504 Name: "cuda-validation",
2505 Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0",
2506 ImagePullPolicy: corev1.PullIfNotPresent,
2507 Env: []corev1.EnvVar{
2508 {Name: ValidatorImageEnvName, Value: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0"},
2509 {Name: ValidatorImagePullPolicyEnvName, Value: "IfNotPresent"},
2510 {Name: ValidatorImagePullSecretsEnvName, Value: "pull-secret1,pull-secret2"},
2511 {Name: ValidatorRuntimeClassEnvName, Value: "nvidia"},
2512 {Name: "foo", Value: "bar"},
2513 },
2514 SecurityContext: &corev1.SecurityContext{
2515 RunAsUser: rootUID,
2516 },

Callers

nothing calls this directly

Calls 7

NewPodFunction · 0.85
newBoolPtrFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.80
WithInitContainerMethod · 0.45
WithRuntimeClassNameMethod · 0.45

Tested by

no test coverage detected