From 7ac6fea9f3803631cd65b72a19618543f9cc7c11 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Sun, 22 Jan 2023 10:04:01 -0800 Subject: [PATCH] Update etcd testing version Also ensure init script passes `shellcheck` Updated while looking into https://github.com/rabbitmq/rabbitmq-server/issues/5792 --- .../test/system_SUITE_data/init-etcd.sh | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/deps/rabbitmq_peer_discovery_etcd/test/system_SUITE_data/init-etcd.sh b/deps/rabbitmq_peer_discovery_etcd/test/system_SUITE_data/init-etcd.sh index 6323657d4b..aca7092606 100755 --- a/deps/rabbitmq_peer_discovery_etcd/test/system_SUITE_data/init-etcd.sh +++ b/deps/rabbitmq_peer_discovery_etcd/test/system_SUITE_data/init-etcd.sh @@ -26,14 +26,13 @@ case "$(uname -s)" in ;; esac -etcd_data_dir=${1:-"$tmpdir/etcd/data"} -pidfile="$etcd_data_dir/etcd.pid" -tcp_port=${2:-2379} +readonly etcd_data_dir="${1:-"$tmpdir/etcd/data"}" +readonly pidfile="$etcd_data_dir/etcd.pid" +readonly tcp_port="${2:-2379}" -ETCD_VER=v3.4.6 - -GITHUB_URL=https://github.com/etcd-io/etcd/releases/download -DOWNLOAD_URL=${GITHUB_URL} +readonly ETCD_VER='v3.5.7' +readonly GITHUB_URL=https://github.com/etcd-io/etcd/releases/download +readonly DOWNLOAD_URL=${GITHUB_URL} rm -rf "${tmpdir}/etcd-${ETCD_VER}" @@ -60,7 +59,7 @@ rm -rf "$etcd_data_dir" mkdir -p "$etcd_data_dir" # daemonize(1) is installed under this path on Debian -PATH=$PATH:/usr/sbin +PATH="$PATH:/usr/sbin" daemonize -p "$pidfile" -l "${etcd_data_dir}/daemonize_lock" -- "$tmpdir/etcd-${ETCD_VER}/etcd" \ --data-dir "$etcd_data_dir" --name peer-discovery-0 --initial-advertise-peer-urls http://127.0.0.1:2380 \ @@ -71,11 +70,18 @@ daemonize -p "$pidfile" -l "${etcd_data_dir}/daemonize_lock" -- "$tmpdir/etcd-${ --initial-cluster peer-discovery-0=http://127.0.0.1:2380 \ --initial-cluster-state new - -for seconds in {1..30}; do - "$tmpdir/etcd-${ETCD_VER}/etcdctl" put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break - sleep 1 +i=0 +while [ "$i" -lt 30 ] +do + "$tmpdir/etcd-${ETCD_VER}/etcdctl" --endpoints="127.0.0.1:${tcp_port}" put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break + sleep 1 + i="$((i+1))" done -echo ETCD_PID=$(cat "$pidfile") - +if [ "$i" -ge 30 ] +then + echo '[ERROR] etcd did not start successfully!' 1>&2 + exit 1 +else + echo ETCD_PID="$(cat "$pidfile")" +fi