]>
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 | |
3efd9988 FG |
125 | testlog "TEST: test image rename" |
126 | new_name="${image}_RENAMED" | |
127 | rename_image ${CLUSTER2} ${POOL} ${image} ${new_name} | |
9f95a23c | 128 | mirror_image_snapshot ${CLUSTER2} ${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' | |
11fdf7f2 TL |
131 | admin_daemons ${CLUSTER1} rbd mirror status ${POOL}/${new_name} |
132 | admin_daemons ${CLUSTER1} rbd mirror restart ${POOL}/${new_name} | |
3efd9988 FG |
133 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${new_name} |
134 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${new_name} 'up+replaying' | |
135 | rename_image ${CLUSTER2} ${POOL} ${new_name} ${image} | |
9f95a23c | 136 | mirror_image_snapshot ${CLUSTER2} ${POOL} ${image} |
3efd9988 FG |
137 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
138 | ||
11fdf7f2 TL |
139 | testlog "TEST: test trash move restore" |
140 | image_id=$(get_image_id ${CLUSTER2} ${POOL} ${image}) | |
141 | trash_move ${CLUSTER2} ${POOL} ${image} | |
142 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' | |
143 | trash_restore ${CLUSTER2} ${POOL} ${image_id} | |
9f95a23c | 144 | enable_mirror ${CLUSTER2} ${POOL} ${image} snapshot |
11fdf7f2 TL |
145 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
146 | ||
7c673cae | 147 | testlog "TEST: failover and failback" |
11fdf7f2 | 148 | start_mirrors ${CLUSTER2} |
7c673cae FG |
149 | |
150 | # demote and promote same cluster | |
151 | demote_image ${CLUSTER2} ${POOL} ${image} | |
152 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
153 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
154 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
155 | promote_image ${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 ${CLUSTER2} ${POOL} ${image} 'up+stopped' | |
9f95a23c | 160 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
161 | compare_images ${POOL} ${image} |
162 | ||
163 | # failover (unmodified) | |
164 | demote_image ${CLUSTER2} ${POOL} ${image} | |
165 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
166 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
167 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
168 | promote_image ${CLUSTER1} ${POOL} ${image} |
169 | wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image} | |
170 | ||
171 | # failback (unmodified) | |
172 | demote_image ${CLUSTER1} ${POOL} ${image} | |
173 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image} | |
c07f9fc5 FG |
174 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
175 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
176 | promote_image ${CLUSTER2} ${POOL} ${image} |
177 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
178 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 179 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
180 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' |
181 | compare_images ${POOL} ${image} | |
182 | ||
183 | # failover | |
184 | demote_image ${CLUSTER2} ${POOL} ${image} | |
185 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
c07f9fc5 FG |
186 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
187 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
188 | promote_image ${CLUSTER1} ${POOL} ${image} |
189 | wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image} | |
190 | write_image ${CLUSTER1} ${POOL} ${image} 100 | |
191 | wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image} | |
192 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' | |
9f95a23c | 193 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
194 | compare_images ${POOL} ${image} |
195 | ||
196 | # failback | |
197 | demote_image ${CLUSTER1} ${POOL} ${image} | |
198 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image} | |
c07f9fc5 FG |
199 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown' |
200 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown' | |
7c673cae FG |
201 | promote_image ${CLUSTER2} ${POOL} ${image} |
202 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
203 | write_image ${CLUSTER2} ${POOL} ${image} 100 | |
204 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} | |
9f95a23c | 205 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
206 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' |
207 | compare_images ${POOL} ${image} | |
208 | ||
209 | # force promote | |
210 | force_promote_image=test_force_promote | |
9f95a23c | 211 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${force_promote_image} |
7c673cae FG |
212 | write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 |
213 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} | |
214 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${force_promote_image} | |
215 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${force_promote_image} | |
9f95a23c | 216 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+replaying' |
7c673cae FG |
217 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' |
218 | promote_image ${CLUSTER1} ${POOL} ${force_promote_image} '--force' | |
219 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${force_promote_image} | |
220 | wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} | |
221 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+stopped' | |
222 | wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' | |
223 | write_image ${CLUSTER1} ${POOL} ${force_promote_image} 100 | |
224 | write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 | |
225 | ||
226 | testlog "TEST: cloned images" | |
92f5a8d4 | 227 | testlog " - default" |
7c673cae FG |
228 | parent_image=test_parent |
229 | parent_snap=snap | |
9f95a23c | 230 | create_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
7c673cae FG |
231 | write_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} 100 |
232 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
233 | protect_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
234 | ||
235 | clone_image=test_clone | |
236 | clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image} | |
237 | write_image ${CLUSTER2} ${POOL} ${clone_image} 100 | |
9f95a23c | 238 | enable_mirror ${CLUSTER2} ${POOL} ${clone_image} snapshot |
7c673cae | 239 | |
7c673cae FG |
240 | wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} ${parent_image} |
241 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${parent_image} | |
9f95a23c | 242 | wait_for_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying' |
7c673cae FG |
243 | compare_images ${PARENT_POOL} ${parent_image} |
244 | ||
245 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image} | |
246 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image} | |
9f95a23c | 247 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' |
7c673cae FG |
248 | compare_images ${POOL} ${clone_image} |
249 | ||
92f5a8d4 | 250 | testlog " - clone v1" |
9f95a23c TL |
251 | clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \ |
252 | ${parent_snap} ${POOL} ${clone_image}1 | |
7c673cae | 253 | |
9f95a23c TL |
254 | clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \ |
255 | ${parent_snap} ${POOL} ${clone_image}_v1 snapshot --rbd-default-clone-format 1 | |
92f5a8d4 TL |
256 | test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v1) = 1 |
257 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v1 | |
258 | test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v1) = 1 | |
259 | ||
260 | testlog " - clone v2" | |
261 | parent_snap=snap_v2 | |
262 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c TL |
263 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
264 | clone_image_and_enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} \ | |
265 | ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2 | |
92f5a8d4 TL |
266 | test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v2) = 2 |
267 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v2 | |
268 | test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v2) = 2 | |
269 | ||
270 | remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 271 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 TL |
272 | test_snap_moved_to_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} |
273 | wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
274 | remove_image_retry ${CLUSTER2} ${POOL} ${clone_image}_v2 | |
275 | wait_for_image_present ${CLUSTER1} ${POOL} ${clone_image}_v2 'deleted' | |
276 | test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
277 | wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
278 | ||
279 | testlog " - clone v2 non-primary" | |
280 | create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 281 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 | 282 | wait_for_snap_present ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} |
9f95a23c TL |
283 | clone_image_and_enable_mirror ${CLUSTER1} ${PARENT_POOL} ${parent_image} \ |
284 | ${parent_snap} ${POOL} ${clone_image}_v2 snapshot --rbd-default-clone-format 2 | |
92f5a8d4 TL |
285 | remove_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} |
286 | test_snap_removed_from_trash ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
9f95a23c | 287 | mirror_image_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} |
92f5a8d4 TL |
288 | wait_for_snap_moved_to_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} |
289 | remove_image_retry ${CLUSTER1} ${POOL} ${clone_image}_v2 | |
290 | wait_for_snap_removed_from_trash ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} | |
291 | ||
b5b8bbf5 FG |
292 | testlog "TEST: data pool" |
293 | dp_image=test_data_pool | |
9f95a23c | 294 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL} |
b5b8bbf5 FG |
295 | data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL} ${dp_image}) |
296 | test "${data_pool}" = "${PARENT_POOL}" | |
297 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${dp_image} | |
298 | data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL} ${dp_image}) | |
299 | test "${data_pool}" = "${PARENT_POOL}" | |
300 | create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap1' | |
301 | write_image ${CLUSTER2} ${POOL} ${dp_image} 100 | |
302 | create_snapshot ${CLUSTER2} ${POOL} ${dp_image} 'snap2' | |
303 | write_image ${CLUSTER2} ${POOL} ${dp_image} 100 | |
304 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${dp_image} | |
9f95a23c | 305 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${dp_image} 'up+replaying' |
b5b8bbf5 FG |
306 | compare_images ${POOL} ${dp_image}@snap1 |
307 | compare_images ${POOL} ${dp_image}@snap2 | |
308 | compare_images ${POOL} ${dp_image} | |
309 | ||
7c673cae FG |
310 | testlog "TEST: disable mirroring / delete non-primary image" |
311 | image2=test2 | |
312 | image3=test3 | |
313 | image4=test4 | |
314 | image5=test5 | |
315 | for 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' | |
328 | done | |
329 | ||
330 | set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image' | |
331 | for i in ${image2} ${image4}; do | |
332 | disable_mirror ${CLUSTER2} ${POOL} ${i} | |
333 | done | |
334 | ||
335 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap1' | |
336 | unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap2' | |
337 | for 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} | |
341 | done | |
342 | ||
343 | for i in ${image2} ${image3} ${image4} ${image5}; do | |
344 | wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'deleted' | |
345 | done | |
346 | ||
7c673cae FG |
347 | testlog "TEST: snapshot rename" |
348 | snap_name='snap_rename' | |
9f95a23c | 349 | enable_mirror ${CLUSTER2} ${POOL} ${image2} |
7c673cae FG |
350 | create_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_0" |
351 | for i in `seq 1 20`; do | |
352 | rename_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_$(expr ${i} - 1)" "${snap_name}_${i}" | |
353 | done | |
9f95a23c | 354 | mirror_image_snapshot ${CLUSTER2} ${POOL} ${image2} |
7c673cae FG |
355 | wait_for_snap_present ${CLUSTER1} ${POOL} ${image2} "${snap_name}_${i}" |
356 | ||
357 | testlog "TEST: disable mirror while daemon is stopped" | |
11fdf7f2 TL |
358 | stop_mirrors ${CLUSTER1} |
359 | stop_mirrors ${CLUSTER2} | |
7c673cae FG |
360 | disable_mirror ${CLUSTER2} ${POOL} ${image} |
361 | if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then | |
362 | test_image_present ${CLUSTER1} ${POOL} ${image} 'present' | |
363 | fi | |
11fdf7f2 | 364 | start_mirrors ${CLUSTER1} |
7c673cae | 365 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' |
9f95a23c | 366 | enable_mirror ${CLUSTER2} ${POOL} ${image} |
7c673cae FG |
367 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
368 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} | |
369 | ||
9f95a23c TL |
370 | testlog "TEST: non-default namespace image mirroring" |
371 | testlog " - replay" | |
372 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${image} | |
373 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image} | |
374 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${image} | |
375 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS2} ${image} | |
376 | write_image ${CLUSTER2} ${POOL}/${NS1} ${image} 100 | |
377 | write_image ${CLUSTER2} ${POOL}/${NS2} ${image} 100 | |
378 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${image} | |
379 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS2} ${image} | |
380 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${image} 'up+replaying' | |
381 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS2} ${image} 'up+replaying' | |
382 | compare_images ${POOL}/${NS1} ${image} | |
383 | compare_images ${POOL}/${NS2} ${image} | |
384 | ||
385 | testlog " - disable mirroring / delete image" | |
386 | remove_image_retry ${CLUSTER2} ${POOL}/${NS1} ${image} | |
387 | disable_mirror ${CLUSTER2} ${POOL}/${NS2} ${image} | |
388 | wait_for_image_present ${CLUSTER1} ${POOL}/${NS1} ${image} 'deleted' | |
389 | wait_for_image_present ${CLUSTER1} ${POOL}/${NS2} ${image} 'deleted' | |
390 | ||
391 | testlog " - data pool" | |
392 | dp_image=test_data_pool | |
393 | create_image_and_enable_mirror ${CLUSTER2} ${POOL}/${NS1} ${dp_image} snapshot 128 --data-pool ${PARENT_POOL} | |
394 | data_pool=$(get_image_data_pool ${CLUSTER2} ${POOL}/${NS1} ${dp_image}) | |
395 | test "${data_pool}" = "${PARENT_POOL}" | |
396 | wait_for_image_replay_started ${CLUSTER1} ${POOL}/${NS1} ${dp_image} | |
397 | data_pool=$(get_image_data_pool ${CLUSTER1} ${POOL}/${NS1} ${dp_image}) | |
398 | test "${data_pool}" = "${PARENT_POOL}" | |
399 | write_image ${CLUSTER2} ${POOL}/${NS1} ${dp_image} 100 | |
400 | wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL}/${NS1} ${dp_image} | |
401 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL}/${NS1} ${dp_image} 'up+replaying' | |
402 | compare_images ${POOL}/${NS1} ${dp_image} | |
403 | ||
7c673cae FG |
404 | testlog "TEST: simple image resync" |
405 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id | |
406 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} | |
d2e6a577 | 407 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
7c673cae | 408 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
9f95a23c | 409 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
410 | compare_images ${POOL} ${image} |
411 | ||
11fdf7f2 | 412 | if [ -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} |
424 | fi | |
7c673cae FG |
425 | |
426 | testlog "TEST: request image resync while daemon is offline" | |
11fdf7f2 | 427 | stop_mirrors ${CLUSTER1} |
7c673cae | 428 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id |
11fdf7f2 | 429 | start_mirrors ${CLUSTER1} |
7c673cae | 430 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} |
d2e6a577 | 431 | wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' |
7c673cae | 432 | wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} |
9f95a23c | 433 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae FG |
434 | compare_images ${POOL} ${image} |
435 | ||
7c673cae FG |
436 | testlog "TEST: split-brain" |
437 | image=split-brain | |
9f95a23c TL |
438 | create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${image} |
439 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' | |
b32b8144 FG |
440 | promote_image ${CLUSTER1} ${POOL} ${image} --force |
441 | wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} | |
442 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' | |
7c673cae FG |
443 | write_image ${CLUSTER1} ${POOL} ${image} 10 |
444 | demote_image ${CLUSTER1} ${POOL} ${image} | |
7c673cae FG |
445 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'split-brain' |
446 | request_resync_image ${CLUSTER1} ${POOL} ${image} image_id | |
9f95a23c | 447 | wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' |
7c673cae | 448 | |
11fdf7f2 TL |
449 | if [ -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" | |
454 | fi |