b4d7e1aa8f4ed6db1da1486c95016f266731be03 add dev helper and docs (Erik Arvstedt) b35d08d3f2b13b74bd9e5c2bc2ec9626ae881829 docs: move test docs from `examples/README` to `test/README` (Erik Arvstedt) 4d76eb9183d5346b94ec8659438b9c467c70ce5d docs/configuration: fix typo (Erik Arvstedt) dc0710f3f48d9c16af9e2d78ff0b018e7c60550d tests: add example scenario `customTest` (Erik Arvstedt) 9e30d2728b9e6ebef556b6b8267971878556cc25 tests: formatting (Erik Arvstedt) c6d85c6fe389e15d82b72774aa256cabc1aac1d1 tests: fix broken unit file when clightning is disabled (Erik Arvstedt) a51f7b419e0e65dc47c945ad775891656b758986 run-tests: use arg instead of env var for scenario overrides (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: ACK b4d7e1aa8f4ed6db1da1486c95016f266731be03 Tree-SHA512: f0ed8f8fe326c64eac3b7e9f48597dd00eedb9244333e199d18d1c2c06f369cd015f77aefd48e87235a68aee0b352057249525bf015e0a564fda380bdf7bb9d1
The run-tests.sh
command is most convenient and versatile way to run tests.
It leave no traces (outside of /nix/store
) on the host system.
run-tests.sh
requires Nix >= 2.10.
Summary
./run-tests.sh [--scenario|-s <scenario>] [build|vm|debug|container]
See the top of run-tests.sh for a complete documentation.
Test scenarios are defined in tests.nix and tests.py.
Tutorial
Running tests
# Run the basic set of tests. These tests are also run on the GitHub CI server.
./run-tests.sh
# Run the test for scenario `regtest`.
# The test is run via the Nix build system. Successful runs are cached.
./run-tests.sh -s regtest build
./run-tests.sh -s regtest # Shorthand, equivalent
# To test a single service, use its name as a scenario.
./run-tests.sh -s clightning
# When no scenario is specified, scenario `default` is used.
./run-tests.sh build
Debugging
# Start a shell is inside a test VM. No tests are executed.
./run-tests.sh -s bitcoind vm
systemctl status bitcoind
# Run a Python NixOS test shell inside a VM.
# See https://nixos.org/manual/nixos/stable/#ssec-machine-objects for available commands.
./run-tests.sh debug
print(succeed("systemctl status bitcoind"))
run_test("bitcoind")
# Start a shell in a container node. Requires systemd and root privileges.
./run-tests.sh container
# In the container shell: Run command in container (with prefix `c`)
c systemctl status bitcoind
# Explore a single feature
./run-tests.sh -s electrs container
# Run a command in a container.
# The container is deleted afterwards.
./run-tests.sh -s clightning container --run c lightning-cli getinfo
# Define a custom scenario
./run-tests.sh --scenario '{
services.clightning.enable = true;
nix-bitcoin.nodeinfo.enable = true;
}' container --run c nodeinfo
Running tests with Flakes
Tests can also be accessed via the nix-bitcoin flake:
# Build test
nix build --no-link ..#tests.default
# Run a node in a VM. No tests are executed.
nix run ..#tests.default.vm
# Run a Python test shell inside a VM node
nix run ..#tests.default.run -- --debug
# Run a node in a container. Requires extra-container, systemd and root privileges
nix run ..#tests.default.container
nix run ..#tests.default.containerLegacy # For NixOS with `system.stateVersion` <22.05
# Run a command in a container
nix run ..#tests.default.container -- --run c nodeinfo
nix run ..#tests.default.containerLegacy -- --run c nodeinfo # For NixOS with `system.stateVersion` <22.05