(t *testing.T)
| 2953 | } |
| 2954 | |
| 2955 | func TestTransformKataDevicePlugin(t *testing.T) { |
| 2956 | resources := corev1.ResourceRequirements{ |
| 2957 | Limits: corev1.ResourceList{ |
| 2958 | corev1.ResourceCPU: resource.MustParse("100m"), |
| 2959 | corev1.ResourceMemory: resource.MustParse("128Mi"), |
| 2960 | }, |
| 2961 | Requests: corev1.ResourceList{ |
| 2962 | corev1.ResourceCPU: resource.MustParse("50m"), |
| 2963 | corev1.ResourceMemory: resource.MustParse("64Mi"), |
| 2964 | }, |
| 2965 | } |
| 2966 | testCases := []struct { |
| 2967 | description string |
| 2968 | ds Daemonset |
| 2969 | cpSpec *gpuv1.ClusterPolicySpec |
| 2970 | expectedDs Daemonset |
| 2971 | }{ |
| 2972 | { |
| 2973 | description: "transform kata device plugin", |
| 2974 | ds: NewDaemonset(). |
| 2975 | WithInitContainer(corev1.Container{Name: "vfio-pci-validation"}). |
| 2976 | WithContainer(corev1.Container{Name: "nvidia-kata-sandbox-device-plugin-ctr"}), |
| 2977 | cpSpec: &gpuv1.ClusterPolicySpec{ |
| 2978 | Validator: gpuv1.ValidatorSpec{ |
| 2979 | Repository: "nvcr.io/nvidia/cloud-native", |
| 2980 | Image: "gpu-operator-validator", |
| 2981 | Version: "v1.0.0", |
| 2982 | ImagePullPolicy: "IfNotPresent", |
| 2983 | ImagePullSecrets: []string{"pull-secret"}, |
| 2984 | }, |
| 2985 | KataSandboxDevicePlugin: gpuv1.KataDevicePluginSpec{ |
| 2986 | ImageSpec: gpuv1.ImageSpec{ |
| 2987 | Repository: "nvcr.io/nvidia/cloud-native", |
| 2988 | Image: "kata-sandbox-device-plugin", |
| 2989 | Version: "v1.0.0", |
| 2990 | ImagePullPolicy: "IfNotPresent", |
| 2991 | }, |
| 2992 | ComponentCommonSpec: gpuv1.ComponentCommonSpec{ |
| 2993 | ImagePullSecrets: []string{"pull-secret"}, |
| 2994 | Resources: &gpuv1.ResourceRequirements{Limits: resources.Limits, Requests: resources.Requests}, |
| 2995 | Args: []string{"--test-flag"}, |
| 2996 | Env: []gpuv1.EnvVar{{Name: "foo", Value: "bar"}}, |
| 2997 | }, |
| 2998 | }, |
| 2999 | }, |
| 3000 | expectedDs: NewDaemonset(). |
| 3001 | WithInitContainer(corev1.Container{ |
| 3002 | Name: "vfio-pci-validation", |
| 3003 | Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0", |
| 3004 | ImagePullPolicy: corev1.PullIfNotPresent, |
| 3005 | SecurityContext: &corev1.SecurityContext{ |
| 3006 | RunAsUser: rootUID, |
| 3007 | }, |
| 3008 | }). |
| 3009 | WithContainer(corev1.Container{ |
| 3010 | Name: "nvidia-kata-sandbox-device-plugin-ctr", |
| 3011 | Image: "nvcr.io/nvidia/cloud-native/kata-sandbox-device-plugin:v1.0.0", |
| 3012 | ImagePullPolicy: corev1.PullIfNotPresent, |
nothing calls this directly
no test coverage detected