vitastor/tests/test_add_osd.sh

60 lines
2.2 KiB
Bash
Raw Normal View History

2022-01-05 17:06:24 +03:00
#!/bin/bash -ex
2022-12-24 11:48:40 +03:00
PG_COUNT=2048
2022-01-05 17:06:24 +03:00
. `dirname $0`/run_3osds.sh
LD_PRELOAD="build/src/libfio_vitastor.so" \
2022-01-05 17:06:24 +03:00
fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4M -direct=1 -iodepth=1 -end_fsync=1 \
-rw=write -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -cluster_log_level=10
for i in 4; do
dd if=/dev/zero of=./testdata/test_osd$i.bin bs=1024 count=1 seek=$((OSD_SIZE*1024-1))
2022-12-22 23:29:36 +03:00
start_osd $i
2022-01-05 17:06:24 +03:00
done
sleep 2
for i in {1..10}; do
($ETCDCTL get /vitastor/config/pgs --print-value-only |\
jq -s -e '([ .[0].items["1"] | map(.osd_set)[][] ] | sort | unique == ["1","2","3","4"])') && \
($ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '([ .[] | select(.state == ["active"]) ] | length) == '$PG_COUNT'') && \
break
sleep 1
done
if ! ($ETCDCTL get /vitastor/config/pgs --print-value-only |\
jq -s -e '([ .[0].items["1"] | map(.osd_set)[][] ] | sort | unique == ["1","2","3","4"])'); then
format_error "FAILED: OSD NOT ADDED INTO DISTRIBUTION"
fi
if ! ($ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '([ .[] | select(.state == ["active"]) ] | length) == '$PG_COUNT''); then
format_error "FAILED: $PG_COUNT PGS NOT ACTIVE"
fi
2022-12-22 23:29:36 +03:00
sleep 1
2022-12-24 11:21:34 +03:00
kill -9 $OSD4_PID
2022-12-22 23:29:36 +03:00
sleep 1
2022-12-25 02:21:04 +03:00
build/src/vitastor-cli --etcd_address $ETCD_URL rm-osd --force 4
2022-12-22 23:29:36 +03:00
sleep 2
for i in {1..10}; do
($ETCDCTL get /vitastor/config/pgs --print-value-only |\
jq -s -e '([ .[0].items["1"] | map(.osd_set)[][] ] | sort | unique == ["1","2","3"])') && \
2022-12-24 11:48:40 +03:00
($ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '([ .[] | select(.state == ["active"] or .state == ["active", "left_on_dead"]) ] | length) == '$PG_COUNT'') && \
2022-12-22 23:29:36 +03:00
break
sleep 1
done
if ! ($ETCDCTL get /vitastor/config/pgs --print-value-only |\
jq -s -e '([ .[0].items["1"] | map(.osd_set)[][] ] | sort | unique == ["1","2","3"])'); then
format_error "FAILED: OSD NOT REMOVED FROM DISTRIBUTION"
fi
2022-12-24 11:48:40 +03:00
if ! ($ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '([ .[] | select(.state == ["active"] or .state == ["active", "left_on_dead"]) ] | length) == '$PG_COUNT''); then
2022-12-22 23:29:36 +03:00
format_error "FAILED: $PG_COUNT PGS NOT ACTIVE"
fi
2022-01-05 17:06:24 +03:00
format_green OK