2021-06-14 23:11:50 +03:00
#!/bin/bash -ex
. ` dirname $0 ` /common.sh
OSD_SIZE = ${ OSD_SIZE :- 1024 }
2021-07-19 01:42:35 +03:00
PG_COUNT = ${ PG_COUNT :- 1 }
2021-11-13 02:48:10 +03:00
PG_SIZE = ${ PG_SIZE :- 3 }
2021-12-28 10:54:36 +03:00
PG_MINSIZE = ${ PG_MINSIZE :- 2 }
2021-11-13 02:48:10 +03:00
OSD_COUNT = ${ OSD_COUNT :- 3 }
SCHEME = ${ SCHEME :- ec }
2021-06-14 23:11:50 +03:00
2021-11-13 02:48:10 +03:00
for i in $( seq 1 $OSD_COUNT ) ; do
dd if = /dev/zero of = ./testdata/test_osd$i .bin bs = 1024 count = 1 seek = $(( OSD_SIZE*1024-1))
2021-11-20 23:51:26 +03:00
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 &
2021-11-13 02:48:10 +03:00
eval OSD${ i } _PID = $!
done
2021-06-14 23:11:50 +03:00
cd mon
npm install
cd ..
2022-04-10 13:57:46 +03:00
node mon/mon-main.js --etcd_url $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 & >./testdata/mon.log &
2021-06-14 23:11:50 +03:00
MON_PID = $!
if [ -n " $GLOBAL_CONF " ] ; then
$ETCDCTL put /vitastor/config/global " $GLOBAL_CONF "
fi
2021-11-13 02:48:10 +03:00
if [ " $SCHEME " = "replicated" ] ; then
2021-12-28 10:54:36 +03:00
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":' $PG_SIZE ',"pg_minsize":' $PG_MINSIZE ',"pg_count":' $PG_COUNT ',"failure_domain":"osd"}}'
2021-11-13 02:48:10 +03:00
else
2021-12-28 10:54:36 +03:00
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"xor","pg_size":' $PG_SIZE ',"pg_minsize":' $PG_MINSIZE ',"parity_chunks":1,"pg_count":' $PG_COUNT ',"failure_domain":"osd"}}'
2021-11-13 02:48:10 +03:00
fi
2021-06-14 23:11:50 +03:00
2022-04-10 13:57:46 +03:00
wait_up( )
{
local sec = $1
local i = 0
local configured = 0
while [ [ $i -lt $sec ] ] ; do
if $ETCDCTL get /vitastor/config/pgs --print-value-only | jq -s -e ' ( . | length) != 0 and ( [ .[ 0] .items[ "1" ] [ ] |
select ( ( ( .osd_set | select ( . != 0) | sort | unique) | length) = = '$PG_SIZE' ) ] | length) = = ' $PG_COUNT ; then
configured = 1
if $ETCDCTL get /vitastor/pg/state/1/ --prefix --print-value-only | jq -s -e '[ .[] | select(.state == ["active"]) ] | length == ' $PG_COUNT ; then
break
fi
fi
sleep 1
i = $(( i+1))
if [ $i -eq $sec ] ; then
if [ [ $configured -ne 0 ] ] ; then
format_error " FAILED: $PG_COUNT PG(s) NOT CONFIGURED "
fi
format_error " FAILED: $PG_COUNT PG(s) NOT UP "
fi
done
}
wait_up 60
2021-06-14 23:11:50 +03:00
if ! cmp build/src/block-vitastor.so /usr/lib/x86_64-linux-gnu/qemu/block-vitastor.so; then
sudo rm -f /usr/lib/x86_64-linux-gnu/qemu/block-vitastor.so
sudo ln -s " $( realpath .) /build/src/block-vitastor.so " /usr/lib/x86_64-linux-gnu/qemu/block-vitastor.so
fi