From edeee514ec44861ac96123e4c940054bfddbdf58 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Mon, 19 Jun 2023 12:12:58 +0100 Subject: [PATCH 1/2] qa/iscsi_test: test also user:rbd (tcmu-runner) backstore Signed-off-by: Mykola Golub --- qa/common/common.sh | 117 +++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/qa/common/common.sh b/qa/common/common.sh index f50df724..38e953ce 100644 --- a/qa/common/common.sh +++ b/qa/common/common.sh @@ -1418,7 +1418,7 @@ function core_dump_test { function _iscsi_test { local client gw_name gw_ip gwcli name node rbd_pool rbd_image target used - local username password + local backstore i username password set -e set -x @@ -1439,7 +1439,6 @@ function _iscsi_test { client=$(sed -ne 's/^InitiatorName=//p' /etc/iscsi/initiatorname.iscsi) target=iqn.2023-01.com.suse.iscsi-gw:iscsi-igw rbd_pool=rbd - rbd_image=iscsi_disk_1 node=$(ceph orch ls --service-type iscsi --format json-pretty | jq -r '.[].placement.hosts[0]') gw_name=$(getent hosts ${node} | awk '{print $2}') @@ -1450,62 +1449,88 @@ function _iscsi_test { jq -r '.[] | select(.name | startswith("iscsi.")) | .name') test -n "${name}" - ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false - rbd info ${rbd_pool}/${rbd_image} && false - - gwcli="ssh ${node} cephadm enter --name "${name}" gwcli" - - ${gwcli} /iscsi-targets create ${target} - ${gwcli} /iscsi-targets/${target}/gateways create ${gw_name} ${gw_ip} skipchecks=true - ${gwcli} /disks create pool=${rbd_pool} image=${rbd_image} size=1G - ${gwcli} /iscsi-targets/${target}/hosts create ${client} - ${gwcli} /iscsi-targets/${target}/hosts/${client} auth username=${username} password=${password} - ${gwcli} /iscsi-targets/${target}/hosts/${client} disk add ${rbd_pool}/${rbd_image} - - ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" + for backstore in rbd user:rbd; do + rbd_image=iscsi_disk_${backstore%:*} + ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false + rbd info ${rbd_pool}/${rbd_image} && false + gwcli="ssh ${node} cephadm enter --name "${name}" gwcli" + + ${gwcli} /iscsi-targets create ${target} + ${gwcli} /iscsi-targets/${target}/gateways create ${gw_name} ${gw_ip} skipchecks=true + ${gwcli} /disks create pool=${rbd_pool} image=${rbd_image} size=1G backstore=${backstore} + ${gwcli} /iscsi-targets/${target}/hosts create ${client} + ${gwcli} /iscsi-targets/${target}/hosts/${client} auth username=${username} password=${password} + ${gwcli} /iscsi-targets/${target}/hosts/${client} disk add ${rbd_pool}/${rbd_image} + + rbd info ${rbd_pool}/${rbd_image} + + case ${backstore} in + rbd) + ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" + ;; + user:rbd) + ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false + ssh ${node} cat '/sys/devices/tcm_user/uio/uio*/name' | + grep "${rbd_pool}/${rbd_image}" + ;; + *) + false + ;; + esac - iscsiadm -m discovery -t st -p ${node} - test $(iscsiadm -m discovery -t st -p ${node} | awk '{print $2; exit}') = ${target} + iscsiadm -m discovery -t st -p ${node} + test $(iscsiadm -m discovery -t st -p ${node} | awk '{print $2; exit}') = ${target} - ! test -e /dev/sda + ! test -e /dev/sda - iscsiadm -m node -T ${target} -l + iscsiadm -m node -T ${target} -l - for i in `seq 10`; do - test -e /sys/block/sda/device/model && break - sleep 1 - done - test -e /dev/sda - test -e /sys/block/sda/device/model - test $(cat /sys/block/sda/device/model) = RBD + for i in `seq 10`; do + test -e /sys/block/sda/device/model && break + sleep 1 + done + test -e /dev/sda + test -e /sys/block/sda/device/model + case ${backstore} in + rbd) + grep RBD /sys/block/sda/device/model + ;; + user:rbd) + grep TCMU /sys/block/sda/device/model + ;; + *) + false + ;; + esac - rbd du ${rbd_pool}/${rbd_image} - used=$(rbd du ${rbd_pool}/${rbd_image} --format json | - jq -r ".images[0].used_size") - test ${used} -eq 0 + rbd du ${rbd_pool}/${rbd_image} + used=$(rbd du ${rbd_pool}/${rbd_image} --format json | + jq -r ".images[0].used_size") + test ${used} -eq 0 - dd if=/dev/urandom of=/tmp/test.dat bs=4M count=10 - dd if=/tmp/test.dat of=/dev/sda bs=4M count=10 + dd if=/dev/urandom of=/tmp/test.dat bs=4M count=10 + dd if=/tmp/test.dat of=/dev/sda bs=4M count=10 - test "$(dd if=/tmp/test.dat bs=4M count=10 | md5sum)" = \ - "$(dd if=/dev/sda bs=4M count=10 | md5sum)" + test "$(dd if=/tmp/test.dat bs=4M count=10 | md5sum)" = \ + "$(dd if=/dev/sda bs=4M count=10 | md5sum)" - rbd du ${rbd_pool}/${rbd_image} - used=$(rbd du ${rbd_pool}/${rbd_image} --format json | - jq -r ".images[0].used_size") - test ${used} -eq 41943040 + rbd du ${rbd_pool}/${rbd_image} + used=$(rbd du ${rbd_pool}/${rbd_image} --format json | + jq -r ".images[0].used_size") + test ${used} -eq 41943040 - iscsiadm -m node -T ${target} -u + iscsiadm -m node -T ${target} -u - ${gwcli} /iscsi-targets/${target}/hosts delete ${client} - ${gwcli} /iscsi-targets/${target}/disks delete ${rbd_pool}/${rbd_image} - ${gwcli} /iscsi-targets/${target}/gateways delete ${gw_name} confirm=true - ${gwcli} /iscsi-targets delete ${target} - ${gwcli} /disks detach ${rbd_pool}/${rbd_image} + ${gwcli} /iscsi-targets/${target}/hosts delete ${client} + ${gwcli} /iscsi-targets/${target}/disks delete ${rbd_pool}/${rbd_image} + ${gwcli} /iscsi-targets/${target}/gateways delete ${gw_name} confirm=true + ${gwcli} /iscsi-targets delete ${target} + ${gwcli} /disks detach ${rbd_pool}/${rbd_image} - ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false + ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false - rbd rm ${rbd_pool}/${rbd_image} + rbd rm ${rbd_pool}/${rbd_image} + done } function iscsi_test { From ca92fa06e8cfd1958234b93cdc5e550a52c9750f Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sat, 24 Jun 2023 09:05:57 +0100 Subject: [PATCH 2/2] qa/iscsi_test: test user:rbd backstore only on sles which has tcmu-runner built with rbd support Signed-off-by: Mykola Golub --- qa/common/common.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qa/common/common.sh b/qa/common/common.sh index 38e953ce..dea8bea2 100644 --- a/qa/common/common.sh +++ b/qa/common/common.sh @@ -1418,7 +1418,7 @@ function core_dump_test { function _iscsi_test { local client gw_name gw_ip gwcli name node rbd_pool rbd_image target used - local backstore i username password + local supported_backstores backstore i username password set -e set -x @@ -1449,7 +1449,13 @@ function _iscsi_test { jq -r '.[] | select(.name | startswith("iscsi.")) | .name') test -n "${name}" - for backstore in rbd user:rbd; do + if [ ${ID} = sles ]; then + supported_backstores='rbd user:rbd' + else + supported_backstores='rbd' + fi + + for backstore in ${supported_backstores}; do rbd_image=iscsi_disk_${backstore%:*} ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}" && false rbd info ${rbd_pool}/${rbd_image} && false