podman

Форк
0
/
005-info.bats 
262 строки · 9.2 Кб
1
#!/usr/bin/env bats
2

3
load helpers
4

5
@test "podman info - basic test" {
6
    run_podman info
7

8
    expected_keys="
9
buildahVersion: *[0-9.]\\\+
10
conmon:\\\s\\\+package:
11
distribution:
12
logDriver:
13
ociRuntime:\\\s\\\+name:
14
os:
15
rootless:
16
registries:
17
store:
18
graphDriverName:
19
graphRoot:
20
graphStatus:
21
imageStore:\\\s\\\+number: 1
22
runRoot:
23
cgroupManager: \\\(systemd\\\|cgroupfs\\\)
24
cgroupVersion: v[12]
25
"
26
    defer-assertion-failures
27

28
    while read expect; do
29
        is "$output" ".*$expect" "output includes '$expect'"
30
    done < <(parse_table "$expected_keys")
31
}
32

33
@test "podman info - json" {
34
    run_podman info --format=json
35

36
    expr_nvr="[a-z0-9-]\\\+-[a-z0-9.]\\\+-[a-z0-9]\\\+\."
37
    expr_path="/[a-z0-9\\\/.-]\\\+\\\$"
38

39
    # FIXME: if we're ever able to get package versions on Debian,
40
    #        add '-[0-9]' to all '*.package' queries below.
41
    tests="
42
host.buildahVersion       | [1-9][0-9]*\.[0-9.]\\\+.*
43
host.conmon.path          | $expr_path
44
host.conmon.package       | .*conmon.*
45
host.cgroupManager        | \\\(systemd\\\|cgroupfs\\\)
46
host.cgroupVersion        | v[12]
47
host.networkBackendInfo   | .*dns.*package.*
48
host.ociRuntime.path      | $expr_path
49
host.pasta                | .*executable.*package.*
50
host.rootlessNetworkCmd   | pasta
51
store.configFile          | $expr_path
52
store.graphDriverName     | [a-z0-9]\\\+\\\$
53
store.graphRoot           | $expr_path
54
store.imageStore.number   | 1
55
host.slirp4netns.executable | $expr_path
56
"
57

58
    defer-assertion-failures
59

60
    while read field expect; do
61
        actual=$(echo "$output" | jq -r ".$field")
62
        dprint "# actual=<$actual> expect=<$expect>"
63
        is "$actual" "$expect" "jq .$field"
64
    done < <(parse_table "$tests")
65
}
66

67
@test "podman info - confirm desired runtime" {
68
    if [[ -z "$CI_DESIRED_RUNTIME" ]]; then
69
        # When running in Cirrus, CI_DESIRED_RUNTIME *must* be defined
70
        # in .cirrus.yml so we can double-check that all CI VMs are
71
        # using crun/runc as desired.
72
        if [[ -n "$CIRRUS_CI" ]]; then
73
            die "CIRRUS_CI is set, but CI_DESIRED_RUNTIME is not! See #14912"
74
        fi
75

76
        # Not running under Cirrus (e.g., gating tests, or dev laptop).
77
        # Totally OK to skip this test.
78
        skip "CI_DESIRED_RUNTIME is unset--OK, because we're not in Cirrus"
79
    fi
80

81
    run_podman info --format '{{.Host.OCIRuntime.Name}}'
82
    is "$output" "$CI_DESIRED_RUNTIME" "CI_DESIRED_RUNTIME (from .cirrus.yml)"
83
}
84

85
@test "podman info - confirm desired network backend" {
86
    run_podman info --format '{{.Host.NetworkBackend}}'
87
    is "$output" "netavark" "netavark backend"
88
}
89

