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