-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·77 lines (53 loc) · 1.2 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/sh
set -ex
dir=/tmp/regmirror
pull_images() {
crictl pull k8s.gcr.io/pause:3.1
}
# clear test dir
rm -rf $dir
mkdir -p $dir
# run mirror instances
start_dreg1() {
docker run -d --net=host -v $dir/cache1:/cache --name dregmirror1 \
mcluseau/docker-registries-mirror -addr 127.0.0.1:8585 -peers http://127.0.1.2:8585
}
start_dreg2() {
docker run -d --net=host -v $dir/cache2:/cache --name dregmirror2 \
mcluseau/docker-registries-mirror -addr 127.0.1.2:8585 -peers http://127.0.0.1:8585
}
# - start cache 1 with a failed cache 2
start_dreg1
#start_dreg2 # uncomment to test with a working (empty) cache 2 instead
# run containerd
export CONTAINER_RUNTIME_ENDPOINT=unix://$dir/containerd.sock
>log_ctrd
runctrd() {
rm -fr $dir/containerd* &&
containerd -c ctrd.toml -l debug >>log_ctrd 2>&1 &
ctrd_pid=$!
sleep 1
}
>log_ctrd
runctrd
pull_images
tree $dir/cache?
kill $ctrd_pid
sleep 1
stop_dreg1() {
docker stop dregmirror1
docker logs dregmirror1
docker rm dregmirror1
}
stop_dreg1
mv $dir/cache1 $dir/cache2
tree $dir/cache?
start_dreg1
start_dreg2
runctrd
pull_images
tree $dir/cache?
kill $ctrd_pid
sleep 1
stop_dreg1
docker rm -f dregmirror2