Debian Codegraph @

script/integration/containerd/entrypoint.sh

raw
1 #!/bin/bash
2
3 # Copyright The containerd Authors.
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -euo pipefail
18
19 # NOTE: The entire contents of containerd/stargz-snapshotter are located in
20 # the testing container so utils.sh is visible from this script during runtime.
21 # TODO: Refactor the code dependencies and pack them in the container without
22 # expecting and relying on volumes.
23 source "/utils.sh"
24
25 PLUGIN=stargz
26 REGISTRY_HOST=registry-integration.test
27 REGISTRY_ALT_HOST=registry-alt.test
28 DUMMYUSER=dummyuser
29 DUMMYPASS=dummypass
30
31 USR_ORG=$(mktemp -d)
32 USR_MIRROR=$(mktemp -d)
33 USR_REFRESH=$(mktemp -d)
34 USR_TMPDIR=$(mktemp -d)
35
36 USR_NORMALSN_UNSTARGZ=$(mktemp -d)
37 USR_STARGZSN_UNSTARGZ=$(mktemp -d)
38 USR_NORMALSN_STARGZ=$(mktemp -d)
39 USR_STARGZSN_STARGZ=$(mktemp -d)
40 USR_NORMALSN_ZSTD=$(mktemp -d)
41 USR_STARGZSN_ZSTD=$(mktemp -d)
42 USR_NORMALSN_PLAIN_STARGZ=$(mktemp -d)
43 USR_STARGZSN_PLAIN_STARGZ=$(mktemp -d)
44
45 USR_NORMALSN_IPFS=$(mktemp -d)
46 USR_STARGZSN_IPFS=$(mktemp -d)
47 USR_STARGZSN_CTD_IPFS=$(mktemp -d)
48
49 LOG_FILE=$(mktemp)
50 function cleanup {
51 ORG_EXIT_CODE="${1}"
52 rm -rf "${USR_ORG}" || true
53 rm -rf "${USR_MIRROR}" || true
54 rm -rf "${USR_REFRESH}" || true
55 rm -rf "${USR_TMPDIR}" || true
56
57 rm -rf "${USR_NORMALSN_UNSTARGZ}" || true
58 rm -rf "${USR_STARGZSN_UNSTARGZ}" || true
59 rm -rf "${USR_NORMALSN_STARGZ}" || true
60 rm -rf "${USR_STARGZSN_STARGZ}" || true
61 rm -rf "${USR_NORMALSN_PLAIN_STARGZ}" || true
62 rm -rf "${USR_STARGZSN_PLAIN_STARGZ}" || true
63 rm -rf "${USR_NORMALSN_ZSTD}" || true
64 rm -rf "${USR_STARGZSN_ZSTD}" || true
65
66 rm -rf "${USR_NORMALSN_IPFS}" || true
67 rm -rf "${USR_STARGZSN_IPFS}" || true
68 rm -rf "${USR_STARGZSN_CTD_IPFS}" || true
69 rm "${LOG_FILE}"
70 exit "${ORG_EXIT_CODE}"
71 }
72 trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
73
74 RETRYNUM=100
75 RETRYINTERVAL=1
76 TIMEOUTSEC=180
77 function retry {
78 local SUCCESS=false
79 for i in $(seq ${RETRYNUM}) ; do
80 if eval "timeout ${TIMEOUTSEC} ${@}" ; then
81 SUCCESS=true
82 break
83 fi
84 echo "Fail(${i}). Retrying..."
85 sleep ${RETRYINTERVAL}
86 done
87 if [ "${SUCCESS}" == "true" ] ; then
88 return 0
89 else
90 return 1
91 fi
92 }
93
94 function kill_all {
95 if [ "${1}" != "" ] ; then
96 ps aux | grep "${1}" | grep -v grep | grep -v $(basename ${0}) | sed -E 's/ +/ /g' | cut -f 2 -d ' ' | xargs -I{} kill -9 {} || true
97 fi
98 }
99
100 CONTAINERD_ROOT=/var/lib/containerd/
101 CONTAINERD_STATUS=/run/containerd/
102 REMOTE_SNAPSHOTTER_SOCKET=/run/containerd-stargz-grpc/containerd-stargz-grpc.sock
103 REMOTE_SNAPSHOTTER_ROOT=/var/lib/containerd-stargz-grpc/
104 function reboot_containerd {
105 kill_all "containerd"
106 kill_all "containerd-stargz-grpc"
107 rm -rf "${CONTAINERD_STATUS}"*
108 rm -rf "${CONTAINERD_ROOT}"*
109 if [ -f "${REMOTE_SNAPSHOTTER_SOCKET}" ] ; then
110 rm "${REMOTE_SNAPSHOTTER_SOCKET}"
111 fi
112 if [ -d "${REMOTE_SNAPSHOTTER_ROOT}snapshotter/snapshots/" ] ; then
113 find "${REMOTE_SNAPSHOTTER_ROOT}snapshotter/snapshots/" \
114 -maxdepth 1 -mindepth 1 -type d -exec umount "{}/fs" \;
115 fi
116 rm -rf "${REMOTE_SNAPSHOTTER_ROOT}"*
117 if [ "${BUILTIN_SNAPSHOTTER}" == "true" ] ; then
118 if [ "${CONTAINERD_CONFIG:-}" != "" ] ; then
119 containerd --log-level debug --config="${CONTAINERD_CONFIG:-}" 2>&1 | tee -a "${LOG_FILE}" &
120 else
121 containerd --log-level debug --config=/etc/containerd/config.toml 2>&1 | tee -a "${LOG_FILE}" &
122 fi
123 else
124 if [ "${SNAPSHOTTER_CONFIG:-}" == "" ] ; then
125 containerd-stargz-grpc --log-level=debug \
126 --address="${REMOTE_SNAPSHOTTER_SOCKET}" \
127 2>&1 | tee -a "${LOG_FILE}" & # Dump all log
128 else
129 containerd-stargz-grpc --log-level=debug \
130 --address="${REMOTE_SNAPSHOTTER_SOCKET}" \
131 --config="${SNAPSHOTTER_CONFIG}" \
132 2>&1 | tee -a "${LOG_FILE}" &
133 fi
134 retry ls "${REMOTE_SNAPSHOTTER_SOCKET}"
135 containerd --log-level debug --config=/etc/containerd/config.toml &
136 fi
137
138 # Makes sure containerd and containerd-stargz-grpc are up-and-running.
139 UNIQUE_SUFFIX=$(date +%s%N | shasum | base64 | fold -w 10 | head -1)
140 retry ctr snapshots --snapshotter="${PLUGIN}" prepare "connectiontest-dummy-${UNIQUE_SUFFIX}" ""
141 }
142
143 function optimize {
144 local SRC="${1}"
145 local DST="${2}"
146 local PLAINHTTP="${3}"
147 local OPTS=${@:4}
148 ctr-remote image pull -u "${DUMMYUSER}:${DUMMYPASS}" "${SRC}"
149 ctr-remote image optimize ${OPTS} --oci "${SRC}" "${DST}"
150 PUSHOPTS=
151 if [ "${PLAINHTTP}" == "true" ] ; then
152 PUSHOPTS=--plain-http
153 fi
154 ctr-remote image push ${PUSHOPTS} -u "${DUMMYUSER}:${DUMMYPASS}" "${DST}"
155 }
156
157 function convert {
158 local SRC="${1}"
159 local DST="${2}"
160 local PLAINHTTP="${3}"
161 local OPTS=${@:4}
162 PUSHOPTS=
163 if [ "${PLAINHTTP}" == "true" ] ; then
164 PUSHOPTS=--plain-http
165 fi
166 ctr-remote image pull -u "${DUMMYUSER}:${DUMMYPASS}" "${SRC}"
167 ctr-remote image convert ${OPTS} --oci "${SRC}" "${DST}"
168 ctr-remote image push ${PUSHOPTS} -u "${DUMMYUSER}:${DUMMYPASS}" "${DST}"
169 }
170
171 function copy {
172 local SRC="${1}"
173 local DST="${2}"
174 ctr-remote i pull --all-platforms "${SRC}"
175 ctr-remote i tag "${SRC}" "${DST}"
176 ctr-remote i push -u "${DUMMYUSER}:${DUMMYPASS}" "${DST}"
177 }
178
179 function copy_out_dir {
180 local IMAGE="${1}"
181 local TARGETDIR="${2}"
182 local DEST="${3}"
183 local SNAPSHOTTER="${4}"
184
185 TMPFILE=$(mktemp)
186
187 UNIQUE=$(date +%s%N | shasum | base64 | fold -w 10 | head -1)
188 ctr-remote run --snapshotter="${SNAPSHOTTER}" "${IMAGE}" "${UNIQUE}" tar -c "${TARGETDIR}" > "${TMPFILE}"
189 tar -C "${DEST}" -xf "${TMPFILE}"
190 ctr-remote c rm "${UNIQUE}" || true
191 rm "${TMPFILE}"
192 }
193
194 function dump_dir {
195 local IMAGE="${1}"
196 local TARGETDIR="${2}"
197 local SNAPSHOTTER="${3}"
198 local REMOTE="${4}"
199 local DEST="${5}"
200
201 reboot_containerd
202 if [ "${REMOTE}" == "true" ] ; then
203 run_and_check_remote_snapshots ctr-remote images rpull --user "${DUMMYUSER}:${DUMMYPASS}" "${IMAGE}"
204 else
205 ctr-remote images pull --snapshotter="${SNAPSHOTTER}" --user "${DUMMYUSER}:${DUMMYPASS}" "${IMAGE}"
206 fi
207 copy_out_dir "${IMAGE}" "${TARGETDIR}" "${DEST}" "${SNAPSHOTTER}"
208 }
209
210 function run_and_check_remote_snapshots {
211 echo -n "" > "${LOG_FILE}"
212 ${@:1}
213 check_remote_snapshots "${LOG_FILE}"
214 }
215
216 # Copied from moby project (Apache License 2.0)
217 # https://github.com/moby/moby/blob/a9fe88e395acaacd84067b5fc701d52dbcf4b625/hack/dind#L28-L38
218 # cgroup v2: enable nesting
219 if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
220 # move the processes from the root group to the /init group,
221 # otherwise writing subtree_control fails with EBUSY.
222 # An error during moving non-existent process (i.e., "cat") is ignored.
223 mkdir -p /sys/fs/cgroup/init
224 xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || :
225 # enable controllers
226 sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \
227 > /sys/fs/cgroup/cgroup.subtree_control
228 fi
229
230 echo "===== VERSION INFORMATION ====="
231 containerd --version
232 runc --version
233 echo "==============================="
234
235 cat <<EOF >> /etc/containerd/config.toml
236 [debug]
237 format = "json"
238 level = "debug"
239 EOF
240 if [ "${BUILTIN_SNAPSHOTTER}" != "true" ] ; then
241 cat <<EOF >> /etc/containerd/config.toml
242 [proxy_plugins]
243 [proxy_plugins.stargz]
244 type = "snapshot"
245 address = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"
246 EOF
247 fi
248
249 echo "Logging into the registry..."
250 cp /auth/certs/domain.crt /usr/local/share/ca-certificates
251 update-ca-certificates
252 retry nerdctl login -u "${DUMMYUSER}" -p "${DUMMYPASS}" "${REGISTRY_HOST}"
253
254 reboot_containerd
255 OK=$(ctr-remote plugins ls \
256 | grep io.containerd.snapshotter \
257 | sed -E 's/ +/ /g' \
258 | cut -d ' ' -f 2,4 \
259 | grep "${PLUGIN}" \
260 | cut -d ' ' -f 2)
261 if [ "${OK}" != "ok" ] ; then
262 echo "Plugin ${PLUGIN} not found" 1>&2
263 exit 1
264 fi
265
266 echo "Preparing images..."
267 copy ghcr.io/stargz-containers/ubuntu:22.04-org "${REGISTRY_HOST}/ubuntu:22.04"
268 copy ghcr.io/stargz-containers/alpine:3.15.3-org "${REGISTRY_HOST}/alpine:3.15.3"
269 stargzify "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:sgz"
270 optimize "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:esgz" "false"
271 optimize "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:zstdchunked" "false" --zstdchunked
272 optimize "${REGISTRY_HOST}/alpine:3.15.3" "${REGISTRY_HOST}/alpine:esgz" "false"
273 optimize "${REGISTRY_HOST}/alpine:3.15.3" "${REGISTRY_ALT_HOST}:5000/alpine:esgz" "true"
274
275 # images for external TOC and min-chunk-size
276 # TODO: support external TOC suffix other than "-esgztoc"
277 optimize "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:esgz-50000" "false" --estargz-min-chunk-size=50000
278 optimize "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:esgz-ex" "false" --estargz-external-toc
279 ctr-remote i push -u "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/ubuntu:esgz-ex-esgztoc"
280 convert "${REGISTRY_HOST}/ubuntu:22.04" "${REGISTRY_HOST}/ubuntu:esgz-ex-keep-diff-id" "false" --estargz --estargz-external-toc --estargz-keep-diff-id
281 ctr-remote i push -u "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/ubuntu:esgz-ex-keep-diff-id-esgztoc"
282
283 if [ "${BUILTIN_SNAPSHOTTER}" != "true" ] ; then
284
285 ############
286 # Tests with IPFS if standalone snapshotter
287 echo "Testing with IPFS..."
288
289 export IPFS_PATH="/tmp/ipfs"
290 mkdir -p "${IPFS_PATH}"
291
292 ipfs init
293 ipfs daemon --offline &
294 retry curl -X POST localhost:5001/api/v0/version >/dev/null 2>&1 # wait for up
295
296 # stargz snapshotter (default labels)
297 ctr-remote i pull --user "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/ubuntu:22.04"
298 CID=$(ctr-remote i ipfs-push "${REGISTRY_HOST}/ubuntu:22.04")
299 reboot_containerd
300 run_and_check_remote_snapshots ctr-remote i rpull --ipfs "${CID}"
301 copy_out_dir "${CID}" "/usr" "${USR_STARGZSN_IPFS}" "stargz"
302
303 # stargz snapshotter (containerd labels)
304 ctr-remote i pull --user "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/ubuntu:22.04"
305 CID=$(ctr-remote i ipfs-push "${REGISTRY_HOST}/ubuntu:22.04")
306 reboot_containerd
307 run_and_check_remote_snapshots ctr-remote i rpull --use-containerd-labels --ipfs "${CID}"
308 copy_out_dir "${CID}" "/usr" "${USR_STARGZSN_CTD_IPFS}" "stargz"
309
310 # overlayfs snapshotter
311 ctr-remote i pull --user "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/ubuntu:22.04"
312 CID=$(ctr-remote i ipfs-push --estargz=false "${REGISTRY_HOST}/ubuntu:22.04")
313 reboot_containerd
314 ctr-remote i rpull --snapshotter=overlayfs --ipfs "${CID}"
315 copy_out_dir "${CID}" "/usr" "${USR_NORMALSN_IPFS}" "overlayfs"
316
317 echo "Diffing between two root filesystems(normal vs stargz snapshotter(default labels), IPFS rootfs)"
318 diff --no-dereference -qr "${USR_NORMALSN_IPFS}/" "${USR_STARGZSN_IPFS}/"
319
320 echo "Diffing between two root filesystems(normal vs stargz snapshotter(containerd labels), IPFS rootfs)"
321 diff --no-dereference -qr "${USR_NORMALSN_IPFS}/" "${USR_STARGZSN_CTD_IPFS}/"
322
323 kill_all ipfs
324 fi
325
326 ############
327 # Tests for refreshing and mirror
328 echo "Testing refreshing and mirror..."
329
330 reboot_containerd
331 echo "Getting image with normal snapshotter..."
332 ctr-remote images pull --user "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/alpine:esgz"
333 copy_out_dir "${REGISTRY_HOST}/alpine:esgz" "/usr" "${USR_ORG}" "overlayfs"
334
335 echo "Getting image with stargz snapshotter..."
336 run_and_check_remote_snapshots ctr-remote images rpull --user "${DUMMYUSER}:${DUMMYPASS}" "${REGISTRY_HOST}/alpine:esgz"
337
338 REGISTRY_HOST_IP=$(getent hosts "${REGISTRY_HOST}" | awk '{ print $1 }')
339 REGISTRY_ALT_HOST_IP=$(getent hosts "${REGISTRY_ALT_HOST}" | awk '{ print $1 }')
340
341 echo "Disabling source registry and check if mirroring is working for stargz snapshotter..."
342 iptables -A OUTPUT -d "${REGISTRY_HOST_IP}" -j DROP
343 iptables -L
344 copy_out_dir "${REGISTRY_HOST}/alpine:esgz" "/usr" "${USR_MIRROR}" "stargz"
345 iptables -D OUTPUT -d "${REGISTRY_HOST_IP}" -j DROP
346
347 echo "Disabling mirror registry and check if refreshing works for stargz snapshotter..."
348 iptables -A OUTPUT -d "${REGISTRY_ALT_HOST_IP}" -j DROP
349 iptables -L
350 copy_out_dir "${REGISTRY_HOST}/alpine:esgz" "/usr" "${USR_REFRESH}" "stargz"
351 iptables -D OUTPUT -d "${REGISTRY_ALT_HOST_IP}" -j DROP
352
353 echo "Disabling all registries and running container should fail"
354 iptables -A OUTPUT -d "${REGISTRY_HOST_IP}","${REGISTRY_ALT_HOST_IP}" -j DROP
355 iptables -L
356 if ctr-remote run --rm --snapshotter=stargz "${REGISTRY_HOST}/alpine:esgz" test tar -c /usr > /usr_dummy_fail.tar ; then
357 echo "All registries are disabled so this must be failed"
358 exit 1
359 else
360 echo "Failed to run the container as expected"
361 fi
362 iptables -D OUTPUT -d "${REGISTRY_HOST_IP}","${REGISTRY_ALT_HOST_IP}" -j DROP
363
364 echo "Diffing root filesystems for mirroring"
365 diff --no-dereference -qr "${USR_ORG}/" "${USR_MIRROR}/"
366
367 echo "Diffing root filesystems for refreshing"
368 diff --no-dereference -qr "${USR_ORG}/" "${USR_REFRESH}/"
369
370 ############
371 # Tests for stargz filesystem
372 echo "Testing stargz filesystem..."
373
374 # Test with a normal image
375
376 echo "Getting normal image with normal snapshotter..."
377 OVERLAYFSSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
378 dump_dir "${REGISTRY_HOST}/ubuntu:22.04" "/usr" "overlayfs" "false" "${OVERLAYFSSN}"
379
380 echo "Getting normal image with stargz snapshotter..."
381 STARGZSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
382 dump_dir "${REGISTRY_HOST}/ubuntu:22.04" "/usr" "stargz" "false" "${STARGZSN}"
383
384 echo "Diffing between two root filesystems(normal vs stargz snapshotter, normal rootfs)"
385 diff --no-dereference -qr "${OVERLAYFSSN}/" "${STARGZSN}/"
386
387 # Test with an eStargz image
388
389 echo "Getting eStargz image with normal snapshotter..."
390 dump_dir "${REGISTRY_HOST}/ubuntu:esgz" "/usr" "overlayfs" "false" "${USR_NORMALSN_STARGZ}"
391
392 echo "Getting eStargz image with stargz snapshotter..."
393 dump_dir "${REGISTRY_HOST}/ubuntu:esgz" "/usr" "stargz" "true" "${USR_STARGZSN_STARGZ}"
394
395 echo "Diffing between two root filesystems(normal vs stargz snapshotter, eStargz rootfs)"
396 diff --no-dereference -qr "${USR_NORMALSN_STARGZ}/" "${USR_STARGZSN_STARGZ}/"
397
398 # Test with a zstd:chunked image
399
400 echo "Getting zstd:chunked image with normal snapshotter..."
401 dump_dir "${REGISTRY_HOST}/ubuntu:zstdchunked" "/usr" "overlayfs" "false" "${USR_NORMALSN_ZSTD}"
402
403 echo "Getting zstd:chunked image with stargz snapshotter..."
404 dump_dir "${REGISTRY_HOST}/ubuntu:zstdchunked" "/usr" "stargz" "true" "${USR_STARGZSN_ZSTD}"
405
406 echo "Diffing between two root filesystems(normal vs stargz snapshotter, zstd:cunked rootfs)"
407 diff --no-dereference -qr "${USR_NORMALSN_ZSTD}/" "${USR_STARGZSN_ZSTD}/"
408
409 # Test with a external TOC image
410
411 echo "Getting external TOC image with normal snapshotter..."
412 EX_OVERLAYFSSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
413 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-ex" "/usr" "overlayfs" "false" "${EX_OVERLAYFSSN}"
414
415 echo "Getting external TOC image with stargz snapshotter..."
416 EX_STARGZSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
417 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-ex" "/usr" "stargz" "true" "${EX_STARGZSN}"
418
419 echo "Diffing between two root filesystems(normal vs stargz snapshotter, eStargz (external TOC) rootfs)"
420 diff --no-dereference -qr "${EX_OVERLAYFSSN}/" "${EX_STARGZSN}/"
421
422 # Test with a external TOC + keep-diff-id image
423
424 echo "Getting external TOC image (keep diff id) with normal snapshotter..."
425 EXLL_OVERLAYFSSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
426 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-ex-keep-diff-id" "/usr" "overlayfs" "false" "${EXLL_OVERLAYFSSN}"
427
428 echo "Getting external TOC image (keep diff id) with stargz snapshotter..."
429 EXLL_STARGZSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
430 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-ex-keep-diff-id" "/usr" "stargz" "true" "${EXLL_STARGZSN}"
431
432 echo "Diffing between two root filesystems(normal vs stargz snapshotter, eStargz (external TOC, keep-diff-id) rootfs)"
433 diff --no-dereference -qr "${EXLL_OVERLAYFSSN}/" "${EXLL_STARGZSN}/"
434
435 # Test with a eStargz with min-chunk-size=50000 image
436
437 echo "Getting eStargz (min-chunk-size=50000) with normal snapshotter..."
438 E50000_OVERLAYFSSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
439 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-50000" "/usr" "overlayfs" "false" "${E50000_OVERLAYFSSN}"
440
441 echo "Getting eStargz (min-chunk-size=50000) with stargz snapshotter..."
442 E50000_STARGZSN=$(mktemp -d --tmpdir="${USR_TMPDIR}")
443 dump_dir "${REGISTRY_HOST}/ubuntu:esgz-50000" "/usr" "stargz" "true" "${E50000_STARGZSN}"
444
445 echo "Diffing between two root filesystems(normal vs stargz snapshotter, eStargz (min-chunk-size=50000) rootfs)"
446 diff --no-dereference -qr "${E50000_OVERLAYFSSN}/" "${E50000_STARGZSN}/"
447
448 ############
449 # Checking compatibility with plain stargz
450
451 reboot_containerd
452 echo "Getting (legacy) stargz image with normal snapshotter..."
453 dump_dir "${REGISTRY_HOST}/ubuntu:sgz" "/usr" "overlayfs" "false" "${USR_NORMALSN_PLAIN_STARGZ}"
454
455 echo "Getting (legacy) stargz image with stargz snapshotter..."
456 TEST_CONTAINERD_CONFIG=
457 TEST_SNAPSHOTTER_CONFIG=
458 if [ "${BUILTIN_SNAPSHOTTER}" == "true" ] ; then
459 cp /etc/containerd/config.toml /tmp/config.containerd.noverify.toml
460 sed -i 's/disable_verification = false/disable_verification = true/g' /tmp/config.containerd.noverify.toml
461 TEST_CONTAINERD_CONFIG="/tmp/config.containerd.noverify.toml"
462 else
463 echo "disable_verification = true" > /tmp/config.stargz.noverify.toml
464 cat /etc/containerd-stargz-grpc/config.toml >> /tmp/config.stargz.noverify.toml
465 TEST_SNAPSHOTTER_CONFIG="/tmp/config.stargz.noverify.toml"
466 fi
467
468 CONTAINERD_CONFIG="${TEST_CONTAINERD_CONFIG}" SNAPSHOTTER_CONFIG="${TEST_SNAPSHOTTER_CONFIG}" \
469 dump_dir "${REGISTRY_HOST}/ubuntu:sgz" "/usr" "stargz" "true" "${USR_STARGZSN_PLAIN_STARGZ}"
470
471 echo "Diffing between two root filesystems(normal vs stargz snapshotter, plain stargz rootfs)"
472 diff --no-dereference -qr "${USR_NORMALSN_PLAIN_STARGZ}/" "${USR_STARGZSN_PLAIN_STARGZ}/"
473
474 ############
475 # Try to pull this image from different namespace.
476 ctr-remote --namespace=dummy images rpull --user "${DUMMYUSER}:${DUMMYPASS}" \
477 "${REGISTRY_HOST}/ubuntu:esgz"
478
479 ############
480 # Test for starting when no configuration file.
481 mv /etc/containerd-stargz-grpc/config.toml /etc/containerd-stargz-grpc/config.toml_rm
482 reboot_containerd
483 mv /etc/containerd-stargz-grpc/config.toml_rm /etc/containerd-stargz-grpc/config.toml
484
485 exit 0