summaryrefslogtreecommitdiff
path: root/test/apiv2/test-apiv2
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-14 22:30:56 +0100
committerGitHub <noreply@github.com>2021-12-14 22:30:56 +0100
commitb01a421f3413ba01b2c189b82c8153bdbd2a05fb (patch)
tree6d00f8d4657325c3eef543adb8b1718b32e8c112 /test/apiv2/test-apiv2
parentc36fb8b1138b112ec3d53e5cf89a2fbcb12e6840 (diff)
parent0a2eb7b1857907f065a48a07a9a3096fa3cc5f77 (diff)
downloadpodman-b01a421f3413ba01b2c189b82c8153bdbd2a05fb.tar.gz
podman-b01a421f3413ba01b2c189b82c8153bdbd2a05fb.tar.bz2
podman-b01a421f3413ba01b2c189b82c8153bdbd2a05fb.zip
Merge pull request #12596 from edsantiago/apiv2_test_refactor
apiv2 tests: refactor complicated curls
Diffstat (limited to 'test/apiv2/test-apiv2')
-rwxr-xr-xtest/apiv2/test-apiv231
1 files changed, 22 insertions, 9 deletions
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index c644b9578..47934cca9 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -182,6 +182,7 @@ function t() {
local method=$1; shift
local path=$1; shift
local curl_args
+ local content_type="application/json"
local testname="$method $path"
# POST requests may be followed by one or more key=value pairs.
@@ -190,13 +191,21 @@ function t() {
local -a post_args
for arg; do
case "$arg" in
- *=*) post_args+=("$arg"); shift ;;
+ *=*) post_args+=("$arg");
+ shift;;
+ *.tar) curl_args="--data-binary @$arg" ;
+ content_type="application/x-tar";
+ shift;;
+ application/*) content_type="$arg";
+ shift;;
[1-9][0-9][0-9]) break;;
*) die "Internal error: invalid POST arg '$arg'" ;;
esac
done
- curl_args="-d $(jsonify ${post_args[@]})"
- testname="$testname [$curl_args]"
+ if [[ -z "$curl_args" ]]; then
+ curl_args="-d $(jsonify ${post_args[@]})"
+ testname="$testname [$curl_args]"
+ fi
fi
# entrypoint path can include a descriptive comment; strip it off
@@ -229,7 +238,7 @@ function t() {
rm -f $WORKDIR/curl.*
# -s = silent, but --write-out 'format' gives us important response data
response=$(curl -s -X $method ${curl_args} \
- -H 'Content-type: application/json' \
+ -H "Content-type: $content_type" \
--dump-header $WORKDIR/curl.headers.out \
--write-out '%{http_code}^%{content_type}^%{time_total}' \
-o $WORKDIR/curl.result.out "$url")
@@ -328,10 +337,13 @@ function start_service() {
fi
echo $WORKDIR
- $PODMAN_BIN --root $WORKDIR/server_root --syslog=true \
- system service \
- --time 15 \
- tcp:127.0.0.1:$PORT \
+ # Some tests use shortnames; force registry override to work around
+ # docker.io throttling.
+ env CONTAINERS_REGISTRIES_CONF=$TESTS_DIR/../registries.conf $PODMAN_BIN \
+ --root $WORKDIR/server_root --syslog=true \
+ system service \
+ --time 15 \
+ tcp:127.0.0.1:$PORT \
&> $WORKDIR/server.log &
service_pid=$!
@@ -460,7 +472,8 @@ function wait_for_port() {
############
function podman() {
echo "\$ $PODMAN_BIN $*" >>$WORKDIR/output.log
- $PODMAN_BIN --root $WORKDIR/server_root "$@" >>$WORKDIR/output.log 2>&1
+ env CONTAINERS_REGISTRIES_CONF=$TESTS_DIR/../registries.conf \
+ $PODMAN_BIN --root $WORKDIR/server_root "$@" >>$WORKDIR/output.log 2>&1
}
####################