90
@test "podman info - confirm desired database" {
91
    # Always run this and preserve its value. We will check again in 999-*.bats
92
    run_podman info --format '{{.Host.DatabaseBackend}}'
93
    db_backend="$output"
94
    echo "$db_backend" > $BATS_SUITE_TMPDIR/db-backend
95

96
    if [[ -z "$CI_DESIRED_DATABASE" ]]; then
97
        # When running in Cirrus, CI_DESIRED_DATABASE *must* be defined
98
        # in .cirrus.yml so we can double-check that all CI VMs are
99
        # using netavark or cni as desired.
100
        if [[ -n "$CIRRUS_CI" ]]; then
101
            die "CIRRUS_CI is set, but CI_DESIRED_DATABASE is not! See #16389"
102
        fi
103

104
        # Not running under Cirrus (e.g., gating tests, or dev laptop).
105
        # Totally OK to skip this test.
106
        skip "CI_DESIRED_DATABASE is unset--OK, because we're not in Cirrus"
107
    fi
108

109
    is "$db_backend" "$CI_DESIRED_DATABASE" "CI_DESIRED_DATABASE (from .cirrus.yml)"
110
}
111

112
@test "podman info - confirm desired storage driver" {
113
    if [[ -z "$CI_DESIRED_STORAGE" ]]; then
114
        # When running in Cirrus, CI_DESIRED_STORAGE *must* be defined
115
        # in .cirrus.yml so we can double-check that all CI VMs are
116
        # using overlay or vfs as desired.
117
        if [[ -n "$CIRRUS_CI" ]]; then
118
            die "CIRRUS_CI is set, but CI_DESIRED_STORAGE is not! See #20161"
119
        fi
120

121
        # Not running under Cirrus (e.g., gating tests, or dev laptop).
122
        # Totally OK to skip this test.
123
        skip "CI_DESIRED_STORAGE is unset--OK, because we're not in Cirrus"
124
    fi
125

126
    is "$(podman_storage_driver)" "$CI_DESIRED_STORAGE" "podman storage driver is not CI_DESIRED_STORAGE (from .cirrus.yml)"
127
}
128

129
# 2021-04-06 discussed in watercooler: RHEL must never use crun, even if
130
# using cgroups v2.
131
@test "podman info - RHEL8 must use runc" {
132
    local osrelease=/etc/os-release
133
    test -e $osrelease || skip "Not a RHEL system (no $osrelease)"
134

135
    local osname=$(source $osrelease; echo $NAME)
136
    if [[ $osname =~ Red.Hat || $osname =~ CentOS ]]; then
137
        # Version can include minor; strip off first dot an all beyond it
138
        local osver=$(source $osrelease; echo $VERSION_ID)
139
        test ${osver%%.*} -le 8 || skip "$osname $osver > RHEL8"
140

141
        # RHEL or CentOS 8.
142
        # FIXME: what does 'CentOS 8' even mean? What is $VERSION_ID in CentOS?
143
        is "$(podman_runtime)" "runc" "$osname only supports OCI Runtime = runc"
144
    else
145
        skip "only applicable on RHEL, this is $osname"
146
    fi
147
}
148

149
@test "podman info --storage-opt='' " {
150
    skip_if_remote "--storage-opt flag is not supported for remote"
151
    skip_if_rootless "storage opts are required for rootless running"
152
    run_podman --storage-opt='' info
153
    # Note this will not work in rootless mode, unless you specify
154
    # storage-driver=vfs, until we have kernels that support rootless overlay
155
    # mounts.
156
    is "$output" ".*graphOptions: {}" "output includes graphOptions: {}"
157
}
158

159
@test "podman info netavark " {
160
    # Confirm netavark in use when explicitly required by execution environment.
161
    if [[ "$NETWORK_BACKEND" == "netavark" ]]; then
162
        if ! is_netavark; then
163
            # Assume is_netavark() will provide debugging feedback.
164
            die "Netavark driver testing required, but not in use by podman."
165
        fi
166
    else
167
        skip "Netavark testing not requested (\$NETWORK_BACKEND='$NETWORK_BACKEND')"
168
    fi
169
}
170

171
@test "podman --root PATH info - basic output" {
172
    if ! is_remote; then
173
        run_podman --storage-driver=vfs --root ${PODMAN_TMPDIR}/nothing-here-move-along info --format '{{ .Store.GraphOptions }}'
174
        is "$output" "map\[\]" "'podman --root should reset GraphOptions to []"
175
    fi
176
}
177

