2020-09-27 03:43:20 -07:00
|
|
|
scenario: testConfig:
|
|
|
|
|
|
|
|
{
|
2020-11-18 18:01:44 -08:00
|
|
|
vm = import ./make-test-vm.nix (pkgs: {
|
2020-09-27 03:43:20 -07:00
|
|
|
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;
|
|
|
|
};
|
2020-11-18 18:01:44 -08:00
|
|
|
dataFile = pkgs.writeText "test-data" (builtins.toJSON data);
|
2020-09-27 03:43:20 -07:00
|
|
|
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()
|
|
|
|
''
|
|
|
|
];
|
2020-11-18 18:01:44 -08:00
|
|
|
});
|
2020-09-27 03:43:28 -07:00
|
|
|
|
|
|
|
container = {
|
|
|
|
# The container name has a 11 char length limit
|
2020-12-11 04:26:05 -08:00
|
|
|
containers.nb-test = { config, ... }: {
|
2020-09-27 03:43:28 -07:00
|
|
|
config = {
|
|
|
|
extra = config.config.test.container;
|
|
|
|
config = testConfig;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-12-11 04:26:05 -08:00
|
|
|
|
|
|
|
config = testConfig;
|
2020-09-27 03:43:20 -07:00
|
|
|
}
|