From 92480e65613e122925b1cc89d7835639cd62c7a5 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Mon, 31 Oct 2022 16:18:16 +0530 Subject: [PATCH] qa/workunits/rbd: added tests for --snap-id Fixes: https://tracker.ceph.com/issues/57902 Signed-off-by: Prasanna Kumar Kalever --- qa/workunits/rbd/rbd-nbd.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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