test/vhost: refactor lvol test
- Removing hardcoded lvol bdevs and blk controller sizes Lvol bdevs will now be created with roughly equal size based on size of used NVMe backend - Create lvol structures and VMs setup independently Change-Id: Ib1cfe1b60033200a9896fa0c8d1b17af41ea0eb1 Signed-off-by: Karol Latecki <karol.latecki@intel.com> Reviewed-on: https://review.gerrithub.io/390983 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8fd2882fb2
commit
233c5189ab
@ -497,5 +497,29 @@ function fio_config_add_job()
|
|||||||
echo "filename=$filename" >> $config_file
|
echo "filename=$filename" >> $config_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_lvs_free_mb()
|
||||||
|
{
|
||||||
|
local lvs_uuid=$1
|
||||||
|
local lvs_info=$($rpc_py get_lvol_stores)
|
||||||
|
local fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info")
|
||||||
|
local cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info")
|
||||||
|
|
||||||
|
# Change to MB's
|
||||||
|
free_mb=$((fc*cs/1024/1024))
|
||||||
|
echo "$free_mb"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_bdev_size()
|
||||||
|
{
|
||||||
|
local bdev_name=$1
|
||||||
|
local bdev_info=$($rpc_py get_bdevs -b $bdev_name)
|
||||||
|
local bs=$(jq ".[] .block_size" <<< "$bdev_info")
|
||||||
|
local nb=$(jq ".[] .num_blocks" <<< "$bdev_info")
|
||||||
|
|
||||||
|
# Change to MB's
|
||||||
|
bdev_size=$((bs*nb/1024/1024))
|
||||||
|
echo "$bdev_size"
|
||||||
|
}
|
||||||
|
|
||||||
set -o errtrace
|
set -o errtrace
|
||||||
trap "trap - ERR; print_backtrace >&2" ERR
|
trap "trap - ERR; print_backtrace >&2" ERR
|
||||||
|
@ -5,7 +5,6 @@ BASE_DIR=$(readlink -f $(dirname $0))
|
|||||||
[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)"
|
[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)"
|
||||||
|
|
||||||
. $COMMON_DIR/common.sh
|
. $COMMON_DIR/common.sh
|
||||||
|
|
||||||
rpc_py="python $SPDK_BUILD_DIR/scripts/rpc.py "
|
rpc_py="python $SPDK_BUILD_DIR/scripts/rpc.py "
|
||||||
|
|
||||||
vm_count=1
|
vm_count=1
|
||||||
@ -14,8 +13,6 @@ ctrl_type="vhost_scsi"
|
|||||||
use_fs=false
|
use_fs=false
|
||||||
nested_lvol=false
|
nested_lvol=false
|
||||||
distribute_cores=false
|
distribute_cores=false
|
||||||
base_bdev_size=10000
|
|
||||||
nest_bdev_size=""
|
|
||||||
|
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
@ -110,44 +107,56 @@ used_vms=""
|
|||||||
|
|
||||||
# On each NVMe create one lvol store
|
# On each NVMe create one lvol store
|
||||||
for (( i=0; i<$max_disks; i++ ));do
|
for (( i=0; i<$max_disks; i++ ));do
|
||||||
|
|
||||||
|
# Create base lvol store on NVMe
|
||||||
echo "INFO: Creating lvol store on device Nvme${i}n1"
|
echo "INFO: Creating lvol store on device Nvme${i}n1"
|
||||||
ls_guid=$($rpc_py construct_lvol_store Nvme${i}n1 lvs_$i)
|
ls_guid=$($rpc_py construct_lvol_store Nvme${i}n1 lvs_$i)
|
||||||
lvol_stores+=("$ls_guid")
|
lvol_stores+=("$ls_guid")
|
||||||
done
|
|
||||||
|
|
||||||
# Create lvol bdev for nested lvol stores if needed
|
|
||||||
if $nested_lvol; then
|
|
||||||
for lvol_store in "${lvol_stores[@]}"; do
|
|
||||||
|
|
||||||
echo "INFO: Creating lvol bdev on lvol store $lvol_store"
|
|
||||||
lb_name=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_nest 16000)
|
|
||||||
lvol_bdevs+=("$lb_name")
|
|
||||||
|
|
||||||
echo "INFO: Creating nested lvol store on lvol bdev: $lb_name"
|
|
||||||
ls_guid=$($rpc_py construct_lvol_store $lb_name lvs_n_$i)
|
|
||||||
nest_lvol_stores+=("$ls_guid")
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For each VM create one lvol bdev on each 'normal' and nested lvol store
|
|
||||||
for (( i=0; i<$vm_count; i++)); do
|
|
||||||
bdevs=()
|
|
||||||
echo "INFO: Creating lvol bdevs for VM $i"
|
|
||||||
for lvol_store in "${lvol_stores[@]}"; do
|
|
||||||
lb_name=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_$i 10000)
|
|
||||||
lvol_bdevs+=("$lb_name")
|
|
||||||
bdevs+=("$lb_name")
|
|
||||||
done
|
|
||||||
|
|
||||||
if $nested_lvol; then
|
if $nested_lvol; then
|
||||||
echo "INFO: Creating nested lvol bdevs for VM $i"
|
free_mb=$(get_lvs_free_mb "$ls_guid")
|
||||||
for lvol_store in "${nest_lvol_stores[@]}"; do
|
size=$((free_mb / (vm_count+1) ))
|
||||||
lb_guid=$($rpc_py construct_lvol_bdev -u $lvol_store lbd_nest_$i 2000)
|
|
||||||
nest_lvol_bdevs+=("$lb_guid")
|
echo "INFO: Creating lvol bdev on lvol store: $ls_guid"
|
||||||
bdevs+=("$lb_guid")
|
lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_nest $size)
|
||||||
|
|
||||||
|
echo "INFO: Creating nested lvol store on lvol bdev: $lb_name"
|
||||||
|
nest_ls_guid=$($rpc_py construct_lvol_store $lb_name lvs_n_$i)
|
||||||
|
nest_lvol_stores+=("$nest_ls_guid")
|
||||||
|
|
||||||
|
for (( j=0; j<$vm_count; j++)); do
|
||||||
|
echo "INFO: Creating nested lvol bdev for VM $i on lvol store $nest_ls_guid"
|
||||||
|
free_mb=$(get_lvs_free_mb "$nest_ls_guid")
|
||||||
|
nest_size=$((free_mb / (vm_count-j) ))
|
||||||
|
lb_name=$($rpc_py construct_lvol_bdev -u $nest_ls_guid lbd_vm_$j $nest_size)
|
||||||
|
nest_lvol_bdevs+=("$lb_name")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create base lvol bdevs
|
||||||
|
for (( j=0; j<$vm_count; j++)); do
|
||||||
|
echo "INFO: Creating lvol bdev for VM $i on lvol store $ls_guid"
|
||||||
|
free_mb=$(get_lvs_free_mb "$ls_guid")
|
||||||
|
size=$((free_mb / (vm_count-j) ))
|
||||||
|
lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_vm_$j $size)
|
||||||
|
lvol_bdevs+=("$lb_name")
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
bdev_info=$($rpc_py get_bdevs)
|
||||||
|
echo "INFO: Configuration after initial set-up:"
|
||||||
|
$rpc_py get_lvol_stores
|
||||||
|
echo "$bdev_info"
|
||||||
|
|
||||||
|
# Set up VMs
|
||||||
|
for (( i=0; i<$vm_count; i++)); do
|
||||||
|
vm="vm_$i"
|
||||||
|
|
||||||
|
# Get all lvol bdevs associated with this VM number
|
||||||
|
bdevs=$(jq -r "map(select(.product_name==\"Logical Volume\") |
|
||||||
|
select(.name | contains(\"$vm\")) | .name) | join(\" \")" <<< "$bdev_info")
|
||||||
|
bdevs=($bdevs)
|
||||||
|
|
||||||
setup_cmd="$COMMON_DIR/vm_setup.sh $x --work-dir=$TEST_DIR"
|
setup_cmd="$COMMON_DIR/vm_setup.sh $x --work-dir=$TEST_DIR"
|
||||||
if [[ "$ctrl_type" == "vhost_scsi" ]]; then
|
if [[ "$ctrl_type" == "vhost_scsi" ]]; then
|
||||||
setup_cmd+=" --test-type=spdk_vhost_scsi"
|
setup_cmd+=" --test-type=spdk_vhost_scsi"
|
||||||
@ -172,8 +181,10 @@ for (( i=0; i<$vm_count; i++)); do
|
|||||||
elif [[ "$ctrl_type" == "vhost_blk" ]]; then
|
elif [[ "$ctrl_type" == "vhost_blk" ]]; then
|
||||||
disk=""
|
disk=""
|
||||||
for (( j=0; j<${#bdevs[@]}; j++)); do
|
for (( j=0; j<${#bdevs[@]}; j++)); do
|
||||||
|
blk_dev_size=$(get_bdev_size "${bdevs[$j]}")
|
||||||
|
|
||||||
$rpc_py construct_vhost_blk_controller naa.$j.$i ${bdevs[$j]} $mask_arg
|
$rpc_py construct_vhost_blk_controller naa.$j.$i ${bdevs[$j]} $mask_arg
|
||||||
disk+="${j}_size_1500M:"
|
disk+="${j}_size_${blk_dev_size}M:"
|
||||||
done
|
done
|
||||||
disk="${disk::-1}"
|
disk="${disk::-1}"
|
||||||
setup_cmd+=" --disk=$disk"
|
setup_cmd+=" --disk=$disk"
|
||||||
@ -183,8 +194,6 @@ for (( i=0; i<$vm_count; i++)); do
|
|||||||
used_vms+=" $i"
|
used_vms+=" $i"
|
||||||
done
|
done
|
||||||
|
|
||||||
$rpc_py get_lvol_stores
|
|
||||||
$rpc_py get_bdevs
|
|
||||||
$rpc_py get_vhost_controllers
|
$rpc_py get_vhost_controllers
|
||||||
$rpc_py get_luns
|
$rpc_py get_luns
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user