Adapt init-etcd.sh for Linux
This commit is contained in:
parent
82a03fcbcb
commit
46ff052218
|
|
@ -57,18 +57,15 @@ init_etcd(Config) ->
|
|||
Cmd = [InitEtcd, EtcdDir, {"~b", [TcpPort]}],
|
||||
case rabbit_ct_helpers:exec(Cmd) of
|
||||
{ok, Stdout} ->
|
||||
{match, [EtcdPid]} = re:run(
|
||||
Stdout,
|
||||
"^ETCD_PID=([0-9]+)$",
|
||||
[{capture, all_but_first, list},
|
||||
multiline]),
|
||||
ct:pal(?LOW_IMPORTANCE,
|
||||
"etcd PID: ~s~netcd is listening on: ~b",
|
||||
[EtcdPid, TcpPort]),
|
||||
rabbit_ct_helpers:set_config(Config,
|
||||
[{etcd_pid, EtcdPid},
|
||||
{etcd_endpoints, [rabbit_misc:format("localhost:~p", [TcpPort])]},
|
||||
{etcd_port, TcpPort}]);
|
||||
case re:run(Stdout, "^ETCD_PID=([0-9]+)$", [{capture, all_but_first, list}, multiline]) of
|
||||
{match, [EtcdPid]} ->
|
||||
ct:pal(?LOW_IMPORTANCE, "etcd PID: ~s~netcd is listening on: ~b", [EtcdPid, TcpPort]),
|
||||
rabbit_ct_helpers:set_config(Config, [{etcd_pid, EtcdPid},
|
||||
{etcd_endpoints, [rabbit_misc:format("localhost:~p", [TcpPort])]},
|
||||
{etcd_port, TcpPort}]);
|
||||
nomatch ->
|
||||
ct:pal(?HI_IMPORTANCE, "init-etcd.sh output did not match what's expected: ~p", [Stdout])
|
||||
end;
|
||||
_ ->
|
||||
_ = rabbit_ct_helpers:exec(["pkill", "-INT", "etcd"]),
|
||||
{skip, "Failed to initialize etcd"}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ case "$(uname -s)" in
|
|||
Linux)
|
||||
package_os="linux"
|
||||
tmpdir=/tmp
|
||||
archive="tar.gz"
|
||||
;;
|
||||
Darwin)
|
||||
package_os="darwin"
|
||||
tmpdir=$TMPDIR
|
||||
archive="zip"
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
|
|
@ -28,11 +30,23 @@ DOWNLOAD_URL=${GITHUB_URL}
|
|||
|
||||
rm -rf "${tmpdir}/etcd-${ETCD_VER}"
|
||||
|
||||
if ! [ -f "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.zip" ]; then
|
||||
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-$package_os-amd64.zip -o "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.zip"
|
||||
if ! [ -f "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.$archive" ]; then
|
||||
curl -L "${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-$package_os-amd64.$archive" -o "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.$archive"
|
||||
fi
|
||||
|
||||
unzip -q -o -d "$tmpdir" "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.zip"
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
mkdir -p "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64/"
|
||||
tar xzvf "/tmp/etcd-${ETCD_VER}-$package_os-amd64.$archive" -C "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64/" --strip-components=1
|
||||
;;
|
||||
Darwin)
|
||||
unzip -q -o -d "$tmpdir" "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64.$archive"
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
mv "${tmpdir}/etcd-${ETCD_VER}-$package_os-amd64/" "${tmpdir}/etcd-${ETCD_VER}/"
|
||||
|
||||
rm -rf "$etcd_data_dir"
|
||||
|
|
@ -48,8 +62,8 @@ daemonize -p "$pidfile" -l "${etcd_data_dir}/daemonize_lock" -- "$tmpdir/etcd-${
|
|||
--initial-cluster-state new
|
||||
|
||||
|
||||
for seconds in 1 2 3 4 5 6 7 8 9 10; do
|
||||
etcdctl put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break
|
||||
for seconds in {1..30}; do
|
||||
"$tmpdir/etcd-${ETCD_VER}/etcdctl" put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue