diff --git a/daemon/test/Makefile b/daemon/test/Makefile index 71371f52a..c05e1b808 100644 --- a/daemon/test/Makefile +++ b/daemon/test/Makefile @@ -1,40 +1,53 @@ check: daemon-tests -daemon-test.sh-%: - NO_VALGRIND=$(NO_VALGRIND) daemon/test/test.sh --$* +# We run three different bitcoinds, for different types of tests. +# Provides limited paralellism. +daemon-test.sh-0-%: + NO_VALGRIND=$(NO_VALGRIND) VARIANT=0 daemon/test/test.sh --$* +daemon-test.sh-1-%: + NO_VALGRIND=$(NO_VALGRIND) VARIANT=1 daemon/test/test.sh --$* +daemon-test.sh-2-%: + NO_VALGRIND=$(NO_VALGRIND) VARIANT=2 daemon/test/test.sh --$* # These don't work in parallel, so chain the deps -daemon-test.sh-steal: daemon-test.sh-dump-onchain -daemon-test.sh-dump-onchain: daemon-test.sh-timeout-anchor -daemon-test.sh-timeout-anchor: daemon-test.sh-different-fee-rates -daemon-test.sh-different-fee-rates: daemon-test.sh-normal -daemon-test.sh-normal: daemon-test.sh-manual-commit -daemon-test.sh-manual-commit: daemon-test.sh-mutual-close-with-htlcs -daemon-test.sh-mutual-close-with-htlcs: daemon-test.sh-steal\ --reconnect -daemon-test.sh-steal\ --reconnect: daemon-test.sh-dump-onchain\ --reconnect -daemon-test.sh-dump-onchain\ --reconnect: daemon-test.sh-timeout-anchor\ --reconnect -daemon-test.sh-timeout-anchor\ --reconnect: daemon-test.sh-different-fee-rates\ --reconnect -daemon-test.sh-different-fee-rates\ --reconnect: daemon-test.sh-normal\ --reconnect -daemon-test.sh-normal\ --reconnect: daemon-test.sh-manual-commit\ --reconnect -daemon-test.sh-manual-commit\ --reconnect: daemon-test.sh-mutual-close-with-htlcs\ --reconnect -daemon-test.sh-mutual-close-with-htlcs\ --reconnect: daemon-test.sh-steal\ --restart -daemon-test.sh-steal\ --restart: daemon-test.sh-dump-onchain\ --restart -daemon-test.sh-dump-onchain\ --restart: daemon-test.sh-timeout-anchor\ --restart -daemon-test.sh-timeout-anchor\ --restart: daemon-test.sh-different-fee-rates\ --restart -daemon-test.sh-different-fee-rates\ --restart: daemon-test.sh-normal\ --restart -daemon-test.sh-normal\ --restart: daemon-test.sh-mutual-close-with-htlcs\ --restart -daemon-test.sh-mutual-close-with-htlcs\ --restart: daemon-test-setup +daemon-test.sh-0-steal: daemon-test.sh-0-dump-onchain +daemon-test.sh-0-dump-onchain: daemon-test.sh-0-timeout-anchor +daemon-test.sh-0-timeout-anchor: daemon-test.sh-0-different-fee-rates +daemon-test.sh-0-different-fee-rates: daemon-test.sh-0-normal +daemon-test.sh-0-normal: daemon-test.sh-0-manual-commit +daemon-test.sh-0-manual-commit: daemon-test.sh-0-mutual-close-with-htlcs +daemon-test.sh-0-mutual-close-with-htlcs: daemon-test-setup-0 + +daemon-test.sh-1-steal\ --restart: daemon-test.sh-1-dump-onchain\ --restart +daemon-test.sh-1-dump-onchain\ --restart: daemon-test.sh-1-timeout-anchor\ --restart +daemon-test.sh-1-timeout-anchor\ --restart: daemon-test.sh-1-different-fee-rates\ --restart +daemon-test.sh-1-different-fee-rates\ --restart: daemon-test.sh-1-normal\ --restart +daemon-test.sh-1-normal\ --restart: daemon-test.sh-1-manual-commit\ --restart +daemon-test.sh-1-manual-commit\ --restart: daemon-test.sh-1-mutual-close-with-htlcs\ --restart +daemon-test.sh-1-mutual-close-with-htlcs\ --restart: daemon-test-setup-1 + +daemon-test.sh-2-steal\ --reconnect: daemon-test.sh-2-dump-onchain\ --reconnect +daemon-test.sh-2-dump-onchain\ --reconnect: daemon-test.sh-2-timeout-anchor\ --reconnect +daemon-test.sh-2-timeout-anchor\ --reconnect: daemon-test.sh-2-different-fee-rates\ --reconnect +daemon-test.sh-2-different-fee-rates\ --reconnect: daemon-test.sh-2-normal\ --reconnect +daemon-test.sh-2-normal\ --reconnect: daemon-test.sh-2-manual-commit\ --reconnect +daemon-test.sh-2-manual-commit\ --reconnect: daemon-test.sh-2-mutual-close-with-htlcs\ --reconnect +daemon-test.sh-2-mutual-close-with-htlcs\ --reconnect: daemon-test-setup-2 # We shutdown first in case something is left over. -daemon-test-setup: daemon-all - daemon/test/scripts/shutdown.sh 2>/dev/null || true - daemon/test/scripts/setup.sh +daemon-test-setup-%: daemon-all + VARIANT=$* daemon/test/scripts/shutdown.sh 2>/dev/null || true + VARIANT=$* daemon/test/scripts/setup.sh -daemon-test-shutdown: daemon-test.sh-steal - daemon/test/scripts/shutdown.sh +daemon-test-shutdown-0: daemon-test.sh-0-steal + VARIANT=0 daemon/test/scripts/shutdown.sh +daemon-test-shutdown-1: daemon-test.sh-1-steal\ --restart + VARIANT=1 daemon/test/scripts/shutdown.sh +daemon-test-shutdown-2: daemon-test.sh-2-steal\ --reconnect + VARIANT=2 daemon/test/scripts/shutdown.sh -# Forms a long dependency chain. -daemon-all-test.sh: daemon-test-shutdown +# Forms long dependency chains. +daemon-all-test.sh: daemon-test-shutdown-0 daemon-test-shutdown-1 daemon-test-shutdown-2 # Note that these actually #include everything they need, except ccan/ and bitcoin/. # That allows for unit testing of statics, and special effects. diff --git a/daemon/test/scripts/setup.sh b/daemon/test/scripts/setup.sh index 8ea494a89..fb9813e79 100755 --- a/daemon/test/scripts/setup.sh +++ b/daemon/test/scripts/setup.sh @@ -15,7 +15,7 @@ rm -rf $DATADIR mkdir $DATADIR # Find a free port (racy, but hey) -PORT=`findport 18332` +PORT=`findport 18332 $VARIANT` RPCPORT=`findport $(($PORT + 1))` # Create appropriate config file so cmdline matches. @@ -29,7 +29,7 @@ EOF $DAEMON & i=0 while ! $CLI getinfo >/dev/null 2>&1; do - if [ $i -gt 30 ]; then + if [ $i -gt 60 ]; then echo $DAEMON start failed? >&1 exit 1 fi diff --git a/daemon/test/scripts/vars.sh b/daemon/test/scripts/vars.sh index a08a3c136..ecea46ea4 100644 --- a/daemon/test/scripts/vars.sh +++ b/daemon/test/scripts/vars.sh @@ -4,7 +4,7 @@ if which eatmydata >/dev/null; then EATMYDATA=eatmydata; fi STYLE=bitcoin -DATADIR=/tmp/bitcoin-lightning +DATADIR=/tmp/bitcoin-lightning$VARIANT CLI="bitcoin-cli -datadir=$DATADIR" REGTESTDIR=regtest DAEMON="$EATMYDATA bitcoind -datadir=$DATADIR" @@ -12,6 +12,8 @@ DAEMON="$EATMYDATA bitcoind -datadir=$DATADIR" findport() { PORT=$1 + # Give two ports per variant. + if [ x"$2" != x ]; then PORT=$(($PORT + $2 * 2)); fi while netstat -ntl | grep -q ":$PORT "; do PORT=$(($PORT + 1)); done echo $PORT } diff --git a/daemon/test/test.sh b/daemon/test/test.sh index 988dda3b0..9db2853a8 100755 --- a/daemon/test/test.sh +++ b/daemon/test/test.sh @@ -234,7 +234,7 @@ check() fi sleep 1 i=$(($i + 1)) - if [ $i = 30 ]; then + if [ $i = 60 ]; then return 1 fi done @@ -399,8 +399,8 @@ cp $DIR2/config $DIR3/config if [ x"$RECONNECT" = xrestart ]; then # Make sure node2 & 3 restart on same port, by setting in config. # Find a free TCP port. - echo port=`findport 4000` >> $DIR2/config - echo port=`findport 4010` >> $DIR3/config + echo port=`findport 4000 $VARIANT` >> $DIR2/config + echo port=`findport 4010 $VARIANT` >> $DIR3/config fi if [ -n "$DIFFERENT_FEES" ]; then