From: Mykola Golub Date: Sun, 27 Nov 2016 14:27:51 +0000 (+0200) Subject: qa/workunits/rbd: use image id when probing for image presence X-Git-Tag: v10.2.6~96^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f9a93c68947c05636a633c92dbbd69d2ed70c3d;p=ceph.git 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 (cherry picked from commit c23f56b9835f4e59d72f20a2218de8236574e65f) --- diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index 5fa138a697d7d..396600baa6fbe 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -255,8 +255,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} @@ -264,9 +264,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' @@ -274,7 +274,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' @@ -295,8 +295,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})" @@ -320,8 +320,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 a658da254d107..e9360e7170409 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -731,9 +731,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}" @@ -745,21 +749,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} }