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 }
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))
build/src/vitastor-osd --osd_num $i --bind_address 127.0.0.1 $OSD_ARGS --etcd_address $ETCD_URL $( node mon/simple-offsets.js --format options --device ./testdata/test_osd$i .bin 2>/dev/null) & >./testdata/osd$i .log &
eval OSD${ i } _PID = $!
done
2021-06-14 23:11:50 +03:00
cd mon
npm install
cd ..
node mon/mon-main.js --etcd_url http://$ETCD_URL --etcd_prefix "/vitastor" & >./testdata/mon.log &
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
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":' $PG_SIZE ',"pg_minsize":' $(( PG_SIZE-1)) ',"pg_count":' $PG_COUNT ',"failure_domain":"osd"}}'
else
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"xor","pg_size":' $PG_SIZE ',"pg_minsize":' $(( PG_SIZE-1)) ',"parity_chunks":1,"pg_count":' $PG_COUNT ',"failure_domain":"osd"}}'
fi
2021-06-14 23:11:50 +03:00
sleep 2
2021-11-13 02:48:10 +03:00
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
2021-07-19 01:42:35 +03:00
format_error " FAILED: $PG_COUNT PG(s) NOT CONFIGURED "
2021-06-14 23:11:50 +03:00
fi
2021-07-19 01:42:35 +03:00
if ! ( $ETCDCTL get /vitastor/pg/state/1/ --prefix --print-value-only | jq -s -e '[ .[] | select(.state == ["active"]) ] | length == ' $PG_COUNT ) ; then
format_error " FAILED: $PG_COUNT PG(s) NOT UP "
2021-06-14 23:11:50 +03:00
fi
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