addfa8ec6bab320de0b808fd76809635947377e8 test: support `run`, `debug` commands in basic NixOS tests (Erik Arvstedt) ae733d887eae83ec589af53aa11638d711135a18 tests/clightning-replication: reuse `pkgs` instance (Erik Arvstedt) 6cbd0d93ae80176a853c31ca8cf5891bd6fb0646 tests: rename `clightningReplication` -> `clightning-replication` (Erik Arvstedt) 85310b533a00f1f5dfbc535a91356bab3692d4c6 secrets: use type `lines` for `generateSecretsCmds` (Erik Arvstedt) bc2f66d4f122dbd37679159002275f87ed87deb4 bitcoind, liquid: increase start/stop timeouts (Erik Arvstedt) 519ae31202a7e878fe7fe3be83f321df741acf43 netns-isolation: improve formatting (Erik Arvstedt) a1023696e69fbe871cfadf18d054d87eede9bba0 netns-isolation: reserve netns id for mempool (Erik Arvstedt) 34fe8675bd6e0396e3986e0d4b262e166708d8b0 add option `nix-bitcoin.pkgOverlays` (Erik Arvstedt) a3bdecb10bd6d27d040d10ac9255d99b86d630df helper: add start-bash-session.sh (Erik Arvstedt) 690a8f6256bfed9b9ed074d89e734364b87681f1 nodeinfo: extract fn `mkInfoLong` (Erik Arvstedt) 2af642f56ad0856d5a07d0bb27722b3861719b75 improve comments (Erik Arvstedt) 5634f0887391419b10a3e8c43c6377214b79b115 rtl: make `extraConfig` recursively mergeable (Erik Arvstedt) b76728a1ec187700fd303933510f0b5a82a2996a treewide: use bool literals for systemd (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: ACK addfa8ec6bab320de0b808fd76809635947377e8 Tree-SHA512: 46f779f8477b566ffc6d0dfb024f2098757f509b2b3e0cbb509cf3308de7029e913f6e6c3d6d3d226cc72f8a5031fd5586b2efdf7c2d9d15f4bdd7ed08b27425
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