178
@test "rootless podman with symlinked $HOME" {
179
    # This is only needed as rootless, but we don't have a skip_if_root
180
    # And it will not hurt to run as root.
181
    skip_if_remote "path validation is only done in libpod, does not effect remote"
182

183
    new_home=$PODMAN_TMPDIR/home
184

185
    ln -s /home $new_home
186

187
    # Just need the command to run cleanly
188
    HOME=$PODMAN_TMPDIR/$HOME run_podman info
189

190
    rm $new_home
191
}
192

193
@test "podman --root PATH --volumepath info - basic output" {
194
    volumePath=${PODMAN_TMPDIR}/volumesGoHere
195
    if ! is_remote; then
196
        run_podman --storage-driver=vfs --root ${PODMAN_TMPDIR}/nothing-here-move-along --volumepath ${volumePath} info --format '{{ .Store.VolumePath }}'
197
        is "$output" "${volumePath}" "'podman --volumepath should reset VolumePath"
198
    fi
199
}
200

201
@test "CONTAINERS_CONF_OVERRIDE" {
202
    skip_if_remote "remote does not support CONTAINERS_CONF*"
203

204
    # Need to include runtime because it's runc in debian CI,
205
    # and crun 1.11.1 barfs with "read from sync socket"
206
    containersConf=$PODMAN_TMPDIR/containers.conf
207
    cat >$containersConf <<EOF
208
[engine]
209
runtime="$(podman_runtime)"
210

211
[containers]
212
env = [ "CONF1=conf1" ]
213

214
[engine.volume_plugins]
215
volplugin1  = "This is not actually used or seen anywhere"
216
EOF
217

218
    overrideConf=$PODMAN_TMPDIR/override.conf
219
    cat >$overrideConf <<EOF
220
[containers]
221
env = [ "CONF2=conf2" ]
222

223
[engine.volume_plugins]
224
volplugin2  = "This is not actually used or seen anywhere, either"
225
EOF
226

227
    CONTAINERS_CONF="$containersConf" run_podman 1 run --rm $IMAGE printenv CONF1 CONF2
228
    is "$output" "conf1" "with CONTAINERS_CONF only"
229

230
    CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman 1 run --rm $IMAGE printenv CONF1 CONF2
231
    is "$output" "conf2" "with CONTAINERS_CONF_OVERRIDE only"
232

233
    # CONTAINERS_CONF will be overridden by _OVERRIDE. env is overridden, not merged.
234
    CONTAINERS_CONF=$containersConf CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman 1 run --rm $IMAGE printenv CONF1 CONF2
235
    is "$output" "conf2" "with both CONTAINERS_CONF and CONTAINERS_CONF_OVERRIDE"
236

237
    # Merge test: each of those conf files defines a distinct volume plugin.
238
    # Confirm that we see both. 'info' outputs in random order, so we need to
239
    # do two tests.
240
    CONTAINERS_CONF=$containersConf CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman info --format '{{.Plugins.Volume}}'
241
    assert "$output" =~ "volplugin1" "CONTAINERS_CONF_OVERRIDE does not clobber volume_plugins from CONTAINERS_CONF"
242
    assert "$output" =~ "volplugin2" "volume_plugins seen from CONTAINERS_CONF_OVERRIDE"
243

244
}
245

246
@test "podman - BoltDB cannot create new databases" {
247
    skip_if_remote "DB checks only work for local Podman"
248

249
    safe_opts=$(podman_isolation_opts ${PODMAN_TMPDIR})
250

251
    CI_DESIRED_DATABASE= run_podman 125 $safe_opts --db-backend=boltdb info
252
    assert "$output" =~ "deprecated, no new BoltDB databases can be created" \
253
           "without CI_DESIRED_DATABASE"
254

255
    CI_DESIRED_DATABASE=boltdb run_podman $safe_opts --log-level=debug --db-backend=boltdb info
256
    assert "$output" =~ "Allowing deprecated database backend" \
257
           "with CI_DESIRED_DATABASE"
258

259
    run_podman $safe_opts system reset --force
260
}
261

262
# vim: filetype=sh
263

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.