Next: (veritas generator), Previous: (veritas cli), Up: API
Docker/Podman helpers for integration and black box testing, following the well known container-test pattern: start a container, wait until it is ready, exercise it (exec, logs, host ports), then clean it up.
The runtime is auto-detected (Podman first, then Docker) and can be forced with the VERITAS_CONTAINER_RUNTIME environment variable, mirroring the way testcontainers libraries target a Docker-compatible endpoint. Everything shells out to the CLI, so no daemon bindings are required.
Typical use inside a suite:
(with-container (lambda (c) (assert-true (container-running? c)) (assert-matches #:pattern "ready" #:got (container-exec c ’("app" "–version")))) #:image "alpine" #:command ’("sh" "-c" "echo ready && sleep 600") #:wait (lambda (c) (container-wait-for-log c "ready" #:timeout 10)))
Return an assertion that container is running.
Unlike assert-true, the check is performed when the assertion
runs, not when it is constructed.
Build an image with tag from dockerfile in context.
Run command (a list of strings) inside running container.
Returns the captured combined output and raises on failure.
Run command inside container, returning two values: status and output.
Return the logs of container as a string.
Force-stop and remove container, returning its exit status.
Start image and return the new container id (or name when given).
env entries are passed as -e variables, ports as
-p bindings and volumes as -v mounts.
Return #t when container exists and is running.
Return the container runtime executable to use.
Honours VERITAS_CONTAINER_RUNTIME, otherwise prefers
podman and falls back to docker.
Return #t when a container runtime is available.
Stop container, returning its exit status.
Wait until command succeeds inside container.
Wait until container logs match pattern (regexp or string).
Wait until a TCP connection to host:port succeeds.
Run command, a list of strings, without a shell.
Returns two values: the exit status (an integer, -1 when the
process could not be started) and the captured standard output as a
string.
(call-with-values (lambda () (run-command (list "echo" "hi"))) (lambda (status output) (list status output))) ⇒ (0 "hi\n")
Like run-command, but raise an error on a non-zero exit status.
Returns the captured standard output.
Poll predicate every interval seconds until it is true.
Returns #t, or raises an error after timeout seconds.
Exceptions raised by predicate are treated as a false result.
Start a container, call thunk with its id, and always clean it up.
wait, when supplied, is a procedure called with the container id after start (for example to wait for a log line or a port). keep? leaves the container running for debugging.
Next: (veritas generator), Previous: (veritas cli), Up: API