@@ -48,6 +48,10 @@ func TestContainerdBuilder_Complex(t *testing.T) {
4848 runContainerdBuilderTest (t , "complex" , distributions .DistributionUbuntu2604 )
4949}
5050
51+ func TestContainerdBuilder_V3 (t * testing.T ) {
52+ runContainerdBuilderTest (t , "v3" , distributions .DistributionUbuntu2604 )
53+ }
54+
5155func TestContainerdBuilder_BuildFlags (t * testing.T ) {
5256 grid := []struct {
5357 config kops.ContainerdConfig
@@ -177,6 +181,41 @@ func runContainerdBuilderTest(t *testing.T, key string, distro distributions.Dis
177181 testutils .ValidateTasks (t , filepath .Join (basedir , "tasks.yaml" ), context )
178182}
179183
184+ func TestUseContainerdConfigV3 (t * testing.T ) {
185+ tests := []struct {
186+ name string
187+ version string
188+ want bool
189+ wantErr bool
190+ }{
191+ {name : "empty defaults to v2" , version : "" , want : false },
192+ {name : "1.7.0 is v2" , version : "1.7.0" , want : false },
193+ {name : "1.999.999 is v2" , version : "1.999.999" , want : false },
194+ {name : "2.0.0 boundary is v3" , version : "2.0.0" , want : true },
195+ {name : "2.0.0 with v prefix is v3" , version : "v2.0.0" , want : true },
196+ {name : "2.1.6 is v3" , version : "2.1.6" , want : true },
197+ {name : "3.0.0 is v3" , version : "3.0.0" , want : true },
198+ {name : "unparseable returns error" , version : "not-a-semver" , wantErr : true },
199+ }
200+ for _ , tc := range tests {
201+ t .Run (tc .name , func (t * testing.T ) {
202+ got , err := useContainerdConfigV3 (tc .version )
203+ if tc .wantErr {
204+ if err == nil {
205+ t .Fatalf ("useContainerdConfigV3(%q) error = nil, want non-nil" , tc .version )
206+ }
207+ return
208+ }
209+ if err != nil {
210+ t .Fatalf ("useContainerdConfigV3(%q) error = %v, want nil" , tc .version , err )
211+ }
212+ if got != tc .want {
213+ t .Errorf ("useContainerdConfigV3(%q) = %v, want %v" , tc .version , got , tc .want )
214+ }
215+ })
216+ }
217+ }
218+
180219func TestContainerdConfig (t * testing.T ) {
181220 b := & ContainerdBuilder {
182221 NodeupModelContext : & NodeupModelContext {
@@ -241,7 +280,8 @@ func TestAppendGPURuntimeContainerdConfig(t *testing.T) {
241280 t .Fatalf ("Unexpected error: %v" , err )
242281 }
243282
244- if err := appendNvidiaGPURuntimeConfig (config ); err != nil {
283+ runtimesPath := []string {"plugins" , "io.containerd.grpc.v1.cri" , "containerd" , "runtimes" }
284+ if err := appendNvidiaGPURuntimeConfig (config , runtimesPath ); err != nil {
245285 t .Errorf ("unexpected error: %v" , err )
246286 }
247287
0 commit comments