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