@@ -40,10 +40,11 @@ func TestApp(t *testing.T) {
40
40
hostRoot := filepath .Join (moduleRoot , "testdata" , "lookup" , "rootfs-1" )
41
41
42
42
testCases := []struct {
43
- description string
44
- args []string
45
- expectedToolkitConfig string
46
- expectedRuntimeConfig string
43
+ description string
44
+ args []string
45
+ expectedToolkitConfig string
46
+ expectedRuntimeConfig string
47
+ expectedDropInRuntimeConfig string
47
48
}{
48
49
{
49
50
description : "no args" ,
@@ -285,7 +286,10 @@ swarm-resource = ""
285
286
[nvidia-ctk]
286
287
path = "{{ .toolkitRoot }}/toolkit/nvidia-ctk"
287
288
` ,
288
- expectedRuntimeConfig : `version = 2
289
+ expectedRuntimeConfig : `imports = ["{{ .testRoot }}/config.d/*.toml"]
290
+ version = 2
291
+ ` ,
292
+ expectedDropInRuntimeConfig : `version = 2
289
293
290
294
[plugins]
291
295
@@ -371,7 +375,10 @@ swarm-resource = ""
371
375
[nvidia-ctk]
372
376
path = "{{ .toolkitRoot }}/toolkit/nvidia-ctk"
373
377
` ,
374
- expectedRuntimeConfig : `version = 2
378
+ expectedRuntimeConfig : `imports = ["{{ .testRoot }}/config.d/*.toml"]
379
+ version = 2
380
+ ` ,
381
+ expectedDropInRuntimeConfig : `version = 2
375
382
376
383
[plugins]
377
384
@@ -418,6 +425,7 @@ swarm-resource = ""
418
425
419
426
cdiOutputDir := filepath .Join (testRoot , "/var/run/cdi" )
420
427
runtimeConfigFile := filepath .Join (testRoot , "config.file" )
428
+ runtimeDropInConfigFile := filepath .Join (testRoot , "config.d/config.toml" )
421
429
422
430
toolkitRoot := filepath .Join (testRoot , "toolkit-test" )
423
431
toolkitConfigFile := filepath .Join (toolkitRoot , "toolkit/.config/nvidia-container-runtime/config.toml" )
@@ -430,6 +438,7 @@ swarm-resource = ""
430
438
"--no-daemon" ,
431
439
"--cdi-output-dir=" + cdiOutputDir ,
432
440
"--config=" + runtimeConfigFile ,
441
+ "--drop-in-config=" + runtimeDropInConfigFile ,
433
442
"--create-device-nodes=none" ,
434
443
"--driver-root-ctr-path=" + hostRoot ,
435
444
"--pid-file=" + filepath .Join (testRoot , "toolkit.pid" ),
@@ -446,10 +455,24 @@ swarm-resource = ""
446
455
require .NoError (t , err )
447
456
require .EqualValues (t , strings .ReplaceAll (tc .expectedToolkitConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (toolkitConfigFileContents ))
448
457
449
- require .FileExists (t , runtimeConfigFile )
450
- runtimeConfigFileContents , err := os .ReadFile (runtimeConfigFile )
451
- require .NoError (t , err )
452
- require .EqualValues (t , strings .ReplaceAll (tc .expectedRuntimeConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeConfigFileContents ))
458
+ if len (tc .expectedRuntimeConfig ) > 0 {
459
+ require .FileExists (t , runtimeConfigFile )
460
+ runtimeConfigFileContents , err := os .ReadFile (runtimeConfigFile )
461
+ require .NoError (t , err )
462
+ expected := strings .ReplaceAll (tc .expectedRuntimeConfig , "{{ .testRoot }}" , testRoot )
463
+ require .Equal (t , strings .ReplaceAll (expected , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeConfigFileContents ))
464
+ } else {
465
+ require .NoFileExists (t , runtimeConfigFile )
466
+ }
467
+
468
+ if len (tc .expectedDropInRuntimeConfig ) > 0 {
469
+ require .FileExists (t , runtimeDropInConfigFile )
470
+ runtimeDropInConfigFileContents , err := os .ReadFile (runtimeDropInConfigFile )
471
+ require .NoError (t , err )
472
+ require .Equal (t , strings .ReplaceAll (tc .expectedDropInRuntimeConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeDropInConfigFileContents ))
473
+ } else {
474
+ require .NoFileExists (t , runtimeDropInConfigFile )
475
+ }
453
476
})
454
477
}
455
478
0 commit comments