From: Prasanna Kumar Kalever Date: Mon, 31 Oct 2022 10:48:16 +0000 (+0530) Subject: qa/workunits/rbd: added tests for --snap-id X-Git-Tag: v17.2.6~177^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71910e7964c5256fac7f35bc1d5b81395aeeded4;p=ceph.git qa/workunits/rbd: added tests for --snap-id Fixes: https://tracker.ceph.com/issues/57902 Signed-off-by: Prasanna Kumar Kalever (cherry picked from commit 92480e65613e122925b1cc89d7835639cd62c7a5) --- diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index e5ded83b79f..1bac4061571 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -253,6 +253,13 @@ get_pid ${POOL} unmap_device "${IMAGE}@snap" ${PID} DEV= +# map/unmap snap test with --snap-id +SNAPID=`rbd snap ls ${POOL}/${IMAGE} | awk '$2 == "snap" {print $1}'` +DEV=`_sudo rbd device --device-type nbd map --snap-id ${SNAPID} ${POOL}/${IMAGE}` +get_pid ${POOL} +unmap_device "--snap-id ${SNAPID} ${IMAGE}" ${PID} +DEV= + # map/unmap namespace test rbd snap create ${POOL}/${NS}/${IMAGE}@snap DEV=`_sudo rbd device --device-type nbd map ${POOL}/${NS}/${IMAGE}@snap` @@ -260,6 +267,13 @@ get_pid ${POOL} ${NS} unmap_device "${POOL}/${NS}/${IMAGE}@snap" ${PID} DEV= +# map/unmap namespace test with --snap-id +SNAPID=`rbd snap ls ${POOL}/${NS}/${IMAGE} | awk '$2 == "snap" {print $1}'` +DEV=`_sudo rbd device --device-type nbd map --snap-id ${SNAPID} ${POOL}/${NS}/${IMAGE}` +get_pid ${POOL} ${NS} +unmap_device "--snap-id ${SNAPID} ${POOL}/${NS}/${IMAGE}" ${PID} +DEV= + # map/unmap namespace using options test DEV=`_sudo rbd device --device-type nbd map --pool ${POOL} --namespace ${NS} --image ${IMAGE}` get_pid ${POOL} ${NS} @@ -409,4 +423,21 @@ if [ -n "${COOKIE}" ]; then unmap_device ${DEV} ${PID} fi +# test detach/attach with --snap-id +SNAPID=`rbd snap ls ${POOL}/${IMAGE} | awk '$2 == "snap" {print $1}'` +OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map --snap-id ${SNAPID} ${POOL}/${IMAGE}` +read DEV COOKIE <<< "${OUT}" +get_pid ${POOL} +_sudo rbd device detach ${POOL}/${IMAGE} --snap-id ${SNAPID} --device-type nbd +expect_false get_pid ${POOL} +expect_false _sudo rbd device attach --device ${DEV} --snap-id ${SNAPID} ${POOL}/${IMAGE} --device-type nbd +if [ -n "${COOKIE}" ]; then + _sudo rbd device attach --device ${DEV} --cookie ${COOKIE} --snap-id ${SNAPID} ${POOL}/${IMAGE} --device-type nbd +else + _sudo rbd device attach --device ${DEV} --snap-id ${SNAPID} ${POOL}/${IMAGE} --device-type nbd --force +fi +get_pid ${POOL} +_sudo rbd device detach ${DEV} --device-type nbd +expect_false get_pid ${POOL} + echo OK