]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/rbd/rbd_mirror_snapshot.sh
import ceph 16.2.7
[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
a4b75251
TL
125remove_image_retry ${CLUSTER2} ${POOL} ${image1}
126
3efd9988
FG
127testlog "TEST: test image rename"
128new_name="${image}_RENAMED"
129rename_image ${CLUSTER2} ${POOL} ${image} ${new_name}
9f95a23c 130mirror_image_snapshot ${CLUSTER2} ${POOL} ${new_name}
3efd9988
FG
131wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name}
132wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying'
11fdf7f2
TL
133admin_daemons ${CLUSTER1} rbd mirror status ${POOL}/${new_name}
134admin_daemons ${CLUSTER1} rbd mirror restart ${POOL}/${new_name}
3efd9988
FG
135wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name}
136wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying'
137rename_image ${CLUSTER2} ${POOL} ${new_name} ${image}
9f95a23c 138mirror_image_snapshot ${CLUSTER2} ${POOL} ${image}
3efd9988
FG
139wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
140
11fdf7f2
TL
141testlog "TEST: test trash move restore"
142image_id=$(get_image_id ${CLUSTER2} ${POOL} ${image})
143trash_move ${CLUSTER2} ${POOL} ${image}
144wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
145trash_restore ${CLUSTER2} ${POOL} ${image_id}
9f95a23c 146enable_mirror ${CLUSTER2} ${POOL} ${image} snapshot
11fdf7f2
TL
147wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
148
a4b75251
TL
149testlog "TEST: check if removed images' OMAP are removed (with rbd-mirror on one cluster)"
150remove_image_retry ${CLUSTER2} ${POOL} ${image}
151
152wait_for_image_in_omap ${CLUSTER1} ${POOL}
153wait_for_image_in_omap ${CLUSTER2} ${POOL}
154
155create_image_and_enable_mirror ${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 ${CLUSTER1} ${POOL} ${image} 'up+replaying'
160
7c673cae 161testlog "TEST: failover and failback"
11fdf7f2 162start_mirrors ${CLUSTER2}
7c673cae
FG
163
164# demote and promote same cluster
165demote_image ${CLUSTER2} ${POOL} ${image}
166wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
c07f9fc5
FG
167wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
168wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
169promote_image ${CLUSTER2} ${POOL} ${image}
170wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
171write_image ${CLUSTER2} ${POOL} ${image} 100
172wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
173wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
9f95a23c 174wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
7c673cae
FG
175compare_images ${POOL} ${image}
176
177# failover (unmodified)
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}
184
185# failback (unmodified)
186demote_image ${CLUSTER1} ${POOL} ${image}
187wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
c07f9fc5
FG
188wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
189wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
190promote_image ${CLUSTER2} ${POOL} ${image}
191wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
192wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
9f95a23c 193wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
7c673cae
FG
194wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
195compare_images ${POOL} ${image}
196
197# failover
198demote_image ${CLUSTER2} ${POOL} ${image}
199wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
c07f9fc5
FG
200wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
201wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
202promote_image ${CLUSTER1} ${POOL} ${image}
203wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image}
204write_image ${CLUSTER1} ${POOL} ${image} 100
205wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image}
206wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
9f95a23c 207wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying'
7c673cae
FG
208compare_images ${POOL} ${image}
209
210# failback
211demote_image ${CLUSTER1} ${POOL} ${image}
212wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
c07f9fc5
FG
213wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
214wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
7c673cae
FG
215promote_image ${CLUSTER2} ${POOL} ${image}
216wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
217write_image ${CLUSTER2} ${POOL} ${image} 100
218wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
9f95a23c 219wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
7c673cae
FG
220wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
221compare_images ${POOL} ${image}
222
223# force promote
224force_promote_image=test_force_promote
9f95a23c 225create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${force_promote_image}
7c673cae
FG
226write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100
227wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image}
228wait_for_image_replay_started ${CLUSTER1} ${POOL} ${force_promote_image}
229wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${force_promote_image}
9f95a23c 230wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+replaying'
7c673cae
FG
231wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped'
232promote_image ${CLUSTER1} ${POOL} ${force_promote_image} '--force'
233wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${force_promote_image}
234wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image}
235wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+stopped'
236wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped'
237write_image ${CLUSTER1} ${POOL} ${force_promote_image} 100
238write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100
a4b75251
TL
239remove_image_retry ${CLUSTER1} ${POOL} ${force_promote_image}
240remove_image_retry ${CLUSTER2} ${POOL} ${force_promote_image}
7c673cae
FG
241
242testlog "TEST: cloned images"
92f5a8d4 243testlog " - default"
7c673cae
FG
244parent_image=test_parent
245parent_snap=snap
9f95a23c 246create_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image}
7c673cae
FG
247write_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} 100
248create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
249protect_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
250
251clone_image=test_clone
252clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}
253write_image ${CLUSTER2} ${POOL} ${clone_image} 100
9f95a23c 254enable_mirror ${CLUSTER2} ${POOL} ${clone_image} snapshot
7c673cae 255
7c673cae
FG
256wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} ${parent_image}
257wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${parent_image}
9f95a23c 258wait_for_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying'
7c673cae
FG
259compare_images ${PARENT_POOL} ${parent_image}
260
261wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}
262wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image}
9f95a23c 263wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying'
7c673cae 264compare_images ${POOL} ${clone_image}
a4b75251 265remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}
7c673cae 266
92f5a8d4 267testlog " - clone v1"
9f95a23c
TL
268clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \
269 ${parent_snap} ${POOL} ${clone_image}1
7c673cae 270
9f95a23c
TL
271clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \
272 ${parent_snap} ${POOL} ${clone_image}_v1 snapshot --rbd-default-clone-format 1
92f5a8d4
TL
273test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v1) = 1
274wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v1
275test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v1) = 1
a4b75251
TL
276remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}_v1
277remove_image_retry ${CLUSTER1} ${POOL} ${clone_image}1
278unprotect_snapshot_retry ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
279remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
92f5a8d4
TL
280
281testlog " - clone v2"
282parent_snap=snap_v2
283create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
9f95a23c
TL
284mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image}
285clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \
286 ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2
92f5a8d4
TL
287test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v2) = 2
288wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v2
289test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v2) = 2
290
291remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
9f95a23c 292mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image}
92f5a8d4
TL
293test_snap_moved_to_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
294wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap}
295remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}_v2
296wait_for_image_present ${CLUSTER1} ${POOL} ${clone_image}_v2 'deleted'
297test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
298wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap}
299
300testlog " - clone v2 non-primary"
301create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
9f95a23c 302mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image}
92f5a8d4 303wait_for_snap_present ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap}
9f95a23c
TL
304clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \
305 ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2
92f5a8d4
TL
306remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
307test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
9f95a23c 308mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image}
92f5a8d4
TL
309wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap}
310remove_image_retry ${CLUSTER1} ${POOL} ${clone_image}_v2
311wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap}
a4b75251 312remove_image_retry ${CLUSTER2} ${PARENT_POOL} ${parent_image}
92f5a8d4 313
b5b8bbf5
FG
314testlog "TEST: data pool"
315dp_image=test_data_pool
9f95a23c 316create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL}
b5b8bbf5
FG
317data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL} ${dp_image})
318test "${data_pool}" = "${PARENT_POOL}"
319wait_for_image_replay_started ${CLUSTER1} ${POOL} ${dp_image}
320data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL} ${dp_image})
321test "${data_pool}" = "${PARENT_POOL}"
322create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap1'
323write_image ${CLUSTER2} ${POOL} ${dp_image} 100
324create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap2'
325write_image ${CLUSTER2} ${POOL} ${dp_image} 100
326wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${dp_image}
9f95a23c 327wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${dp_image} 'up+replaying'
b5b8bbf5
FG
328compare_images ${POOL} ${dp_image}@snap1
329compare_images ${POOL} ${dp_image}@snap2
330compare_images ${POOL} ${dp_image}
a4b75251 331remove_image_retry ${CLUSTER2} ${POOL} ${dp_image}
b5b8bbf5 332
7c673cae
FG
333testlog "TEST: disable mirroring / delete non-primary image"
334image2=test2
335image3=test3
336image4=test4
337image5=test5
338for i in ${image2} ${image3} ${image4} ${image5}; do
9f95a23c 339 create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${i}
7c673cae
FG
340 write_image ${CLUSTER2} ${POOL} ${i} 100
341 create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
342 create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
343 if [ "${i}" = "${image4}" ] || [ "${i}" = "${image5}" ]; then
344 protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
345 protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
346 fi
347 write_image ${CLUSTER2} ${POOL} ${i} 100
9f95a23c 348 mirror_image_snapshot ${CLUSTER2} ${POOL} ${i}
7c673cae
FG
349 wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'present'
350 wait_for_snap_present ${CLUSTER1} ${POOL} ${i} 'snap2'
351done
352
353set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image'
354for i in ${image2} ${image4}; do
355 disable_mirror ${CLUSTER2} ${POOL} ${i}
356done
357
358unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap1'
359unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap2'
360for i in ${image3} ${image5}; do
361 remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
362 remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
363 remove_image_retry ${CLUSTER2} ${POOL} ${i}
364done
365
366for i in ${image2} ${image3} ${image4} ${image5}; do
367 wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'deleted'
368done
369
7c673cae
FG
370testlog "TEST: snapshot rename"
371snap_name='snap_rename'
9f95a23c 372enable_mirror ${CLUSTER2} ${POOL} ${image2}
7c673cae
FG
373create_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_0"
374for i in `seq 1 20`; do
375 rename_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_$(expr ${i} - 1)" "${snap_name}_${i}"
376done
9f95a23c 377mirror_image_snapshot ${CLUSTER2} ${POOL} ${image2}
7c673cae
FG
378wait_for_snap_present ${CLUSTER1} ${POOL} ${image2} "${snap_name}_${i}"
379
a4b75251
TL
380unprotect_snapshot ${CLUSTER2} ${POOL} ${image4} 'snap1'
381unprotect_snapshot ${CLUSTER2} ${POOL} ${image4} 'snap2'
382for i in ${image2} ${image4}; do
383 remove_image_retry ${CLUSTER2} ${POOL} ${i}
384done
385
7c673cae 386testlog "TEST: disable mirror while daemon is stopped"
11fdf7f2
TL
387stop_mirrors ${CLUSTER1}
388stop_mirrors ${CLUSTER2}
7c673cae
FG
389disable_mirror ${CLUSTER2} ${POOL} ${image}
390if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
391 test_image_present ${CLUSTER1} ${POOL} ${image} 'present'
392fi
11fdf7f2 393start_mirrors ${CLUSTER1}
7c673cae 394wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
9f95a23c 395enable_mirror ${CLUSTER2} ${POOL} ${image}
7c673cae
FG
396wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
397wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
398
9f95a23c
TL
399testlog "TEST: non-default namespace image mirroring"
400testlog " - replay"
401create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${image}
402create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image}
403wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${image}
404wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS2} ${image}
405write_image ${CLUSTER2} ${POOL}/${NS1} ${image} 100
406write_image ${CLUSTER2} ${POOL}/${NS2} ${image} 100
407wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${image}
408wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS2} ${image}
409wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${image} 'up+replaying'
410wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS2} ${image} 'up+replaying'
411compare_images ${POOL}/${NS1} ${image}
412compare_images ${POOL}/${NS2} ${image}
413
414testlog " - disable mirroring / delete image"
415remove_image_retry ${CLUSTER2} ${POOL}/${NS1} ${image}
416disable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image}
417wait_for_image_present ${CLUSTER1} ${POOL}/${NS1} ${image} 'deleted'
418wait_for_image_present ${CLUSTER1} ${POOL}/${NS2} ${image} 'deleted'
a4b75251 419remove_image_retry ${CLUSTER2} ${POOL}/${NS2} ${image}
9f95a23c
TL
420
421testlog " - data pool"
422dp_image=test_data_pool
423create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL}
424data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL}/${NS1} ${dp_image})
425test "${data_pool}" = "${PARENT_POOL}"
426wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${dp_image}
427data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL}/${NS1} ${dp_image})
428test "${data_pool}" = "${PARENT_POOL}"
429write_image ${CLUSTER2} ${POOL}/${NS1} ${dp_image} 100
430wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${dp_image}
431wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${dp_image} 'up+replaying'
432compare_images ${POOL}/${NS1} ${dp_image}
a4b75251 433remove_image_retry ${CLUSTER2} ${POOL}/${NS1} ${dp_image}
9f95a23c 434
7c673cae
FG
435testlog "TEST: simple image resync"
436request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
437wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 438wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae 439wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
9f95a23c 440wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
7c673cae
FG
441compare_images ${POOL} ${image}
442
11fdf7f2 443if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
9f95a23c 444 testlog "TEST: image resync while replayer is stopped"
11fdf7f2
TL
445 admin_daemons ${CLUSTER1} rbd mirror stop ${POOL}/${image}
446 wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
447 request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
448 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
449 wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
450 admin_daemons ${CLUSTER1} rbd mirror start ${POOL}/${image}
451 wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
452 wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
9f95a23c 453 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
11fdf7f2
TL
454 compare_images ${POOL} ${image}
455fi
7c673cae
FG
456
457testlog "TEST: request image resync while daemon is offline"
11fdf7f2 458stop_mirrors ${CLUSTER1}
7c673cae 459request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
11fdf7f2 460start_mirrors ${CLUSTER1}
7c673cae 461wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id}
d2e6a577 462wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
7c673cae 463wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
9f95a23c 464wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
7c673cae 465compare_images ${POOL} ${image}
a4b75251 466remove_image_retry ${CLUSTER2} ${POOL} ${image}
7c673cae 467
7c673cae
FG
468testlog "TEST: split-brain"
469image=split-brain
9f95a23c
TL
470create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image}
471wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
b32b8144
FG
472promote_image ${CLUSTER1} ${POOL} ${image} --force
473wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
474wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
7c673cae
FG
475write_image ${CLUSTER1} ${POOL} ${image} 10
476demote_image ${CLUSTER1} ${POOL} ${image}
7c673cae
FG
477wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'split-brain'
478request_resync_image ${CLUSTER1} ${POOL} ${image} image_id
9f95a23c 479wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
a4b75251
TL
480remove_image_retry ${CLUSTER2} ${POOL} ${image}
481
482testlog "TEST: check if removed images' OMAP are removed"
483start_mirrors ${CLUSTER2}
484wait_for_image_in_omap ${CLUSTER1} ${POOL}
485wait_for_image_in_omap ${CLUSTER2} ${POOL}
7c673cae 486
11fdf7f2
TL
487if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then
488 # teuthology will trash the daemon
f67539c2
TL
489 testlog "TEST: no blocklists"
490 CEPH_ARGS='--id admin' ceph --cluster ${CLUSTER1} osd blocklist ls 2>&1 | grep -q "listed 0 entries"
491 CEPH_ARGS='--id admin' ceph --cluster ${CLUSTER2} osd blocklist ls 2>&1 | grep -q "listed 0 entries"
11fdf7f2 492fi