(t *testing.T)
| 3978 | } |
| 3979 | |
| 3980 | func TestTransformGPUDiscoveryPluginOCP(t *testing.T) { |
| 3981 | node := &corev1.Node{ |
| 3982 | ObjectMeta: metav1.ObjectMeta{ |
| 3983 | Name: "test-ocp-node", |
| 3984 | Labels: map[string]string{ |
| 3985 | nfdKernelLabelKey: "5.14.0-284.43.1.el9_2.x86_64", |
| 3986 | commonGPULabelKey: "true", |
| 3987 | }, |
| 3988 | }, |
| 3989 | } |
| 3990 | mockClient := fake.NewFakeClient(node) |
| 3991 | ds := NewDaemonset().WithContainer(corev1.Container{Name: "gpu-feature-discovery"}). |
| 3992 | WithInitContainer(corev1.Container{Name: "toolkit-validation"}). |
| 3993 | WithInitContainer(corev1.Container{Name: "config-manager-init"}) |
| 3994 | cpSpec := &gpuv1.ClusterPolicySpec{ |
| 3995 | GPUFeatureDiscovery: gpuv1.GPUFeatureDiscoverySpec{ |
| 3996 | Repository: "nvcr.io/nvidia", |
| 3997 | Image: "k8s-device-plugin", |
| 3998 | Version: "v0.18.1", |
| 3999 | }, |
| 4000 | Validator: gpuv1.ValidatorSpec{ |
| 4001 | Repository: "nvcr.io/nvidia/cloud-native", |
| 4002 | Image: "gpu-operator-validator", |
| 4003 | Version: "v1.0.0", |
| 4004 | ImagePullPolicy: "IfNotPresent", |
| 4005 | ImagePullSecrets: []string{"pull-secret"}, |
| 4006 | Toolkit: gpuv1.ToolkitValidatorSpec{ |
| 4007 | Env: []gpuv1.EnvVar{{Name: "foo", Value: "bar"}}, |
| 4008 | }, |
| 4009 | }, |
| 4010 | } |
| 4011 | expectedDs := NewDaemonset().WithContainer(corev1.Container{ |
| 4012 | Name: "gpu-feature-discovery", |
| 4013 | Image: "nvcr.io/nvidia/k8s-device-plugin:v0.18.1", |
| 4014 | ImagePullPolicy: corev1.PullIfNotPresent, |
| 4015 | Env: []corev1.EnvVar{ |
| 4016 | { |
| 4017 | Name: "USE_NODE_FEATURE_API", |
| 4018 | Value: "false", |
| 4019 | }, |
| 4020 | { |
| 4021 | Name: "NVIDIA_MIG_MONITOR_DEVICES", |
| 4022 | Value: "all", |
| 4023 | }, |
| 4024 | }, |
| 4025 | }).WithInitContainer(corev1.Container{ |
| 4026 | Name: "toolkit-validation", |
| 4027 | Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0", |
| 4028 | ImagePullPolicy: corev1.PullIfNotPresent, |
| 4029 | Env: []corev1.EnvVar{{Name: "foo", Value: "bar"}}, |
| 4030 | SecurityContext: &corev1.SecurityContext{ |
| 4031 | RunAsUser: rootUID, |
| 4032 | }, |
| 4033 | }).WithPullSecret("pull-secret").WithRuntimeClassName("nvidia") |
| 4034 | |
| 4035 | err := TransformGPUDiscoveryPlugin(ds.DaemonSet, cpSpec, |
| 4036 | ClusterPolicyController{client: mockClient, runtime: gpuv1.Containerd, |
| 4037 | operatorNamespace: "test-ns", logger: ctrl.Log.WithName("test"), openshift: "4.14"}) |
nothing calls this directly
no test coverage detected