1
#!/usr/bin/env bats -*- bats -*-
12
run_podman rmi -f $SYSTEMD_IMAGE
21
run_podman volume rm -a
24
@test "podman system df - basic functionality" {
26
is "$output" ".*Images *1 *0 " "Exactly one image"
27
is "$output" ".*Containers *0 *0 " "No containers"
28
is "$output" ".*Local Volumes *0 *0 " "No volumes"
31
@test "podman system df --format {{ json . }} functionality" {
32
run_podman system df --format '{{json .}}'
33
is "$output" '.*"TotalCount":1' "Exactly one image"
34
is "$output" '.*"RawSize".*"Size"' "RawSize and Size reported"
35
is "$output" '.*"RawReclaimable".*"Reclaimable"' "RawReclaimable and Reclaimable reported"
36
is "$output" '.*"Containers".*"Total":0' "Total containers reported"
37
is "$output" '.*"Local Volumes".*"Size":"0B"' "Total containers reported"
38
is "$output" '.*"Local Volumes".*"Size":"0B"' "Total containers reported"
41
@test "podman system df --format json functionality" {
43
run_podman run --name stoppedcontainer $IMAGE true
44
run_podman run -d --name runningcontainer $IMAGE top
45
run_podman system df --format json
46
local results="$output"
50
if [[ "$(uname -m)" = "aarch64" ]]; then
61
Type | Images | Containers | Local Volumes
64
RawSize | ~${size}...... | !0 | 0
65
RawReclaimable | 0 | !0 | 0
66
Reclaimable | ~\(0%\) | ~\(50%\) | ~\(0%\)
68
Size | ~${size}.*MB | !0B | 0B
70
while read -a fields; do
72
expect="${fields[$((i+1))]}"
73
actual=$(jq -r ".[$i].${fields[0]}" <<<"$results")
77
if [[ "$expect" =~ ^\! ]]; then
81
if [[ "$expect" =~ ^~ ]]; then
86
assert "$actual" "$op" "$expect" "system df[$i].${fields[0]}"
88
done < <(parse_table "$tests")
91
run_podman rm -f -t 0 stoppedcontainer runningcontainer
94
@test "podman system df - with active containers and volumes" {
95
run_podman run -v /myvol1 --name c1 $IMAGE true
96
run_podman run -d -v /myvol2 --name c2 $IMAGE top
98
run_podman system df --format '{{ .Type }}:{{ .Total }}:{{ .Active }}'
99
is "${lines[0]}" "Images:1:1" "system df : Images line"
100
is "${lines[1]}" "Containers:2:1" "system df : Containers line"
101
is "${lines[2]}" "Local Volumes:2:2" "system df : Volumes line"
107
run_podman system df -v
109
"${PODMAN_TEST_IMAGE_REGISTRY}/${PODMAN_TEST_IMAGE_USER}/${PODMAN_TEST_IMAGE_NAME} * ${PODMAN_TEST_IMAGE_TAG} [0-9a-f]* .* 2" \
110
"system df -v: the 'Images' line"
114
"[0-9a-f]\{12\} *[0-9a-f]\{12\} .* 1 .* c[12]" \
115
"system df -v, 'Containers', first line"
117
"[0-9a-f]\{12\} *[0-9a-f]\{12\} .* 1 .* c[12]" \
118
"system df -v, 'Containers', second line"
121
is "${lines[9]}" "[0-9a-f]\{64\} *[01] * 0B" \
122
"system df -v, 'Volumes', first line"
123
is "${lines[10]}" "[0-9a-f]\{64\} *[01] * 0B" \
124
"system df -v, 'Volumes', second line"
127
run_podman image inspect $IMAGE --format "{{.Size}}"
128
expectedSize="$output"
130
run_podman system df --format "{{.RawSize}}"
131
is "${lines[0]}" "$expectedSize" "raw image size is correct"
134
run_podman system df --format '{{.Reclaimable}}'
135
is "${lines[0]}" "0B (0%)" "cannot reclaim image data as it's still used by the containers"
140
run_podman container commit -q c1
143
run_podman system df --format '{{.Reclaimable}}'
144
is "${lines[0]}" ".* (100%)" "100 percent of image data is reclaimable because $IMAGE has unique size of 0"
149
run_podman system df -v
150
is "$output" ".*0B\\s\\+2.*"
154
run_podman system df --format '{{.Reclaimable}}'
155
is "${lines[0]}" ".* (100%)" "100 percent of image data is reclaimable because all containers are gone"
157
run_podman rmi $image
158
run_podman volume rm -a