Skip to content

Commit

Permalink
Merge pull request #699 from trociny/wip-qa-iscsi-tcmu
Browse files Browse the repository at this point in the history
qa/iscsi_test: test also user:rbd (tcmu-runner) backstore
  • Loading branch information
tserong authored Jun 26, 2023
2 parents 36553b0 + ca92fa0 commit 9083721
Showing 1 changed file with 76 additions and 45 deletions.
121 changes: 76 additions & 45 deletions qa/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 supported_backstores backstore i username password

set -e
set -x
Expand All @@ -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}')
Expand All @@ -1450,62 +1449,94 @@ 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}
if [ ${ID} = sles ]; then
supported_backstores='rbd user:rbd'
else
supported_backstores='rbd'
fi

ssh ${node} rbd showmapped | grep "${rbd_pool} *${rbd_image}"
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
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 {
Expand Down

0 comments on commit 9083721

Please sign in to comment.