2017-03-02 14:12:20 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-05-10 17:54:24 +00:00
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
source $rootdir/test/vhost/common.sh
|
2017-03-02 14:12:20 +00:00
|
|
|
|
|
|
|
dry_run=false
|
|
|
|
no_shutdown=false
|
2017-12-15 15:11:02 +00:00
|
|
|
fio_bin=""
|
|
|
|
remote_fio_bin=""
|
|
|
|
fio_jobs=""
|
2017-06-16 10:03:46 +00:00
|
|
|
test_type=spdk_vhost_scsi
|
2017-03-02 14:12:20 +00:00
|
|
|
reuse_vms=false
|
|
|
|
vms=()
|
|
|
|
used_vms=""
|
|
|
|
x=""
|
|
|
|
|
|
|
|
function usage()
|
|
|
|
{
|
2019-07-25 13:01:09 +00:00
|
|
|
[[ -n $2 ]] && ( echo "$2"; echo ""; )
|
2017-03-02 14:12:20 +00:00
|
|
|
echo "Shortcut script for doing automated test"
|
|
|
|
echo "Usage: $(basename $1) [OPTIONS]"
|
|
|
|
echo
|
|
|
|
echo "-h, --help print help and exit"
|
|
|
|
echo " --test-type=TYPE Perform specified test:"
|
|
|
|
echo " virtio - test host virtio-scsi-pci using file as disk image"
|
|
|
|
echo " kernel_vhost - use kernel driver vhost-scsi"
|
2017-06-16 10:03:46 +00:00
|
|
|
echo " spdk_vhost_scsi - use spdk vhost scsi"
|
|
|
|
echo " spdk_vhost_blk - use spdk vhost block"
|
2017-03-02 14:12:20 +00:00
|
|
|
echo "-x set -x for script debug"
|
|
|
|
echo " --fio-bin=FIO Use specific fio binary (will be uploaded to VM)"
|
2017-12-15 15:11:02 +00:00
|
|
|
echo " --fio-job= Fio config to use for test."
|
2017-03-02 14:12:20 +00:00
|
|
|
echo " All VMs will run the same fio job when FIO executes."
|
|
|
|
echo " (no unique jobs for specific VMs)"
|
|
|
|
echo " --dry-run Don't perform any tests, run only and wait for enter to terminate"
|
|
|
|
echo " --no-shutdown Don't shutdown at the end but leave envirionment working"
|
|
|
|
echo " --vm=NUM[,OS][,DISKS] VM configuration. This parameter might be used more than once:"
|
|
|
|
echo " NUM - VM number (mandatory)"
|
|
|
|
echo " OS - VM os disk path (optional)"
|
|
|
|
echo " DISKS - VM os test disks/devices path (virtio - optional, kernel_vhost - mandatory)"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
#default raw file is NVMe drive
|
|
|
|
|
|
|
|
while getopts 'xh-:' optchar; do
|
|
|
|
case "$optchar" in
|
|
|
|
-)
|
|
|
|
case "$OPTARG" in
|
|
|
|
help) usage $0 ;;
|
|
|
|
fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;;
|
2017-12-15 15:11:02 +00:00
|
|
|
fio-job=*) fio_job="${OPTARG#*=}" ;;
|
2017-03-02 14:12:20 +00:00
|
|
|
dry-run) dry_run=true ;;
|
|
|
|
no-shutdown) no_shutdown=true ;;
|
|
|
|
test-type=*) test_type="${OPTARG#*=}" ;;
|
|
|
|
vm=*) vms+=("${OPTARG#*=}") ;;
|
|
|
|
*) usage $0 "Invalid argument '$OPTARG'" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
h) usage $0 ;;
|
|
|
|
x) set -x
|
|
|
|
x="-x" ;;
|
|
|
|
*) usage $0 "Invalid argument '$OPTARG'"
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
|
2017-12-15 15:11:02 +00:00
|
|
|
if [[ ! -r "$fio_job" ]]; then
|
2017-12-18 19:45:33 +00:00
|
|
|
fail "no fio job file specified"
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-17 21:09:40 +00:00
|
|
|
vhosttestinit
|
|
|
|
|
2017-03-02 14:12:20 +00:00
|
|
|
trap 'error_exit "${FUNCNAME}" "${LINENO}"' ERR
|
|
|
|
|
|
|
|
vm_kill_all
|
|
|
|
|
2017-06-16 10:03:46 +00:00
|
|
|
if [[ $test_type =~ "spdk_vhost" ]]; then
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "==============="
|
|
|
|
notice ""
|
|
|
|
notice "running SPDK"
|
|
|
|
notice ""
|
2019-06-05 19:47:53 +00:00
|
|
|
vhost_run 0
|
2019-08-06 14:25:38 +00:00
|
|
|
vhost_load_config 0 $testdir/conf.json
|
2017-12-18 19:45:33 +00:00
|
|
|
notice ""
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "==============="
|
|
|
|
notice ""
|
|
|
|
notice "Setting up VM"
|
|
|
|
notice ""
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2019-06-04 20:55:21 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
2017-03-02 14:12:20 +00:00
|
|
|
|
|
|
|
for vm_conf in ${vms[@]}; do
|
|
|
|
IFS=',' read -ra conf <<< "$vm_conf"
|
|
|
|
if [[ x"${conf[0]}" == x"" ]] || ! assert_number ${conf[0]}; then
|
2017-12-18 19:45:33 +00:00
|
|
|
fail "invalid VM configuration syntax $vm_conf"
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Sanity check if VM is not defined twice
|
|
|
|
for vm_num in $used_vms; do
|
|
|
|
if [[ $vm_num -eq ${conf[0]} ]]; then
|
2017-12-18 19:45:33 +00:00
|
|
|
fail "VM$vm_num defined more than twice ( $(printf "'%s' " "${vms[@]}"))!"
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
used_vms+=" ${conf[0]}"
|
|
|
|
|
2017-06-16 10:03:46 +00:00
|
|
|
if [[ $test_type =~ "spdk_vhost" ]]; then
|
2017-03-15 16:00:55 +00:00
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Adding device via RPC ..."
|
2017-03-02 14:12:20 +00:00
|
|
|
|
|
|
|
while IFS=':' read -ra disks; do
|
|
|
|
for disk in "${disks[@]}"; do
|
2018-09-14 07:07:18 +00:00
|
|
|
notice "Create a lvol store on RaidBdev2 and then a lvol bdev on the lvol store"
|
|
|
|
if [[ $disk == "RaidBdev2" ]]; then
|
|
|
|
ls_guid=$($rpc_py construct_lvol_store RaidBdev2 lvs_0 -c 4194304)
|
|
|
|
free_mb=$(get_lvs_free_mb "$ls_guid")
|
2019-08-29 11:01:30 +00:00
|
|
|
based_disk=$($rpc_py bdev_lvol_create -u $ls_guid lbd_0 $free_mb)
|
2018-09-14 07:07:18 +00:00
|
|
|
else
|
|
|
|
based_disk="$disk"
|
|
|
|
fi
|
|
|
|
|
2017-06-16 10:03:46 +00:00
|
|
|
if [[ "$test_type" == "spdk_vhost_blk" ]]; then
|
|
|
|
disk=${disk%%_*}
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Creating vhost block controller naa.$disk.${conf[0]} with device $disk"
|
2018-09-14 07:07:18 +00:00
|
|
|
$rpc_py construct_vhost_blk_controller naa.$disk.${conf[0]} $based_disk
|
2017-06-16 10:03:46 +00:00
|
|
|
else
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Creating controller naa.$disk.${conf[0]}"
|
2017-06-16 10:03:46 +00:00
|
|
|
$rpc_py construct_vhost_scsi_controller naa.$disk.${conf[0]}
|
|
|
|
|
2018-06-04 11:16:50 +00:00
|
|
|
notice "Adding device (0) to naa.$disk.${conf[0]}"
|
2018-09-14 07:07:18 +00:00
|
|
|
$rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $based_disk
|
2017-03-15 16:00:55 +00:00
|
|
|
fi
|
2017-03-02 14:12:20 +00:00
|
|
|
done
|
|
|
|
done <<< "${conf[2]}"
|
|
|
|
unset IFS;
|
2017-07-13 14:37:50 +00:00
|
|
|
$rpc_py get_vhost_controllers
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
2017-12-28 16:00:44 +00:00
|
|
|
|
|
|
|
setup_cmd="vm_setup --force=${conf[0]} --disk-type=$test_type"
|
|
|
|
[[ x"${conf[1]}" != x"" ]] && setup_cmd+=" --os=${conf[1]}"
|
|
|
|
[[ x"${conf[2]}" != x"" ]] && setup_cmd+=" --disks=${conf[2]}"
|
|
|
|
|
2017-03-02 14:12:20 +00:00
|
|
|
$setup_cmd
|
|
|
|
done
|
|
|
|
|
|
|
|
# Run everything
|
2017-12-28 15:24:44 +00:00
|
|
|
vm_run $used_vms
|
2019-03-25 13:14:55 +00:00
|
|
|
vm_wait_for_boot 300 $used_vms
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2017-07-26 10:17:52 +00:00
|
|
|
if [[ $test_type == "spdk_vhost_scsi" ]]; then
|
|
|
|
for vm_conf in ${vms[@]}; do
|
|
|
|
IFS=',' read -ra conf <<< "$vm_conf"
|
|
|
|
while IFS=':' read -ra disks; do
|
|
|
|
for disk in "${disks[@]}"; do
|
2018-09-14 07:07:18 +00:00
|
|
|
# For RaidBdev2, the lvol bdev on RaidBdev2 is being used.
|
|
|
|
if [[ $disk == "RaidBdev2" ]]; then
|
|
|
|
based_disk="lvs_0/lbd_0"
|
|
|
|
else
|
|
|
|
based_disk="$disk"
|
|
|
|
fi
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Hotdetach test. Trying to remove existing device from a controller naa.$disk.${conf[0]}"
|
2017-12-08 16:05:58 +00:00
|
|
|
$rpc_py remove_vhost_scsi_target naa.$disk.${conf[0]} 0
|
2017-07-26 10:17:52 +00:00
|
|
|
|
|
|
|
sleep 0.1
|
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Hotattach test. Re-adding device 0 to naa.$disk.${conf[0]}"
|
2018-09-14 07:07:18 +00:00
|
|
|
$rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $based_disk
|
2017-07-26 10:17:52 +00:00
|
|
|
done
|
|
|
|
done <<< "${conf[2]}"
|
|
|
|
unset IFS;
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 0.1
|
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "==============="
|
|
|
|
notice ""
|
|
|
|
notice "Testing..."
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Running fio jobs ..."
|
2017-03-02 14:12:20 +00:00
|
|
|
|
|
|
|
# Check if all VM have disk in tha same location
|
|
|
|
DISK=""
|
|
|
|
|
2017-12-15 15:11:02 +00:00
|
|
|
fio_disks=""
|
2017-03-02 14:12:20 +00:00
|
|
|
for vm_num in $used_vms; do
|
2019-06-04 20:29:27 +00:00
|
|
|
vm_dir=$VM_DIR/$vm_num
|
2017-04-27 16:34:55 +00:00
|
|
|
|
|
|
|
qemu_mask_param="VM_${vm_num}_qemu_mask"
|
|
|
|
|
2018-06-15 11:43:55 +00:00
|
|
|
host_name="VM-$vm_num"
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Setting up hostname: $host_name"
|
2019-06-04 22:00:09 +00:00
|
|
|
vm_exec $vm_num "hostname $host_name"
|
2017-03-02 14:12:20 +00:00
|
|
|
vm_start_fio_server $fio_bin $readonly $vm_num
|
|
|
|
|
2017-06-16 10:03:46 +00:00
|
|
|
if [[ "$test_type" == "spdk_vhost_scsi" ]]; then
|
|
|
|
vm_check_scsi_location $vm_num
|
2017-08-25 00:12:56 +00:00
|
|
|
#vm_reset_scsi_devices $vm_num $SCSI_DISK
|
2017-06-16 10:03:46 +00:00
|
|
|
elif [[ "$test_type" == "spdk_vhost_blk" ]]; then
|
|
|
|
vm_check_blk_location $vm_num
|
|
|
|
fi
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2017-12-15 15:11:02 +00:00
|
|
|
fio_disks+=" --vm=${vm_num}$(printf ':/dev/%s' $SCSI_DISK)"
|
2017-03-02 14:12:20 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if $dry_run; then
|
|
|
|
read -p "Enter to kill evething" xx
|
|
|
|
sleep 3
|
|
|
|
at_app_exit
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-06-04 20:29:27 +00:00
|
|
|
run_fio $fio_bin --job-file="$fio_job" --out="$VHOST_DIR/fio_results" $fio_disks
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2017-07-08 10:26:37 +00:00
|
|
|
if [[ "$test_type" == "spdk_vhost_scsi" ]]; then
|
|
|
|
for vm_num in $used_vms; do
|
|
|
|
vm_reset_scsi_devices $vm_num $SCSI_DISK
|
|
|
|
done
|
|
|
|
fi
|
2017-03-02 14:12:20 +00:00
|
|
|
|
|
|
|
if ! $no_shutdown; then
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "==============="
|
|
|
|
notice "APP EXITING"
|
|
|
|
notice "killing all VMs"
|
2017-06-19 11:19:51 +00:00
|
|
|
vm_shutdown_all
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "waiting 2 seconds to let all VMs die"
|
2017-03-15 16:00:55 +00:00
|
|
|
sleep 2
|
2017-06-16 10:03:46 +00:00
|
|
|
if [[ $test_type =~ "spdk_vhost" ]]; then
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Removing vhost devices & controllers via RPC ..."
|
2017-03-15 16:00:55 +00:00
|
|
|
for vm_conf in ${vms[@]}; do
|
|
|
|
IFS=',' read -ra conf <<< "$vm_conf"
|
|
|
|
|
|
|
|
while IFS=':' read -ra disks; do
|
|
|
|
for disk in "${disks[@]}"; do
|
2017-06-16 10:03:46 +00:00
|
|
|
disk=${disk%%_*}
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Removing all vhost devices from controller naa.$disk.${conf[0]}"
|
2017-09-05 18:23:43 +00:00
|
|
|
if [[ "$test_type" == "spdk_vhost_scsi" ]]; then
|
2017-12-08 16:05:58 +00:00
|
|
|
$rpc_py remove_vhost_scsi_target naa.$disk.${conf[0]} 0
|
2017-06-16 10:03:46 +00:00
|
|
|
fi
|
2017-09-05 18:23:43 +00:00
|
|
|
|
|
|
|
$rpc_py remove_vhost_controller naa.$disk.${conf[0]}
|
2018-09-14 07:07:18 +00:00
|
|
|
if [[ $disk == "RaidBdev2" ]]; then
|
|
|
|
notice "Removing lvol bdev and lvol store"
|
2019-08-29 10:33:16 +00:00
|
|
|
$rpc_py bdev_lvol_delete lvs_0/lbd_0
|
2019-08-29 12:07:56 +00:00
|
|
|
$rpc_py bdev_lvol_delete_lvstore -l lvs_0
|
2018-09-14 07:07:18 +00:00
|
|
|
fi
|
2017-03-15 16:00:55 +00:00
|
|
|
done
|
|
|
|
done <<< "${conf[2]}"
|
|
|
|
done
|
|
|
|
fi
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "Testing done -> shutting down"
|
|
|
|
notice "killing vhost app"
|
2019-06-04 20:55:21 +00:00
|
|
|
vhost_kill 0
|
2017-03-15 16:00:55 +00:00
|
|
|
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "EXIT DONE"
|
|
|
|
notice "==============="
|
2017-03-02 14:12:20 +00:00
|
|
|
else
|
2017-12-18 19:45:33 +00:00
|
|
|
notice "==============="
|
|
|
|
notice ""
|
|
|
|
notice "Leaving environment working!"
|
|
|
|
notice ""
|
|
|
|
notice "==============="
|
2017-03-02 14:12:20 +00:00
|
|
|
fi
|
2019-05-17 21:09:40 +00:00
|
|
|
|
|
|
|
vhosttestfini
|