2021-10-11 14:31:02 +00:00
|
|
|
/**
|
|
|
|
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-02-23 20:01:24 +00:00
|
|
|
"fmt"
|
2021-10-11 14:31:02 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/pelletier/go-toml"
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-12-01 01:10:10 +00:00
|
|
|
|
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/containerd"
|
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/tools/container"
|
2021-10-11 14:31:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
runtimeType = "runtime_type"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUpdateV2ConfigDefaultRuntime(t *testing.T) {
|
|
|
|
const runtimeDir = "/test/runtime/dir"
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
setAsDefault bool
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName string
|
2021-10-11 14:31:02 +00:00
|
|
|
expectedDefaultRuntimeName interface{}
|
|
|
|
}{
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
setAsDefault: false,
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "nvidia",
|
2021-10-11 14:31:02 +00:00
|
|
|
expectedDefaultRuntimeName: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
setAsDefault: false,
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "NAME",
|
2021-10-11 14:31:02 +00:00
|
|
|
expectedDefaultRuntimeName: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
setAsDefault: true,
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "nvidia",
|
2021-10-11 14:31:02 +00:00
|
|
|
expectedDefaultRuntimeName: "nvidia",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
setAsDefault: true,
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "NAME",
|
2021-10-11 14:31:02 +00:00
|
|
|
expectedDefaultRuntimeName: "NAME",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testCases {
|
2023-02-24 09:06:59 +00:00
|
|
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
|
|
|
o := &options{
|
2023-06-09 15:17:54 +00:00
|
|
|
Options: container.Options{
|
|
|
|
RuntimeName: tc.runtimeName,
|
|
|
|
RuntimeDir: runtimeDir,
|
|
|
|
SetAsDefault: tc.setAsDefault,
|
|
|
|
},
|
2023-02-24 09:06:59 +00:00
|
|
|
}
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
config, err := toml.TreeFromMap(map[string]interface{}{})
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
v2 := &containerd.Config{
|
|
|
|
Tree: config,
|
|
|
|
RuntimeType: runtimeType,
|
|
|
|
}
|
2023-02-23 20:01:24 +00:00
|
|
|
|
2023-06-09 15:17:54 +00:00
|
|
|
err = o.UpdateConfig(v2)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
defaultRuntimeName := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "default_runtime_name"})
|
2023-03-01 14:06:28 +00:00
|
|
|
require.EqualValues(t, tc.expectedDefaultRuntimeName, defaultRuntimeName)
|
2023-02-24 09:06:59 +00:00
|
|
|
})
|
2021-10-11 14:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdateV2Config(t *testing.T) {
|
|
|
|
const runtimeDir = "/test/runtime/dir"
|
|
|
|
|
|
|
|
testCases := []struct {
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName string
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig map[string]interface{}
|
2021-10-11 14:31:02 +00:00
|
|
|
}{
|
|
|
|
{
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "nvidia",
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
|
|
|
"nvidia": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-cdi": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.cdi",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-legacy": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.legacy",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
{
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "NAME",
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
|
|
|
"NAME": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-cdi": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.cdi",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-legacy": map[string]interface{}{
|
|
|
|
"runtime_type": "runtime_type",
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.legacy",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testCases {
|
2023-03-01 14:06:28 +00:00
|
|
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
|
|
|
o := &options{
|
2023-06-09 15:17:54 +00:00
|
|
|
Options: container.Options{
|
|
|
|
RuntimeName: tc.runtimeName,
|
|
|
|
RuntimeDir: runtimeDir,
|
|
|
|
},
|
|
|
|
runtimeType: runtimeType,
|
2023-03-01 14:06:28 +00:00
|
|
|
}
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
config, err := toml.TreeFromMap(map[string]interface{}{})
|
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
v2 := &containerd.Config{
|
2023-03-23 19:12:23 +00:00
|
|
|
Tree: config,
|
|
|
|
RuntimeType: runtimeType,
|
|
|
|
ContainerAnnotations: []string{"cdi.k8s.io/*"},
|
2023-03-01 14:06:28 +00:00
|
|
|
}
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-06-09 15:17:54 +00:00
|
|
|
err = o.UpdateConfig(v2)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
expected, err := toml.TreeFromMap(tc.expectedConfig)
|
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
require.Equal(t, expected.String(), config.String())
|
|
|
|
})
|
2021-10-11 14:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdateV2ConfigWithRuncPresent(t *testing.T) {
|
|
|
|
const runtimeDir = "/test/runtime/dir"
|
|
|
|
|
|
|
|
testCases := []struct {
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName string
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig map[string]interface{}
|
2021-10-11 14:31:02 +00:00
|
|
|
}{
|
|
|
|
{
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "nvidia",
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
|
|
|
"runc": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/runc-binary",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-cdi": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.cdi",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-legacy": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.legacy",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
{
|
2023-06-09 15:17:54 +00:00
|
|
|
runtimeName: "NAME",
|
2023-03-01 14:06:28 +00:00
|
|
|
expectedConfig: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
|
|
|
"runc": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/runc-binary",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"NAME": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-cdi": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.cdi",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nvidia-legacy": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"container_annotations": []string{"cdi.k8s.io/*"},
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": "/test/runtime/dir/nvidia-container-runtime.legacy",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testCases {
|
2023-02-23 20:01:24 +00:00
|
|
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
|
|
|
o := &options{
|
2023-06-09 15:17:54 +00:00
|
|
|
Options: container.Options{
|
|
|
|
RuntimeName: tc.runtimeName,
|
|
|
|
RuntimeDir: runtimeDir,
|
|
|
|
},
|
2023-02-23 20:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config, err := toml.TreeFromMap(runcConfigMapV2("/runc-binary"))
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-23 20:01:24 +00:00
|
|
|
v2 := &containerd.Config{
|
2023-03-23 19:12:23 +00:00
|
|
|
Tree: config,
|
|
|
|
RuntimeType: runtimeType,
|
|
|
|
ContainerAnnotations: []string{"cdi.k8s.io/*"},
|
2023-02-23 20:01:24 +00:00
|
|
|
}
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-06-09 15:17:54 +00:00
|
|
|
err = o.UpdateConfig(v2)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
expected, err := toml.TreeFromMap(tc.expectedConfig)
|
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
require.Equal(t, expected.String(), config.String())
|
2023-02-23 20:01:24 +00:00
|
|
|
})
|
2021-10-11 14:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRevertV2Config(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
config map[string]interface {
|
|
|
|
}
|
|
|
|
expected map[string]interface{}
|
|
|
|
}{
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
config: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
2022-11-07 11:22:30 +00:00
|
|
|
"nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"),
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config: map[string]interface{}{
|
|
|
|
"version": int64(2),
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
2022-11-07 11:22:30 +00:00
|
|
|
"nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"),
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
"default_runtime_name": "nvidia",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testCases {
|
2023-02-24 09:06:59 +00:00
|
|
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
|
|
|
o := &options{
|
2023-06-09 15:17:54 +00:00
|
|
|
Options: container.Options{
|
|
|
|
RuntimeName: "nvidia",
|
|
|
|
},
|
2023-02-24 09:06:59 +00:00
|
|
|
}
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
config, err := toml.TreeFromMap(tc.config)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
expected, err := toml.TreeFromMap(tc.expected)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
v2 := &containerd.Config{
|
|
|
|
Tree: config,
|
|
|
|
RuntimeType: runtimeType,
|
|
|
|
}
|
2023-02-23 20:01:24 +00:00
|
|
|
|
2023-06-09 15:17:54 +00:00
|
|
|
err = o.RevertConfig(v2)
|
2023-03-01 14:06:28 +00:00
|
|
|
require.NoError(t, err)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-02-24 09:06:59 +00:00
|
|
|
configContents, _ := toml.Marshal(config)
|
|
|
|
expectedContents, _ := toml.Marshal(expected)
|
2021-10-11 14:31:02 +00:00
|
|
|
|
2023-03-01 14:06:28 +00:00
|
|
|
require.Equal(t, string(expectedContents), string(configContents))
|
2023-02-24 09:06:59 +00:00
|
|
|
})
|
2021-10-11 14:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func runtimeMapV2(binary string) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"runtime_type": runtimeType,
|
|
|
|
"runtime_root": "",
|
|
|
|
"runtime_engine": "",
|
|
|
|
"privileged_without_host_devices": false,
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"BinaryName": binary,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func runcConfigMapV2(binary string) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"plugins": map[string]interface{}{
|
|
|
|
"io.containerd.grpc.v1.cri": map[string]interface{}{
|
|
|
|
"containerd": map[string]interface{}{
|
|
|
|
"runtimes": map[string]interface{}{
|
2023-03-01 14:06:28 +00:00
|
|
|
"runc": map[string]interface{}{
|
|
|
|
"runtime_type": "runc_runtime_type",
|
|
|
|
"runtime_root": "runc_runtime_root",
|
|
|
|
"runtime_engine": "runc_runtime_engine",
|
|
|
|
"privileged_without_host_devices": true,
|
|
|
|
"options": map[string]interface{}{
|
|
|
|
"runc-option": "value",
|
|
|
|
"BinaryName": binary,
|
|
|
|
},
|
|
|
|
},
|
2021-10-11 14:31:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|