From fc40776689baa4f06e83440a0340ba1a071763f8 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sat, 30 Jan 2021 10:47:00 +0100 Subject: [PATCH] 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. --- test/tests.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/tests.py b/test/tests.py index 49f881b..0d6b2de 100644 --- a/test/tests.py +++ b/test/tests.py @@ -296,12 +296,18 @@ def _(): "0 differences found", ) # Backup should include important files - files = succeed(f"{run_duplicity} list-current-files file:///var/lib/localBackups") - assert "var/lib/clightning/bitcoin/hsm_secret" in files - assert "secrets/lnd-seed-mnemonic" in files - assert "secrets/jm-wallet-seed" in files - assert "var/lib/bitcoind/wallet.dat" in files - assert "var/backup/postgresql/btcpaydb.sql.gz" in files + files = { + "bitcoind": "var/lib/bitcoind/wallet.dat", + "clightning": "var/lib/clightning/bitcoin/hsm_secret", + "lnd": "secrets/lnd-seed-mnemonic", + "joinmarket": "secrets/jm-wallet-seed", + "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