aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-06-28 12:05:27 +0200
committerLoïc Hoguin <[email protected]>2019-06-28 12:05:27 +0200
commit5e8c5fa7a0e009b7d73b26937ea23f3b685a3f2f (patch)
treec460dad3243bc0600b1d8e08e70f9e24be7b660f
parent80ddc8d5a8a6a60da99fb34fb5f12ce4f36d8d63 (diff)
downloaderlang.mk-5e8c5fa7a0e009b7d73b26937ea23f3b685a3f2f.tar.gz
erlang.mk-5e8c5fa7a0e009b7d73b26937ea23f3b685a3f2f.tar.bz2
erlang.mk-5e8c5fa7a0e009b7d73b26937ea23f3b685a3f2f.zip
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.
-rw-r--r--test/Makefile25
-rw-r--r--test/plugin_relx.mk13
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)"