tests: add compatibility with 21.11

Adapt to the new test driver and systemd versions.
This commit is contained in:
Erik Arvstedt 2021-12-09 21:04:11 +01:00 committed by nixbitcoin
parent 88fa33479f
commit b2f7a80f9f
No known key found for this signature in database
GPG Key ID: B6044ECBA2DAE5D0

View File

@ -1,7 +1,6 @@
from collections import OrderedDict from collections import OrderedDict
import json import json
import re
logger = machine.logger
def succeed(*cmds): def succeed(*cmds):
"""Returns the concatenated output of all cmds""" """Returns the concatenated output of all cmds"""
@ -34,7 +33,7 @@ def wait_for_open_port(address, port):
status, _ = machine.execute(f"nc -z {address} {port}") status, _ = machine.execute(f"nc -z {address} {port}")
return status == 0 return status == 0
with logger.nested(f"Waiting for TCP port {address}:{port}"): with machine.nested(f"Waiting for TCP port {address}:{port}"):
retry(is_port_open) retry(is_port_open)
@ -58,7 +57,7 @@ def run_tests():
raise RuntimeError(f"The following tests are enabled but not defined: {enabled}") raise RuntimeError(f"The following tests are enabled but not defined: {enabled}")
machine.connect() # Visually separate boot output from the test output machine.connect() # Visually separate boot output from the test output
for test in to_run: for test in to_run:
with logger.nested(f"test: {test}"): with machine.nested(f"test: {test}"):
tests[test]() tests[test]()
def run_test(test): def run_test(test):
@ -139,9 +138,9 @@ def _():
f"Output of 'lightning-cli plugin list':\n{plugin_list}" f"Output of 'lightning-cli plugin list':\n{plugin_list}"
) )
else: else:
logger.log("Active clightning plugins:") machine.log("Active clightning plugins:")
for p in test_data["clightning-plugins"]: for p in test_data["clightning-plugins"]:
logger.log(os.path.basename(p)) machine.log(os.path.basename(p))
@test("lnd") @test("lnd")
def _(): def _():
@ -314,7 +313,7 @@ def _():
succeed("systemctl stop bitcoind") succeed("systemctl stop bitcoind")
succeed("systemctl start duplicity") succeed("systemctl start duplicity")
machine.wait_until_succeeds(log_has_string("duplicity", "duplicity.service: Succeeded.")) machine.wait_until_succeeds(log_has_string("duplicity", "duplicity.service: Deactivated successfully."))
run_duplicity = "export $(cat /secrets/backup-encryption-env); duplicity" run_duplicity = "export $(cat /secrets/backup-encryption-env); duplicity"
# Files in backup and /var/lib should be identical # Files in backup and /var/lib should be identical
assert_matches( assert_matches(