@@ -21,6 +21,7 @@ import (
2121 "testing"
2222
2323 "github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/containerd"
24+ "github.com/NVIDIA/nvidia-container-toolkit/tools/container"
2425 "github.com/pelletier/go-toml"
2526 "github.com/stretchr/testify/require"
2627)
@@ -31,7 +32,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
3132 testCases := []struct {
3233 legacyConfig bool
3334 setAsDefault bool
34- runtimeClass string
35+ runtimeName string
3536 expectedDefaultRuntimeName interface {}
3637 expectedDefaultRuntimeBinary interface {}
3738 }{
@@ -51,14 +52,14 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
5152 {
5253 legacyConfig : true ,
5354 setAsDefault : true ,
54- runtimeClass : "NAME" ,
55+ runtimeName : "NAME" ,
5556 expectedDefaultRuntimeName : nil ,
5657 expectedDefaultRuntimeBinary : "/test/runtime/dir/nvidia-container-runtime" ,
5758 },
5859 {
5960 legacyConfig : true ,
6061 setAsDefault : true ,
61- runtimeClass : "nvidia-experimental" ,
62+ runtimeName : "nvidia-experimental" ,
6263 expectedDefaultRuntimeName : nil ,
6364 expectedDefaultRuntimeBinary : "/test/runtime/dir/nvidia-container-runtime.experimental" ,
6465 },
@@ -77,14 +78,14 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
7778 {
7879 legacyConfig : false ,
7980 setAsDefault : true ,
80- runtimeClass : "NAME" ,
81+ runtimeName : "NAME" ,
8182 expectedDefaultRuntimeName : "NAME" ,
8283 expectedDefaultRuntimeBinary : nil ,
8384 },
8485 {
8586 legacyConfig : false ,
8687 setAsDefault : true ,
87- runtimeClass : "nvidia-experimental" ,
88+ runtimeName : "nvidia-experimental" ,
8889 expectedDefaultRuntimeName : "nvidia-experimental" ,
8990 expectedDefaultRuntimeBinary : nil ,
9091 },
@@ -93,11 +94,13 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
9394 for i , tc := range testCases {
9495 t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
9596 o := & options {
96- useLegacyConfig : tc .legacyConfig ,
97- setAsDefault : tc .setAsDefault ,
98- runtimeClass : tc .runtimeClass ,
97+ Options : container.Options {
98+ RuntimeName : tc .runtimeName ,
99+ RuntimeDir : runtimeDir ,
100+ SetAsDefault : tc .setAsDefault ,
101+ },
99102 runtimeType : runtimeType ,
100- runtimeDir : runtimeDir ,
103+ useLegacyConfig : tc . legacyConfig ,
101104 }
102105
103106 config , err := toml .TreeFromMap (map [string ]interface {}{})
@@ -109,7 +112,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
109112 RuntimeType : runtimeType ,
110113 }
111114
112- err = UpdateConfig (v1 , o )
115+ err = o . UpdateConfig (v1 )
113116 require .NoError (t , err , "%d: %v" , i , tc )
114117
115118 defaultRuntimeName := v1 .GetPath ([]string {"plugins" , "cri" , "containerd" , "default_runtime_name" })
@@ -138,11 +141,11 @@ func TestUpdateV1Config(t *testing.T) {
138141 const runtimeDir = "/test/runtime/dir"
139142
140143 testCases := []struct {
141- runtimeClass string
144+ runtimeName string
142145 expectedConfig map [string ]interface {}
143146 }{
144147 {
145- runtimeClass : "nvidia" ,
148+ runtimeName : "nvidia" ,
146149 expectedConfig : map [string ]interface {}{
147150 "version" : int64 (1 ),
148151 "plugins" : map [string ]interface {}{
@@ -200,7 +203,7 @@ func TestUpdateV1Config(t *testing.T) {
200203 },
201204 },
202205 {
203- runtimeClass : "NAME" ,
206+ runtimeName : "NAME" ,
204207 expectedConfig : map [string ]interface {}{
205208 "version" : int64 (1 ),
206209 "plugins" : map [string ]interface {}{
@@ -258,7 +261,7 @@ func TestUpdateV1Config(t *testing.T) {
258261 },
259262 },
260263 {
261- runtimeClass : "nvidia-experimental" ,
264+ runtimeName : "nvidia-experimental" ,
262265 expectedConfig : map [string ]interface {}{
263266 "version" : int64 (1 ),
264267 "plugins" : map [string ]interface {}{
@@ -320,9 +323,10 @@ func TestUpdateV1Config(t *testing.T) {
320323 for i , tc := range testCases {
321324 t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
322325 o := & options {
323- runtimeClass : tc .runtimeClass ,
324- runtimeType : runtimeType ,
325- runtimeDir : runtimeDir ,
326+ Options : container.Options {
327+ RuntimeName : tc .runtimeName ,
328+ RuntimeDir : runtimeDir ,
329+ },
326330 }
327331
328332 config , err := toml .TreeFromMap (map [string ]interface {}{})
@@ -335,7 +339,7 @@ func TestUpdateV1Config(t *testing.T) {
335339 ContainerAnnotations : []string {"cdi.k8s.io/*" },
336340 }
337341
338- err = UpdateConfig (v1 , o )
342+ err = o . UpdateConfig (v1 )
339343 require .NoError (t , err )
340344
341345 expected , err := toml .TreeFromMap (tc .expectedConfig )
@@ -350,11 +354,11 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
350354 const runtimeDir = "/test/runtime/dir"
351355
352356 testCases := []struct {
353- runtimeClass string
357+ runtimeName string
354358 expectedConfig map [string ]interface {}
355359 }{
356360 {
357- runtimeClass : "nvidia" ,
361+ runtimeName : "nvidia" ,
358362 expectedConfig : map [string ]interface {}{
359363 "version" : int64 (1 ),
360364 "plugins" : map [string ]interface {}{
@@ -426,7 +430,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
426430 },
427431 },
428432 {
429- runtimeClass : "NAME" ,
433+ runtimeName : "NAME" ,
430434 expectedConfig : map [string ]interface {}{
431435 "version" : int64 (1 ),
432436 "plugins" : map [string ]interface {}{
@@ -498,7 +502,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
498502 },
499503 },
500504 {
501- runtimeClass : "nvidia-experimental" ,
505+ runtimeName : "nvidia-experimental" ,
502506 expectedConfig : map [string ]interface {}{
503507 "version" : int64 (1 ),
504508 "plugins" : map [string ]interface {}{
@@ -574,9 +578,10 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
574578 for i , tc := range testCases {
575579 t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
576580 o := & options {
577- runtimeClass : tc .runtimeClass ,
578- runtimeType : runtimeType ,
579- runtimeDir : runtimeDir ,
581+ Options : container.Options {
582+ RuntimeName : tc .runtimeName ,
583+ RuntimeDir : runtimeDir ,
584+ },
580585 }
581586
582587 config , err := toml .TreeFromMap (runcConfigMapV1 ("/runc-binary" ))
@@ -589,7 +594,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
589594 ContainerAnnotations : []string {"cdi.k8s.io/*" },
590595 }
591596
592- err = UpdateConfig (v1 , o )
597+ err = o . UpdateConfig (v1 )
593598 require .NoError (t , err )
594599
595600 expected , err := toml .TreeFromMap (tc .expectedConfig )
@@ -653,7 +658,9 @@ func TestRevertV1Config(t *testing.T) {
653658 for i , tc := range testCases {
654659 t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
655660 o := & options {
656- runtimeClass : "nvidia" ,
661+ Options : container.Options {
662+ RuntimeName : "nvidia" ,
663+ },
657664 }
658665
659666 config , err := toml .TreeFromMap (tc .config )
@@ -668,7 +675,7 @@ func TestRevertV1Config(t *testing.T) {
668675 RuntimeType : runtimeType ,
669676 }
670677
671- err = RevertConfig (v1 , o )
678+ err = o . RevertConfig (v1 )
672679 require .NoError (t , err , "%d: %v" , i , tc )
673680
674681 configContents , _ := toml .Marshal (config )
0 commit comments