mirror of
https://github.com/containers/podman.git
synced 2025-09-10 04:12:20 +08:00

Versions of the ps command have additional spaces between fields, this manifests as the container asking to run "top" and API reporting "top " as a process. Endpoint and tests updated to check that "top" is reported. There is no libpod specialized endpoint to update. Signed-off-by: Jhon Honce <jhonce@redhat.com>
93 lines
2.5 KiB
Bash
93 lines
2.5 KiB
Bash
# -*- sh -*-
|
|
#
|
|
# test more container-related endpoints
|
|
#
|
|
|
|
podman pull $IMAGE &>/dev/null
|
|
|
|
# Ensure clean slate
|
|
podman rm -a -f &>/dev/null
|
|
|
|
podman run -d --name foo $IMAGE top
|
|
|
|
# Check exists for none such
|
|
t GET libpod/containers/nonesuch/exists 404
|
|
|
|
# Check container foo exists
|
|
t GET libpod/containers/foo/exists 204
|
|
|
|
# Pause the container
|
|
t POST libpod/containers/foo/pause 204
|
|
|
|
t GET libpod/containers/foo/json 200 \
|
|
.Id~[0-9a-f]\\{64\\} \
|
|
.State.Status=paused \
|
|
.ImageName=$IMAGE \
|
|
.Config.Cmd[0]=top \
|
|
.Name=foo
|
|
|
|
# Unpause the container
|
|
t POST libpod/containers/foo/unpause 204
|
|
|
|
t GET libpod/containers/foo/json 200 \
|
|
.Id~[0-9a-f]\\{64\\} \
|
|
.State.Status=running \
|
|
.ImageName=$IMAGE \
|
|
.Config.Cmd[0]=top \
|
|
.Name=foo
|
|
|
|
# List processes of the container
|
|
t GET libpod/containers/foo/top 200 \
|
|
length=2 \
|
|
.Processes[0][7]="top"
|
|
|
|
# List processes of none such
|
|
t GET libpod/containers/nonesuch/top 404
|
|
|
|
# Mount the container to host filesystem
|
|
t POST libpod/containers/foo/mount 200
|
|
like "$output" ".*merged" "Check container mount"
|
|
|
|
# Unmount the container
|
|
t POST libpod/containers/foo/unmount 204
|
|
|
|
t DELETE libpod/containers/foo?force=true 204
|
|
|
|
podman run $IMAGE true
|
|
|
|
t GET libpod/containers/json?last=1 200 \
|
|
length=1 \
|
|
.[0].Id~[0-9a-f]\\{64\\} \
|
|
.[0].Image=$IMAGE \
|
|
.[0].Command[0]="true" \
|
|
.[0].State~\\\(exited\\\|stopped\\\) \
|
|
.[0].ExitCode=0 \
|
|
.[0].IsInfra=false
|
|
|
|
cid=$(jq -r '.[0].Id' <<<"$output")
|
|
|
|
t GET libpod/generate/kube?names=$cid 200
|
|
like "$output" ".*apiVersion:.*" "Check generated kube yaml - apiVersion"
|
|
like "$output" ".*kind:\\sPod.*" "Check generated kube yaml - kind: Pod"
|
|
like "$output" ".*metadata:.*" "Check generated kube yaml - metadata"
|
|
like "$output" ".*spec:.*" "Check generated kube yaml - spec"
|
|
|
|
t GET "libpod/generate/kube?service=true&names=$cid" 200
|
|
like "$output" ".*apiVersion:.*" "Check generated kube yaml(service=true) - apiVersion"
|
|
like "$output" ".*kind:\\sPod.*" "Check generated kube yaml(service=true) - kind: Pod"
|
|
like "$output" ".*metadata:.*" "Check generated kube yaml(service=true) - metadata"
|
|
like "$output" ".*spec:.*" "Check generated kube yaml(service=true) - spec"
|
|
like "$output" ".*kind:\\sService.*" "Check generated kube yaml(service=true) - kind: Service"
|
|
|
|
t DELETE libpod/containers/$cid 204
|
|
|
|
# Create 3 stopped containers to test containers prune
|
|
podman run $IMAGE true
|
|
podman run $IMAGE true
|
|
podman run $IMAGE true
|
|
|
|
t POST libpod/containers/prune 200
|
|
t GET libpod/containers/json 200 \
|
|
length=0
|
|
# vim: filetype=sh
|