(t *testing.T)
| 1089 | } |
| 1090 | |
| 1091 | func TestTransformDevicePlugin(t *testing.T) { |
| 1092 | testCases := []struct { |
| 1093 | description string |
| 1094 | ds Daemonset // Input DaemonSet |
| 1095 | cpSpec *gpuv1.ClusterPolicySpec // Input configuration |
| 1096 | expectedDs Daemonset // Expected output DaemonSet |
| 1097 | }{ |
| 1098 | { |
| 1099 | description: "transform device plugin", |
| 1100 | ds: NewDaemonset(). |
| 1101 | WithContainer(corev1.Container{Name: "nvidia-device-plugin"}). |
| 1102 | WithContainer(corev1.Container{Name: "dummy"}), |
| 1103 | cpSpec: &gpuv1.ClusterPolicySpec{ |
| 1104 | DevicePlugin: gpuv1.DevicePluginSpec{ |
| 1105 | Repository: "nvcr.io/nvidia/cloud-native", |
| 1106 | Image: "nvidia-device-plugin", |
| 1107 | Version: "v1.0.0", |
| 1108 | ImagePullPolicy: "IfNotPresent", |
| 1109 | ImagePullSecrets: []string{"pull-secret"}, |
| 1110 | Args: []string{"--fail-on-init-error=false"}, |
| 1111 | Env: []gpuv1.EnvVar{ |
| 1112 | {Name: "foo", Value: "bar"}, |
| 1113 | }, |
| 1114 | }, |
| 1115 | Toolkit: gpuv1.ToolkitSpec{ |
| 1116 | Enabled: newBoolPtr(true), |
| 1117 | InstallDir: "/path/to/install", |
| 1118 | }, |
| 1119 | }, |
| 1120 | expectedDs: NewDaemonset().WithContainer(corev1.Container{ |
| 1121 | Name: "nvidia-device-plugin", |
| 1122 | Image: "nvcr.io/nvidia/cloud-native/nvidia-device-plugin:v1.0.0", |
| 1123 | ImagePullPolicy: corev1.PullIfNotPresent, |
| 1124 | Args: []string{"--fail-on-init-error=false"}, |
| 1125 | Env: []corev1.EnvVar{ |
| 1126 | {Name: "NVIDIA_MIG_MONITOR_DEVICES", Value: "all"}, |
| 1127 | {Name: CDIEnabledEnvName, Value: "true"}, |
| 1128 | {Name: DeviceListStrategyEnvName, Value: "cdi-annotations,cdi-cri"}, |
| 1129 | {Name: CDIAnnotationPrefixEnvName, Value: "cdi.k8s.io/"}, |
| 1130 | {Name: NvidiaCDIHookPathEnvName, Value: "/path/to/install/toolkit/nvidia-cdi-hook"}, |
| 1131 | {Name: "foo", Value: "bar"}, |
| 1132 | }, |
| 1133 | }).WithContainer(corev1.Container{Name: "dummy"}).WithPullSecret("pull-secret").WithRuntimeClassName("nvidia"), |
| 1134 | }, |
| 1135 | { |
| 1136 | description: "transform device plugin, gds and gdrcopy enabled", |
| 1137 | ds: NewDaemonset(). |
| 1138 | WithContainer(corev1.Container{Name: "nvidia-device-plugin"}), |
| 1139 | cpSpec: &gpuv1.ClusterPolicySpec{ |
| 1140 | DevicePlugin: gpuv1.DevicePluginSpec{ |
| 1141 | Repository: "nvcr.io/nvidia/cloud-native", |
| 1142 | Image: "nvidia-device-plugin", |
| 1143 | Version: "v1.0.0", |
| 1144 | ImagePullPolicy: "IfNotPresent", |
| 1145 | }, |
| 1146 | Toolkit: gpuv1.ToolkitSpec{ |
| 1147 | Enabled: newBoolPtr(true), |
| 1148 | InstallDir: "/path/to/install", |
nothing calls this directly
no test coverage detected