]>
Commit | Line | Data |
---|---|---|
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 |
10 | MIRROR_POOL_MODE=image |
11 | MIRROR_IMAGE_MODE=snapshot | |
12 | ||
7c673cae FG |
13 | . $(dirname $0)/rbd_mirror_helpers.sh |
14 | ||
11fdf7f2 TL |
15 | setup |
16 | ||
7c673cae | 17 | testlog "TEST: add image and test replay" |
11fdf7f2 | 18 | start_mirrors ${CLUSTER1} |
7c673cae | 19 | image=test |
9f95a23c | 20 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image} |
b32b8144 FG |
21 | set_image_meta ${CLUSTER2} ${POOL} ${image} "key1" "value1" |
22 | set_image_meta ${CLUSTER2} ${POOL} ${image} "key2" "value2" | |
7c673cae FG |
23 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
24 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
25 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 26 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
27 | if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then |
28 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'down+unknown' | |
29 | fi | |
30 | compare_images ${POOL} ${image} | |
b32b8144 FG |
31 | compare_image_meta ${CLUSTER1} ${POOL} ${image} "key1" "value1" |
32 | compare_image_meta ${CLUSTER1} ${POOL} ${image} "key2" "value2" | |
7c673cae FG |
33 | |
34 | testlog "TEST: stop mirror, add image, start mirror and test replay" | |
11fdf7f2 | 35 | stop_mirrors ${CLUSTER1} |
7c673cae | 36 | image1=test1 |
9f95a23c | 37 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image1} |
7c673cae | 38 | write_image ${CLUSTER2} ${POOL} ${image1} 100 |
11fdf7f2 | 39 | start_mirrors ${CLUSTER1} |
7c673cae FG |
40 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1} |
41 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image1} | |
9f95a23c | 42 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying' |
7c673cae FG |
43 | if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then |
44 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image1} 'down+unknown' | |
45 | fi | |
46 | compare_images ${POOL} ${image1} | |
47 | ||
48 | testlog "TEST: test the first image is replaying after restart" | |
49 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
50 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
51 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 52 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
53 | compare_images ${POOL} ${image} |
54 | ||
11fdf7f2 TL |
55 | if [ -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 | |
123 | fi | |
7c673cae | 124 | |
a4b75251 TL |
125 | remove_image_retry ${CLUSTER2} ${POOL} ${image1} |
126 | ||
3efd9988 FG |
127 | testlog "TEST: test image rename" |
128 | new_name="${image}_RENAMED" | |
129 | rename_image ${CLUSTER2} ${POOL} ${image} ${new_name} | |
9f95a23c | 130 | mirror_image_snapshot ${CLUSTER2} ${POOL} ${new_name} |
3efd9988 FG |
131 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name} |
132 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying' | |
11fdf7f2 TL |
133 | admin_daemons ${CLUSTER1} rbd mirror status ${POOL}/${new_name} |
134 | admin_daemons ${CLUSTER1} rbd mirror restart ${POOL}/${new_name} | |
3efd9988 FG |
135 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name} |
136 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying' | |
137 | rename_image ${CLUSTER2} ${POOL} ${new_name} ${image} | |
9f95a23c | 138 | mirror_image_snapshot ${CLUSTER2} ${POOL} ${image} |
3efd9988 FG |
139 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
140 | ||
11fdf7f2 TL |
141 | testlog "TEST: test trash move restore" |
142 | image_id=$(get_image_id ${CLUSTER2} ${POOL} ${image}) | |
143 | trash_move ${CLUSTER2} ${POOL} ${image} | |
144 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' | |
145 | trash_restore ${CLUSTER2} ${POOL} ${image_id} | |
9f95a23c | 146 | enable_mirror ${CLUSTER2} ${POOL} ${image} snapshot |
11fdf7f2 TL |
147 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
148 | ||
a4b75251 TL |
149 | testlog "TEST: check if removed images' OMAP are removed (with rbd-mirror on one cluster)" |
150 | remove_image_retry ${CLUSTER2} ${POOL} ${image} | |
151 | ||
152 | wait_for_image_in_omap ${CLUSTER1} ${POOL} | |
153 | wait_for_image_in_omap ${CLUSTER2} ${POOL} | |
154 | ||
155 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image} | |
156 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
157 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
158 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
159 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' | |
160 | ||
7c673cae | 161 | testlog "TEST: failover and failback" |
11fdf7f2 | 162 | start_mirrors ${CLUSTER2} |
7c673cae FG |
163 | |
164 | # demote and promote same cluster | |
165 | demote_image ${CLUSTER2} ${POOL} ${image} | |
166 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
167 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
168 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
169 | promote_image ${CLUSTER2} ${POOL} ${image} |
170 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
171 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
172 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
173 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' | |
9f95a23c | 174 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
175 | compare_images ${POOL} ${image} |
176 | ||
177 | # failover (unmodified) | |
178 | demote_image ${CLUSTER2} ${POOL} ${image} | |
179 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
180 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
181 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
182 | promote_image ${CLUSTER1} ${POOL} ${image} |
183 | wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image} | |
184 | ||
185 | # failback (unmodified) | |
186 | demote_image ${CLUSTER1} ${POOL} ${image} | |
187 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image} | |
c07f9fc5 FG |
188 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
189 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
190 | promote_image ${CLUSTER2} ${POOL} ${image} |
191 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
192 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 193 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
194 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' |
195 | compare_images ${POOL} ${image} | |
196 | ||
197 | # failover | |
198 | demote_image ${CLUSTER2} ${POOL} ${image} | |
199 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
200 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
201 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
202 | promote_image ${CLUSTER1} ${POOL} ${image} |
203 | wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image} | |
204 | write_image ${CLUSTER1} ${POOL} ${image} 100 | |
205 | wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image} | |
206 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' | |
9f95a23c | 207 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
208 | compare_images ${POOL} ${image} |
209 | ||
210 | # failback | |
211 | demote_image ${CLUSTER1} ${POOL} ${image} | |
212 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image} | |
c07f9fc5 FG |
213 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
214 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
215 | promote_image ${CLUSTER2} ${POOL} ${image} |
216 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
217 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
218 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 219 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
220 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' |
221 | compare_images ${POOL} ${image} | |
222 | ||
223 | # force promote | |
224 | force_promote_image=test_force_promote | |
9f95a23c | 225 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${force_promote_image} |
7c673cae FG |
226 | write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 |
227 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} | |
228 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${force_promote_image} | |
229 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${force_promote_image} | |
9f95a23c | 230 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+replaying' |
7c673cae FG |
231 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' |
232 | promote_image ${CLUSTER1} ${POOL} ${force_promote_image} '--force' | |
233 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${force_promote_image} | |
234 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} | |
235 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+stopped' | |
236 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' | |
237 | write_image ${CLUSTER1} ${POOL} ${force_promote_image} 100 | |
238 | write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 | |
a4b75251 TL |
239 | remove_image_retry ${CLUSTER1} ${POOL} ${force_promote_image} |
240 | remove_image_retry ${CLUSTER2} ${POOL} ${force_promote_image} | |
7c673cae FG |
241 | |
242 | testlog "TEST: cloned images" | |
92f5a8d4 | 243 | testlog " - default" |
7c673cae FG |
244 | parent_image=test_parent |
245 | parent_snap=snap | |
9f95a23c | 246 | create_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
7c673cae FG |
247 | write_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} 100 |
248 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
249 | protect_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
250 | ||
251 | clone_image=test_clone | |
252 | clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image} | |
253 | write_image ${CLUSTER2} ${POOL} ${clone_image} 100 | |
9f95a23c | 254 | enable_mirror ${CLUSTER2} ${POOL} ${clone_image} snapshot |
7c673cae | 255 | |
7c673cae FG |
256 | wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} ${parent_image} |
257 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${parent_image} | |
9f95a23c | 258 | wait_for_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying' |
7c673cae FG |
259 | compare_images ${PARENT_POOL} ${parent_image} |
260 | ||
261 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image} | |
262 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image} | |
9f95a23c | 263 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' |
7c673cae | 264 | compare_images ${POOL} ${clone_image} |
a4b75251 | 265 | remove_image_retry ${CLUSTER2} ${POOL} ${clone_image} |
7c673cae | 266 | |
92f5a8d4 | 267 | testlog " - clone v1" |
9f95a23c TL |
268 | clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \ |
269 | ${parent_snap} ${POOL} ${clone_image}1 | |
7c673cae | 270 | |
9f95a23c TL |
271 | clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \ |
272 | ${parent_snap} ${POOL} ${clone_image}_v1 snapshot --rbd-default-clone-format 1 | |
92f5a8d4 TL |
273 | test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v1) = 1 |
274 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v1 | |
275 | test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v1) = 1 | |
a4b75251 TL |
276 | remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}_v1 |
277 | remove_image_retry ${CLUSTER1} ${POOL} ${clone_image}1 | |
278 | unprotect_snapshot_retry ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
279 | remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
92f5a8d4 TL |
280 | |
281 | testlog " - clone v2" | |
282 | parent_snap=snap_v2 | |
283 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c TL |
284 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
285 | clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \ | |
286 | ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2 | |
92f5a8d4 TL |
287 | test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v2) = 2 |
288 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v2 | |
289 | test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v2) = 2 | |
290 | ||
291 | remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 292 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 TL |
293 | test_snap_moved_to_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} |
294 | wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
295 | remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}_v2 | |
296 | wait_for_image_present ${CLUSTER1} ${POOL} ${clone_image}_v2 'deleted' | |
297 | test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
298 | wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
299 | ||
300 | testlog " - clone v2 non-primary" | |
301 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 302 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 | 303 | wait_for_snap_present ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} |
9f95a23c TL |
304 | clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \ |
305 | ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2 | |
92f5a8d4 TL |
306 | remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} |
307 | test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 308 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 TL |
309 | wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} |
310 | remove_image_retry ${CLUSTER1} ${POOL} ${clone_image}_v2 | |
311 | wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
a4b75251 | 312 | remove_image_retry ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 | 313 | |
b5b8bbf5 FG |
314 | testlog "TEST: data pool" |
315 | dp_image=test_data_pool | |
9f95a23c | 316 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL} |
b5b8bbf5 FG |
317 | data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL} ${dp_image}) |
318 | test "${data_pool}" = "${PARENT_POOL}" | |
319 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${dp_image} | |
320 | data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL} ${dp_image}) | |
321 | test "${data_pool}" = "${PARENT_POOL}" | |
322 | create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap1' | |
323 | write_image ${CLUSTER2} ${POOL} ${dp_image} 100 | |
324 | create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap2' | |
325 | write_image ${CLUSTER2} ${POOL} ${dp_image} 100 | |
326 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${dp_image} | |
9f95a23c | 327 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${dp_image} 'up+replaying' |
b5b8bbf5 FG |
328 | compare_images ${POOL} ${dp_image}@snap1 |
329 | compare_images ${POOL} ${dp_image}@snap2 | |
330 | compare_images ${POOL} ${dp_image} | |
a4b75251 | 331 | remove_image_retry ${CLUSTER2} ${POOL} ${dp_image} |
b5b8bbf5 | 332 | |
7c673cae FG |
333 | testlog "TEST: disable mirroring / delete non-primary image" |
334 | image2=test2 | |
335 | image3=test3 | |
336 | image4=test4 | |
337 | image5=test5 | |
338 | for 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' | |
351 | done | |
352 | ||
353 | set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image' | |
354 | for i in ${image2} ${image4}; do | |
355 | disable_mirror ${CLUSTER2} ${POOL} ${i} | |
356 | done | |
357 | ||
358 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap1' | |
359 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap2' | |
360 | for 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} | |
364 | done | |
365 | ||
366 | for i in ${image2} ${image3} ${image4} ${image5}; do | |
367 | wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'deleted' | |
368 | done | |
369 | ||
7c673cae FG |
370 | testlog "TEST: snapshot rename" |
371 | snap_name='snap_rename' | |
9f95a23c | 372 | enable_mirror ${CLUSTER2} ${POOL} ${image2} |
7c673cae FG |
373 | create_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_0" |
374 | for i in `seq 1 20`; do | |
375 | rename_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_$(expr ${i} - 1)" "${snap_name}_${i}" | |
376 | done | |
9f95a23c | 377 | mirror_image_snapshot ${CLUSTER2} ${POOL} ${image2} |
7c673cae FG |
378 | wait_for_snap_present ${CLUSTER1} ${POOL} ${image2} "${snap_name}_${i}" |
379 | ||
a4b75251 TL |
380 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image4} 'snap1' |
381 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image4} 'snap2' | |
382 | for i in ${image2} ${image4}; do | |
383 | remove_image_retry ${CLUSTER2} ${POOL} ${i} | |
384 | done | |
385 | ||
7c673cae | 386 | testlog "TEST: disable mirror while daemon is stopped" |
11fdf7f2 TL |
387 | stop_mirrors ${CLUSTER1} |
388 | stop_mirrors ${CLUSTER2} | |
7c673cae FG |
389 | disable_mirror ${CLUSTER2} ${POOL} ${image} |
390 | if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then | |
391 | test_image_present ${CLUSTER1} ${POOL} ${image} 'present' | |
392 | fi | |
11fdf7f2 | 393 | start_mirrors ${CLUSTER1} |
7c673cae | 394 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' |
9f95a23c | 395 | enable_mirror ${CLUSTER2} ${POOL} ${image} |
7c673cae FG |
396 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
397 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
398 | ||
9f95a23c TL |
399 | testlog "TEST: non-default namespace image mirroring" |
400 | testlog " - replay" | |
401 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${image} | |
402 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image} | |
403 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${image} | |
404 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS2} ${image} | |
405 | write_image ${CLUSTER2} ${POOL}/${NS1} ${image} 100 | |
406 | write_image ${CLUSTER2} ${POOL}/${NS2} ${image} 100 | |
407 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${image} | |
408 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS2} ${image} | |
409 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${image} 'up+replaying' | |
410 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS2} ${image} 'up+replaying' | |
411 | compare_images ${POOL}/${NS1} ${image} | |
412 | compare_images ${POOL}/${NS2} ${image} | |
413 | ||
414 | testlog " - disable mirroring / delete image" | |
415 | remove_image_retry ${CLUSTER2} ${POOL}/${NS1} ${image} | |
416 | disable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image} | |
417 | wait_for_image_present ${CLUSTER1} ${POOL}/${NS1} ${image} 'deleted' | |
418 | wait_for_image_present ${CLUSTER1} ${POOL}/${NS2} ${image} 'deleted' | |
a4b75251 | 419 | remove_image_retry ${CLUSTER2} ${POOL}/${NS2} ${image} |
9f95a23c TL |
420 | |
421 | testlog " - data pool" | |
422 | dp_image=test_data_pool | |
423 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL} | |
424 | data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL}/${NS1} ${dp_image}) | |
425 | test "${data_pool}" = "${PARENT_POOL}" | |
426 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${dp_image} | |
427 | data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL}/${NS1} ${dp_image}) | |
428 | test "${data_pool}" = "${PARENT_POOL}" | |
429 | write_image ${CLUSTER2} ${POOL}/${NS1} ${dp_image} 100 | |
430 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${dp_image} | |
431 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${dp_image} 'up+replaying' | |
432 | compare_images ${POOL}/${NS1} ${dp_image} | |
a4b75251 | 433 | remove_image_retry ${CLUSTER2} ${POOL}/${NS1} ${dp_image} |
9f95a23c | 434 | |
7c673cae FG |
435 | testlog "TEST: simple image resync" |
436 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id | |
437 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} | |
d2e6a577 | 438 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
7c673cae | 439 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
9f95a23c | 440 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
441 | compare_images ${POOL} ${image} |
442 | ||
11fdf7f2 | 443 | if [ -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} |
455 | fi | |
7c673cae FG |
456 | |
457 | testlog "TEST: request image resync while daemon is offline" | |
11fdf7f2 | 458 | stop_mirrors ${CLUSTER1} |
7c673cae | 459 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id |
11fdf7f2 | 460 | start_mirrors ${CLUSTER1} |
7c673cae | 461 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} |
d2e6a577 | 462 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
7c673cae | 463 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
9f95a23c | 464 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae | 465 | compare_images ${POOL} ${image} |
a4b75251 | 466 | remove_image_retry ${CLUSTER2} ${POOL} ${image} |
7c673cae | 467 | |
7c673cae FG |
468 | testlog "TEST: split-brain" |
469 | image=split-brain | |
9f95a23c TL |
470 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image} |
471 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' | |
b32b8144 FG |
472 | promote_image ${CLUSTER1} ${POOL} ${image} --force |
473 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
474 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' | |
7c673cae FG |
475 | write_image ${CLUSTER1} ${POOL} ${image} 10 |
476 | demote_image ${CLUSTER1} ${POOL} ${image} | |
7c673cae FG |
477 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'split-brain' |
478 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id | |
9f95a23c | 479 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
a4b75251 TL |
480 | remove_image_retry ${CLUSTER2} ${POOL} ${image} |
481 | ||
482 | testlog "TEST: check if removed images' OMAP are removed" | |
483 | start_mirrors ${CLUSTER2} | |
484 | wait_for_image_in_omap ${CLUSTER1} ${POOL} | |
485 | wait_for_image_in_omap ${CLUSTER2} ${POOL} | |
7c673cae | 486 | |
11fdf7f2 TL |
487 | if [ -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 | 492 | fi |