From 5e8c5fa7a0e009b7d73b26937ea23f3b685a3f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 28 Jun 2019 12:05:27 +0200 Subject: Try to make relx-start-stop more reliable Using new wait_for_success/wait_for_failure functions that will loop the ping commands up to 10 times then give up. This allows us to remove the "sleep 1" and lets us handle intermittent slowness at the same time. --- test/Makefile | 25 +++++++++++++++++++++++++ test/plugin_relx.mk | 13 ++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 39973ce..b7e8724 100644 --- a/test/Makefile +++ b/test/Makefile @@ -50,6 +50,31 @@ else SLEEP = endif +# In some cases it is more appropriate to wait until a command succeeds or fails. +# These functions run the given command every second and gives up after 10 tries. + +define wait_for_success + count=10; \ + until [ $$count = 0 ] || $1; do \ + count=`expr $$count - 1`; \ + sleep 1; \ + done; \ + if [ $$count = 0 ]; then \ + false; \ + fi +endef + +define wait_for_failure + count=10; \ + while [ $$count != 0 ] && $1; do \ + count=`expr $$count - 1`; \ + sleep 1; \ + done; \ + if [ $$count = 0 ]; then \ + false; \ + fi +endef + # OTP master, for downloading files for testing. OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master diff --git a/test/plugin_relx.mk b/test/plugin_relx.mk index c65e672..2771e8f 100644 --- a/test/plugin_relx.mk +++ b/test/plugin_relx.mk @@ -301,28 +301,27 @@ ifeq ($(PLATFORM),msys2) $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) install endif $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) start - $t sleep 1 $i "Ping the release" - $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping + $t $(call wait_for_success,$(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping) $i "Stop the release" $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) stop - $t sleep 1 ifeq ($(PLATFORM),msys2) + $t sleep 1 $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) uninstall endif - $i "Check that there's no erl_crash.dump file" - $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump - ifneq ($(PLATFORM),msys2) # The script will not return false on Windows when the ping fails. # It sometimes also gets stuck. So we just skip the ping for now. $i "Check that further pings get no replies" - $t ! $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping + $t $(call wait_for_failure,$(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping) endif + $i "Check that there's no erl_crash.dump file" + $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump + relx-tar: init $i "Bootstrap a new release named $(APP)" -- cgit v1.2.3