improve backup test

Only check enabled services. This allows running the backup test with a custom subset of other
tests.

Also, show a meaningful error on test failure.
Previously, just an AssertionError without a message was shown.
Because the test code is evaluated from a string and not a file, there
was also no backtrace to the tests file.
This commit is contained in:
Erik Arvstedt 2021-01-30 10:47:00 +01:00
parent 9a67a32779
commit fc40776689
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -296,12 +296,18 @@ def _():
"0 differences found", "0 differences found",
) )
# Backup should include important files # Backup should include important files
files = succeed(f"{run_duplicity} list-current-files file:///var/lib/localBackups") files = {
assert "var/lib/clightning/bitcoin/hsm_secret" in files "bitcoind": "var/lib/bitcoind/wallet.dat",
assert "secrets/lnd-seed-mnemonic" in files "clightning": "var/lib/clightning/bitcoin/hsm_secret",
assert "secrets/jm-wallet-seed" in files "lnd": "secrets/lnd-seed-mnemonic",
assert "var/lib/bitcoind/wallet.dat" in files "joinmarket": "secrets/jm-wallet-seed",
assert "var/backup/postgresql/btcpaydb.sql.gz" in files "btcpayserver": "var/backup/postgresql/btcpaydb.sql.gz",
}
actual_files = succeed(f"{run_duplicity} list-current-files file:///var/lib/localBackups")
for test, file in files.items():
if test in enabled_tests and file not in actual_files:
raise Exception(f"Backup file '{file}' is missing.")
# Impure: restarts services # Impure: restarts services