Skip to content

Commit 153df2d

Browse files
committed
qa: add "failover / failback loop" test for rbd-mirror
For snapshot-based mirroring, check that demote (or other mirror snapshots) don't pile up. Nothing in particular to assert on for journal-based mirroring but the test is still useful. Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 9c05d3d commit 153df2d

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

qa/workunits/rbd/rbd_mirror_helpers.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,16 @@ wait_for_snap_removed_from_trash()
11691169
return 1
11701170
}
11711171

1172+
count_mirror_snaps()
1173+
{
1174+
local cluster=$1
1175+
local pool=$2
1176+
local image=$3
1177+
1178+
rbd --cluster ${cluster} snap ls ${pool}/${image} --all |
1179+
grep -c -F " mirror ("
1180+
}
1181+
11721182
write_image()
11731183
{
11741184
local cluster=$1

qa/workunits/rbd/rbd_mirror_journal.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,29 @@ wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'primary
214214
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
215215
compare_images ${POOL} ${image}
216216

217-
# force promote
217+
testlog "TEST: failover / failback loop"
218+
for i in `seq 1 20`; do
219+
demote_image ${CLUSTER2} ${POOL} ${image}
220+
wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
221+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
222+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
223+
promote_image ${CLUSTER1} ${POOL} ${image}
224+
wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image}
225+
wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image}
226+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
227+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying'
228+
demote_image ${CLUSTER1} ${POOL} ${image}
229+
wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
230+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
231+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
232+
promote_image ${CLUSTER2} ${POOL} ${image}
233+
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
234+
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
235+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
236+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
237+
done
238+
239+
testlog "TEST: force promote"
218240
force_promote_image=test_force_promote
219241
create_image ${CLUSTER2} ${POOL} ${force_promote_image}
220242
write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100

qa/workunits/rbd/rbd_mirror_snapshot.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,32 @@ wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
220220
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
221221
compare_images ${POOL} ${image}
222222

223-
# force promote
223+
testlog "TEST: failover / failback loop"
224+
for i in `seq 1 20`; do
225+
demote_image ${CLUSTER2} ${POOL} ${image}
226+
wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image}
227+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
228+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
229+
promote_image ${CLUSTER1} ${POOL} ${image}
230+
wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image}
231+
wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image}
232+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped'
233+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying'
234+
demote_image ${CLUSTER1} ${POOL} ${image}
235+
wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image}
236+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+unknown'
237+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+unknown'
238+
promote_image ${CLUSTER2} ${POOL} ${image}
239+
wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
240+
wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image}
241+
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
242+
wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying'
243+
done
244+
# check that demote (or other mirror snapshots) don't pile up
245+
test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3
246+
test "$(count_mirror_snaps ${CLUSTER2} ${POOL} ${image})" -le 3
247+
248+
testlog "TEST: force promote"
224249
force_promote_image=test_force_promote
225250
create_image_and_enable_mirror ${CLUSTER2} ${POOL} ${force_promote_image}
226251
write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100

0 commit comments

Comments
 (0)