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

Function TestTransformDriver

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

Source from the content-addressed store, hash-verified

3086}
3087
3088func TestTransformDriver(t *testing.T) {
3089 initMockK8sClients()
3090 testCases := []struct {
3091 description string
3092 ds Daemonset
3093 cpSpec *gpuv1.ClusterPolicySpec
3094 client client.Client
3095 expectedDs Daemonset
3096 errorExpected bool
3097 }{
3098 {
3099 description: "driver spec with secret env",
3100 ds: NewDaemonset().WithContainer(corev1.Container{Name: "nvidia-driver-ctr"}).
3101 WithContainer(corev1.Container{Name: "nvidia-fs"}).
3102 WithContainer(corev1.Container{Name: "nvidia-gdrcopy"}).
3103 WithInitContainer(corev1.Container{Name: "k8s-driver-manager"}),
3104 cpSpec: &gpuv1.ClusterPolicySpec{
3105 Driver: gpuv1.DriverSpec{
3106 Repository: "nvcr.io/nvidia",
3107 Image: "driver",
3108 Version: "570.172.08",
3109 Manager: gpuv1.DriverManagerSpec{
3110 Repository: "nvcr.io/nvidia/cloud-native",
3111 Image: "k8s-driver-manager",
3112 Version: "v0.8.0",
3113 },
3114 SecretEnv: "test-env-secret",
3115 },
3116 GPUDirectStorage: &gpuv1.GPUDirectStorageSpec{
3117 Enabled: newBoolPtr(true),
3118 Repository: "nvcr.io/nvidia/cloud-native",
3119 Image: "nvidia-fs",
3120 Version: "2.20.5",
3121 },
3122 GDRCopy: &gpuv1.GDRCopySpec{
3123 Enabled: newBoolPtr(true),
3124 Repository: "nvcr.io/nvidia/cloud-native",
3125 Image: "gdrdrv",
3126 Version: "v2.5",
3127 },
3128 },
3129 client: mockClientMap["secret-env-client"],
3130 expectedDs: NewDaemonset().WithContainer(corev1.Container{
3131 Name: "nvidia-driver-ctr",
3132 Image: "nvcr.io/nvidia/driver:570.172.08-ubuntu20.04",
3133 ImagePullPolicy: corev1.PullIfNotPresent,
3134 EnvFrom: []corev1.EnvFromSource{{
3135 SecretRef: &corev1.SecretEnvSource{
3136 LocalObjectReference: corev1.LocalObjectReference{
3137 Name: "test-env-secret",
3138 },
3139 },
3140 }},
3141 Env: []corev1.EnvVar{
3142 {
3143 Name: "GDRCOPY_ENABLED",
3144 Value: "true",
3145 },

Callers

nothing calls this directly

Calls 9

initMockK8sClientsFunction · 0.85
NewDaemonsetFunction · 0.85
newBoolPtrFunction · 0.85
TransformDriverFunction · 0.85
WithContainerMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80
ErrorMethod · 0.80
WithInitContainerMethod · 0.45

Tested by

no test coverage detected