Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for missing toolkit container
Signed-off-by: Evan Lezar <elezar@nvidia.com>
  • Loading branch information
elezar committed Jan 20, 2026
commit a7ebf09cbe18787ae7c05e4cce03a7d8dceda1d0
20 changes: 14 additions & 6 deletions controllers/transforms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package controllers

import (
"errors"
"path/filepath"
"testing"

Expand Down Expand Up @@ -777,11 +778,12 @@ func TestApplyCommonDaemonsetMetadata(t *testing.T) {

func TestTransformToolkit(t *testing.T) {
testCases := []struct {
description string
ds Daemonset // Input DaemonSet
cpSpec *gpuv1.ClusterPolicySpec // Input configuration
runtime gpuv1.Runtime
expectedDs Daemonset // Expected output DaemonSet
description string
ds Daemonset // Input DaemonSet
cpSpec *gpuv1.ClusterPolicySpec // Input configuration
runtime gpuv1.Runtime
expectedError error
expectedDs Daemonset // Expected output DaemonSet
}{
{
description: "transform nvidia-container-toolkit-ctr container",
Expand Down Expand Up @@ -1002,6 +1004,12 @@ func TestTransformToolkit(t *testing.T) {
WithHostPathVolume("crio-config", "/etc/crio", ptr.To(corev1.HostPathDirectoryOrCreate)).
WithHostPathVolume("crio-drop-in-config", "/etc/crio/crio.conf.d", ptr.To(corev1.HostPathDirectoryOrCreate)),
},
{
description: "no nvidia-container-toolkit-ctr container",
ds: NewDaemonset(),
expectedError: errors.New(`failed to find toolkit container "nvidia-container-toolkit-ctr"`),
expectedDs: NewDaemonset(),
},
}

for _, tc := range testCases {
Expand All @@ -1012,7 +1020,7 @@ func TestTransformToolkit(t *testing.T) {
}

err := TransformToolkit(tc.ds.DaemonSet, tc.cpSpec, controller)
require.NoError(t, err)
require.EqualValues(t, tc.expectedError, err)
require.EqualValues(t, tc.expectedDs, tc.ds)
})
}
Expand Down