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

Function TestTransformMPSControlDaemon

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

Source from the content-addressed store, hash-verified

1185}
1186
1187func 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
1244func TestTransformDCGMExporter(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewDaemonsetFunction · 0.85
WithHostPathVolumeMethod · 0.80
WithContainerMethod · 0.80
WithPullSecretMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80
WithInitContainerMethod · 0.45
WithRuntimeClassNameMethod · 0.45

Tested by

no test coverage detected