Enable runc.v2 as the default runtime in test.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-04-03 18:47:25 -07:00
parent b23b406fed
commit fae4f79060
3 changed files with 38 additions and 12 deletions

View File

@@ -215,7 +215,9 @@ systemd_cgroup = true
[containerd.default_runtime]
runtime_type = "` + linuxRuntime + `"
[containerd.runtimes.runc]
runtime_type = "` + runcRuntime + `"
runtime_type = "` + runcRuntimeV1 + `"
[containerd.runtimes.runcv2]
runtime_type = "` + runcRuntimeV2 + `"
`
nonNilOpts := `
systemd_cgroup = true
@@ -227,30 +229,41 @@ systemd_cgroup = true
Runtime = "default"
RuntimeRoot = "/default"
[containerd.runtimes.runc]
runtime_type = "` + runcRuntime + `"
runtime_type = "` + runcRuntimeV1 + `"
[containerd.runtimes.runc.options]
BinaryName = "runc"
Root = "/runc"
NoNewKeyring = true
[containerd.runtimes.runcv2]
runtime_type = "` + runcRuntimeV2 + `"
[containerd.runtimes.runcv2.options]
BinaryName = "runc"
Root = "/runcv2"
NoNewKeyring = true
`
var nilOptsConfig, nonNilOptsConfig criconfig.Config
_, err := toml.Decode(nilOpts, &nilOptsConfig)
require.NoError(t, err)
_, err = toml.Decode(nonNilOpts, &nonNilOptsConfig)
require.NoError(t, err)
require.Len(t, nilOptsConfig.Runtimes, 1)
require.Len(t, nonNilOptsConfig.Runtimes, 1)
require.Len(t, nilOptsConfig.Runtimes, 2)
require.Len(t, nonNilOptsConfig.Runtimes, 2)
for desc, test := range map[string]struct {
r criconfig.Runtime
c criconfig.Config
expectedOptions interface{}
}{
"when options is nil, should return nil option for non legacy runtime": {
"when options is nil, should return nil option for io.containerd.runc.v1": {
r: nilOptsConfig.Runtimes["runc"],
c: nilOptsConfig,
expectedOptions: nil,
},
"when options is nil, should return nil option for io.containerd.runc.v2": {
r: nilOptsConfig.Runtimes["runcv2"],
c: nilOptsConfig,
expectedOptions: nil,
},
"when options is nil, should use legacy fields for legacy runtime": {
r: nilOptsConfig.DefaultRuntime,
c: nilOptsConfig,
@@ -267,6 +280,15 @@ systemd_cgroup = true
NoNewKeyring: true,
},
},
"when options is not nil, should be able to decode for io.containerd.runc.v2": {
r: nonNilOptsConfig.Runtimes["runcv2"],
c: nonNilOptsConfig,
expectedOptions: &runcoptions.Options{
BinaryName: "runc",
Root: "/runcv2",
NoNewKeyring: true,
},
},
"when options is not nil, should be able to decode for legacy runtime": {
r: nonNilOptsConfig.DefaultRuntime,
c: nonNilOptsConfig,