Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Vitaliy Filippov | d23a8a83e5 |
|
@ -20,6 +20,7 @@ cd `dirname $0`/..
|
|||
|
||||
trap 'kill -9 $(jobs -p)' EXIT
|
||||
|
||||
ANTIETCD=1
|
||||
ETCD=${ETCD:-etcd}
|
||||
ETCD_IP=${ETCD_IP:-127.0.0.1}
|
||||
ETCD_PORT=${ETCD_PORT:-12379}
|
||||
|
@ -32,14 +33,20 @@ if [ "$KEEP_DATA" = "" ]; then
|
|||
fi
|
||||
|
||||
ETCD_URL="http://$ETCD_IP:$ETCD_PORT"
|
||||
ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
|
||||
for i in $(seq 2 $ETCD_COUNT); do
|
||||
ETCD_URL="$ETCD_URL,http://$ETCD_IP:$((ETCD_PORT+2*i-2))"
|
||||
ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-1))"
|
||||
done
|
||||
ETCDCTL="${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=5s --command-timeout=10s"
|
||||
|
||||
start_etcd()
|
||||
{
|
||||
if [[ "$ANTIETCD" -eq "1" ]]; then
|
||||
start_antietcd $*
|
||||
else
|
||||
start__etcd $*
|
||||
fi
|
||||
}
|
||||
|
||||
start__etcd()
|
||||
{
|
||||
local i=$1
|
||||
local t=/run/user/$(id -u)
|
||||
|
@ -53,15 +60,65 @@ start_etcd()
|
|||
eval ETCD${i}_PID=$!
|
||||
}
|
||||
|
||||
for i in $(seq 1 $ETCD_COUNT); do
|
||||
start_etcd $i
|
||||
done
|
||||
for i in {1..30}; do
|
||||
${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=1s --command-timeout=1s member list >/dev/null && break
|
||||
if [[ $i = 30 ]]; then
|
||||
format_error "Failed to start etcd"
|
||||
start_etcd_cluster()
|
||||
{
|
||||
ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
|
||||
for i in $(seq 2 $ETCD_COUNT); do
|
||||
ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-1))"
|
||||
done
|
||||
for i in $(seq 1 $ETCD_COUNT); do
|
||||
start__etcd $i
|
||||
done
|
||||
ETCDCTL="${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=5s --command-timeout=10s"
|
||||
for i in {1..30}; do
|
||||
${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=1s --command-timeout=1s member list >/dev/null && break
|
||||
if [[ $i = 30 ]]; then
|
||||
format_error "Failed to start etcd"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
start_antietcd()
|
||||
{
|
||||
local i=$1
|
||||
local t=/run/user/$(id -u)
|
||||
findmnt $t >/dev/null || (sudo mkdir -p $t && sudo mount -t tmpfs tmpfs $t)
|
||||
local persist=""
|
||||
if [[ -n "$ANTIETCD_PERSISTENCE" ]]; then
|
||||
persist="--data ./testdata/antietcd$i.json.gz --persist_interval 500"
|
||||
fi
|
||||
done
|
||||
local cluster=""
|
||||
if [[ $ETCD_COUNT -gt 1 ]]; then
|
||||
cluster="--node_id etcd$i --cluster_key abcdef --cluster $ETCD_CLUSTER"
|
||||
fi
|
||||
nodejs mon/tinyraft/antietcd-app.js $persist --port $((ETCD_PORT+2*i-2)) $cluster &>./testdata/antietcd$i.log &
|
||||
eval ETCD${i}_PID=$!
|
||||
}
|
||||
|
||||
start_antietcd_cluster()
|
||||
{
|
||||
ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT))"
|
||||
for i in $(seq 2 $ETCD_COUNT); do
|
||||
ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-2))"
|
||||
done
|
||||
for i in $(seq 1 $ETCD_COUNT); do
|
||||
start_antietcd $i
|
||||
done
|
||||
ETCDCTL="nodejs mon/tinyraft/anticli.js -e $ETCD_URL"
|
||||
for i in {1..30}; do
|
||||
nodejs mon/tinyraft/anticli.js -e "$ETCD_URL" get --prefix / && break
|
||||
if [[ $i = 30 ]]; then
|
||||
format_error "Failed to start antietcd"
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
if [[ "$ANTIETCD" -eq "1" ]]; then
|
||||
start_antietcd_cluster
|
||||
else
|
||||
start_etcd_cluster
|
||||
fi
|
||||
|
||||
echo leak:fio >> testdata/lsan-suppress.txt
|
||||
echo leak:tcmalloc >> testdata/lsan-suppress.txt
|
||||
|
|
Loading…
Reference in New Issue