From 2ec5e93806f8487bdc5f8df23740aab5738cde1f Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 13 Sep 2016 12:32:45 -0400 Subject: [PATCH] qa/workunits/rbd: new mirroring forced promotion test Signed-off-by: Jason Dillaman (cherry picked from commit a43268a4a30c06233152d531cbf2550224fb8a15) --- qa/workunits/rbd/rbd_mirror.sh | 65 ++++++++++++++++---------- qa/workunits/rbd/rbd_mirror_helpers.sh | 18 ++++++- 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index 9047483f7a677..4ce92fc4eee99 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -21,9 +21,9 @@ create_image ${CLUSTER2} ${POOL} ${image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} write_image ${CLUSTER2} ${POOL} ${image} 100 wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then - test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'down+unknown' + wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'down+unknown' fi compare_images ${POOL} ${image} @@ -35,16 +35,16 @@ write_image ${CLUSTER2} ${POOL} ${image1} 100 start_mirror ${CLUSTER1} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image1} wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image1} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image1} 'up+replaying' 'master_position' if [ -z "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then - test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image1} 'down+unknown' + wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image1} 'down+unknown' fi compare_images ${POOL} ${image1} testlog "TEST: test the first image is replaying after restart" write_image ${CLUSTER2} ${POOL} ${image} 100 wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} testlog "TEST: stop/start/restart mirror via admin socket" @@ -96,41 +96,58 @@ start_mirror ${CLUSTER2} # demote and promote same cluster demote_image ${CLUSTER2} ${POOL} ${image} wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' promote_image ${CLUSTER2} ${POOL} ${image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} write_image ${CLUSTER2} ${POOL} ${image} 100 wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} # failover demote_image ${CLUSTER2} ${POOL} ${image} wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' promote_image ${CLUSTER1} ${POOL} ${image} wait_for_image_replay_started ${CLUSTER2} ${POOL} ${image} write_image ${CLUSTER1} ${POOL} ${image} 100 wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} # failback demote_image ${CLUSTER1} ${POOL} ${image} wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' promote_image ${CLUSTER2} ${POOL} ${image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} write_image ${CLUSTER2} ${POOL} ${image} 100 wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' -test_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped' compare_images ${POOL} ${image} +# force promote +force_promote_image=test_force_promote +create_image ${CLUSTER2} ${POOL} ${force_promote_image} +write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 +wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} +wait_for_image_replay_started ${CLUSTER1} ${POOL} ${force_promote_image} +wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${force_promote_image} +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' +promote_image ${CLUSTER1} ${POOL} ${force_promote_image} '--force' +wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${force_promote_image} +wait_for_image_replay_stopped ${CLUSTER2} ${POOL} ${force_promote_image} +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${force_promote_image} 'up+stopped' +wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${force_promote_image} 'up+stopped' +write_image ${CLUSTER1} ${POOL} ${force_promote_image} 100 +write_image ${CLUSTER2} ${POOL} ${force_promote_image} 100 + testlog "TEST: cloned images" parent_image=test_parent parent_snap=snap @@ -146,12 +163,12 @@ write_image ${CLUSTER2} ${POOL} ${clone_image} 100 enable_mirror ${CLUSTER2} ${PARENT_POOL} ${parent_image} wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} ${parent_image} wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} ${parent_image} -test_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${PARENT_POOL} ${parent_image} 'up+replaying' 'master_position' compare_images ${PARENT_POOL} ${parent_image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image} wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' 'master_position' compare_images ${POOL} ${clone_image} testlog "TEST: disable mirroring / delete non-primary image" @@ -225,7 +242,7 @@ testlog "TEST: simple image resync" request_resync_image ${CLUSTER1} ${POOL} ${image} wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} testlog "TEST: image resync while replayer is stopped" @@ -236,7 +253,7 @@ admin_daemon ${CLUSTER1} rbd mirror start ${POOL}/${image} wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' admin_daemon ${CLUSTER1} rbd mirror start ${POOL}/${image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} testlog "TEST: request image resync while daemon is offline" @@ -244,7 +261,7 @@ stop_mirror ${CLUSTER1} request_resync_image ${CLUSTER1} ${POOL} ${image} start_mirror ${CLUSTER1} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} testlog "TEST: client disconnect" @@ -259,7 +276,7 @@ test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})" disconnect_image ${CLUSTER2} ${POOL} ${image} test -z "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})" wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' testlog " - replay started after resync requested" request_resync_image ${CLUSTER1} ${POOL} ${image} @@ -284,7 +301,7 @@ set_image_meta ${CLUSTER2} ${POOL} ${image} \ testlog " - replay is still stopped (disconnected) after restart" admin_daemon ${CLUSTER1} rbd mirror start ${POOL}/${image} wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' testlog " - replay started after resync requested" request_resync_image ${CLUSTER1} ${POOL} ${image} @@ -308,6 +325,6 @@ set_image_meta ${CLUSTER1} ${POOL} ${image} \ disconnect_image ${CLUSTER2} ${POOL} ${image} test -z "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})" wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -test_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' +wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' echo OK diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index f8f2ccaece1a9..d7d06d7a7dac2 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -450,6 +450,21 @@ test_status_in_pool_dir() grep "description: .*${description_pattern}" ${status_log} } +wait_for_status_in_pool_dir() +{ + local cluster=$1 + local pool=$2 + local image=$3 + local state_pattern=$4 + local description_pattern=$5 + + for s in 1 2 4 8 8 8 8 8 8 8 8 16 16; do + sleep ${s} + test_status_in_pool_dir ${cluster} ${pool} ${image} ${state_pattern} ${description_pattern} && return 0 + done + return 1 +} + create_image() { local cluster=$1 ; shift @@ -655,8 +670,9 @@ promote_image() local cluster=$1 local pool=$2 local image=$3 + local force=$4 - rbd --cluster=${cluster} mirror image promote ${pool}/${image} + rbd --cluster=${cluster} mirror image promote ${pool}/${image} ${force} } set_pool_mirror_mode() -- 2.39.5