From 15dcaf7903e4bd905424e08c20dce4948a68413c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 8 Apr 2022 11:48:31 +0300 Subject: [PATCH] Add the same "rebalance" test with regular reads --- tests/run_7osds.sh | 11 +++++-- tests/test_rebalance_verify.sh | 56 ++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/tests/run_7osds.sh b/tests/run_7osds.sh index 70bd7d05..41ae2f7a 100644 --- a/tests/run_7osds.sh +++ b/tests/run_7osds.sh @@ -25,11 +25,18 @@ cd .. node mon/mon-main.js --etcd_url $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 &>./testdata/mon.log & MON_PID=$! -$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":32,"failure_domain":"osd"}}' +if [ "$EC" != "" ]; then + POOLCFG='"scheme":"xor","pg_size":3,"pg_minsize":2,"parity_chunks":1' + PG_SIZE=3 +else + POOLCFG='"scheme":"replicated","pg_size":2,"pg_minsize":2' + PG_SIZE=2 +fi +$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool",'$POOLCFG',"pg_count":32,"failure_domain":"osd"}}' sleep 2 -if ! ($ETCDCTL get /vitastor/config/pgs --print-value-only | jq -s -e '(.[0].items["1"] | map((.osd_set | select(. > 0)) | length == 2) | length) == 32'); then +if ! ($ETCDCTL get /vitastor/config/pgs --print-value-only | jq -s -e '(.[0].items["1"] | map((.osd_set | select(. > 0)) | length == '$PG_SIZE') | length) == 32'); then format_error "FAILED: 32 PGS NOT CONFIGURED" fi diff --git a/tests/test_rebalance_verify.sh b/tests/test_rebalance_verify.sh index f8ff8f4c..7f3d6bf2 100755 --- a/tests/test_rebalance_verify.sh +++ b/tests/test_rebalance_verify.sh @@ -16,32 +16,42 @@ dd if=/dev/urandom of=./testdata/img1.bin bs=1M count=$IMG_SIZE dd if=./testdata/img1.bin of=$NBD_DEV bs=1M count=$IMG_SIZE oflag=direct +verify() { + echo "Verifying before rebalance" + dd if=$NBD_DEV of=./testdata/img2.bin bs=1M count=$IMG_SIZE iflag=direct + diff ./testdata/img1.bin ./testdata/img2.bin + + $ETCDCTL put /vitastor/config/osd/1 '{"reweight":'$1'}' + $ETCDCTL put /vitastor/config/osd/2 '{"reweight":'$1'}' + $ETCDCTL put /vitastor/config/osd/3 '{"reweight":'$1'}' + sleep 1 + + for i in {1..10000}; do + O=$(((RANDOM*RANDOM) % (IMG_SIZE*128))) + dd if=$NBD_DEV of=./testdata/img2.bin bs=4k seek=$O skip=$O count=1 iflag=direct conv=notrunc + done + + echo "Verifying during rebalance" + diff ./testdata/img1.bin ./testdata/img2.bin + + # Wait for the rebalance to finish + wait_finish_rebalance 60 + + echo "Verifying after rebalance" + dd if=$NBD_DEV of=./testdata/img2.bin bs=1M count=$IMG_SIZE iflag=direct + diff ./testdata/img1.bin ./testdata/img2.bin +} + +# Verify with regular reads + +verify 0 + +# Same with chained reads + $ETCDCTL put /vitastor/config/inode/1/1 '{"name":"testimg0","size":'$((IMG_SIZE*1024*1024))'}' $ETCDCTL put /vitastor/config/inode/1/2 '{"name":"testimg","size":'$((IMG_SIZE*1024*1024))',"parent_id":1}' sleep 1 -echo "Verifying before rebalance" -dd if=$NBD_DEV of=./testdata/img2.bin bs=1M count=$IMG_SIZE iflag=direct -diff ./testdata/img1.bin ./testdata/img2.bin - -$ETCDCTL put /vitastor/config/osd/1 '{"reweight":0}' -$ETCDCTL put /vitastor/config/osd/2 '{"reweight":0}' -$ETCDCTL put /vitastor/config/osd/3 '{"reweight":0}' -sleep 1 - -for i in {1..10000}; do - O=$(((RANDOM*RANDOM) % (IMG_SIZE*128))) - dd if=$NBD_DEV of=./testdata/img2.bin bs=4k seek=$O skip=$O count=1 iflag=direct conv=notrunc -done - -echo "Verifying during rebalance" -diff ./testdata/img1.bin ./testdata/img2.bin - -# Wait for the rebalance to finish -wait_finish_rebalance 60 - -echo "Verifying after rebalance" -dd if=$NBD_DEV of=./testdata/img2.bin bs=1M count=$IMG_SIZE iflag=direct -diff ./testdata/img1.bin ./testdata/img2.bin +verify 1 format_green OK