@@ -48,6 +48,7 @@ func TestCrioConfigLifecycle(t *testing.T) {
48
48
description : "config mode: top-level config does not exist" ,
49
49
containerOptions : container.Options {
50
50
Config : "{{ .testRoot }}/etc/crio/crio.conf" ,
51
+ DropInConfig : "{{ .testRoot }}/conf.d/99-nvidia.toml" ,
51
52
RuntimeName : "nvidia" ,
52
53
RuntimeDir : "/usr/bin" ,
53
54
SetAsDefault : false ,
@@ -57,7 +58,9 @@ func TestCrioConfigLifecycle(t *testing.T) {
57
58
configMode : "config" ,
58
59
},
59
60
assertSetupPostConditions : func (t * testing.T , testRoot string ) error {
60
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
61
+ topLevelConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
62
+ require .NoFileExists (t , topLevelConfigPath )
63
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
61
64
require .FileExists (t , configPath )
62
65
63
66
actual , err := os .ReadFile (configPath )
@@ -86,7 +89,9 @@ func TestCrioConfigLifecycle(t *testing.T) {
86
89
return nil
87
90
},
88
91
assertCleanupPostConditions : func (t * testing.T , testRoot string ) error {
89
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
92
+ topLevelConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
93
+ require .NoFileExists (t , topLevelConfigPath )
94
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
90
95
require .NoFileExists (t , configPath )
91
96
return nil
92
97
},
@@ -95,6 +100,7 @@ func TestCrioConfigLifecycle(t *testing.T) {
95
100
description : "config mode: existing config without nvidia runtime" ,
96
101
containerOptions : container.Options {
97
102
Config : "{{ .testRoot }}/etc/crio/crio.conf" ,
103
+ DropInConfig : "{{ .testRoot }}/conf.d/99-nvidia.toml" ,
98
104
RuntimeName : "nvidia" ,
99
105
RuntimeDir : "/usr/bin" ,
100
106
SetAsDefault : false ,
@@ -125,29 +131,40 @@ signature_policy = "/etc/crio/policy.json"
125
131
return nil
126
132
},
127
133
assertSetupPostConditions : func (t * testing.T , testRoot string ) error {
128
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
129
- require .FileExists (t , configPath )
134
+ topLevelConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
135
+ require .FileExists (t , topLevelConfigPath )
136
+
137
+ actualTopLevel , err := os .ReadFile (topLevelConfigPath )
138
+ require .NoError (t , err )
139
+
140
+ expectedTopLevel := `[crio]
141
+ [crio.runtime]
142
+ default_runtime = "crun"
130
143
144
+ [crio.runtime.runtimes.crun]
145
+ runtime_path = "/usr/bin/crun"
146
+ runtime_type = "oci"
147
+ runtime_root = "/run/crun"
148
+ monitor_path = "/usr/libexec/crio/conmon"
149
+
150
+ [crio.image]
151
+ signature_policy = "/etc/crio/policy.json"
152
+ `
153
+
154
+ require .Equal (t , expectedTopLevel , string (actualTopLevel ))
155
+
156
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
157
+ require .FileExists (t , configPath )
131
158
actual , err := os .ReadFile (configPath )
132
159
require .NoError (t , err )
133
160
134
161
expected := `
135
162
[crio]
136
163
137
- [crio.image]
138
- signature_policy = "/etc/crio/policy.json"
139
-
140
164
[crio.runtime]
141
- default_runtime = "crun"
142
165
143
166
[crio.runtime.runtimes]
144
167
145
- [crio.runtime.runtimes.crun]
146
- monitor_path = "/usr/libexec/crio/conmon"
147
- runtime_path = "/usr/bin/crun"
148
- runtime_root = "/run/crun"
149
- runtime_type = "oci"
150
-
151
168
[crio.runtime.runtimes.nvidia]
152
169
monitor_path = "/usr/libexec/crio/conmon"
153
170
runtime_path = "/usr/bin/nvidia-container-runtime"
@@ -170,38 +187,39 @@ signature_policy = "/etc/crio/policy.json"
170
187
return nil
171
188
},
172
189
assertCleanupPostConditions : func (t * testing.T , testRoot string ) error {
173
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
174
- require .FileExists (t , configPath )
190
+ topLevelConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
191
+ require .FileExists (t , topLevelConfigPath )
175
192
176
- actual , err := os .ReadFile (configPath )
177
- require .NoError (t , err )
178
-
179
- // Should restore to original config
180
- expected := `
181
- [crio]
193
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
194
+ require .NoFileExists (t , configPath )
182
195
183
- [crio.image]
184
- signature_policy = "/etc/crio/policy.json"
196
+ actualTopLevel , err := os . ReadFile ( topLevelConfigPath )
197
+ require . NoError ( t , err )
185
198
186
- [crio.runtime]
187
- default_runtime = "crun"
199
+ // Leaves original config unchanged
200
+ expectedTopLevel := `[crio]
201
+ [crio.runtime]
202
+ default_runtime = "crun"
188
203
189
- [crio.runtime.runtimes]
204
+ [crio.runtime.runtimes.crun]
205
+ runtime_path = "/usr/bin/crun"
206
+ runtime_type = "oci"
207
+ runtime_root = "/run/crun"
208
+ monitor_path = "/usr/libexec/crio/conmon"
190
209
191
- [crio.runtime.runtimes.crun]
192
- monitor_path = "/usr/libexec/crio/conmon"
193
- runtime_path = "/usr/bin/crun"
194
- runtime_root = "/run/crun"
195
- runtime_type = "oci"
210
+ [crio.image]
211
+ signature_policy = "/etc/crio/policy.json"
196
212
`
197
- require .Equal (t , expected , string (actual ))
213
+ require .Equal (t , expectedTopLevel , string (actualTopLevel ))
214
+
198
215
return nil
199
216
},
200
217
},
201
218
{
202
219
description : "config mode: existing config with nvidia runtime already present" ,
203
220
containerOptions : container.Options {
204
221
Config : "{{ .testRoot }}/etc/crio/crio.conf" ,
222
+ DropInConfig : "{{ .testRoot }}/conf.d/99-nvidia.toml" ,
205
223
RuntimeName : "nvidia" ,
206
224
RuntimeDir : "/usr/bin" ,
207
225
SetAsDefault : true ,
@@ -231,7 +249,30 @@ runtime_type = "oci"
231
249
return nil
232
250
},
233
251
assertSetupPostConditions : func (t * testing.T , testRoot string ) error {
234
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
252
+ topLevelConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
253
+ require .FileExists (t , topLevelConfigPath )
254
+
255
+ actualTopLevel , err := os .ReadFile (topLevelConfigPath )
256
+ require .NoError (t , err )
257
+
258
+ // TODO: Do we expect the top-level config to change? i.e. Should
259
+ // we REMOVE the default_runtime = "nvidia" setting?
260
+ expectedTopLevel := `[crio]
261
+ [crio.runtime]
262
+ default_runtime = "nvidia"
263
+
264
+ [crio.runtime.runtimes.crun]
265
+ runtime_path = "/usr/bin/crun"
266
+ runtime_type = "oci"
267
+
268
+ [crio.runtime.runtimes.nvidia]
269
+ runtime_path = "/old/path/nvidia-container-runtime"
270
+ runtime_type = "oci"
271
+ `
272
+
273
+ require .Equal (t , expectedTopLevel , string (actualTopLevel ))
274
+
275
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
235
276
require .FileExists (t , configPath )
236
277
237
278
actual , err := os .ReadFile (configPath )
@@ -245,10 +286,6 @@ runtime_type = "oci"
245
286
246
287
[crio.runtime.runtimes]
247
288
248
- [crio.runtime.runtimes.crun]
249
- runtime_path = "/usr/bin/crun"
250
- runtime_type = "oci"
251
-
252
289
[crio.runtime.runtimes.nvidia]
253
290
runtime_path = "/usr/bin/nvidia-container-runtime"
254
291
runtime_type = "oci"
@@ -265,25 +302,32 @@ runtime_type = "oci"
265
302
return nil
266
303
},
267
304
assertCleanupPostConditions : func (t * testing.T , testRoot string ) error {
268
- configPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
269
- require .FileExists (t , configPath )
305
+ topLeveConfigPath := filepath .Join (testRoot , "etc/crio/crio.conf" )
306
+ require .FileExists (t , topLeveConfigPath )
270
307
271
- actual , err := os .ReadFile (configPath )
308
+ actualTopLevel , err := os .ReadFile (topLeveConfigPath )
272
309
require .NoError (t , err )
273
310
274
- // Note: cleanup removes nvidia runtimes but doesn't restore original default_runtime
275
- expected := `
276
- [crio]
277
-
278
- [crio.runtime]
311
+ // TODO: Do we expect the top-level config to change? i.e. Should
312
+ // we REMOVE the default_runtime = "nvidia" setting?
313
+ expectedTopLevel := ` [crio]
314
+ [crio.runtime]
315
+ default_runtime = "nvidia"
279
316
280
- [crio.runtime.runtimes]
317
+ [crio.runtime.runtimes.crun]
318
+ runtime_path = "/usr/bin/crun"
319
+ runtime_type = "oci"
281
320
282
- [crio.runtime.runtimes.crun ]
283
- runtime_path = "/usr/bin/crun "
284
- runtime_type = "oci"
321
+ [crio.runtime.runtimes.nvidia ]
322
+ runtime_path = "/old/path/nvidia-container-runtime "
323
+ runtime_type = "oci"
285
324
`
286
- require .Equal (t , expected , string (actual ))
325
+
326
+ require .Equal (t , expectedTopLevel , string (actualTopLevel ))
327
+
328
+ configPath := filepath .Join (testRoot , "conf.d/99-nvidia.toml" )
329
+ require .NoFileExists (t , configPath )
330
+
287
331
return nil
288
332
},
289
333
},
@@ -575,11 +619,15 @@ plugin_dirs = [
575
619
},
576
620
}
577
621
578
- for _ , tc := range testCases {
622
+ for i , tc := range testCases {
623
+ if i > 2 {
624
+ t .SkipNow ()
625
+ }
579
626
t .Run (tc .description , func (t * testing.T ) {
580
627
// Update any paths as required
581
628
testRoot := t .TempDir ()
582
629
tc .containerOptions .Config = strings .ReplaceAll (tc .containerOptions .Config , "{{ .testRoot }}" , testRoot )
630
+ tc .containerOptions .DropInConfig = strings .ReplaceAll (tc .containerOptions .DropInConfig , "{{ .testRoot }}" , testRoot )
583
631
tc .options .hooksDir = strings .ReplaceAll (tc .options .hooksDir , "{{ .testRoot }}" , testRoot )
584
632
585
633
// Prepare the test environment
0 commit comments