3 # rbd_mirror_stress.sh - stress test rbd-mirror daemon
5 # The following additional environment variables affect the test:
7 # RBD_MIRROR_REDUCE_WRITES - if not empty, don't run the stress bench write
8 # tool during the many image test
14 . $
(dirname $0)/rbd_mirror_helpers.sh
25 rbd
--cluster ${cluster} -p ${pool} snap create ${image}@${snap_name} \
26 --debug-rbd=20 --debug-journaler=20 2> ${TEMPDIR}/rbd-snap-create.log
36 local rmt_export
=${TEMPDIR}/${CLUSTER2}-${pool}-${image}.
export
37 local loc_export
=${TEMPDIR}/${CLUSTER1}-${pool}-${image}.
export
39 rm -f ${rmt_export} ${loc_export}
40 rbd
--cluster ${CLUSTER2} -p ${pool} export ${image}@${snap_name} ${rmt_export}
41 rbd
--cluster ${CLUSTER1} -p ${pool} export ${image}@${snap_name} ${loc_export}
42 if ! cmp ${rmt_export} ${loc_export}
44 show_diff
${rmt_export} ${loc_export}
47 rm -f ${rmt_export} ${loc_export}
51 wait_for_pool_images
()
61 for s
in `seq 1 40`; do
62 test $s -ne 1 && sleep 30
63 count
=$
(rbd
--cluster ${cluster} -p ${pool} mirror pool status |
grep 'images: ' | cut
-d' ' -f 2)
64 test "${count}" = "${image_count}" && return 0
66 # reset timeout if making forward progress
67 test $count -ne $last_count && break
70 test $count -eq $last_count && break
73 rbd
--cluster ${cluster} -p ${pool} mirror pool status
--verbose >&2
77 wait_for_pool_healthy
()
84 for s
in `seq 1 40`; do
85 test $s -ne 1 && sleep 30
86 state
=$
(rbd
--cluster ${cluster} -p ${pool} mirror pool status |
grep 'image health:' | cut
-d' ' -f 3)
87 test "${state}" = "ERROR" && break
88 test "${state}" = "OK" && return 0
90 rbd
--cluster ${cluster} -p ${pool} mirror pool status
--verbose >&2
94 start_mirrors
${CLUSTER1}
95 start_mirrors
${CLUSTER2}
97 testlog
"TEST: add image and test replay after client crashes"
99 create_image_and_enable_mirror
${CLUSTER2} ${POOL} ${image} ${MIRROR_IMAGE_MODE} '512M'
100 wait_for_image_replay_started
${CLUSTER1} ${POOL} ${image}
105 stress_write_image
${CLUSTER2} ${POOL} ${image}
107 wait_for_status_in_pool_dir
${CLUSTER1} ${POOL} ${image} 'up+replaying'
110 create_snap
${CLUSTER2} ${POOL} ${image} ${snap_name}
111 wait_for_image_replay_started
${CLUSTER1} ${POOL} ${image}
112 wait_for_replay_complete
${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
113 wait_for_snap_present
${CLUSTER1} ${POOL} ${image} ${snap_name}
115 if [ -n "${clean_snap_name}" ]; then
116 compare_image_snaps
${POOL} ${image} ${clean_snap_name}
118 compare_image_snaps
${POOL} ${image} ${snap_name}
120 clean_snap_name
="snap${i}-clean"
121 create_snap
${CLUSTER2} ${POOL} ${image} ${clean_snap_name}
124 wait_for_image_replay_started
${CLUSTER1} ${POOL} ${image}
125 wait_for_replay_complete
${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
126 wait_for_snap_present
${CLUSTER1} ${POOL} ${image} ${clean_snap_name}
131 compare_image_snaps
${POOL} ${image} ${snap_name}
133 snap_name
="snap${i}-clean"
134 compare_image_snaps
${POOL} ${image} ${snap_name}
140 remove_snapshot
${CLUSTER2} ${POOL} ${image} ${snap_name}
142 snap_name
="snap${i}-clean"
143 remove_snapshot
${CLUSTER2} ${POOL} ${image} ${snap_name}
146 remove_image_retry
${CLUSTER2} ${POOL} ${image}
147 wait_for_image_present
${CLUSTER1} ${POOL} ${image} 'deleted'
149 testlog
"TEST: create many images"
151 for i
in `seq 1 ${IMAGE_COUNT}`
154 create_image_and_enable_mirror
${CLUSTER2} ${POOL} ${image} ${MIRROR_IMAGE_MODE} '128M'
155 if [ -n "${RBD_MIRROR_REDUCE_WRITES}" ]; then
156 write_image
${CLUSTER2} ${POOL} ${image} 100
158 stress_write_image
${CLUSTER2} ${POOL} ${image}
162 wait_for_pool_images
${CLUSTER2} ${POOL} ${IMAGE_COUNT}
163 wait_for_pool_healthy
${CLUSTER2} ${POOL}
165 wait_for_pool_images
${CLUSTER1} ${POOL} ${IMAGE_COUNT}
166 wait_for_pool_healthy
${CLUSTER1} ${POOL}
168 testlog
"TEST: compare many images"
169 for i
in `seq 1 ${IMAGE_COUNT}`
172 create_snap
${CLUSTER2} ${POOL} ${image} ${snap_name}
173 wait_for_image_replay_started
${CLUSTER1} ${POOL} ${image}
174 wait_for_replay_complete
${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
175 wait_for_snap_present
${CLUSTER1} ${POOL} ${image} ${snap_name}
176 compare_image_snaps
${POOL} ${image} ${snap_name}
179 testlog
"TEST: delete many images"
180 for i
in `seq 1 ${IMAGE_COUNT}`
183 remove_snapshot
${CLUSTER2} ${POOL} ${image} ${snap_name}
184 remove_image_retry
${CLUSTER2} ${POOL} ${image}
187 testlog
"TEST: image deletions should propagate"
188 wait_for_pool_images
${CLUSTER1} ${POOL} 0
189 wait_for_pool_healthy
${CLUSTER1} ${POOL} 0
190 for i
in `seq 1 ${IMAGE_COUNT}`
193 wait_for_image_present
${CLUSTER1} ${POOL} ${image} 'deleted'
196 testlog
"TEST: delete images during bootstrap"
197 set_pool_mirror_mode
${CLUSTER1} ${POOL} 'image'
198 set_pool_mirror_mode
${CLUSTER2} ${POOL} 'image'
200 start_mirror
${CLUSTER1}
206 create_image
${CLUSTER2} ${POOL} ${image} '512M'
207 enable_mirror
${CLUSTER2} ${POOL} ${image}
209 stress_write_image
${CLUSTER2} ${POOL} ${image}
210 wait_for_image_present
${CLUSTER1} ${POOL} ${image} 'present'
212 disable_mirror
${CLUSTER2} ${POOL} ${image}
213 wait_for_image_present
${CLUSTER1} ${POOL} ${image} 'deleted'
214 purge_snapshots
${CLUSTER2} ${POOL} ${image}
215 remove_image_retry
${CLUSTER2} ${POOL} ${image}
218 testlog
"TEST: check if removed images' OMAP are removed"
220 wait_for_image_in_omap
${CLUSTER1} ${POOL}
221 wait_for_image_in_omap
${CLUSTER2} ${POOL}