(t *testing.T)
| 1185 | } |
| 1186 | |
| 1187 | func TestTransformMPSControlDaemon(t *testing.T) { |
| 1188 | testCases := []struct { |
| 1189 | description string |
| 1190 | daemonset Daemonset |
| 1191 | clusterPolicySpec *gpuv1.ClusterPolicySpec |
| 1192 | expectedDaemonset Daemonset |
| 1193 | }{ |
| 1194 | { |
| 1195 | description: "transform mps control daemon", |
| 1196 | daemonset: NewDaemonset(). |
| 1197 | WithInitContainer(corev1.Container{Name: "mps-control-daemon-mounts"}). |
| 1198 | WithContainer(corev1.Container{Name: "mps-control-daemon-ctr"}). |
| 1199 | WithHostPathVolume("mps-root", "/run/nvidia/mps", ptr.To(corev1.HostPathDirectoryOrCreate)). |
| 1200 | WithHostPathVolume("mps-shm", "/run/nvidia/mps/shm", ptr.To(corev1.HostPathDirectoryOrCreate)), |
| 1201 | clusterPolicySpec: &gpuv1.ClusterPolicySpec{ |
| 1202 | DevicePlugin: gpuv1.DevicePluginSpec{ |
| 1203 | Repository: "nvcr.io", |
| 1204 | Image: "mps", |
| 1205 | Version: "latest", |
| 1206 | ImagePullPolicy: string(corev1.PullAlways), |
| 1207 | ImagePullSecrets: []string{"secret"}, |
| 1208 | MPS: &gpuv1.MPSConfig{Root: "/var/mps"}, |
| 1209 | }, |
| 1210 | }, |
| 1211 | expectedDaemonset: NewDaemonset(). |
| 1212 | WithInitContainer(corev1.Container{ |
| 1213 | Name: "mps-control-daemon-mounts", |
| 1214 | Image: "nvcr.io/mps:latest", |
| 1215 | ImagePullPolicy: corev1.PullAlways, |
| 1216 | }). |
| 1217 | WithContainer(corev1.Container{ |
| 1218 | Name: "mps-control-daemon-ctr", |
| 1219 | Image: "nvcr.io/mps:latest", |
| 1220 | ImagePullPolicy: corev1.PullAlways, |
| 1221 | Env: []corev1.EnvVar{ |
| 1222 | {Name: "NVIDIA_MIG_MONITOR_DEVICES", Value: "all"}, |
| 1223 | }, |
| 1224 | }). |
| 1225 | WithHostPathVolume("mps-root", "/var/mps", ptr.To(corev1.HostPathDirectoryOrCreate)). |
| 1226 | WithHostPathVolume("mps-shm", "/var/mps/shm", ptr.To(corev1.HostPathDirectoryOrCreate)). |
| 1227 | WithPullSecret("secret"). |
| 1228 | WithRuntimeClassName("nvidia"), |
| 1229 | }, |
| 1230 | } |
| 1231 | |
| 1232 | for _, tc := range testCases { |
| 1233 | t.Run(tc.description, func(t *testing.T) { |
| 1234 | err := TransformMPSControlDaemon(tc.daemonset.DaemonSet, tc.clusterPolicySpec, ClusterPolicyController{ |
| 1235 | runtime: gpuv1.Containerd, |
| 1236 | logger: ctrl.Log.WithName("test"), |
| 1237 | }) |
| 1238 | require.NoError(t, err) |
| 1239 | require.EqualValues(t, tc.expectedDaemonset.DaemonSet, tc.daemonset.DaemonSet) |
| 1240 | }) |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | func TestTransformDCGMExporter(t *testing.T) { |
nothing calls this directly
no test coverage detected