diff options
author | Ed Santiago <santiago@redhat.com> | 2021-12-14 08:41:26 -0700 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2021-12-14 12:10:19 -0700 |
commit | 0a2eb7b1857907f065a48a07a9a3096fa3cc5f77 (patch) | |
tree | e84b116a2af32c9d7dbd94a525e0751cad11e493 /test/apiv2/test-apiv2 | |
parent | a0894b5ecd6c64d30b82a7b79bc1e2e87c7f0a4e (diff) | |
download | podman-0a2eb7b1857907f065a48a07a9a3096fa3cc5f77.tar.gz podman-0a2eb7b1857907f065a48a07a9a3096fa3cc5f77.tar.bz2 podman-0a2eb7b1857907f065a48a07a9a3096fa3cc5f77.zip |
apiv2 tests: refactor complicated curls
Some months ago, apiv2 tests got added that needed new
functionality: passing a tarball to the remote server.
There was no mechanism to do so in the 't' helper, so
these tests used complicated (and actually not-really-
working) curl commands.
This PR introduces and documents a new usage of 't', in
which passing an argument ending in '.tar' adds the
right magic syntax (--data-binary @PATH) to the existing
curl. This lets us use all standard 't' checks, making
for simpler tests and in the process fixing some bugs.
Also: drive-by fix of a typo bug in the networks test.
Also: set CONTAINERS_REGISTRIES_CONF when starting server
and when running direct podman, to avoid docker.io throttling.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/apiv2/test-apiv2')
-rwxr-xr-x | test/apiv2/test-apiv2 | 31 |
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 } #################### |