docker-volume-backup/test
2025-06-11 18:46:31 +02:00
..
age-passphrase Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
age-publickey Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
azure Bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.6.0 to 1.6.1 (#579) 2025-04-29 10:17:00 +00:00
certs Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
cli Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
collision Defining test sandbox in compose file allows testing against multi node swarm setup (#591) 2025-06-06 17:46:25 +02:00
commands Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
confd Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
dropbox Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
extend Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
gpg Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
gpg-asym Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
ignore version key in compose file is deprecated (#445) 2024-07-23 20:47:45 +02:00
local Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
lock Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
nonroot version key in compose file is deprecated (#445) 2024-07-23 20:47:45 +02:00
notifications version key in compose file is deprecated (#445) 2024-07-23 20:47:45 +02:00
ownership version key in compose file is deprecated (#445) 2024-07-23 20:47:45 +02:00
pgzip Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
proxy Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
pruning Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
s3 Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
secrets Defining test sandbox in compose file allows testing against multi node swarm setup (#591) 2025-06-06 17:46:25 +02:00
services Defining test sandbox in compose file allows testing against multi node swarm setup (#591) 2025-06-06 17:46:25 +02:00
ssh Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
swarm Defining test sandbox in compose file allows testing against multi node swarm setup (#591) 2025-06-06 17:46:25 +02:00
tar Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
user Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
webdav Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
worker-node Current test setup is too restrictive, allow running a series of executables in different contexts instead 2025-06-11 18:46:31 +02:00
zstd Always use read only socket mount in tests (#546) 2025-02-26 12:00:39 +01:00
docker-compose.yml Fall back to default behavior when deployed to a worker node (#593) 2025-06-09 14:19:18 +02:00
Dockerfile Bump github.com/docker/cli from 28.1.1+incompatible to 28.2.2+incompatible (#590) 2025-06-03 13:40:07 +00:00
README.md Current test setup is too restrictive, allow running a series of executables in different contexts instead 2025-06-11 18:46:31 +02:00
test.sh Current test setup is too restrictive, allow running a series of executables in different contexts instead 2025-06-11 18:46:31 +02:00
util.sh Allow backup to be run as non-root user 2024-02-22 17:42:53 +01:00

Integration Tests

Running tests

The main entry point for running tests is the ./test.sh script. It can be used to run the entire test suite, or just a single test case.

Run all tests

./test.sh

Run a single test case

./test.sh <directory-name>

Configuring a test run

In addition to the match pattern, which can be given as the first positional argument, certain behavior can be changed by setting environment variables:

BUILD_IMAGE

When set, the test script will build an up-to-date docker-volume-backup image from the current state of your source tree, and run the tests against it.

BUILD_IMAGE=1 ./test.sh

The default behavior is not to build an image, and instead look for a version on your host system.

IMAGE_TAG

Setting this value lets you run tests against different existing images, so you can compare behavior:

IMAGE_TAG=v2.30.0 ./test.sh

By default, two local images are created that persist the image data and provide it to containers at runtime.

Understanding the test setup

The test setup runs each test case in an isolated Docker container, which itself is running an otherwise unused Docker daemon. This means, tests can rely on noone else using that daemon, making expectations about the number of running containers and so forth. As the sandbox container is also expected to be torn down post test, the scripts do not need to do any clean up or similar.

Anatomy of a test case

The test.sh script looks for all exectuable files in each directory. When found, all of them are executed in series and are expected to signal success by returning a 0 exit code. Any other exit code is considered a failure and will halt execution of further tests.

There is an util.sh file containing a few commonly used helpers which can be used by putting the following prelude to a new test case:

cd "$(dirname "$0")"
. ../util.sh
current_test=$(basename $(pwd))

Running tests in swarm mode

A test case can signal it wants to run in swarm mode by placing an empty .swarm file inside the directory. In case the swarm setup should be compose of multiple nodes, a .multinode file can be used.

A multinode setup will contain one manager (manager) and two worker nodes (worker1 and worker2).

If a test is expected to run in the context of a node other than the manager, you can create a .context file containing the name of the node you want the test to run in. E.g. if your script 02run.sh is expected to be run on worker2, create a file called 02run.sh.context with the content worker2