From 2d4cc688b253240151d7a19bd026fc708443400b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 22 Dec 2022 23:29:36 +0300 Subject: [PATCH] Add a remove-osd test --- tests/test_add_osd.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/test_add_osd.sh b/tests/test_add_osd.sh index 718ab855..fbd2888d 100755 --- a/tests/test_add_osd.sh +++ b/tests/test_add_osd.sh @@ -10,8 +10,7 @@ LD_PRELOAD="build/src/libfio_vitastor.so" \ for i in 4; do dd if=/dev/zero of=./testdata/test_osd$i.bin bs=1024 count=1 seek=$((OSD_SIZE*1024-1)) - build/src/vitastor-osd --osd_num $i --bind_address 127.0.0.1 $OSD_ARGS --etcd_address $ETCD_URL $(build/src/vitastor-disk simple-offsets --format options ./testdata/test_osd$i.bin 2>/dev/null) &>./testdata/osd$i.log & - eval OSD${i}_PID=$! + start_osd $i done sleep 2 @@ -33,4 +32,31 @@ if ! ($ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '( format_error "FAILED: $PG_COUNT PGS NOT ACTIVE" fi +sleep 1 +kill $OSD4_PID +sleep 1 +$ETCDCTL del /vitastor/osd/state/4 +$ETCDCTL del /vitastor/osd/stats/4 +$ETCDCTL del /vitastor/osd/inodestats/4 +$ETCDCTL del /vitastor/osd/space/4 + +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"])') && \ + ($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"])'); then + format_error "FAILED: OSD NOT REMOVED FROM 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 + format_green OK