mirror of
https://github.com/containers/podman.git
synced 2025-06-24 11:28:24 +08:00
Merge pull request #9289 from edsantiago/apiv2_test_fixes
apiv2 test fixes
This commit is contained in:
@ -24,7 +24,7 @@ t GET libpod/images/$IMAGE/json 200 \
|
|||||||
|
|
||||||
# Run registry container
|
# Run registry container
|
||||||
podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml
|
podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml
|
||||||
sleep 2
|
wait_for_port localhost 5000
|
||||||
|
|
||||||
# Push to local registry
|
# Push to local registry
|
||||||
t POST "images/localhost:5000/myrepo/push?tlsVerify=false&tag=mytag" '' 200
|
t POST "images/localhost:5000/myrepo/push?tlsVerify=false&tag=mytag" '' 200
|
||||||
|
@ -13,13 +13,10 @@ podman rm -a -f &>/dev/null
|
|||||||
|
|
||||||
CTR="ArchiveTestingCtr"
|
CTR="ArchiveTestingCtr"
|
||||||
|
|
||||||
TMPD=$(mktemp -d)
|
TMPD=$(mktemp -d podman-apiv2-test.archive.XXXXXXXX)
|
||||||
pushd "${TMPD}"
|
|
||||||
echo "Hello" > "hello.txt"
|
|
||||||
tar --format=posix -cvf "hello.tar" "hello.txt" &> /dev/null
|
|
||||||
popd
|
|
||||||
|
|
||||||
HELLO_TAR="${TMPD}/hello.tar"
|
HELLO_TAR="${TMPD}/hello.tar"
|
||||||
|
echo "Hello" > $TMPD/hello.txt
|
||||||
|
tar --format=posix -C $TMPD -cvf ${HELLO_TAR} hello.txt &> /dev/null
|
||||||
|
|
||||||
podman run -d --name "${CTR}" "${IMAGE}" top
|
podman run -d --name "${CTR}" "${IMAGE}" top
|
||||||
|
|
||||||
|
@ -84,7 +84,9 @@ function like() {
|
|||||||
|
|
||||||
if expr "$actual" : "$expect" &>/dev/null; then
|
if expr "$actual" : "$expect" &>/dev/null; then
|
||||||
# On success, include expected value; this helps readers understand
|
# On success, include expected value; this helps readers understand
|
||||||
_show_ok 1 "$testname ('$actual') ~ $expect"
|
# (but don't show enormous multi-line output like 'generate kube')
|
||||||
|
blurb=$(head -n1 <<<"$actual")
|
||||||
|
_show_ok 1 "$testname ('$blurb') ~ $expect"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
_show_ok 0 "$testname" "~ $expect" "$actual"
|
_show_ok 0 "$testname" "~ $expect" "$actual"
|
||||||
@ -231,14 +233,17 @@ function t() {
|
|||||||
if [[ $content_type =~ /octet ]]; then
|
if [[ $content_type =~ /octet ]]; then
|
||||||
output="[$(file --brief $WORKDIR/curl.result.out)]"
|
output="[$(file --brief $WORKDIR/curl.result.out)]"
|
||||||
echo "$output" >>$LOG
|
echo "$output" >>$LOG
|
||||||
else
|
elif [[ -e $WORKDIR/curl.result.out ]]; then
|
||||||
output=$(< $WORKDIR/curl.result.out)
|
output=$(< $WORKDIR/curl.result.out)
|
||||||
|
|
||||||
if [[ $content_type =~ application/json ]]; then
|
if [[ $content_type =~ application/json ]] && [[ $method != "HEAD" ]]; then
|
||||||
jq . <<<"$output" >>$LOG
|
jq . <<<"$output" >>$LOG
|
||||||
else
|
else
|
||||||
echo "$output" >>$LOG
|
echo "$output" >>$LOG
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
output=
|
||||||
|
echo "[no output]" >>$LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test return code
|
# Test return code
|
||||||
@ -305,10 +310,20 @@ function start_service() {
|
|||||||
&> $WORKDIR/server.log &
|
&> $WORKDIR/server.log &
|
||||||
service_pid=$!
|
service_pid=$!
|
||||||
|
|
||||||
|
wait_for_port $HOST $PORT
|
||||||
|
}
|
||||||
|
|
||||||
|
###################
|
||||||
|
# wait_for_port # Returns once port is available on host
|
||||||
|
###################
|
||||||
|
function wait_for_port() {
|
||||||
|
local host=$1 # Probably "localhost"
|
||||||
|
local port=$2 # Numeric port
|
||||||
|
local timeout=${3:-5} # Optional; default to 5 seconds
|
||||||
|
|
||||||
# Wait
|
# Wait
|
||||||
local _timeout=5
|
while [ $timeout -gt 0 ]; do
|
||||||
while [ $_timeout -gt 0 ]; do
|
{ exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
|
||||||
{ exec 3<> /dev/tcp/$HOST/$PORT; } &>/dev/null && return
|
|
||||||
sleep 1
|
sleep 1
|
||||||
_timeout=$(( $_timeout - 1 ))
|
_timeout=$(( $_timeout - 1 ))
|
||||||
done
|
done
|
||||||
@ -385,6 +400,12 @@ done
|
|||||||
# Clean up
|
# Clean up
|
||||||
|
|
||||||
if [ -n "$service_pid" ]; then
|
if [ -n "$service_pid" ]; then
|
||||||
|
# Remove any containers and images; this prevents the following warning:
|
||||||
|
# 'rm: cannot remove '/.../overlay': Device or resource busy
|
||||||
|
podman rm -a
|
||||||
|
podman rmi -af
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
kill $service_pid
|
kill $service_pid
|
||||||
wait $service_pid
|
wait $service_pid
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user