2022-04-03 01:35:29 +03:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
2022-06-03 01:56:36 +03:00
|
|
|
OSD_COUNT=7
|
|
|
|
PG_COUNT=32
|
|
|
|
. `dirname $0`/run_3osds.sh
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2023-05-08 20:37:34 +03:00
|
|
|
check_nbd
|
|
|
|
|
2022-04-03 01:35:29 +03:00
|
|
|
IMG_SIZE=256
|
|
|
|
|
|
|
|
$ETCDCTL put /vitastor/config/inode/1/1 '{"name":"testimg","size":'$((IMG_SIZE*1024*1024))'}'
|
|
|
|
|
2023-05-12 23:15:14 +03:00
|
|
|
NBD_DEV=$(sudo build/src/vitastor-nbd map --nbd_timeout 180 --etcd_address $ETCD_URL --image testimg --logfile ./testdata/nbd.log &)
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-06 02:12:51 +03:00
|
|
|
trap "sudo build/src/vitastor-nbd unmap $NBD_DEV"'; kill -9 $(jobs -p)' EXIT
|
2022-04-03 01:35:29 +03:00
|
|
|
|
|
|
|
sudo chown $(id -u) $NBD_DEV
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
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
|
2022-04-06 02:12:51 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
$ETCDCTL put /vitastor/config/osd/1 '{"reweight":'$1'}'
|
|
|
|
$ETCDCTL put /vitastor/config/osd/2 '{"reweight":'$1'}'
|
|
|
|
sleep 1
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
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
|
2023-05-17 01:58:01 +03:00
|
|
|
wait_finish_rebalance 300
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
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
|
|
|
|
}
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
# Verify with regular reads
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
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
|
2022-04-03 01:35:29 +03:00
|
|
|
|
2022-04-08 11:48:31 +03:00
|
|
|
verify 1
|
2022-04-03 01:35:29 +03:00
|
|
|
|
|
|
|
format_green OK
|