podman/test/apiv2
Ed Santiago 20e104351d move from docker.io
Followon to #7965 (mirror registry). mirror.gcr.io doesn't
cache all the images we need, and I can't find a way to
add to its cache, so let's just use quay.io for those
images that it can't serve.

Tools used:
  skopeo copy --all docker://docker.io/library/alpine:3.10.2 \
                    docker://quay.io/libpod/alpine:3.10.2

...and also:

    docker.io/library/alpine:3.2
    docker.io/library/busybox:latest
    docker.io/library/busybox:glibc
    docker.io/library/busybox:1.30.1
    docker.io/library/redis:alpine
    docker.io/libpod/alpine-with-bogus-seccomp:label
    docker.io/libpod/alpine-with-seccomp:label
    docker.io/libpod/alpine_healthcheck:latest
    docker.io/libpod/badhealthcheck:latest

Since most of those were new quay.io/libpod images, they required
going in through the quay.io GUI, image, settings, Make Public.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-28 13:16:37 -06:00
..
rest_api Restore 'id' stanza in pull results 2020-09-21 08:51:52 -07:00
00-TEMPLATE Tests for API v2 2020-01-17 09:59:22 -07:00
01-basic.at Tests: Fix common flakes, and improve apiv2 test log 2020-10-20 11:32:49 -06:00
10-images.at move from docker.io 2020-10-28 13:16:37 -06:00
12-imagesMore.at move from docker.io 2020-10-28 13:16:37 -06:00
20-containers.at move from docker.io 2020-10-28 13:16:37 -06:00
22-stop.at APIv2 tests: add tests for stop 2020-03-03 06:40:27 -07:00
25-containersMore.at APIv2 test: add more tests for containers 2020-09-01 04:00:39 -04:00
30-volumes.at Add test cases to cover podman volume 2020-10-27 13:16:04 -04:00
35-networks.at APIv2 tests: try again to fix them 2020-10-12 13:57:59 -06:00
40-pods.at APIv2 tests: get them passing again 2020-10-12 08:45:39 -06:00
README.md Tests for API v2 2020-01-17 09:59:22 -07:00
test-apiv2 Tests: Fix common flakes, and improve apiv2 test log 2020-10-20 11:32:49 -06:00

API v2 tests

This directory contains tests for the podman version 2 API (HTTP).

Tests themselves are in files of the form 'NN-NAME.at' where NN is a two-digit number, NAME is a descriptive name, and '.at' is just an extension I picked.

Running Tests

The main test runner is test-apiv2. Usage is:

$ sudo ./test-apiv2 [NAME [...]]

...where NAME is one or more optional test names, e.g. 'image' or 'pod' or both. By default, test-apiv2 will invoke all *.at tests.

test-apiv2 connects to localhost only and via TCP. There is no support here for remote hosts or for UNIX sockets. This is a framework for testing the API, not all possible protocols.

test-apiv2 will start the service if it isn't already running.

Writing Tests

The main test function is t. It runs curl against the server, with POST parameters if present, and compares return status and (optionally) string results from the server:

t GET /_ping 200 OK
  ^^^ ^^^^^^ ^^^ ^^
  |   |      |   +--- expected string result
  |   |      +------- expected return code
  |   +-------------- endpoint to access
  +------------------ method (GET, POST, DELETE, HEAD)


t POST libpod/volumes/create name=foo 201 .ID~[0-9a-f]\\{12\\}
       ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^
       |                     |        |   JSON '.ID': expect 12-char hex
       |                     |        +-- expected code
       |                     +----------- POST params
       +--------------------------------- note the missing slash

Notes:

  • If the endpoint has a leading slash (/_ping), t leaves it unchanged. If there's no leading slash, t prepends /v1.40. This is a simple convenience for simplicity of writing tests.

  • When method is POST, the argument after the endpoint must be a series of POST arguments in the form 'key=value', separated by commas. t will convert those to JSON form for passing to the server.

  • The final arguments are one or more expected string results. If an argument starts with a dot, t will invoke jq on the output to fetch that field, and will compare it to the right-hand side of the argument. If the separator is = (equals), t will require an exact match; if ~ (tilde), t will use expr to compare.