|
Some checks failed
ci / path-filter (push) Has been cancelled
ci / Validate source code changes (push) Has been cancelled
ci / Cross Build (Linux, FreeBSD) (push) Has been cancelled
ci / build debian-sid (push) Has been cancelled
ci / build fedora-current (push) Has been cancelled
ci / build fedora-prior (push) Has been cancelled
ci / build fedora-rawhide (push) Has been cancelled
ci / windows installer hyperv (push) Has been cancelled
ci / windows installer wsl (push) Has been cancelled
ci / macos installer (push) Has been cancelled
zizmor: GitHub Actions Security Analysis / Zizmor (push) Has been cancelled
ci / int local root debian-sid (push) Has been cancelled
ci / sys local root debian-sid (push) Has been cancelled
ci / int local rootless debian-sid (push) Has been cancelled
ci / sys local rootless debian-sid (push) Has been cancelled
ci / int remote root debian-sid (push) Has been cancelled
ci / sys remote root debian-sid (push) Has been cancelled
ci / bud local root fedora-current (push) Has been cancelled
ci / int local root fedora-current (push) Has been cancelled
ci / sys local root fedora-current (push) Has been cancelled
ci / int local rootless fedora-current (push) Has been cancelled
ci / sys local rootless fedora-current (push) Has been cancelled
ci / bud remote root fedora-current (push) Has been cancelled
ci / int remote root fedora-current (push) Has been cancelled
ci / sys remote root fedora-current (push) Has been cancelled
ci / int remote rootless fedora-current (push) Has been cancelled
ci / sys remote rootless fedora-current (push) Has been cancelled
ci / int local root fedora-prior (push) Has been cancelled
ci / sys local root fedora-prior (push) Has been cancelled
ci / int local rootless fedora-prior (push) Has been cancelled
ci / sys local rootless fedora-prior (push) Has been cancelled
ci / int remote root fedora-prior (push) Has been cancelled
ci / sys remote root fedora-prior (push) Has been cancelled
ci / int local root fedora-rawhide (push) Has been cancelled
ci / sys local root fedora-rawhide (push) Has been cancelled
ci / int local rootless fedora-rawhide (push) Has been cancelled
ci / sys local rootless fedora-rawhide (push) Has been cancelled
ci / int remote root fedora-rawhide (push) Has been cancelled
ci / sys remote root fedora-rawhide (push) Has been cancelled
ci / apiv2 root fedora-current (push) Has been cancelled
ci / bindings root fedora-current (push) Has been cancelled
ci / compose_v2 root fedora-current (push) Has been cancelled
ci / docker_py root fedora-current (push) Has been cancelled
ci / unit root fedora-current (push) Has been cancelled
ci / apiv2 rootless fedora-current (push) Has been cancelled
ci / compose_v2 rootless fedora-current (push) Has been cancelled
ci / farm rootless fedora-current (push) Has been cancelled
ci / unit rootless fedora-current (push) Has been cancelled
ci / upgrade v5.3.1 root fedora-current (push) Has been cancelled
ci / upgrade v5.6.2 root fedora-current (push) Has been cancelled
ci / machine linux amd64 (push) Has been cancelled
ci / windows unit (push) Has been cancelled
ci / windows e2e (push) Has been cancelled
ci / windows machine hyperv (push) Has been cancelled
ci / windows machine wsl (push) Has been cancelled
ci / macos machine applehv (push) Has been cancelled
ci / macos machine libkrun (push) Has been cancelled
ci / Total Success (push) Has been cancelled
compat: Restart policy no longer resets on compat update |
||
|---|---|---|
| .. | ||
| python | ||
| 00-TEMPLATE | ||
| 01-basic.at | ||
| 10-images.at | ||
| 12-imagesMore.at | ||
| 14-commit.at | ||
| 15-manifest.at | ||
| 19-stats.at | ||
| 20-containers.at | ||
| 21-restart.at | ||
| 22-stop.at | ||
| 23-containersArchive.at | ||
| 25-containersMore.at | ||
| 26-containersWait.at | ||
| 27-containersEvents.at | ||
| 28-containersAnnotations.at | ||
| 29-containersUpdate.at | ||
| 30-volumes.at | ||
| 35-networks.at | ||
| 36-quadlets.at | ||
| 37-autoupdate.at | ||
| 40-pods.at | ||
| 44-mounts.at | ||
| 45-system.at | ||
| 47-subnet-pools.at | ||
| 50-secrets.at | ||
| 60-auth.at | ||
| 70-short-names.at | ||
| 80-kube.at | ||
| 90-build.at | ||
| containers.conf | ||
| containers.host-netns.conf | ||
| containers.no_hosts.conf | ||
| README.md | ||
| storage.partial-pull.conf | ||
| test-apiv2 | ||
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
Never, ever, ever, seriously EVER exit from a test. Just don't.
That skips cleanup, and leaves the system in a broken state.
Notes:
-
If the endpoint has a leading slash (
/_ping),tleaves it unchanged. If there's no leading slash,tprepends/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...
twill 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,.yaml, or.json,twill invokecurlwith--data-binary @PATHand setContent-typeas appropriate. This is useful forbuildendpoints. (To overrideContent-type, simply pass along an extra string argument matchingapplication/*): t POST myentrypoint /mytmpdir/myfile.tar application/foo 400 ** Like above, when using PUT,tdoes--upload-timeinstead of--data-binary -
The final arguments are one or more expected string results. If an argument starts with a dot,
twill invokejqon the output to fetch that field, and will compare it to the right-hand side of the argument. If the separator is=(equals),twill require an exact match; if~(tilde),twill useexprto compare. -
If your test expects
curlto time out: APIV2_TEST_EXPECT_TIMEOUT=5 t POST /foo 999