github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/apiv2/25-containersMore.at (about) 1 # -*- sh -*- 2 # 3 # test more container-related endpoints 4 # 5 6 podman pull $IMAGE &>/dev/null 7 8 # Ensure clean slate 9 podman rm -a -f &>/dev/null 10 11 podman run -d --name foo $IMAGE top 12 13 # Check exists for none such 14 t GET libpod/containers/nonesuch/exists 404 15 16 # Check container foo exists 17 t GET libpod/containers/foo/exists 204 18 19 # Pause the container 20 t POST libpod/containers/foo/pause 204 21 22 t GET libpod/containers/foo/json 200 \ 23 .Id~[0-9a-f]\\{64\\} \ 24 .State.Status=paused \ 25 .ImageName=$IMAGE \ 26 .Config.Cmd[0]=top \ 27 .Name=foo 28 29 # Unpause the container 30 t POST libpod/containers/foo/unpause 204 31 32 t GET libpod/containers/foo/json 200 \ 33 .Id~[0-9a-f]\\{64\\} \ 34 .State.Status=running \ 35 .ImageName=$IMAGE \ 36 .Config.Cmd[0]=top \ 37 .Name=foo 38 39 # List processes of the container 40 t GET libpod/containers/foo/top 200 \ 41 length=2 \ 42 .Processes[0][7]="top" 43 44 # List processes of none such 45 t GET libpod/containers/nonesuch/top 404 46 47 # Mount the container to host filesystem 48 t POST libpod/containers/foo/mount 200 49 like "$output" ".*merged" "Check container mount" 50 51 # Unmount the container 52 t POST libpod/containers/foo/unmount 204 53 54 t DELETE libpod/containers/foo?force=true 200 55 56 podman run $IMAGE true 57 58 t GET libpod/containers/json?last=1 200 \ 59 length=1 \ 60 .[0].Id~[0-9a-f]\\{64\\} \ 61 .[0].Image=$IMAGE \ 62 .[0].Command[0]="true" \ 63 .[0].State~\\\(exited\\\|stopped\\\) \ 64 .[0].ExitCode=0 \ 65 .[0].IsInfra=false 66 67 cid=$(jq -r '.[0].Id' <<<"$output") 68 69 t GET libpod/generate/kube?names=$cid 200 70 like "$output" ".*apiVersion:.*" "Check generated kube yaml - apiVersion" 71 like "$output" ".*kind:\\sPod.*" "Check generated kube yaml - kind: Pod" 72 like "$output" ".*metadata:.*" "Check generated kube yaml - metadata" 73 like "$output" ".*spec:.*" "Check generated kube yaml - spec" 74 75 t GET "libpod/generate/kube?service=true&names=$cid" 200 76 like "$output" ".*apiVersion:.*" "Check generated kube yaml(service=true) - apiVersion" 77 like "$output" ".*kind:\\sPod.*" "Check generated kube yaml(service=true) - kind: Pod" 78 like "$output" ".*metadata:.*" "Check generated kube yaml(service=true) - metadata" 79 like "$output" ".*spec:.*" "Check generated kube yaml(service=true) - spec" 80 like "$output" ".*kind:\\sService.*" "Check generated kube yaml(service=true) - kind: Service" 81 82 t DELETE libpod/containers/$cid 200 .[0].Id=$cid 83 84 # Create 3 stopped containers to test containers prune 85 podman run $IMAGE true 86 podman run $IMAGE true 87 podman run $IMAGE true 88 89 t POST libpod/containers/prune 200 90 t GET libpod/containers/json 200 \ 91 length=0 92 # vim: filetype=sh