tests: make lnd & clightning tests run concurrently

This commit is contained in:
nixbitcoin 2020-08-04 08:24:49 +00:00
parent ac96fd59db
commit 46e15ee9cc
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA
4 changed files with 27 additions and 25 deletions

View File

@ -25,7 +25,7 @@ def web_index():
assert_matches("curl -L localhost/store", "tshirt")
def post_clightning():
def final():
pass
@ -35,7 +35,7 @@ extra_tests = {
"lightning-charge": lightning_charge,
"nanopos": nanopos,
"web-index": web_index,
"post-clightning": post_clightning,
"final": final,
}
run_tests(extra_tests)

View File

@ -70,6 +70,18 @@ def run_tests(extra_tests):
assert_running("clightning")
assert_matches("su operator -c 'lightning-cli getinfo' | jq", '"id"')
assert_running("lnd")
assert_matches("su operator -c 'lncli getinfo' | jq", '"version"')
assert_no_failure("lnd")
succeed("systemctl start lightning-loop")
assert_matches("su operator -c 'loop --version'", "version")
# Check that lightning-loop fails with the right error, making sure
# lightning-loop can connect to lnd
machine.wait_until_succeeds(
log_has_string("lightning-loop", "chain notifier RPC isstill in the process of starting")
)
assert_running("spark-wallet")
extra_tests.pop("spark-wallet")()
@ -104,7 +116,9 @@ def run_tests(extra_tests):
pre_restart = succeed("date +%s.%6N").rstrip()
# Sanity-check system by restarting all services
succeed("systemctl restart bitcoind clightning spark-wallet lightning-charge nanopos liquidd")
succeed(
"systemctl restart bitcoind clightning lnd lightning-loop spark-wallet lightning-charge nanopos liquidd"
)
# Now that the bitcoind restart triggered a banlist import restart, check that
# re-importing already banned addresses works
@ -113,25 +127,7 @@ def run_tests(extra_tests):
)
assert_no_failure("bitcoind-import-banlist")
extra_tests.pop("post-clightning")()
### Test lnd
stopped_services = "nanopos lightning-charge spark-wallet clightning"
succeed("systemctl stop " + stopped_services)
succeed("systemctl start lnd")
assert_matches("su operator -c 'lncli getinfo' | jq", '"version"')
assert_no_failure("lnd")
### Test loopd
succeed("systemctl start lightning-loop")
assert_matches("su operator -c 'loop --version'", "version")
# Check that lightning-loop fails with the right error, making sure
# lightning-loop can connect to lnd
machine.wait_until_succeeds(
log_has_string("lightning-loop", "chain notifier RPC isstill in the process of starting")
)
extra_tests.pop("final")()
### Check that all extra_tests have been run
assert len(extra_tests) == 0

View File

@ -9,6 +9,7 @@ lightningcharge_ip = "169.254.1.18"
nanopos_ip = "169.254.1.19"
recurringdonations_ip = "169.254.1.20"
nginx_ip = "169.254.1.21"
lightningloop_ip = "169.254.1.22"
def electrs():
@ -46,7 +47,7 @@ def web_index():
assert_matches("ip netns exec nb-nginx curl -L localhost/store", "tshirt")
def post_clightning():
def final():
ping_bitcoind = "ip netns exec nb-bitcoind ping -c 1 -w 1"
ping_nanopos = "ip netns exec nb-nanopos ping -c 1 -w 1"
@ -54,6 +55,7 @@ def post_clightning():
machine.succeed(
"%s %s &&" % (ping_bitcoind, bitcoind_ip)
+ "%s %s &&" % (ping_bitcoind, clightning_ip)
+ "%s %s &&" % (ping_bitcoind, lnd_ip)
+ "%s %s &&" % (ping_bitcoind, liquidd_ip)
+ "%s %s &&" % (ping_nanopos, lightningcharge_ip)
+ "%s %s &&" % (ping_nanopos, nanopos_ip)
@ -63,6 +65,7 @@ def post_clightning():
# Negative ping tests (non-exhaustive)
machine.fail(
"%s %s ||" % (ping_bitcoind, sparkwallet_ip)
+ "%s %s ||" % (ping_bitcoind, lightningloop_ip)
+ "%s %s ||" % (ping_bitcoind, lightningcharge_ip)
+ "%s %s ||" % (ping_bitcoind, nanopos_ip)
+ "%s %s ||" % (ping_bitcoind, recurringdonations_ip)
@ -70,6 +73,7 @@ def post_clightning():
+ "%s %s ||" % (ping_nanopos, bitcoind_ip)
+ "%s %s ||" % (ping_nanopos, clightning_ip)
+ "%s %s ||" % (ping_nanopos, lnd_ip)
+ "%s %s ||" % (ping_nanopos, lightningloop_ip)
+ "%s %s ||" % (ping_nanopos, liquidd_ip)
+ "%s %s ||" % (ping_nanopos, electrs_ip)
+ "%s %s ||" % (ping_nanopos, sparkwallet_ip)
@ -94,7 +98,7 @@ extra_tests = {
"lightning-charge": lightning_charge,
"nanopos": nanopos,
"web-index": web_index,
"post-clightning": post_clightning,
"final": final,
}
run_tests(extra_tests)

View File

@ -33,8 +33,10 @@ import ./make-test.nix rec {
services.nanopos.enable = true;
services.lnd.enable = true;
systemd.services.lnd.wantedBy = mkForce [];
services.lnd.listenPort = 9736;
services.lightning-loop.enable = true;
# needed because we must control when lightning-loop starts so it doesn't
# fail before we run commands in the nb-lightning-loop netns
systemd.services.lightning-loop.wantedBy = mkForce [];
services.electrs.enable = true;