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