From 8c908316d9add0326b992b7fa008e6001ebc1546 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 5 Jan 2022 17:06:24 +0300 Subject: [PATCH] Add a test with an OSD being added --- tests/test_add_osd.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tests/test_add_osd.sh diff --git a/tests/test_add_osd.sh b/tests/test_add_osd.sh new file mode 100755 index 00000000..dbc3e15c --- /dev/null +++ b/tests/test_add_osd.sh @@ -0,0 +1,36 @@ +#!/bin/bash -ex + +PG_COUNT=16 + +. `dirname $0`/run_3osds.sh + +LD_PRELOAD=libasan.so.5 \ + 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)) + build/src/vitastor-osd --osd_num $i --bind_address 127.0.0.1 $OSD_ARGS --etcd_address $ETCD_URL $(build/src/vitastor-cli simple-offsets --format options ./testdata/test_osd$i.bin 2>/dev/null) &>./testdata/osd$i.log & + eval OSD${i}_PID=$! +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 + +format_green OK