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

Function TestDriverSpec

internal/state/driver_test.go:190–279  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestDriverSpec(t *testing.T) {
191 const (
192 testName = "driver-full-spec"
193 )
194 state, err := NewStateDriver(nil, "", nil, manifestDir)
195 require.Nil(t, err)
196 stateDriver, ok := state.(*stateDriver)
197 require.True(t, ok)
198
199 // set every field in driverSpec
200 driverSpec := &nvidiav1alpha1.NVIDIADriverSpec{
201 Manager: nvidiav1alpha1.DriverManagerSpec{
202 Repository: "/path/to/repository",
203 Image: "image",
204 Version: "version",
205 ImagePullPolicy: "Always",
206 ImagePullSecrets: []string{"manager-secret"},
207 Env: []nvidiav1alpha1.EnvVar{
208 {Name: "FOO", Value: "foo"},
209 {Name: "BAR", Value: "bar"},
210 },
211 },
212 StartupProbe: getDefaultContainerProbeSpec(),
213 LivenessProbe: getDefaultContainerProbeSpec(),
214 ReadinessProbe: getDefaultContainerProbeSpec(),
215 UsePrecompiled: new(bool),
216 ImagePullPolicy: "Always",
217 ImagePullSecrets: []string{"secret-a", "secret-b"},
218 Resources: &nvidiav1alpha1.ResourceRequirements{
219 Requests: corev1.ResourceList{
220 corev1.ResourceCPU: resource.MustParse("200m"),
221 corev1.ResourceMemory: resource.MustParse("100Mi"),
222 },
223 Limits: corev1.ResourceList{
224 "memory": resource.MustParse("200Mi"),
225 "cpu": resource.MustParse("500m"),
226 },
227 },
228 Args: []string{"--foo", "--bar"},
229 Env: []nvidiav1alpha1.EnvVar{
230 {Name: "FOO", Value: "foo"},
231 {Name: "BAR", Value: "bar"},
232 },
233 NodeSelector: map[string]string{
234 "example.com/foo": "foo",
235 "example.com/bar": "bar",
236 },
237 Labels: map[string]string{
238 "custom-label-1": "custom-value-1",
239 "custom-label-2": "custom-value-2",
240 // The below standard labels should not be overridden in the
241 // DaemonSet that gets rendered
242 "app": "foo",
243 "app.kubernetes.io/part-of": "foo",
244 },
245 Annotations: map[string]string{
246 "custom-annotation-1": "custom-value-1",
247 "custom-annotation-2": "custom-value-2",

Callers

nothing calls this directly

Calls 6

NewStateDriverFunction · 0.85
sanitizeDriverLabelsFunction · 0.85
getYAMLStringFunction · 0.85
RenderObjectsMethod · 0.65

Tested by

no test coverage detected