mirror of
https://github.com/ceph/ceph
synced 2024-12-22 11:31:55 +00:00
9bcc19de58
Fail if 'rbd rm' fails - most probably it'd fail with "image still has watchers" and in that case it's a bug in the kernel client which we do want to notice. Also nuke the trap-based error handling - cleanup() is half-baked and not really necessary here. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
45 lines
781 B
Bash
Executable File
45 lines
781 B
Bash
Executable File
#!/bin/bash -ex
|
|
|
|
RUN_TIME=300 # approximate duration of run (seconds)
|
|
|
|
[ $# -eq 1 ] && RUN_TIME="$1"
|
|
|
|
IMAGE_NAME="image-$$"
|
|
IMAGE_SIZE="1024" # MB
|
|
|
|
function get_time() {
|
|
date '+%s'
|
|
}
|
|
|
|
function times_up() {
|
|
local end_time="$1"
|
|
|
|
test $(get_time) -ge "${end_time}"
|
|
}
|
|
|
|
function map_unmap() {
|
|
[ $# -eq 1 ] || exit 99
|
|
local image_name="$1"
|
|
|
|
local dev
|
|
dev="$(sudo rbd map "${image_name}")"
|
|
sudo rbd unmap "${dev}"
|
|
}
|
|
|
|
#### Start
|
|
|
|
rbd create "${IMAGE_NAME}" --size="${IMAGE_SIZE}"
|
|
|
|
COUNT=0
|
|
START_TIME=$(get_time)
|
|
END_TIME=$(expr $(get_time) + ${RUN_TIME})
|
|
while ! times_up "${END_TIME}"; do
|
|
map_unmap "${IMAGE_NAME}"
|
|
COUNT=$(expr $COUNT + 1)
|
|
done
|
|
ELAPSED=$(expr "$(get_time)" - "${START_TIME}")
|
|
|
|
rbd rm "${IMAGE_NAME}"
|
|
|
|
echo "${COUNT} iterations completed in ${ELAPSED} seconds"
|