MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / TestGetRuntimeConfigFiles

Function TestGetRuntimeConfigFiles

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

Source from the content-addressed store, hash-verified

3317}
3318
3319func TestGetRuntimeConfigFiles(t *testing.T) {
3320 testCases := []struct {
3321 description string
3322 container corev1.Container
3323 runtime string
3324 expectedTopLevelConfigFile string
3325 expectedDropInConfigFile string
3326 errorExpected bool
3327 }{
3328 {
3329 description: "invalid runtime",
3330 container: corev1.Container{},
3331 runtime: "foo",
3332 errorExpected: true,
3333 },
3334 {
3335 description: "docker",
3336 container: corev1.Container{},
3337 runtime: gpuv1.Docker.String(),
3338 expectedTopLevelConfigFile: DefaultDockerConfigFile,
3339 expectedDropInConfigFile: "",
3340 },
3341 {
3342 description: "docker, config path overridden",
3343 container: corev1.Container{
3344 Env: []corev1.EnvVar{
3345 {Name: "RUNTIME_CONFIG", Value: "/path/to/docker/daemon.json"},
3346 },
3347 },
3348 runtime: gpuv1.Docker.String(),
3349 expectedTopLevelConfigFile: "/path/to/docker/daemon.json",
3350 expectedDropInConfigFile: "",
3351 },
3352 {
3353 description: "docker, config path overridden, DOCKER_CONFIG envvar has highest precedence",
3354 container: corev1.Container{
3355 Env: []corev1.EnvVar{
3356 {Name: "RUNTIME_CONFIG", Value: "/path/to/docker/daemon.json"},
3357 {Name: "DOCKER_CONFIG", Value: "/another/path/to/docker/daemon.json"},
3358 },
3359 },
3360 runtime: gpuv1.Docker.String(),
3361 expectedTopLevelConfigFile: "/another/path/to/docker/daemon.json",
3362 expectedDropInConfigFile: "",
3363 },
3364 {
3365 description: "containerd",
3366 container: corev1.Container{},
3367 runtime: gpuv1.Containerd.String(),
3368 expectedTopLevelConfigFile: DefaultContainerdConfigFile,
3369 expectedDropInConfigFile: DefaultContainerdDropInConfigFile,
3370 },
3371 {
3372 description: "containerd, config path overridden",
3373 container: corev1.Container{
3374 Env: []corev1.EnvVar{
3375 {Name: "RUNTIME_CONFIG", Value: "/path/to/containerd/config.toml"},
3376 {Name: "RUNTIME_DROP_IN_CONFIG", Value: "/path/to/containerd/drop-in/config.toml"},

Callers

nothing calls this directly

Calls 4

getRuntimeConfigFilesFunction · 0.85
StringMethod · 0.80
RunMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected