2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2012-11-26 21:43:13 +00:00
|
|
|
# can't use -e because of background process
|
2017-07-20 22:26:42 +00:00
|
|
|
set -x
|
2012-11-26 21:43:13 +00:00
|
|
|
|
|
|
|
IMAGE=rbdrw-image
|
|
|
|
LOCKID=rbdrw
|
2017-01-02 21:49:13 +00:00
|
|
|
RELPATH=$(dirname $0)/../../../src/test/librbd
|
2016-12-15 20:10:28 +00:00
|
|
|
RBDRW=$RELPATH/rbdrw.py
|
2012-11-26 21:43:13 +00:00
|
|
|
|
2015-01-20 23:55:11 +00:00
|
|
|
rbd create $IMAGE --size 10 --image-format 2 --image-shared || exit 1
|
2012-11-26 21:43:13 +00:00
|
|
|
|
|
|
|
# rbdrw loops doing I/O to $IMAGE after locking with lockid $LOCKID
|
2019-12-19 18:38:03 +00:00
|
|
|
python3 $RBDRW $IMAGE $LOCKID &
|
2012-11-26 21:43:13 +00:00
|
|
|
iochild=$!
|
|
|
|
|
|
|
|
# give client time to lock and start reading/writing
|
2018-01-10 19:46:07 +00:00
|
|
|
LOCKS='[]'
|
|
|
|
while [ "$LOCKS" == '[]' ]
|
2012-11-26 21:43:13 +00:00
|
|
|
do
|
|
|
|
LOCKS=$(rbd lock list $IMAGE --format json)
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
clientaddr=$(rbd lock list $IMAGE | tail -1 | awk '{print $NF;}')
|
|
|
|
clientid=$(rbd lock list $IMAGE | tail -1 | awk '{print $1;}')
|
|
|
|
echo "clientaddr: $clientaddr"
|
|
|
|
echo "clientid: $clientid"
|
|
|
|
|
|
|
|
ceph osd blacklist add $clientaddr || exit 1
|
|
|
|
|
|
|
|
wait $iochild
|
|
|
|
rbdrw_exitcode=$?
|
|
|
|
if [ $rbdrw_exitcode != 108 ]
|
|
|
|
then
|
|
|
|
echo "wrong exitcode from rbdrw: $rbdrw_exitcode"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "rbdrw stopped with ESHUTDOWN"
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
ceph osd blacklist rm $clientaddr
|
|
|
|
rbd lock remove $IMAGE $LOCKID "$clientid"
|
|
|
|
# rbdrw will have exited with an existing watch, so, until #3527 is fixed,
|
|
|
|
# hang out until the watch expires
|
|
|
|
sleep 30
|
|
|
|
rbd rm $IMAGE
|
|
|
|
echo OK
|