diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/test/vhost/integrity | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/test/vhost/integrity')
-rwxr-xr-x | src/spdk/test/vhost/integrity/integrity_start.sh | 97 | ||||
-rwxr-xr-x | src/spdk/test/vhost/integrity/integrity_vm.sh | 69 |
2 files changed, 166 insertions, 0 deletions
diff --git a/src/spdk/test/vhost/integrity/integrity_start.sh b/src/spdk/test/vhost/integrity/integrity_start.sh new file mode 100755 index 00000000..a9899e9f --- /dev/null +++ b/src/spdk/test/vhost/integrity/integrity_start.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +set -e + +INTEGRITY_BASE_DIR=$(readlink -f $(dirname $0)) +ctrl_type="spdk_vhost_scsi" +vm_fs="ext4" + +function usage() +{ + [[ ! -z $2 ]] && ( echo "$2"; echo ""; ) + echo "Shortcut script for doing automated test" + echo "Usage: $(basename $1) [OPTIONS]" + echo + echo "-h, --help Print help and exit" + echo " --work-dir=WORK_DIR Workspace for the test to run" + echo " --ctrl-type=TYPE Controller type to use for test:" + echo " spdk_vhost_scsi - use spdk vhost scsi" + echo " --fs=FS_LIST Filesystems to use for test in VM:" + echo " Example: --fs=\"ext4 ntfs ext2\"" + echo " Default: ext4" + echo " spdk_vhost_blk - use spdk vhost block" + echo "-x set -x for script debug" + exit 0 +} + +function clean_lvol_cfg() +{ + notice "Removing lvol bdev and lvol store" + $rpc_py destroy_lvol_bdev lvol_store/lvol_bdev + $rpc_py destroy_lvol_store -l lvol_store +} + +while getopts 'xh-:' optchar; do + case "$optchar" in + -) + case "$OPTARG" in + help) usage $0 ;; + ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; + fs=*) vm_fs="${OPTARG#*=}" ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) set -x + x="-x" ;; + *) usage $0 "Invalid argument '$OPTARG'" + esac +done + +. $(readlink -e "$(dirname $0)/../common/common.sh") || exit 1 +rpc_py="$SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" + +trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR + +# Try to kill if any VM remains from previous runs +vm_kill_all + +notice "Starting SPDK vhost" +spdk_vhost_run +notice "..." + +# Set up lvols and vhost controllers +trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR +notice "Constructing lvol store and lvol bdev on top of Nvme0n1" +lvs_uuid=$($rpc_py construct_lvol_store Nvme0n1 lvol_store) +$rpc_py construct_lvol_bdev lvol_bdev 10000 -l lvol_store + +if [[ "$ctrl_type" == "spdk_vhost_scsi" ]]; then + $rpc_py construct_vhost_scsi_controller naa.Nvme0n1.0 + $rpc_py add_vhost_scsi_lun naa.Nvme0n1.0 0 lvol_store/lvol_bdev +elif [[ "$ctrl_type" == "spdk_vhost_blk" ]]; then + $rpc_py construct_vhost_blk_controller naa.Nvme0n1.0 lvol_store/lvol_bdev +fi + +# Set up and run VM +setup_cmd="vm_setup --disk-type=$ctrl_type --force=0" +setup_cmd+=" --os=/home/sys_sgsw/vhost_vm_image.qcow2" +setup_cmd+=" --disks=Nvme0n1" +$setup_cmd + +# Run VM +vm_run 0 +vm_wait_for_boot 600 0 + +# Run tests on VM +vm_scp 0 $INTEGRITY_BASE_DIR/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh +vm_ssh 0 "~/integrity_vm.sh $ctrl_type \"$vm_fs\"" + +notice "Shutting down virtual machine..." +vm_shutdown_all + +clean_lvol_cfg + +$rpc_py delete_nvme_controller Nvme0 + +notice "Shutting down SPDK vhost app..." +spdk_vhost_kill diff --git a/src/spdk/test/vhost/integrity/integrity_vm.sh b/src/spdk/test/vhost/integrity/integrity_vm.sh new file mode 100755 index 00000000..ccb01cea --- /dev/null +++ b/src/spdk/test/vhost/integrity/integrity_vm.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -xe + +basedir=$(readlink -f $(dirname $0)) +MAKE="make -j$(( $(nproc) * 2 ))" + +if [[ $1 == "spdk_vhost_scsi" ]]; then + devs="" + for entry in /sys/block/sd*; do + if grep -Eq '(INTEL|RAWSCSI|LIO-ORG)' $entry/device/vendor; then + devs+="$(basename $entry) " + fi + done +elif [[ $1 == "spdk_vhost_blk" ]]; then + devs=$(cd /sys/block; echo vd*) +fi + +fs=$2 + +trap "exit 1" SIGINT SIGTERM EXIT + +for fs in $fs; do + for dev in $devs; do + parted_cmd="parted -s /dev/${dev}" + + echo "INFO: Creating partition table on disk using: $parted_cmd mklabel gpt" + $parted_cmd mklabel gpt + $parted_cmd mkpart primary 2048s 100% + sleep 2 + + mkfs_cmd="mkfs.$fs" + if [[ $fs == "ntfs" ]]; then + mkfs_cmd+=" -f" + fi + mkfs_cmd+=" /dev/${dev}1" + echo "INFO: Creating filesystem using: $mkfs_cmd" + wipefs -a /dev/${dev}1 + $mkfs_cmd + + mkdir -p /mnt/${dev}dir + mount -o sync /dev/${dev}1 /mnt/${dev}dir + + fio --name="integrity" --bsrange=4k-512k --iodepth=128 --numjobs=1 --direct=1 \ + --thread=1 --group_reporting=1 --rw=randrw --rwmixread=70 \ + --filename=/mnt/${dev}dir/test_file --verify=md5 --do_verify=1 \ + --verify_backlog=1024 --fsync_on_close=1 --runtime=20 --time_based=1 --size=512m + + # Print out space consumed on target device + df -h /dev/$dev + done + + for dev in $devs; do + umount /mnt/${dev}dir + rm -rf /mnt/${dev}dir + + stats=( $(cat /sys/block/$dev/stat) ) + echo "" + echo "$dev stats" + printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ + ${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]} + printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ + ${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]} + printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \ + ${stats[8]} ${stats[9]} ${stats[10]} + echo "" + done +done + +trap - SIGINT SIGTERM EXIT |