test/nvme: enable OPAL test
Due to the firmware response time for REVERT action, currently we only enable this test with P4510 drives. Change-Id: I4b02008ec0b7d2caeba20c566b1cf1b69404ae12 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2816 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com> Reviewed-by: Michal Berger <michalx.berger@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
efb72886b3
commit
919fdece12
@ -148,8 +148,7 @@ fi
|
||||
|
||||
# Revert existing OPAL to factory settings that may have been left from earlier failed tests.
|
||||
# This ensures we won't hit any unexpected failures due to NVMe SSDs being locked.
|
||||
# Disable this for now as we don't have opal test running
|
||||
# opal_revert_cleanup
|
||||
opal_revert_cleanup
|
||||
|
||||
#####################
|
||||
# Unit Tests
|
||||
|
@ -1230,21 +1230,6 @@ function get_nvme_ctrlr_from_bdf() {
|
||||
printf '%s\n' "$(basename $bdf_sysfs_path)"
|
||||
}
|
||||
|
||||
function opal_revert_cleanup() {
|
||||
$SPDK_BIN_DIR/spdk_tgt &
|
||||
spdk_tgt_pid=$!
|
||||
waitforlisten $spdk_tgt_pid
|
||||
|
||||
# OPAL test only runs on the first NVMe device
|
||||
# So we just revert the first one here
|
||||
bdf=$($rootdir/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr')
|
||||
$rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a $bdf
|
||||
# Ignore if this fails.
|
||||
$rootdir/scripts/rpc.py bdev_nvme_opal_revert -b nvme0 -p test || true
|
||||
|
||||
killprocess $spdk_tgt_pid
|
||||
}
|
||||
|
||||
# Get BDF addresses of all NVMe drives currently attached to
|
||||
# uio-pci-generic or vfio-pci
|
||||
function get_nvme_bdfs() {
|
||||
@ -1307,6 +1292,40 @@ function nvme_namespace_revert() {
|
||||
done
|
||||
}
|
||||
|
||||
# Get BDFs based on device ID, such as 0x0a54
|
||||
function get_nvme_bdfs_by_id() {
|
||||
local bdfs=()
|
||||
|
||||
for bdf in $(get_nvme_bdfs); do
|
||||
device=$(cat /sys/bus/pci/devices/$bdf/device) || true
|
||||
if [[ "$device" == "$1" ]]; then
|
||||
bdfs+=($bdf)
|
||||
fi
|
||||
done
|
||||
|
||||
printf '%s\n' "${bdfs[@]}"
|
||||
}
|
||||
|
||||
function opal_revert_cleanup() {
|
||||
# The OPAL CI tests is only used for P4510 devices.
|
||||
mapfile -t bdfs < <(get_nvme_bdfs_by_id 0x0a54)
|
||||
if [[ -z ${bdfs[0]} ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
$SPDK_BIN_DIR/spdk_tgt &
|
||||
spdk_tgt_pid=$!
|
||||
waitforlisten $spdk_tgt_pid
|
||||
|
||||
for bdf in "${bdfs[@]}"; do
|
||||
$rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a ${bdf}
|
||||
# Ignore if this fails.
|
||||
$rootdir/scripts/rpc.py bdev_nvme_opal_revert -b nvme0 -p test || true
|
||||
done
|
||||
|
||||
killprocess $spdk_tgt_pid
|
||||
}
|
||||
|
||||
# Define temp storage for all the tests. Look for 2GB at minimum
|
||||
set_test_storage "${TEST_MIN_STORAGE_SIZE:-$((1 << 31))}"
|
||||
|
||||
|
@ -8,16 +8,33 @@ rpc_py="$rootdir/scripts/rpc.py"
|
||||
source "$rootdir/scripts/common.sh"
|
||||
source "$rootdir/test/common/autotest_common.sh"
|
||||
|
||||
function opal_init() {
|
||||
bdf1=$($rootdir/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr')
|
||||
$rpc_py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a $bdf1
|
||||
# The OPAL CI tests is only used for P4510 devices.
|
||||
mapfile -t bdfs < <(get_nvme_bdfs_by_id 0x0a59)
|
||||
if [[ -z ${bdfs[0]} ]]; then
|
||||
echo "No P4510 device found, exit the tests"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ignore bdev_nvme_opal_init failure because sometimes revert TPer might fail and
|
||||
# in another run we don't want init to return errors to stop other tests.
|
||||
$rpc_py bdev_nvme_opal_init -b nvme0 -p test || true
|
||||
bdf=${bdfs[0]}
|
||||
|
||||
function opal_revert_and_init() {
|
||||
$SPDK_BIN_DIR/spdk_tgt &
|
||||
spdk_tgt_pid=$!
|
||||
waitforlisten $spdk_tgt_pid
|
||||
|
||||
$rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a ${bdf}
|
||||
# Ignore if this fails.
|
||||
$rootdir/scripts/rpc.py bdev_nvme_opal_revert -b nvme0 -p test || true
|
||||
sleep 1
|
||||
$rpc_py bdev_nvme_opal_init -b nvme0 -p test
|
||||
$rpc_py bdev_nvme_detach_controller nvme0
|
||||
|
||||
killprocess $spdk_tgt_pid
|
||||
}
|
||||
|
||||
function test_opal_cmds() {
|
||||
$rpc_py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a ${bdf}
|
||||
|
||||
$rpc_py bdev_opal_create -b nvme0 -n 1 -i 1 -s 0 -l 1024 -p test
|
||||
$rpc_py bdev_opal_create -b nvme0 -n 1 -i 2 -s 1024 -l 512 -p test
|
||||
$rpc_py bdev_opal_get_info -b nvme0n1r1 -p test
|
||||
@ -49,7 +66,8 @@ function test_opal_cmds() {
|
||||
}
|
||||
|
||||
function setup_test_environment() {
|
||||
$rpc_py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a $bdf1
|
||||
$rpc_py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a ${bdf}
|
||||
|
||||
$rpc_py bdev_opal_create -b nvme0 -n 1 -i 1 -s 0 -l 1024 -p test
|
||||
$rpc_py bdev_opal_create -b nvme0 -n 1 -i 2 -s 1024 -l 512 -p test
|
||||
$rpc_py bdev_opal_create -b nvme0 -n 1 -i 3 -s 4096 -l 4096 -p test
|
||||
@ -69,16 +87,14 @@ function clean_up() {
|
||||
}
|
||||
|
||||
function revert() {
|
||||
# Ignore revert failure and kill the process
|
||||
$rpc_py bdev_nvme_opal_revert -b nvme0 -p test || true
|
||||
$rpc_py bdev_nvme_opal_revert -b nvme0 -p test
|
||||
}
|
||||
|
||||
function opal_spdk_tgt() {
|
||||
$SPDK_BIN_DIR/spdk_tgt &
|
||||
spdk_tgt_pid=$!
|
||||
trap 'revert; killprocess $spdk_tgt_pid; exit 1' SIGINT SIGTERM EXIT
|
||||
trap 'killprocess $spdk_tgt_pid; exit 1' SIGINT SIGTERM EXIT
|
||||
waitforlisten $spdk_tgt_pid
|
||||
opal_init
|
||||
test_opal_cmds
|
||||
killprocess $spdk_tgt_pid
|
||||
}
|
||||
@ -86,11 +102,12 @@ function opal_spdk_tgt() {
|
||||
function opal_bdevio() {
|
||||
$rootdir/test/bdev/bdevio/bdevio -w &
|
||||
bdevio_pid=$!
|
||||
trap 'revert; killprocess $bdevio_pid; exit 1' SIGINT SIGTERM EXIT
|
||||
trap 'killprocess $bdevio_pid; exit 1' SIGINT SIGTERM EXIT
|
||||
waitforlisten $bdevio_pid
|
||||
setup_test_environment
|
||||
$rootdir/test/bdev/bdevio/tests.py perform_tests
|
||||
clean_up
|
||||
$rpc_py bdev_nvme_detach_controller nvme0
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
killprocess $bdevio_pid
|
||||
}
|
||||
@ -104,10 +121,13 @@ function opal_bdevperf() {
|
||||
$rootdir/test/bdev/bdevperf/bdevperf.py perform_tests
|
||||
clean_up
|
||||
revert
|
||||
$rpc_py bdev_nvme_detach_controller nvme0
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
killprocess $bdevperf_pid
|
||||
}
|
||||
|
||||
opal_revert_and_init
|
||||
|
||||
run_test "nvme_opal_spdk_tgt" opal_spdk_tgt
|
||||
run_test "nvme_opal_bdevio" opal_bdevio
|
||||
run_test "nvme_opal_bdevperf" opal_bdevperf
|
||||
|
Loading…
Reference in New Issue
Block a user