diff --git a/test/scenarios/default.py b/test/scenarios/default.py index 453e3dd..dbea1e3 100644 --- a/test/scenarios/default.py +++ b/test/scenarios/default.py @@ -25,7 +25,7 @@ def web_index(): assert_matches("curl -L localhost/store", "tshirt") -def final(): +def prestop(): pass @@ -35,7 +35,7 @@ extra_tests = { "lightning-charge": lightning_charge, "nanopos": nanopos, "web-index": web_index, - "final": final, + "prestop": prestop, } run_tests(extra_tests) diff --git a/test/scenarios/lib.py b/test/scenarios/lib.py index 8595149..2989fec 100644 --- a/test/scenarios/lib.py +++ b/test/scenarios/lib.py @@ -127,7 +127,31 @@ def run_tests(extra_tests): ) assert_no_failure("bitcoind-import-banlist") - extra_tests.pop("final")() + extra_tests.pop("prestop")() + + ### Test duplicity + + succeed("systemctl stop bitcoind") + succeed("systemctl start duplicity") + machine.wait_until_succeeds(log_has_string("duplicity", "duplicity.service: Succeeded.")) + # Make sure files in duplicity backup and /var/lib are identical + assert_matches( + "export $(cat /secrets/backup-encryption-env); duplicity verify '--archive-dir' '/var/lib/duplicity' 'file:///var/lib/localBackups' '/var/lib'", + "0 differences found", + ) + # Make sure duplicity backup includes important files + assert_matches( + "export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'", + "var/lib/clightning/bitcoin/hsm_secret", + ) + assert_matches( + "export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'", + "secrets/lnd-seed-mnemonic", + ) + assert_matches( + "export $(cat /secrets/backup-encryption-env); duplicity list-current-files 'file:///var/lib/localBackups'", + "var/lib/bitcoind/wallet.dat", + ) ### Check that all extra_tests have been run assert len(extra_tests) == 0 diff --git a/test/scenarios/withnetns.py b/test/scenarios/withnetns.py index bc6f9f5..7534a14 100644 --- a/test/scenarios/withnetns.py +++ b/test/scenarios/withnetns.py @@ -47,7 +47,7 @@ def web_index(): assert_matches("ip netns exec nb-nginx curl -L localhost/store", "tshirt") -def final(): +def prestop(): ping_bitcoind = "ip netns exec nb-bitcoind ping -c 1 -w 1" ping_nanopos = "ip netns exec nb-nanopos ping -c 1 -w 1" @@ -98,7 +98,7 @@ extra_tests = { "lightning-charge": lightning_charge, "nanopos": nanopos, "web-index": web_index, - "final": final, + "prestop": prestop, } run_tests(extra_tests) diff --git a/test/test.nix b/test/test.nix index 190c2d6..27155bf 100644 --- a/test/test.nix +++ b/test/test.nix @@ -54,6 +54,8 @@ import ./make-test.nix rec { ledger = true; }; + services.backups.enable = true; + # to test that unused secrets are made inaccessible by 'setup-secrets' systemd.services.generate-secrets.postStart = '' install -o nobody -g nogroup -m777 <(:) /secrets/dummy