Skip to content

Commit f48f61f

Browse files
committed
Add migration integration test
Signed-off-by: Derek McGowan <[email protected]>
1 parent eb9925d commit f48f61f

File tree

3 files changed

+661
-0
lines changed

3 files changed

+661
-0
lines changed

integration/client/migration_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package client
18+
19+
import (
20+
"bytes"
21+
"os"
22+
"os/exec"
23+
"path/filepath"
24+
"runtime"
25+
"strings"
26+
"testing"
27+
28+
"github.com/stretchr/testify/assert"
29+
"github.com/stretchr/testify/require"
30+
)
31+
32+
func TestMigration(t *testing.T) {
33+
currentDefault := filepath.Join(t.TempDir(), "default.toml")
34+
defaultContent, err := currentDefaultConfig()
35+
require.NoError(t, err)
36+
require.NoError(t, os.WriteFile(currentDefault, []byte(defaultContent), 0644))
37+
38+
type migrationTest struct {
39+
Name string
40+
File string
41+
Migrated string
42+
}
43+
migrationTests := []migrationTest{
44+
{
45+
Name: "CurrentDefault",
46+
File: currentDefault,
47+
Migrated: defaultContent,
48+
},
49+
}
50+
51+
// Only run the old version migration tests for the same platform
52+
// and build settings the default config was generated for.
53+
if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" && strings.Contains(defaultContent, "btrfs") && strings.Contains(defaultContent, "devmapper") {
54+
migrationTests = append(migrationTests, []migrationTest{
55+
{
56+
Name: "1.6-Default",
57+
File: "testdata/default-1.6.toml",
58+
Migrated: defaultContent,
59+
},
60+
{
61+
Name: "1.7-Default",
62+
File: "testdata/default-1.7.toml",
63+
Migrated: defaultContent,
64+
},
65+
}...)
66+
}
67+
68+
for _, tc := range migrationTests {
69+
tc := tc
70+
t.Run(tc.Name, func(t *testing.T) {
71+
buf := bytes.NewBuffer(nil)
72+
cmd := exec.Command("containerd", "-c", tc.File, "config", "migrate")
73+
cmd.Stdout = buf
74+
cmd.Stderr = os.Stderr
75+
require.NoError(t, cmd.Run())
76+
actual := buf.String()
77+
assert.Equal(t, tc.Migrated, actual)
78+
})
79+
}
80+
81+
}
82+
83+
func currentDefaultConfig() (string, error) {
84+
cmd := exec.Command("containerd", "config", "default")
85+
buf := bytes.NewBuffer(nil)
86+
cmd.Stdout = buf
87+
cmd.Stderr = os.Stderr
88+
if err := cmd.Run(); err != nil {
89+
return "", err
90+
}
91+
return buf.String(), nil
92+
}
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
disabled_plugins = []
2+
imports = []
3+
oom_score = 0
4+
plugin_dir = ""
5+
required_plugins = []
6+
root = "/var/lib/containerd"
7+
state = "/run/containerd"
8+
temp = ""
9+
version = 2
10+
11+
[cgroup]
12+
path = ""
13+
14+
[debug]
15+
address = ""
16+
format = ""
17+
gid = 0
18+
level = ""
19+
uid = 0
20+
21+
[grpc]
22+
address = "/run/containerd/containerd.sock"
23+
gid = 0
24+
max_recv_message_size = 16777216
25+
max_send_message_size = 16777216
26+
tcp_address = ""
27+
tcp_tls_ca = ""
28+
tcp_tls_cert = ""
29+
tcp_tls_key = ""
30+
uid = 0
31+
32+
[metrics]
33+
address = ""
34+
grpc_histogram = false
35+
36+
[plugins]
37+
38+
[plugins."io.containerd.gc.v1.scheduler"]
39+
deletion_threshold = 0
40+
mutation_threshold = 100
41+
pause_threshold = 0.02
42+
schedule_delay = "0s"
43+
startup_delay = "100ms"
44+
45+
[plugins."io.containerd.grpc.v1.cri"]
46+
device_ownership_from_security_context = false
47+
disable_apparmor = false
48+
disable_cgroup = false
49+
disable_hugetlb_controller = true
50+
disable_proc_mount = false
51+
disable_tcp_service = true
52+
enable_selinux = false
53+
enable_tls_streaming = false
54+
# Defaults change to true in latest
55+
#enable_unprivileged_icmp = false
56+
#enable_unprivileged_ports = false
57+
enable_unprivileged_icmp = true
58+
enable_unprivileged_ports = true
59+
ignore_image_defined_volumes = false
60+
max_concurrent_downloads = 3
61+
max_container_log_line_size = 16384
62+
netns_mounts_under_state_dir = false
63+
restrict_oom_score_adj = false
64+
# Default image update in latest
65+
#sandbox_image = "registry.k8s.io/pause:3.6"
66+
sandbox_image = "registry.k8s.io/pause:3.9"
67+
selinux_category_range = 1024
68+
stats_collect_period = 10
69+
stream_idle_timeout = "4h0m0s"
70+
stream_server_address = "127.0.0.1"
71+
stream_server_port = "0"
72+
systemd_cgroup = false
73+
tolerate_missing_hugetlb_controller = true
74+
unset_seccomp_profile = ""
75+
76+
[plugins."io.containerd.grpc.v1.cri".cni]
77+
bin_dir = "/opt/cni/bin"
78+
conf_dir = "/etc/cni/net.d"
79+
conf_template = ""
80+
ip_pref = ""
81+
max_conf_num = 1
82+
83+
[plugins."io.containerd.grpc.v1.cri".containerd]
84+
default_runtime_name = "runc"
85+
disable_snapshot_annotations = true
86+
discard_unpacked_layers = false
87+
ignore_rdt_not_enabled_errors = false
88+
no_pivot = false
89+
snapshotter = "overlayfs"
90+
91+
[plugins."io.containerd.grpc.v1.cri".containerd.default_runtime]
92+
base_runtime_spec = ""
93+
cni_conf_dir = ""
94+
cni_max_conf_num = 0
95+
container_annotations = []
96+
pod_annotations = []
97+
privileged_without_host_devices = false
98+
runtime_engine = ""
99+
runtime_path = ""
100+
runtime_root = ""
101+
runtime_type = ""
102+
103+
[plugins."io.containerd.grpc.v1.cri".containerd.default_runtime.options]
104+
105+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
106+
107+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
108+
base_runtime_spec = ""
109+
cni_conf_dir = ""
110+
cni_max_conf_num = 0
111+
container_annotations = []
112+
pod_annotations = []
113+
privileged_without_host_devices = false
114+
runtime_engine = ""
115+
runtime_path = ""
116+
runtime_root = ""
117+
runtime_type = "io.containerd.runc.v2"
118+
119+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
120+
BinaryName = ""
121+
CriuImagePath = ""
122+
CriuWorkPath = ""
123+
IoGid = 0
124+
IoUid = 0
125+
NoNewKeyring = false
126+
Root = ""
127+
ShimCgroup = ""
128+
# Removed in latest
129+
#CriuPath = ""
130+
#NoPivotRoot = false
131+
#SystemdCgroup = false
132+
133+
[plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime]
134+
base_runtime_spec = ""
135+
cni_conf_dir = ""
136+
cni_max_conf_num = 0
137+
container_annotations = []
138+
pod_annotations = []
139+
privileged_without_host_devices = false
140+
runtime_engine = ""
141+
runtime_path = ""
142+
runtime_root = ""
143+
runtime_type = ""
144+
145+
[plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime.options]
146+
147+
[plugins."io.containerd.grpc.v1.cri".image_decryption]
148+
key_model = "node"
149+
150+
[plugins."io.containerd.grpc.v1.cri".registry]
151+
config_path = ""
152+
153+
[plugins."io.containerd.grpc.v1.cri".registry.auths]
154+
155+
[plugins."io.containerd.grpc.v1.cri".registry.configs]
156+
157+
[plugins."io.containerd.grpc.v1.cri".registry.headers]
158+
159+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
160+
161+
[plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming]
162+
tls_cert_file = ""
163+
tls_key_file = ""
164+
165+
[plugins."io.containerd.internal.v1.opt"]
166+
path = "/opt/containerd"
167+
168+
[plugins."io.containerd.internal.v1.restart"]
169+
interval = "10s"
170+
171+
[plugins."io.containerd.internal.v1.tracing"]
172+
sampling_ratio = 1.0
173+
service_name = "containerd"
174+
175+
[plugins."io.containerd.metadata.v1.bolt"]
176+
content_sharing_policy = "shared"
177+
178+
[plugins."io.containerd.monitor.v1.cgroups"]
179+
no_prometheus = false
180+
181+
# Removed in latest
182+
#[plugins."io.containerd.runtime.v1.linux"]
183+
# no_shim = false
184+
# runtime = "runc"
185+
# runtime_root = ""
186+
# shim = "containerd-shim"
187+
# shim_debug = false
188+
189+
[plugins."io.containerd.runtime.v2.task"]
190+
platforms = ["linux/amd64"]
191+
sched_core = false
192+
193+
[plugins."io.containerd.service.v1.diff-service"]
194+
default = ["walking"]
195+
196+
[plugins."io.containerd.service.v1.tasks-service"]
197+
rdt_config_file = ""
198+
199+
# Removed in latest
200+
#[plugins."io.containerd.snapshotter.v1.aufs"]
201+
# root_path = ""
202+
203+
[plugins."io.containerd.snapshotter.v1.btrfs"]
204+
root_path = ""
205+
206+
[plugins."io.containerd.snapshotter.v1.devmapper"]
207+
async_remove = false
208+
base_image_size = ""
209+
discard_blocks = false
210+
fs_options = ""
211+
fs_type = ""
212+
pool_name = ""
213+
root_path = ""
214+
215+
[plugins."io.containerd.snapshotter.v1.native"]
216+
root_path = ""
217+
218+
[plugins."io.containerd.snapshotter.v1.overlayfs"]
219+
mount_options = []
220+
root_path = ""
221+
sync_remove = false
222+
upperdir_label = false
223+
224+
# Removed in latest
225+
#[plugins."io.containerd.snapshotter.v1.zfs"]
226+
# root_path = ""
227+
228+
[plugins."io.containerd.tracing.processor.v1.otlp"]
229+
endpoint = ""
230+
insecure = false
231+
protocol = ""
232+
233+
[proxy_plugins]
234+
235+
[stream_processors]
236+
237+
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
238+
accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
239+
args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
240+
env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
241+
path = "ctd-decoder"
242+
returns = "application/vnd.oci.image.layer.v1.tar"
243+
244+
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar.gzip"]
245+
accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
246+
args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
247+
env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
248+
path = "ctd-decoder"
249+
returns = "application/vnd.oci.image.layer.v1.tar+gzip"
250+
251+
[timeouts]
252+
"io.containerd.timeout.bolt.open" = "0s"
253+
"io.containerd.timeout.shim.cleanup" = "5s"
254+
"io.containerd.timeout.shim.load" = "5s"
255+
"io.containerd.timeout.shim.shutdown" = "3s"
256+
"io.containerd.timeout.task.state" = "2s"
257+
# Added in latest
258+
"io.containerd.timeout.metrics.shimstats" = "2s"
259+
260+
[ttrpc]
261+
address = ""
262+
gid = 0
263+
uid = 0

0 commit comments

Comments
 (0)