test: improve modularization
This improves debugging and experimenting by making it easy to compose fine-grained scenarios that have specific tests and features enabled. The VM test output now includes the subtest name and duration. Remove the 'raise Exception()' hack for interactive mode. Run 'banlist-and-restart' test before 'backups'. This speeds up the test by avoiding an extra shutdown of all bitcoin-related services.
This commit is contained in:
parent
14d2d97ba6
commit
1e18d3ea3b
8 changed files with 385 additions and 181 deletions
41
test/lib/make-test.nix
Normal file
41
test/lib/make-test.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
scenario: testConfig:
|
||||
|
||||
{
|
||||
vm = import ./make-test-vm.nix {
|
||||
name = "nix-bitcoin-${scenario}";
|
||||
|
||||
machine = {
|
||||
imports = [ testConfig ];
|
||||
# Needed because duplicity requires 270 MB of free temp space, regardless of backup size
|
||||
virtualisation.diskSize = 1024;
|
||||
};
|
||||
|
||||
testScript = nodes: let
|
||||
cfg = nodes.nodes.machine.config;
|
||||
data = {
|
||||
data = cfg.test.data;
|
||||
tests = cfg.tests;
|
||||
};
|
||||
dataFile = builtins.toFile "test-data" (builtins.toJSON data);
|
||||
initData = ''
|
||||
import json
|
||||
|
||||
with open("${dataFile}") as f:
|
||||
data = json.load(f)
|
||||
|
||||
enabled_tests = set(test for (test, enabled) in data["tests"].items() if enabled)
|
||||
test_data = data["data"]
|
||||
'';
|
||||
in
|
||||
builtins.concatStringsSep "\n\n" [
|
||||
initData
|
||||
(builtins.readFile ./../tests.py)
|
||||
# Don't run tests in interactive mode.
|
||||
# is_interactive is set in ../run-tests.sh
|
||||
''
|
||||
if not "is_interactive" in vars():
|
||||
run_tests()
|
||||
''
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue