From c23f56b9835f4e59d72f20a2218de8236574e65f Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sun, 27 Nov 2016 16:27:51 +0200 Subject: [PATCH] qa/workunits/rbd: use image id when probing for image presence This fixes a race in resync tests leading to false negative results. Fixes: http://tracker.ceph.com/issues/18048 Signed-off-by: Mykola Golub --- qa/workunits/rbd/rbd_mirror.sh | 18 ++++++++--------- qa/workunits/rbd/rbd_mirror_helpers.sh | 28 ++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index d1a963292a911..ee5755caac178 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -267,8 +267,8 @@ wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present' wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} testlog "TEST: simple image resync" -request_resync_image ${CLUSTER1} ${POOL} ${image} -wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' +request_resync_image ${CLUSTER1} ${POOL} ${image} image_id +wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' compare_images ${POOL} ${image} @@ -276,9 +276,9 @@ compare_images ${POOL} ${image} testlog "TEST: image resync while replayer is stopped" admin_daemon ${CLUSTER1} rbd mirror stop ${POOL}/${image} wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} -request_resync_image ${CLUSTER1} ${POOL} ${image} +request_resync_image ${CLUSTER1} ${POOL} ${image} image_id admin_daemon ${CLUSTER1} rbd mirror start ${POOL}/${image} -wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' +wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} admin_daemon ${CLUSTER1} rbd mirror start ${POOL}/${image} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' @@ -286,7 +286,7 @@ compare_images ${POOL} ${image} testlog "TEST: request image resync while daemon is offline" stop_mirror ${CLUSTER1} -request_resync_image ${CLUSTER1} ${POOL} ${image} +request_resync_image ${CLUSTER1} ${POOL} ${image} image_id start_mirror ${CLUSTER1} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+replaying' 'master_position' @@ -307,8 +307,8 @@ wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' testlog " - replay started after resync requested" -request_resync_image ${CLUSTER1} ${POOL} ${image} -wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' +request_resync_image ${CLUSTER1} ${POOL} ${image} image_id +wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})" @@ -332,8 +332,8 @@ wait_for_image_replay_stopped ${CLUSTER1} ${POOL} ${image} wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${image} 'up+error' 'disconnected' testlog " - replay started after resync requested" -request_resync_image ${CLUSTER1} ${POOL} ${image} -wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' +request_resync_image ${CLUSTER1} ${POOL} ${image} image_id +wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted' ${image_id} wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image} wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${image} test -n "$(get_mirror_position ${CLUSTER2} ${POOL} ${image})" diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index 44377f73e347d..6f51ca97dbc52 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -746,9 +746,13 @@ test_image_present() local pool=$2 local image=$3 local test_state=$4 + local image_id=$5 local current_state=deleted + local current_image_id - rbd --cluster=${cluster} -p ${pool} ls | grep "^${image}$" && + current_image_id=$(get_image_id ${cluster} ${pool} ${image}) + test -n "${current_image_id}" && + test -z "${image_id}" -o "${image_id}" = "${current_image_id}" && current_state=present test "${test_state}" = "${current_state}" @@ -760,21 +764,41 @@ wait_for_image_present() local pool=$2 local image=$3 local state=$4 + local image_id=$5 local s + test -n "${image_id}" || + image_id=$(get_image_id ${cluster} ${pool} ${image}) + # TODO: add a way to force rbd-mirror to update replayers for s in 0.1 1 2 4 8 8 8 8 8 8 8 8 16 16 32 32; do sleep ${s} - test_image_present "${cluster}" "${pool}" "${image}" "${state}" && return 0 + test_image_present \ + "${cluster}" "${pool}" "${image}" "${state}" "${image_id}" && + return 0 done return 1 } +get_image_id() +{ + local cluster=$1 + local pool=$2 + local image=$3 + + rbd --cluster=${cluster} -p ${pool} info ${image} | + sed -ne 's/^.*block_name_prefix: rbd_data\.//p' +} + request_resync_image() { local cluster=$1 local pool=$2 local image=$3 + local image_id_var_name=$1 + + eval "${image_id_var_name}='$(get_image_id ${cluster} ${pool} ${image})'" + eval 'test -n "$'${image_id_var_name}'"' rbd --cluster=${cluster} -p ${pool} mirror image resync ${image} } -- 2.39.5