test/bdev: Make sure cleanup() is always called upon exiting
This is mostly relevant for making sure the nvme drive used for gpt test is cleaned up. To that effect, replace dd with wipefs to make sure all signatures are wiped and kernel updated with the changes. Also, since gpt test is not supported on FreeBSD don't try to run it from autotest. Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: Ic970026363a6269f85b63e713f4187268fd6f923 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9290 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@gmail.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
84a9119bb0
commit
8419c294b4
@ -208,7 +208,9 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
|
|||||||
|
|
||||||
if [ $SPDK_TEST_NVME -eq 1 ]; then
|
if [ $SPDK_TEST_NVME -eq 1 ]; then
|
||||||
run_test "blockdev_nvme" test/bdev/blockdev.sh "nvme"
|
run_test "blockdev_nvme" test/bdev/blockdev.sh "nvme"
|
||||||
run_test "blockdev_nvme_gpt" test/bdev/blockdev.sh "gpt"
|
if [[ $(uname -s) == Linux ]]; then
|
||||||
|
run_test "blockdev_nvme_gpt" test/bdev/blockdev.sh "gpt"
|
||||||
|
fi
|
||||||
run_test "nvme" test/nvme/nvme.sh
|
run_test "nvme" test/nvme/nvme.sh
|
||||||
if [[ $SPDK_TEST_NVME_PMR -eq 1 ]]; then
|
if [[ $SPDK_TEST_NVME_PMR -eq 1 ]]; then
|
||||||
run_test "nvme_pmr" test/nvme/nvme_pmr.sh
|
run_test "nvme_pmr" test/nvme/nvme_pmr.sh
|
||||||
|
@ -18,6 +18,13 @@ function cleanup() {
|
|||||||
if [[ $test_type == rbd ]]; then
|
if [[ $test_type == rbd ]]; then
|
||||||
rbd_cleanup
|
rbd_cleanup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$test_type" = "gpt" ]]; then
|
||||||
|
"$rootdir/scripts/setup.sh" reset
|
||||||
|
if [[ -b $gpt_nvme ]]; then
|
||||||
|
wipefs --all "$gpt_nvme"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_spdk_tgt() {
|
function start_spdk_tgt() {
|
||||||
@ -55,44 +62,35 @@ function setup_nvme_conf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup_gpt_conf() {
|
function setup_gpt_conf() {
|
||||||
if [[ $(uname -s) = Linux ]] && hash sgdisk; then
|
$rootdir/scripts/setup.sh reset
|
||||||
$rootdir/scripts/setup.sh reset
|
# Get nvme devices by following drivers' links towards nvme class
|
||||||
# Get nvme devices by following drivers' links towards nvme class
|
local nvme_devs=(/sys/bus/pci/drivers/nvme/*/nvme/nvme*/nvme*n*) nvme_dev
|
||||||
local nvme_devs=(/sys/bus/pci/drivers/nvme/*/nvme/nvme*/nvme*n*) nvme_dev
|
gpt_nvme=""
|
||||||
gpt_nvme=""
|
# Pick first device which doesn't have any valid partition table
|
||||||
# Pick first device which doesn't have any valid partition table
|
for nvme_dev in "${nvme_devs[@]}"; do
|
||||||
for nvme_dev in "${nvme_devs[@]}"; do
|
dev=/dev/${nvme_dev##*/}
|
||||||
dev=/dev/${nvme_dev##*/}
|
if ! pt=$(parted "$dev" -ms print 2>&1); then
|
||||||
if ! pt=$(parted "$dev" -ms print 2>&1); then
|
[[ $pt == *"$dev: unrecognised disk label"* ]] || continue
|
||||||
[[ $pt == *"$dev: unrecognised disk label"* ]] || continue
|
gpt_nvme=$dev
|
||||||
gpt_nvme=$dev
|
break
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ -n $gpt_nvme ]]; then
|
|
||||||
# Create gpt partition table
|
|
||||||
parted -s "$gpt_nvme" mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
|
|
||||||
# change the GUID to SPDK GUID value
|
|
||||||
# FIXME: Hardcode this in some common place, this value should not be changed much
|
|
||||||
IFS="()" read -r _ SPDK_GPT_GUID _ < <(grep SPDK_GPT_PART_TYPE_GUID module/bdev/gpt/gpt.h)
|
|
||||||
SPDK_GPT_GUID=${SPDK_GPT_GUID//, /-} SPDK_GPT_GUID=${SPDK_GPT_GUID//0x/}
|
|
||||||
sgdisk -t "1:$SPDK_GPT_GUID" "$gpt_nvme"
|
|
||||||
sgdisk -t "2:$SPDK_GPT_GUID" "$gpt_nvme"
|
|
||||||
"$rootdir/scripts/setup.sh"
|
|
||||||
"$rpc_py" bdev_get_bdevs
|
|
||||||
setup_nvme_conf
|
|
||||||
else
|
|
||||||
printf 'Did not find any nvme block devices to work with, aborting the test\n' >&2
|
|
||||||
"$rootdir/scripts/setup.sh"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
if [[ -n $gpt_nvme ]]; then
|
||||||
|
# Create gpt partition table
|
||||||
|
parted -s "$gpt_nvme" mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
|
||||||
|
# change the GUID to SPDK GUID value
|
||||||
|
# FIXME: Hardcode this in some common place, this value should not be changed much
|
||||||
|
IFS="()" read -r _ SPDK_GPT_GUID _ < <(grep SPDK_GPT_PART_TYPE_GUID module/bdev/gpt/gpt.h)
|
||||||
|
SPDK_GPT_GUID=${SPDK_GPT_GUID//, /-} SPDK_GPT_GUID=${SPDK_GPT_GUID//0x/}
|
||||||
|
sgdisk -t "1:$SPDK_GPT_GUID" "$gpt_nvme"
|
||||||
|
sgdisk -t "2:$SPDK_GPT_GUID" "$gpt_nvme"
|
||||||
|
"$rootdir/scripts/setup.sh"
|
||||||
|
"$rpc_py" bdev_get_bdevs
|
||||||
|
setup_nvme_conf
|
||||||
else
|
else
|
||||||
# Not supported platform or missing tooling, nothing to be done, simply exit the test
|
printf 'Did not find any nvme block devices to work with, aborting the test\n' >&2
|
||||||
# in a graceful manner.
|
"$rootdir/scripts/setup.sh"
|
||||||
trap - SIGINT SIGTERM EXIT
|
return 1
|
||||||
killprocess "$spdk_tgt_pid"
|
|
||||||
cleanup
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +137,7 @@ function setup_rbd_conf() {
|
|||||||
function bdev_bounds() {
|
function bdev_bounds() {
|
||||||
$testdir/bdevio/bdevio -w -s $PRE_RESERVED_MEM --json "$conf_file" &
|
$testdir/bdevio/bdevio -w -s $PRE_RESERVED_MEM --json "$conf_file" &
|
||||||
bdevio_pid=$!
|
bdevio_pid=$!
|
||||||
trap 'killprocess $bdevio_pid; exit 1' SIGINT SIGTERM EXIT
|
trap 'cleanup; killprocess $bdevio_pid; exit 1' SIGINT SIGTERM EXIT
|
||||||
echo "Process bdevio pid: $bdevio_pid"
|
echo "Process bdevio pid: $bdevio_pid"
|
||||||
waitforlisten $bdevio_pid
|
waitforlisten $bdevio_pid
|
||||||
$testdir/bdevio/tests.py perform_tests
|
$testdir/bdevio/tests.py perform_tests
|
||||||
@ -171,7 +169,7 @@ function nbd_function_test() {
|
|||||||
modprobe nbd
|
modprobe nbd
|
||||||
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 --json "$conf" &
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 --json "$conf" &
|
||||||
nbd_pid=$!
|
nbd_pid=$!
|
||||||
trap 'killprocess $nbd_pid; exit 1' SIGINT SIGTERM EXIT
|
trap 'cleanup; killprocess $nbd_pid; exit 1' SIGINT SIGTERM EXIT
|
||||||
echo "Process nbd pid: $nbd_pid"
|
echo "Process nbd pid: $nbd_pid"
|
||||||
waitforlisten $nbd_pid $rpc_server
|
waitforlisten $nbd_pid $rpc_server
|
||||||
|
|
||||||
@ -291,7 +289,7 @@ function qos_test_suite() {
|
|||||||
"$testdir/bdevperf/bdevperf" -z -m 0x2 -q 256 -o 4096 -w randread -t 60 &
|
"$testdir/bdevperf/bdevperf" -z -m 0x2 -q 256 -o 4096 -w randread -t 60 &
|
||||||
QOS_PID=$!
|
QOS_PID=$!
|
||||||
echo "Process qos testing pid: $QOS_PID"
|
echo "Process qos testing pid: $QOS_PID"
|
||||||
trap 'killprocess $QOS_PID; exit 1' SIGINT SIGTERM EXIT
|
trap 'cleanup; killprocess $QOS_PID; exit 1' SIGINT SIGTERM EXIT
|
||||||
waitforlisten $QOS_PID
|
waitforlisten $QOS_PID
|
||||||
|
|
||||||
$rpc_py bdev_malloc_create -b $QOS_DEV_1 128 512
|
$rpc_py bdev_malloc_create -b $QOS_DEV_1 128 512
|
||||||
@ -370,6 +368,8 @@ killprocess "$spdk_tgt_pid"
|
|||||||
# End bdev configuration
|
# End bdev configuration
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
|
|
||||||
|
trap "cleanup" SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
run_test "bdev_hello_world" $SPDK_EXAMPLE_DIR/hello_bdev --json "$conf_file" -b "$hello_world_bdev"
|
run_test "bdev_hello_world" $SPDK_EXAMPLE_DIR/hello_bdev --json "$conf_file" -b "$hello_world_bdev"
|
||||||
run_test "bdev_bounds" bdev_bounds
|
run_test "bdev_bounds" bdev_bounds
|
||||||
run_test "bdev_nbd" nbd_function_test $conf_file "$bdevs_name"
|
run_test "bdev_nbd" nbd_function_test $conf_file "$bdevs_name"
|
||||||
@ -385,6 +385,8 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
trap "cleanup" SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
run_test "bdev_verify" $testdir/bdevperf/bdevperf --json "$conf_file" -q 128 -o 4096 -w verify -t 5 -C -m 0x3
|
run_test "bdev_verify" $testdir/bdevperf/bdevperf --json "$conf_file" -q 128 -o 4096 -w verify -t 5 -C -m 0x3
|
||||||
run_test "bdev_write_zeroes" $testdir/bdevperf/bdevperf --json "$conf_file" -q 128 -o 4096 -w write_zeroes -t 1
|
run_test "bdev_write_zeroes" $testdir/bdevperf/bdevperf --json "$conf_file" -q 128 -o 4096 -w write_zeroes -t 1
|
||||||
|
|
||||||
@ -399,11 +401,6 @@ fi
|
|||||||
|
|
||||||
# Bdev and configuration cleanup below this line
|
# Bdev and configuration cleanup below this line
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
if [ "$test_type" = "gpt" ]; then
|
|
||||||
"$rootdir/scripts/setup.sh" reset
|
|
||||||
if [[ -b $gpt_nvme ]]; then
|
|
||||||
dd if=/dev/zero of="$gpt_nvme" bs=4096 count=8 oflag=direct
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
trap - SIGINT SIGTERM EXIT
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user