2016-06-09 20:23:52 +00:00
|
|
|
#!/bin/sh
|
2016-05-17 01:17:09 +00:00
|
|
|
#
|
2016-06-09 20:23:52 +00:00
|
|
|
# rbd_mirror_stress.sh - stress test rbd-mirror daemon
|
2016-05-17 01:17:09 +00:00
|
|
|
#
|
2016-06-15 21:49:54 +00:00
|
|
|
# The following additional environment variables affect the test:
|
|
|
|
#
|
|
|
|
# RBD_MIRROR_REDUCE_WRITES - if not empty, don't run the stress bench write
|
|
|
|
# tool during the many image test
|
|
|
|
#
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
IMAGE_COUNT=50
|
|
|
|
export LOCKDEP=0
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-12-15 20:10:28 +00:00
|
|
|
. $(dirname $0)/rbd_mirror_helpers.sh
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
create_snap()
|
2016-05-17 01:17:09 +00:00
|
|
|
{
|
|
|
|
local cluster=$1
|
2016-06-09 20:23:52 +00:00
|
|
|
local pool=$2
|
|
|
|
local image=$3
|
|
|
|
local snap_name=$4
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
rbd --cluster ${cluster} -p ${pool} snap create ${image}@${snap_name} \
|
|
|
|
--debug-rbd=20 --debug-journaler=20 2> ${TEMPDIR}/rbd-snap-create.log
|
2016-05-17 01:17:09 +00:00
|
|
|
}
|
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
compare_image_snaps()
|
2016-05-17 01:17:09 +00:00
|
|
|
{
|
2016-06-09 20:23:52 +00:00
|
|
|
local pool=$1
|
2016-05-17 01:17:09 +00:00
|
|
|
local image=$2
|
2016-06-09 20:23:52 +00:00
|
|
|
local snap_name=$3
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
local rmt_export=${TEMPDIR}/${CLUSTER2}-${pool}-${image}.export
|
|
|
|
local loc_export=${TEMPDIR}/${CLUSTER1}-${pool}-${image}.export
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
rm -f ${rmt_export} ${loc_export}
|
|
|
|
rbd --cluster ${CLUSTER2} -p ${pool} export ${image}@${snap_name} ${rmt_export}
|
|
|
|
rbd --cluster ${CLUSTER1} -p ${pool} export ${image}@${snap_name} ${loc_export}
|
|
|
|
cmp ${rmt_export} ${loc_export}
|
2016-06-27 17:01:13 +00:00
|
|
|
rm -f ${rmt_export} ${loc_export}
|
2016-05-17 01:17:09 +00:00
|
|
|
}
|
|
|
|
|
2016-06-15 21:49:54 +00:00
|
|
|
wait_for_pool_images()
|
2016-05-17 01:17:09 +00:00
|
|
|
{
|
|
|
|
local cluster=$1
|
2016-06-09 20:23:52 +00:00
|
|
|
local pool=$2
|
|
|
|
local image_count=$3
|
2016-05-17 01:17:09 +00:00
|
|
|
local s
|
2016-06-09 20:23:52 +00:00
|
|
|
local count
|
2016-06-15 21:49:54 +00:00
|
|
|
local last_count=0
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
for s in `seq 1 40`; do
|
2016-07-28 11:49:37 +00:00
|
|
|
test $s -ne 1 && sleep 30
|
2016-06-15 21:49:54 +00:00
|
|
|
count=$(rbd --cluster ${cluster} -p ${pool} mirror pool status | grep 'images: ' | cut -d' ' -f 2)
|
|
|
|
test "${count}" = "${image_count}" && return 0
|
|
|
|
|
|
|
|
# reset timeout if making forward progress
|
2016-07-28 11:49:37 +00:00
|
|
|
test $count -ne $last_count && break
|
2016-06-15 21:49:54 +00:00
|
|
|
done
|
|
|
|
|
2016-07-28 11:49:37 +00:00
|
|
|
test $count -eq $last_count && break
|
|
|
|
last_count=$count
|
2016-06-15 21:49:54 +00:00
|
|
|
done
|
2016-07-28 11:49:37 +00:00
|
|
|
rbd --cluster ${cluster} -p ${pool} mirror pool status --verbose >&2
|
2016-06-15 21:49:54 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
wait_for_pool_healthy()
|
|
|
|
{
|
|
|
|
local cluster=$1
|
|
|
|
local pool=$2
|
|
|
|
local s
|
2016-06-09 20:23:52 +00:00
|
|
|
local state
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
for s in `seq 1 40`; do
|
2016-07-28 11:49:37 +00:00
|
|
|
test $s -ne 1 && sleep 30
|
2016-06-15 21:49:54 +00:00
|
|
|
state=$(rbd --cluster ${cluster} -p ${pool} mirror pool status | grep 'health:' | cut -d' ' -f 2)
|
2016-07-28 11:49:37 +00:00
|
|
|
test "${state}" = "ERROR" && break
|
2016-06-15 21:49:54 +00:00
|
|
|
test "${state}" = "OK" && return 0
|
2016-05-17 01:17:09 +00:00
|
|
|
done
|
2016-07-28 11:49:37 +00:00
|
|
|
rbd --cluster ${cluster} -p ${pool} mirror pool status --verbose >&2
|
2016-05-17 01:17:09 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
start_mirror ${CLUSTER1}
|
|
|
|
start_mirror ${CLUSTER2}
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: add image and test replay after client crashes"
|
|
|
|
image=test
|
|
|
|
create_image ${CLUSTER2} ${POOL} ${image} '512M'
|
|
|
|
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
for i in `seq 1 10`
|
|
|
|
do
|
|
|
|
stress_write_image ${CLUSTER2} ${POOL} ${image}
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-09-14 12:49:39 +00:00
|
|
|
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
snap_name="snap${i}"
|
|
|
|
create_snap ${CLUSTER2} ${POOL} ${image} ${snap_name}
|
2016-09-21 22:08:18 +00:00
|
|
|
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
|
|
|
|
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
|
2016-06-09 20:23:52 +00:00
|
|
|
wait_for_snap_present ${CLUSTER1} ${POOL} ${image} ${snap_name}
|
|
|
|
compare_image_snaps ${POOL} ${image} ${snap_name}
|
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
for i in `seq 1 10`
|
|
|
|
do
|
|
|
|
snap_name="snap${i}"
|
|
|
|
remove_snapshot ${CLUSTER2} ${POOL} ${image} ${snap_name}
|
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-09-14 12:49:39 +00:00
|
|
|
remove_image_retry ${CLUSTER2} ${POOL} ${image}
|
2016-06-09 20:23:52 +00:00
|
|
|
wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: create many images"
|
2016-06-15 21:49:54 +00:00
|
|
|
snap_name="snap"
|
2016-06-09 20:23:52 +00:00
|
|
|
for i in `seq 1 ${IMAGE_COUNT}`
|
|
|
|
do
|
|
|
|
image="image_${i}"
|
|
|
|
create_image ${CLUSTER2} ${POOL} ${image} '128M'
|
2016-06-15 21:49:54 +00:00
|
|
|
if [ -n "${RBD_MIRROR_REDUCE_WRITES}" ]; then
|
|
|
|
write_image ${CLUSTER2} ${POOL} ${image} 100
|
|
|
|
else
|
|
|
|
stress_write_image ${CLUSTER2} ${POOL} ${image}
|
|
|
|
fi
|
2016-06-09 20:23:52 +00:00
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-15 21:49:54 +00:00
|
|
|
wait_for_pool_images ${CLUSTER2} ${POOL} ${IMAGE_COUNT}
|
|
|
|
wait_for_pool_healthy ${CLUSTER2} ${POOL}
|
|
|
|
|
|
|
|
wait_for_pool_images ${CLUSTER1} ${POOL} ${IMAGE_COUNT}
|
|
|
|
wait_for_pool_healthy ${CLUSTER1} ${POOL}
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: compare many images"
|
|
|
|
for i in `seq 1 ${IMAGE_COUNT}`
|
|
|
|
do
|
|
|
|
image="image_${i}"
|
2016-06-15 21:49:54 +00:00
|
|
|
create_snap ${CLUSTER2} ${POOL} ${image} ${snap_name}
|
2016-06-09 20:23:52 +00:00
|
|
|
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
|
|
|
|
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
|
2016-06-15 21:49:54 +00:00
|
|
|
wait_for_snap_present ${CLUSTER1} ${POOL} ${image} ${snap_name}
|
|
|
|
compare_image_snaps ${POOL} ${image} ${snap_name}
|
2016-06-09 20:23:52 +00:00
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: delete many images"
|
|
|
|
for i in `seq 1 ${IMAGE_COUNT}`
|
|
|
|
do
|
|
|
|
image="image_${i}"
|
2016-06-15 21:49:54 +00:00
|
|
|
remove_snapshot ${CLUSTER2} ${POOL} ${image} ${snap_name}
|
2016-09-14 12:49:39 +00:00
|
|
|
remove_image_retry ${CLUSTER2} ${POOL} ${image}
|
2016-06-09 20:23:52 +00:00
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: image deletions should propagate"
|
2016-08-02 17:06:17 +00:00
|
|
|
wait_for_pool_images ${CLUSTER1} ${POOL} 0
|
2016-06-09 20:23:52 +00:00
|
|
|
wait_for_pool_healthy ${CLUSTER1} ${POOL} 0
|
|
|
|
for i in `seq 1 ${IMAGE_COUNT}`
|
|
|
|
do
|
|
|
|
image="image_${i}"
|
|
|
|
wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
|
|
|
|
done
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
testlog "TEST: delete images during bootstrap"
|
|
|
|
set_pool_mirror_mode ${CLUSTER1} ${POOL} 'image'
|
|
|
|
set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image'
|
2016-05-17 01:17:09 +00:00
|
|
|
|
|
|
|
start_mirror ${CLUSTER1}
|
|
|
|
image=test
|
|
|
|
|
|
|
|
for i in `seq 1 10`
|
|
|
|
do
|
2016-06-09 20:23:52 +00:00
|
|
|
image="image_${i}"
|
|
|
|
create_image ${CLUSTER2} ${POOL} ${image} '512M'
|
|
|
|
enable_mirror ${CLUSTER2} ${POOL} ${image}
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
stress_write_image ${CLUSTER2} ${POOL} ${image}
|
|
|
|
wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
|
2016-05-17 01:17:09 +00:00
|
|
|
|
2016-06-09 20:23:52 +00:00
|
|
|
disable_mirror ${CLUSTER2} ${POOL} ${image}
|
|
|
|
wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
|
|
|
|
purge_snapshots ${CLUSTER2} ${POOL} ${image}
|
|
|
|
remove_image_retry ${CLUSTER2} ${POOL} ${image}
|
2016-05-17 01:17:09 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo OK
|