automation-tests/test/apiv2
Paul Holzinger 609b52f726
Bump version to v4.1.0-dev
I think we forgot to bump the version in the main branch. It should be
v4.1.0-dev now.
Also set the min api version to 4.0.0 as on the podman 4.0 branch.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-27 14:32:28 +02:00
..
python Fix hang in test_connect 2022-04-22 16:16:32 -04:00
00-TEMPLATE
01-basic.at Bump version to v4.1.0-dev 2022-04-27 14:32:28 +02:00
10-images.at compat: endpoint /build must set header content type as application/json in reponse 2022-02-07 13:38:19 +05:30
12-imagesMore.at Move all python tests to pytest 2022-03-04 10:35:29 -07:00
15-manifest.at
20-containers.at Allow filtering of "removing", it is a valid status 2022-04-24 06:07:10 -04:00
22-stop.at
23-containersArchive.at
25-containersMore.at
26-containersWait.at
27-containersEvents.at
30-volumes.at
35-networks.at test/apiv2: support netavark 2022-03-30 13:38:47 +02:00
40-pods.at
44-mounts.at
45-system.at
50-secrets.at
60-auth.at
70-short-names.at
README.md
containers.conf
containers.no_hosts.conf API: use no_hosts from containers.conf 2022-04-11 18:41:19 +02:00
test-apiv2 Exit with 0 when receiving SIGTERM 2022-03-15 14:45:11 -07:00

README.md

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(s) after the endpoint may be a series of POST parameters in the form 'key=value', separated by spaces: t POST myentrypoint 200 ! no params t POST myentrypoint id=$id 200 ! just one t POST myentrypoint id=$id filter='{"foo":"bar"}' 200 ! two, with json t POST myentrypoint name=$name badparam='["foo","bar"]' 500 ! etc... t will convert the param list to JSON form for passing to the server. A numeric status code terminates processing of POST parameters. ** As a special case, when one POST argument is a string ending in .tar, t will invoke curl with --data-binary @PATH and set Content-type: application/x-tar. This is useful for build endpoints. (To override Content-type, simply pass along an extra string argument matching application/*): t POST myentrypoint /mytmpdir/myfile.tar application/foo 400

  • 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.