summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-12-19 06:18:21 -0500
committerGitHub <noreply@github.com>2021-12-19 06:18:21 -0500
commitf45070ee0e63ea26e475e618ff32a498096fa561 (patch)
tree4419895229b9a8dc848f2ee11f845d416b2b41c2 /test/system
parent65efd55d416e84a953b11211b2c80783ff632379 (diff)
parent12d762f8ee288164cdb1a8390520d88c4c5eb1bc (diff)
downloadpodman-f45070ee0e63ea26e475e618ff32a498096fa561.tar.gz
podman-f45070ee0e63ea26e475e618ff32a498096fa561.tar.bz2
podman-f45070ee0e63ea26e475e618ff32a498096fa561.zip
Merge pull request #12626 from vrothberg/may-the-force-be-with-removal
image rm: allow for force-remove infra images
Diffstat (limited to 'test/system')
-rw-r--r--test/system/010-images.bats60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/system/010-images.bats b/test/system/010-images.bats
index 9de31f96c..201418620 100644
--- a/test/system/010-images.bats
+++ b/test/system/010-images.bats
@@ -240,4 +240,64 @@ Labels.created_at | 20[0-9-]\\\+T[0-9:]\\\+Z
run_podman rmi test:1.0
}
+
+@test "podman images - rmi -af removes all containers and pods" {
+ pname=$(random_string)
+ run_podman create --pod new:$pname $IMAGE
+
+ run_podman inspect --format '{{.ID}}' $IMAGE
+ imageID=$output
+
+ run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
+ pauseImage=localhost/podman-pause:$output
+ run_podman inspect --format '{{.ID}}' $pauseImage
+ pauseID=$output
+
+ run_podman 2 rmi -a
+ is "$output" "Error: 2 errors occurred:
+.** Image used by .*: image is in use by a container
+.** Image used by .*: image is in use by a container"
+
+ run_podman rmi -af
+ is "$output" "Untagged: $IMAGE
+Untagged: $pauseImage
+Deleted: $imageID
+Deleted: $pauseID" "infra images gets removed as well"
+
+ run_podman images --noheading
+ is "$output" ""
+ run_podman ps --all --noheading
+ is "$output" ""
+ run_podman pod ps --noheading
+ is "$output" ""
+
+ run_podman create --pod new:$pname $IMAGE
+}
+
+@test "podman images - rmi -f can remove infra images" {
+ pname=$(random_string)
+ run_podman create --pod new:$pname $IMAGE
+
+ run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
+ pauseImage=localhost/podman-pause:$output
+ run_podman inspect --format '{{.ID}}' $pauseImage
+ pauseID=$output
+
+ run_podman 2 rmi $pauseImage
+ is "$output" "Error: Image used by .* image is in use by a container"
+
+ run_podman rmi -f $pauseImage
+ is "$output" "Untagged: $pauseImage
+Deleted: $pauseID"
+
+ # Force-removing the infra container removes the pod and all its containers.
+ run_podman ps --all --noheading
+ is "$output" ""
+ run_podman pod ps --noheading
+ is "$output" ""
+
+ # Other images are still present.
+ run_podman image exists $IMAGE
+}
+
# vim: filetype=sh