-
Notifications
You must be signed in to change notification settings - Fork 33
/
test_docker.sh
executable file
·179 lines (145 loc) · 4.57 KB
/
test_docker.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash -e
# Test pman in isolation with docker OR podman
#
# Notes:
# - state is dirty if tests fail
# - suggested that you run this script with no existing containers nor volumes
set -o pipefail
HERE=$(dirname "$(readlink -f "$0")")
CONTAINER_RUNTIME=$1
if [ -z "$CONTAINER_RUNTIME" ]; then
echo "usage: $0 [docker|podman]"
exit 1
fi
CR_EXEC=$(which $CONTAINER_RUNTIME)
# shadows the name "podman" so that it calls the specified runtime
# which might be docker OR podman
function podman () {
$CR_EXEC "$@"
}
# find out where the podman/docker socket is
if [ -n "$DOCKER_HOST" ]; then
socket="$DOCKER_HOST"
else
if [[ "$CR_EXEC" = *podman* ]]; then
if [ "$(podman info --format '{{ .Host.RemoteSocket.Exists }}')" != 'true' ]; then
echo "error: podman socket must be active."
echo "try running:"
echo
echo " systemctl --user start podman.service"
echo
exit 1
fi
socket="$(podman info --format '{{ .Host.RemoteSocket.Path }}')"
elif [[ "$CR_EXEC" = *docker* ]]; then
socket=/var/run/docker.sock
fi
fi
set -ex
# pull example ChRIS plugin
SIMPLEDSAPP=docker.io/fnndsc/pl-simpledsapp:2.1.0
podman pull $SIMPLEDSAPP
# build
pman_image="localhost/fnndsc/pman:${0##*/}"
podman build -t $pman_image .
# "storebase" directory where "pfcon" writes data
volume=$(podman volume create --driver local)
storeBase=$(podman volume inspect --format '{{ .Mountpoint }}' $volume)
# simulate action of pfcon receiving data
jid="pmantest-$RANDOM"
podman run --rm \
-v "$HERE:/here:ro" -w /here \
-v "$volume:/var/local/storeBase:rw" \
alpine sh -c "mkdir -vp /var/local/storeBase/key-$jid/incoming /var/local/storeBase/key-$jid/outgoing && cp -v README.md LICENSE /var/local/storeBase/key-$jid/incoming"
# pman identifies the aforementioned volume by inspecting
# its peer pfcon, so run a mock pfcon container