1
0
Fork 0

Compare commits

...

1 Commits

Author SHA1 Message Date
Vitaliy Filippov d23a8a83e5 Run tests with antietcd 2024-05-29 10:54:18 +03:00
1 changed files with 68 additions and 11 deletions

View File

@ -20,6 +20,7 @@ cd `dirname $0`/..
trap 'kill -9 $(jobs -p)' EXIT trap 'kill -9 $(jobs -p)' EXIT
ANTIETCD=1
ETCD=${ETCD:-etcd} ETCD=${ETCD:-etcd}
ETCD_IP=${ETCD_IP:-127.0.0.1} ETCD_IP=${ETCD_IP:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-12379} ETCD_PORT=${ETCD_PORT:-12379}
@ -32,14 +33,20 @@ if [ "$KEEP_DATA" = "" ]; then
fi fi
ETCD_URL="http://$ETCD_IP:$ETCD_PORT" ETCD_URL="http://$ETCD_IP:$ETCD_PORT"
ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
for i in $(seq 2 $ETCD_COUNT); do for i in $(seq 2 $ETCD_COUNT); do
ETCD_URL="$ETCD_URL,http://$ETCD_IP:$((ETCD_PORT+2*i-2))" 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 done
ETCDCTL="${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=5s --command-timeout=10s"
start_etcd() start_etcd()
{
if [[ "$ANTIETCD" -eq "1" ]]; then
start_antietcd $*
else
start__etcd $*
fi
}
start__etcd()
{ {
local i=$1 local i=$1
local t=/run/user/$(id -u) local t=/run/user/$(id -u)
@ -53,15 +60,65 @@ start_etcd()
eval ETCD${i}_PID=$! eval ETCD${i}_PID=$!
} }
for i in $(seq 1 $ETCD_COUNT); do start_etcd_cluster()
start_etcd $i {
done ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
for i in {1..30}; do for i in $(seq 2 $ETCD_COUNT); do
${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=1s --command-timeout=1s member list >/dev/null && break ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-1))"
if [[ $i = 30 ]]; then done
format_error "Failed to start etcd" 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 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:fio >> testdata/lsan-suppress.txt
echo leak:tcmalloc >> testdata/lsan-suppress.txt echo leak:tcmalloc >> testdata/lsan-suppress.txt