Commit db43b387 authored by Karol Latecki's avatar Karol Latecki Committed by Tomasz Zawadzki
Browse files

test: do not use iter_pci_class_code in tests



Do not use iter_pci_class_code function in tests to
iterate over NVMe drives. This function can return
drives which at the moment of execution can not be
whitelisted for use.

This can result in test errors (such as simply
bdev_nvme_attach_controller RPC command failing) or
even using and deleting data from NVMe drive which
was not meant to be used in tests.

Fixes #1235

Change-Id: I82b9935fc88605b636c2096be6c71d4880a567c8
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1309


Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent bad71510
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ def get_nvme_devices_count():

def get_nvme_devices_bdf():
    print("Getting BDFs for NVMe section")
    output = check_output("source scripts/common.sh; iter_pci_class_code 01 08 02",
    output = check_output("rootdir=$PWD; \
                          source test/common/autotest_common.sh; \
                          get_nvme_bdfs 01 08 02",
                          executable="/bin/bash", shell=True)
    output = [str(x, encoding="utf-8") for x in output.split()]
    print("Done getting BDFs")
+13 −0
Original line number Diff line number Diff line
@@ -1126,6 +1126,19 @@ function opal_revert_cleanup {
	killprocess $spdk_tgt_pid
}

# Get BDF addresses of all NVMe drives currently attached to
# uio-pci-generic or vfio-pci
function get_nvme_bdfs() {
    xtrace_disable
    jq -r .config[].params.traddr <<< $(scripts/gen_nvme.sh --json)
    xtrace_restore
}

# Same as function above, but just get the first disks BDF address
function get_first_nvme_bdf() {
    head -1 <<< $(get_nvme_bdfs)
}

set -o errtrace
shopt -s extdebug
trap "trap - ERR; print_backtrace >&2" ERR
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ echo "iscsi_tgt is listening. Running tests..."

timing_exit start_iscsi_tgt

bdf=$(iter_pci_class_code 01 08 02 | head -1)
bdf=$(get_first_nvme_bdf)
$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
$rpc_py bdev_nvme_attach_controller -b "Nvme0" -t "pcie" -a $bdf
+3 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ source $rootdir/test/common/autotest_common.sh

function nvme_identify {
	$rootdir/examples/nvme/identify/identify -i 0
	for bdf in $(iter_pci_class_code 01 08 02); do
	for bdf in $(get_nvme_bdfs); do
		$rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:${bdf}" -i 0
	done
	timing_exit identify
@@ -25,7 +25,7 @@ function nvme_perf {

function nvme_fio_test {
	PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin
	for bdf in $(iter_pci_class_code 01 08 02); do
	for bdf in $(get_nvme_bdfs); do
		for blkname in $(get_nvme_name_from_bdf $bdf); do
			fio_nvme $PLUGIN_DIR/example_config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=${blkname##*n}"
		done
@@ -55,7 +55,7 @@ if [ $(uname) = Linux ]; then
	#
	# note: more work probably needs to be done to properly handle devices with multiple
	# namespaces
	for bdf in $(iter_pci_class_code 01 08 02); do
	for bdf in $(get_nvme_bdfs); do
		for name in $(get_nvme_name_from_bdf $bdf); do
			if [ "$name" != "" ]; then
				mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w)
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ source $rootdir/test/common/autotest_common.sh

rpc_py=$rootdir/scripts/rpc.py

bdf=$(iter_pci_class_code 01 08 02 | head -1)
bdf=$(get_first_nvme_bdf)

$rootdir/app/spdk_tgt/spdk_tgt -m 0x3 &
spdk_tgt_pid=$!
Loading