]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/rbd/rbd_mirror.sh
Add patch for failing prerm scripts
[ceph.git] / ceph / qa / workunits / rbd / rbd_mirror.sh
CommitLineData
11fdf7f2 1#!/bin/sh -ex
7c673cae
FG
2#
3# rbd_mirror.sh - test rbd-mirror daemon
4#
5# The scripts starts two ("local" and "remote") clusters using mstart.sh script,
6# creates a temporary directory, used for cluster configs, daemon logs, admin
7# socket, temporary files, and launches rbd-mirror daemon.
8#
9
10. $(dirname $0)/rbd_mirror_helpers.sh
11
11fdf7f2
TL
12setup
13
7c673cae 14testlog "TEST: add image and test replay"
11fdf7f2 15start_mirrors ${CLUSTER1}
7c673cae
FG
16image=test
17create_image ${CLUSTER2} ${POOL} ${image}
b32b8144
FG
18set_image_meta ${CLUSTER2} ${POOL} ${image} "key1" "value1"
19set_image_meta ${CLUSTER2} ${POOL} ${image} "key2" "value2"
7c673cae
FG
20wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
21write_image ${CLUSTER2} ${POOL} ${image} 100
22wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
23wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
24if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
25 wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'down+unknown'
26fi
27compare_images ${POOL} ${image}
b32b8144
FG
28compare_image_meta ${CLUSTER1} ${POOL} ${image} "key1" "value1"
29compare_image_meta ${CLUSTER1} ${POOL} ${image} "key2" "value2"
7c673cae
FG
30
31testlog "TEST: stop mirror, add image, start mirror and test replay"
11fdf7f2 32stop_mirrors ${CLUSTER1}
7c673cae
FG
33image1=test1
34create_image ${CLUSTER2} ${POOL} ${image1}
35write_image ${CLUSTER2} ${POOL} ${image1} 100
11fdf7f2 36start_mirrors ${CLUSTER1}
7c673cae
FG
37wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
38wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image1}
39wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying' 'master_position'
40if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
41 wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image1} 'down+unknown'
42fi
43compare_images ${POOL} ${image1}
44
45testlog "TEST: test the first image is replaying after restart"
46write_image ${CLUSTER2} ${POOL} ${image} 100
47wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
48wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
49wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
50compare_images ${POOL} ${image}
51
11fdf7f2
TL
52if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
53 testlog "TEST: stop/start/restart mirror via admin socket"
54 all_admin_daemons ${CLUSTER1} rbd mirror stop
55 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
56 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image1}
57 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
58 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+stopped'
59
60 all_admin_daemons ${CLUSTER1} rbd mirror start
61 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
62 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
63 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
64 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying'
65
66 all_admin_daemons ${CLUSTER1} rbd mirror restart
67 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
68 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
69 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
70 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying'
71
72 all_admin_daemons ${CLUSTER1} rbd mirror stop
73 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
74 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image1}
75 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
76 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+stopped'
77
78 all_admin_daemons ${CLUSTER1} rbd mirror restart
79 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
80 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
81 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
82 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying'
83
84 all_admin_daemons ${CLUSTER1} rbd mirror stop ${POOL} ${CLUSTER2}${PEER_CLUSTER_SUFFIX}
85 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
86 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image1}
87 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
88 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+stopped'
89
90 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
91 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
92 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
93
94 all_admin_daemons ${CLUSTER1} rbd mirror start ${POOL} ${CLUSTER2}${PEER_CLUSTER_SUFFIX}
95 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
96 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying'
97
98 admin_daemons ${CLUSTER1} rbd mirror restart ${POOL}/${image}
99 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
100 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
101
102 all_admin_daemons ${CLUSTER1} rbd mirror restart ${POOL} ${CLUSTER2}${PEER_CLUSTER_SUFFIX}
103 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
104 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
105
106 all_admin_daemons ${CLUSTER1} rbd mirror stop ${POOL} ${CLUSTER2}${PEER_CLUSTER_SUFFIX}
107 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
108 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image1}
109 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
110 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+stopped'
111
112 all_admin_daemons ${CLUSTER1} rbd mirror restart ${POOL} ${CLUSTER2}${PEER_CLUSTER_SUFFIX}
113 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
114 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1}
115 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
116 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying'
117
118 flush ${CLUSTER1}
119 all_admin_daemons ${CLUSTER1} rbd mirror status
120fi
7c673cae 121
3efd9988
FG
122testlog "TEST: test image rename"
123new_name="${image}_RENAMED"
124rename_image ${CLUSTER2} ${POOL} ${image} ${new_name}
125wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name}
126wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying'
11fdf7f2
TL
127admin_daemons ${CLUSTER1} rbd mirror status ${POOL}/${new_name}
128admin_daemons ${CLUSTER1} rbd mirror restart ${POOL}/${new_name}
3efd9988
FG
129wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name}
130wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying'
131rename_image ${CLUSTER2} ${POOL} ${new_name} ${image}
132wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
133
11fdf7f2
TL
134testlog "TEST: test trash move restore"
135image_id=$(get_image_id ${CLUSTER2} ${POOL} ${image})
136trash_move ${CLUSTER2} ${POOL} ${image}
137wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
138trash_restore ${CLUSTER2} ${POOL} ${image_id}
139wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
140
7c673cae 141testlog "TEST: failover and failback"
11fdf7f2 142start_mirrors ${CLUSTER2}
7c673cae
FG
143
144# demote and promote same cluster
145demote_image ${CLUSTER2} ${POOL} ${image}
146wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
c07f9fc5
FG
147wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
148wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
149promote_image ${CLUSTER2} ${POOL} ${image}
150wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
151write_image ${CLUSTER2} ${POOL} ${image} 100
152wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
153wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
154wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
155compare_images ${POOL} ${image}
156
157# failover (unmodified)
158demote_image ${CLUSTER2} ${POOL} ${image}
159wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
c07f9fc5
FG
160wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
161wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
162promote_image ${CLUSTER1} ${POOL} ${image}
163wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image}
164
165# failback (unmodified)
166demote_image ${CLUSTER1} ${POOL} ${image}
167wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
c07f9fc5
FG
168wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
169wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
170promote_image ${CLUSTER2} ${POOL} ${image}
171wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
172wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
173wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
174wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
175compare_images ${POOL} ${image}
176
177# failover
178demote_image ${CLUSTER2} ${POOL} ${image}
179wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
c07f9fc5
FG
180wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
181wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
182promote_image ${CLUSTER1} ${POOL} ${image}
183wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image}
184write_image ${CLUSTER1} ${POOL} ${image} 100
185wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image}
186wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
187wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying' 'master_position'
188compare_images ${POOL} ${image}
189
190# failback
191demote_image ${CLUSTER1} ${POOL} ${image}
192wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
c07f9fc5
FG
193wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
194wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
195promote_image ${CLUSTER2} ${POOL} ${image}
196wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
197write_image ${CLUSTER2} ${POOL} ${image} 100
198wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
199wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
200wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
201compare_images ${POOL} ${image}
202
203# force promote
204force_promote_image=test_force_promote
205create_image ${CLUSTER2} ${POOL} ${force_promote_image}
206write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100
207wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image}
208wait_for_image_replay_started ${CLUSTER1} ${POOL} ${force_promote_image}
209wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${force_promote_image}
210wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+replaying' 'master_position'
211wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped'
212promote_image ${CLUSTER1} ${POOL} ${force_promote_image} '--force'
213wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${force_promote_image}
214wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image}
215wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+stopped'
216wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped'
217write_image ${CLUSTER1} ${POOL} ${force_promote_image} 100
218write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100
219
220testlog "TEST: cloned images"
221parent_image=test_parent
222parent_snap=snap
223create_image ${CLUSTER2} ${PARENT_POOL} ${parent_image}
224write_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} 100
225create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
226protect_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
227
228clone_image=test_clone
229clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}
230write_image ${CLUSTER2} ${POOL} ${clone_image} 100
231
232enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image}
233wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} ${parent_image}
234wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${parent_image}
235wait_for_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying' 'master_position'
236compare_images ${PARENT_POOL} ${parent_image}
237
238wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}
239wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image}
240wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' 'master_position'
241compare_images ${POOL} ${clone_image}
242
11fdf7f2 243clone_image ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}1
7c673cae 244
b5b8bbf5
FG
245testlog "TEST: data pool"
246dp_image=test_data_pool
247create_image ${CLUSTER2} ${POOL} ${dp_image} 128 --data-pool ${PARENT_POOL}
248data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL} ${dp_image})
249test "${data_pool}" = "${PARENT_POOL}"
250wait_for_image_replay_started ${CLUSTER1} ${POOL} ${dp_image}
251data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL} ${dp_image})
252test "${data_pool}" = "${PARENT_POOL}"
253create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap1'
254write_image ${CLUSTER2} ${POOL} ${dp_image} 100
255create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap2'
256write_image ${CLUSTER2} ${POOL} ${dp_image} 100
257wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${dp_image}
258wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${dp_image} 'up+replaying' 'master_position'
259compare_images ${POOL} ${dp_image}@snap1
260compare_images ${POOL} ${dp_image}@snap2
261compare_images ${POOL} ${dp_image}
262
7c673cae
FG
263testlog "TEST: disable mirroring / delete non-primary image"
264image2=test2
265image3=test3
266image4=test4
267image5=test5
268for i in ${image2} ${image3} ${image4} ${image5}; do
269 create_image ${CLUSTER2} ${POOL} ${i}
270 write_image ${CLUSTER2} ${POOL} ${i} 100
271 create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
272 create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
273 if [ "${i}" = "${image4}" ] || [ "${i}" = "${image5}" ]; then
274 protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
275 protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
276 fi
277 write_image ${CLUSTER2} ${POOL} ${i} 100
278 wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'present'
279 wait_for_snap_present ${CLUSTER1} ${POOL} ${i} 'snap2'
280done
281
282set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image'
283for i in ${image2} ${image4}; do
284 disable_mirror ${CLUSTER2} ${POOL} ${i}
285done
286
287unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap1'
288unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap2'
289for i in ${image3} ${image5}; do
290 remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
291 remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
292 remove_image_retry ${CLUSTER2} ${POOL} ${i}
293done
294
295for i in ${image2} ${image3} ${image4} ${image5}; do
296 wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'deleted'
297done
298
299set_pool_mirror_mode ${CLUSTER2} ${POOL} 'pool'
300for i in ${image2} ${image4}; do
301 wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'present'
302 wait_for_snap_present ${CLUSTER1} ${POOL} ${i} 'snap2'
303 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${i}
304 wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${i}
305 compare_images ${POOL} ${i}
306done
307
eafe8130
TL
308testlog "TEST: remove mirroring pool"
309pool=pool_to_remove
310for cluster in ${CLUSTER1} ${CLUSTER2}; do
311 CEPH_ARGS='' ceph --cluster ${cluster} osd pool create ${pool} 16 16
312 CEPH_ARGS='' rbd --cluster ${cluster} pool init ${pool}
313 rbd --cluster ${cluster} mirror pool enable ${pool} pool
314done
315rbd --cluster ${CLUSTER1} mirror pool peer add ${pool} ${CLUSTER2}
316rbd --cluster ${CLUSTER2} mirror pool peer add ${pool} ${CLUSTER1}
317rdp_image=test_remove_data_pool
318create_image ${CLUSTER2} ${pool} ${image} 128
319create_image ${CLUSTER2} ${POOL} ${rdp_image} 128 --data-pool ${pool}
320write_image ${CLUSTER2} ${pool} ${image} 100
321write_image ${CLUSTER2} ${POOL} ${rdp_image} 100
322wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${pool} ${image}
323wait_for_status_in_pool_dir ${CLUSTER1} ${pool} ${image} 'up+replaying' 'master_position'
324wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${rdp_image}
325wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${rdp_image} 'up+replaying' 'master_position'
326for cluster in ${CLUSTER1} ${CLUSTER2}; do
327 CEPH_ARGS='' ceph --cluster ${cluster} osd pool rm ${pool} ${pool} --yes-i-really-really-mean-it
328done
329remove_image_retry ${CLUSTER2} ${POOL} ${rdp_image}
330wait_for_image_present ${CLUSTER1} ${POOL} ${rdp_image} 'deleted'
331for i in 0 1 2 4 8 8 8 8 16 16; do
332 sleep $i
333 admin_daemons "${CLUSTER2}" rbd mirror status ${pool}/${image} || break
334done
335admin_daemons "${CLUSTER2}" rbd mirror status ${pool}/${image} && false
336
7c673cae
FG
337testlog "TEST: snapshot rename"
338snap_name='snap_rename'
339create_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_0"
340for i in `seq 1 20`; do
341 rename_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_$(expr ${i} - 1)" "${snap_name}_${i}"
342done
343wait_for_snap_present ${CLUSTER1} ${POOL} ${image2} "${snap_name}_${i}"
344
345testlog "TEST: disable mirror while daemon is stopped"
11fdf7f2
TL
346stop_mirrors ${CLUSTER1}
347stop_mirrors ${CLUSTER2}
7c673cae
FG
348set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image'
349disable_mirror ${CLUSTER2} ${POOL} ${image}
350if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
351 test_image_present ${CLUSTER1} ${POOL} ${image} 'present'
352fi
11fdf7f2 353start_mirrors ${CLUSTER1}
7c673cae
FG
354wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
355set_pool_mirror_mode ${CLUSTER2} ${POOL} 'pool'
356wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
357wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
358
359testlog "TEST: simple image resync"
360request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
361wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 362wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae
FG
363wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
364wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
365compare_images ${POOL} ${image}
366
367testlog "TEST: image resync while replayer is stopped"
11fdf7f2
TL
368if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
369 admin_daemons ${CLUSTER1} rbd mirror stop ${POOL}/${image}
370 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
371 request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
372 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
373 wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
374 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
375 wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
376 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
377 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
378 compare_images ${POOL} ${image}
379fi
7c673cae
FG
380
381testlog "TEST: request image resync while daemon is offline"
11fdf7f2 382stop_mirrors ${CLUSTER1}
7c673cae 383request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
11fdf7f2 384start_mirrors ${CLUSTER1}
7c673cae 385wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 386wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae
FG
387wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
388wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
389compare_images ${POOL} ${image}
390
391testlog "TEST: client disconnect"
392image=laggy
393create_image ${CLUSTER2} ${POOL} ${image} 128 --journal-object-size 64K
394write_image ${CLUSTER2} ${POOL} ${image} 10
395
396testlog " - replay stopped after disconnect"
397wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
398wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
399test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
400disconnect_image ${CLUSTER2} ${POOL} ${image}
401test -z "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
402wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
403wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected'
404
405testlog " - replay started after resync requested"
406request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
407wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 408wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae
FG
409wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
410wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
411test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
412compare_images ${POOL} ${image}
413
414testlog " - disconnected after max_concurrent_object_sets reached"
11fdf7f2
TL
415if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
416 admin_daemons ${CLUSTER1} rbd mirror stop ${POOL}/${image}
417 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
418 test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
419 set_image_meta ${CLUSTER2} ${POOL} ${image} \
420 conf_rbd_journal_max_concurrent_object_sets 1
421 write_image ${CLUSTER2} ${POOL} ${image} 20 16384
422 write_image ${CLUSTER2} ${POOL} ${image} 20 16384
423 test -z "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
424 set_image_meta ${CLUSTER2} ${POOL} ${image} \
425 conf_rbd_journal_max_concurrent_object_sets 0
426
427 testlog " - replay is still stopped (disconnected) after restart"
428 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
429 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
430 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected'
431fi
7c673cae
FG
432
433testlog " - replay started after resync requested"
434request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
435wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 436wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae
FG
437wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
438wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
439test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
440compare_images ${POOL} ${image}
441
442testlog " - rbd_mirroring_resync_after_disconnect config option"
443set_image_meta ${CLUSTER2} ${POOL} ${image} \
444 conf_rbd_mirroring_resync_after_disconnect true
445wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
28e407b8 446image_id=$(get_image_id ${CLUSTER1} ${POOL} ${image})
7c673cae 447disconnect_image ${CLUSTER2} ${POOL} ${image}
d2e6a577
FG
448wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
449wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae
FG
450wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
451wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
452test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
453compare_images ${POOL} ${image}
454set_image_meta ${CLUSTER2} ${POOL} ${image} \
455 conf_rbd_mirroring_resync_after_disconnect false
456wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
457disconnect_image ${CLUSTER2} ${POOL} ${image}
458test -z "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})"
459wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
460wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected'
461
462testlog "TEST: split-brain"
463image=split-brain
464create_image ${CLUSTER2} ${POOL} ${image}
465wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
b32b8144
FG
466promote_image ${CLUSTER1} ${POOL} ${image} --force
467wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
468wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
7c673cae
FG
469write_image ${CLUSTER1} ${POOL} ${image} 10
470demote_image ${CLUSTER1} ${POOL} ${image}
7c673cae
FG
471wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'split-brain'
472request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
473wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position'
474
11fdf7f2
TL
475if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
476 # teuthology will trash the daemon
477 testlog "TEST: no blacklists"
478 CEPH_ARGS='--id admin' ceph --cluster ${CLUSTER1} osd blacklist ls 2>&1 | grep -q "listed 0 entries"
479 CEPH_ARGS='--id admin' ceph --cluster ${CLUSTER2} osd blacklist ls 2>&1 | grep -q "listed 0 entries"
480fi