Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiv2 test fixes #9289

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/api/handlers/compat/images_push.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package compat

import (
"context"
"net/http"
"strings"

Expand Down Expand Up @@ -76,7 +75,15 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
if _, found := r.URL.Query()["tlsVerify"]; found {
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
}
if err := imageEngine.Push(context.Background(), imageName, query.Destination, options); err != nil {

var destination string
if _, found := r.URL.Query()["destination"]; found {
destination = query.Destination
} else {
destination = imageName
}

if err := imageEngine.Push(r.Context(), imageName, destination, options); err != nil {
if errors.Cause(err) != storage.ErrImageUnknown {
utils.ImageNotFound(w, imageName, errors.Wrapf(err, "failed to find image %s", imageName))
return
Expand Down
7 changes: 2 additions & 5 deletions test/apiv2/12-imagesMore.at
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ t GET libpod/images/$IMAGE/json 200 \

# Run registry container
podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml
wait_for_port localhost 5000

# Push to local registry
# FIXME: this is failing:
# "cause": "received unexpected HTTP status: 500 Internal Server Error",
# "message": "error pushing image \"localhost:5000/myrepo:mytag\": error copying image to the remote destination: Error writing blob: Error initiating layer upload to /v2/myrepo/blobs/uploads/ in localhost:5000: received unexpected HTTP status: 500 Internal Server Error",
# "response": 400
#t POST libpod/images/localhost:5000/myrepo:mytag/push\?tlsVerify\=false '' 200
t POST "images/localhost:5000/myrepo/push?tlsVerify=false&tag=mytag" '' 200

# Untag the image
t POST "libpod/images/$iid/untag?repo=localhost:5000/myrepo&tag=mytag" '' 201
Expand Down
9 changes: 3 additions & 6 deletions test/apiv2/23-containersArchive.at
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ podman rm -a -f &>/dev/null

CTR="ArchiveTestingCtr"

TMPD=$(mktemp -d)
pushd "${TMPD}"
echo "Hello" > "hello.txt"
tar --format=posix -cvf "hello.tar" "hello.txt" &> /dev/null
popd

TMPD=$(mktemp -d podman-apiv2-test.archive.XXXXXXXX)
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

Expand Down
33 changes: 27 additions & 6 deletions test/apiv2/test-apiv2
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function like() {

if expr "$actual" : "$expect" &>/dev/null; then
# 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
fi
_show_ok 0 "$testname" "~ $expect" "$actual"
Expand Down Expand Up @@ -231,14 +233,17 @@ function t() {
if [[ $content_type =~ /octet ]]; then
output="[$(file --brief $WORKDIR/curl.result.out)]"
echo "$output" >>$LOG
else
elif [[ -e $WORKDIR/curl.result.out ]]; then
output=$(< $WORKDIR/curl.result.out)

if [[ $content_type =~ application/json ]]; then
if [[ $content_type =~ application/json ]] && [[ $method != "HEAD" ]]; then
jq . <<<"$output" >>$LOG
else
echo "$output" >>$LOG
fi
else
output=
echo "[no output]" >>$LOG
fi

# Test return code
Expand Down Expand Up @@ -305,10 +310,20 @@ function start_service() {
&> $WORKDIR/server.log &
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
local _timeout=5
while [ $_timeout -gt 0 ]; do
{ exec 3<> /dev/tcp/$HOST/$PORT; } &>/dev/null && return
while [ $timeout -gt 0 ]; do
{ exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
sleep 1
_timeout=$(( $_timeout - 1 ))
done
Expand Down Expand Up @@ -385,6 +400,12 @@ done
# Clean up

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
wait $service_pid
fi
Expand Down