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

Function TestTransformDevicePluginCtrForCDI

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

Source from the content-addressed store, hash-verified

3261}
3262
3263func TestTransformDevicePluginCtrForCDI(t *testing.T) {
3264 testCases := []struct {
3265 description string
3266 ds Daemonset
3267 cpSpec *gpuv1.ClusterPolicySpec
3268 expectedDs Daemonset
3269 }{
3270 {
3271 description: "toolkit disabled",
3272 ds: NewDaemonset().WithContainer(corev1.Container{Name: "main-ctr"}),
3273 cpSpec: &gpuv1.ClusterPolicySpec{
3274 Toolkit: gpuv1.ToolkitSpec{
3275 Enabled: newBoolPtr(false),
3276 },
3277 },
3278 expectedDs: NewDaemonset().WithContainer(
3279 corev1.Container{
3280 Name: "main-ctr",
3281 Env: []corev1.EnvVar{
3282 {Name: CDIEnabledEnvName, Value: "true"},
3283 {Name: DeviceListStrategyEnvName, Value: "cdi-annotations,cdi-cri"},
3284 {Name: CDIAnnotationPrefixEnvName, Value: "cdi.k8s.io/"},
3285 },
3286 }),
3287 },
3288 {
3289 description: "toolkit enabled",
3290 ds: NewDaemonset().WithContainer(corev1.Container{Name: "main-ctr"}),
3291 cpSpec: &gpuv1.ClusterPolicySpec{
3292 Toolkit: gpuv1.ToolkitSpec{
3293 Enabled: newBoolPtr(true),
3294 InstallDir: "/path/to/install",
3295 },
3296 },
3297 expectedDs: NewDaemonset().WithContainer(
3298 corev1.Container{
3299 Name: "main-ctr",
3300 Env: []corev1.EnvVar{
3301 {Name: CDIEnabledEnvName, Value: "true"},
3302 {Name: DeviceListStrategyEnvName, Value: "cdi-annotations,cdi-cri"},
3303 {Name: CDIAnnotationPrefixEnvName, Value: "cdi.k8s.io/"},
3304 {Name: NvidiaCDIHookPathEnvName, Value: "/path/to/install/toolkit/nvidia-cdi-hook"},
3305 },
3306 }),
3307 },
3308 }
3309
3310 for _, tc := range testCases {
3311 t.Run(tc.description, func(t *testing.T) {
3312 mainContainer := &tc.ds.Spec.Template.Spec.Containers[0]
3313 transformDevicePluginCtrForCDI(mainContainer, tc.cpSpec)
3314 require.EqualValues(t, tc.expectedDs, tc.ds)
3315 })
3316 }
3317}
3318
3319func TestGetRuntimeConfigFiles(t *testing.T) {
3320 testCases := []struct {

Callers

nothing calls this directly

Calls 5

NewDaemonsetFunction · 0.85
newBoolPtrFunction · 0.85
WithContainerMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected