MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / TestTransformValidatorShared

Function TestTransformValidatorShared

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

Source from the content-addressed store, hash-verified

2394}
2395
2396func TestTransformValidatorShared(t *testing.T) {
2397 testCases := []struct {
2398 description string
2399 ds Daemonset
2400 cpSpec *gpuv1.ClusterPolicySpec
2401 expectedDs Daemonset
2402 }{
2403 {
2404 description: "transform validator daemonset's main container",
2405 ds: NewDaemonset().WithContainer(corev1.Container{Name: "test-ctr"}),
2406 cpSpec: &gpuv1.ClusterPolicySpec{
2407 Validator: gpuv1.ValidatorSpec{
2408 Repository: "nvcr.io/nvidia/cloud-native",
2409 Image: "gpu-operator-validator",
2410 Version: "v1.0.0",
2411 ImagePullPolicy: "IfNotPresent",
2412 ImagePullSecrets: []string{"pull-secret"},
2413 Resources: &gpuv1.ResourceRequirements{
2414 Limits: corev1.ResourceList{
2415 corev1.ResourceCPU: resource.MustParse("500m"),
2416 "memory": resource.MustParse("200Mi"),
2417 },
2418 Requests: corev1.ResourceList{
2419 corev1.ResourceCPU: resource.MustParse("500m"),
2420 "memory": resource.MustParse("200Mi"),
2421 },
2422 },
2423 Args: []string{"--test-flag"},
2424 Env: []gpuv1.EnvVar{{Name: "foo", Value: "bar"}},
2425 },
2426 },
2427 expectedDs: NewDaemonset().WithContainer(corev1.Container{
2428 Name: "test-ctr",
2429 Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0",
2430 ImagePullPolicy: corev1.PullIfNotPresent,
2431 Resources: corev1.ResourceRequirements{
2432 Limits: corev1.ResourceList{
2433 corev1.ResourceCPU: resource.MustParse("500m"),
2434 "memory": resource.MustParse("200Mi"),
2435 },
2436 Requests: corev1.ResourceList{
2437 corev1.ResourceCPU: resource.MustParse("500m"),
2438 "memory": resource.MustParse("200Mi"),
2439 },
2440 },
2441 Args: []string{"--test-flag"},
2442 Env: []corev1.EnvVar{{Name: "foo", Value: "bar"}},
2443 SecurityContext: &corev1.SecurityContext{
2444 RunAsUser: rootUID,
2445 },
2446 }).WithPullSecret("pull-secret"),
2447 },
2448 }
2449
2450 for _, tc := range testCases {
2451 t.Run(tc.description, func(t *testing.T) {
2452 err := TransformValidatorShared(tc.ds.DaemonSet, tc.cpSpec)
2453 require.NoError(t, err)

Callers

nothing calls this directly

Calls 5

NewDaemonsetFunction · 0.85
TransformValidatorSharedFunction · 0.85
WithContainerMethod · 0.80
WithPullSecretMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected