test/nvmf: only run RDMA NIC setup once

Change-Id: I69607670de95652f997712ad3e7441718c97e3ab
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-07-08 14:19:11 -07:00 committed by Benjamin Walker
parent e6a5bb1067
commit c4bb610d93
5 changed files with 34 additions and 18 deletions

View File

@ -2,6 +2,7 @@
rootdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $(dirname $0))
source "$rootdir/scripts/autotest_common.sh" source "$rootdir/scripts/autotest_common.sh"
source "$rootdir/test/nvmf/common.sh"
set -xe set -xe
@ -43,6 +44,10 @@ timing_enter afterboot
./scripts/setup.sh ./scripts/setup.sh
timing_exit afterboot timing_exit afterboot
timing_enter nvmf_setup
rdma_device_init
timing_exit nvmf_setup
##################### #####################
# Unit Tests # Unit Tests
##################### #####################

View File

@ -8,7 +8,7 @@ NVMF_FIRST_TARGET_IP=$NVMF_IP_PREFIX.$NVMF_IP_LEAST_ADDR
function load_ib_rdma_modules() function load_ib_rdma_modules()
{ {
if [ `uname` != Linux ]; then if [ `uname` != Linux ]; then
exit 0 return 0
fi fi
modprobe ib_cm modprobe ib_cm
@ -23,13 +23,17 @@ function load_ib_rdma_modules()
function detect_mellanox_nics() function detect_mellanox_nics()
{ {
if ! hash lspci; then
return 0
fi
nvmf_nic_bdfs=`lspci | grep Ethernet | grep Mellanox | awk -F ' ' '{print "0000:"$1}'` nvmf_nic_bdfs=`lspci | grep Ethernet | grep Mellanox | awk -F ' ' '{print "0000:"$1}'`
mlx_core_driver="mlx4_core" mlx_core_driver="mlx4_core"
mlx_ib_driver="mlx4_ib" mlx_ib_driver="mlx4_ib"
mlx_en_driver="mlx4_en" mlx_en_driver="mlx4_en"
if [ -z "$nvmf_nic_bdfs" ]; then if [ -z "$nvmf_nic_bdfs" ]; then
exit 0 return 0
fi fi
# for nvmf target loopback test, suppose we only have one type of card. # for nvmf target loopback test, suppose we only have one type of card.
@ -68,8 +72,6 @@ function detect_mellanox_nics()
# The mlx4 driver takes an extra few seconds to load after modprobe returns, # The mlx4 driver takes an extra few seconds to load after modprobe returns,
# otherwise ifconfig operations will do nothing. # otherwise ifconfig operations will do nothing.
sleep 5 sleep 5
trap - SIGINT SIGTERM EXIT
} }
function detect_rdma_nics() function detect_rdma_nics()
@ -84,16 +86,12 @@ function allocate_nic_ips()
for nic_type in `ls /sys/class/infiniband`; do for nic_type in `ls /sys/class/infiniband`; do
for nic_name in `ls /sys/class/infiniband/${nic_type}/device/net`; do for nic_name in `ls /sys/class/infiniband/${nic_type}/device/net`; do
ifconfig $nic_name $NVMF_IP_PREFIX.$count netmask 255.255.255.0 up ifconfig $nic_name $NVMF_IP_PREFIX.$count netmask 255.255.255.0 up
# dump configuration for debug log
ifconfig $nic_name
let count=$count+1 let count=$count+1
done done
done done
# check whether the IP is configured
result=`ifconfig | grep $NVMF_IP_PREFIX`
if [ -z "$result" ]; then
echo "no NIC for nvmf test"
exit 0
fi
} }
function nvmfcleanup() function nvmfcleanup()
@ -109,3 +107,7 @@ function rdma_device_init()
allocate_nic_ips allocate_nic_ips
} }
function rdma_nic_available()
{
ifconfig | grep -q $NVMF_IP_PREFIX
}

View File

@ -5,14 +5,17 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/scripts/autotest_common.sh source $rootdir/scripts/autotest_common.sh
source $rootdir/test/nvmf/common.sh source $rootdir/test/nvmf/common.sh
set -e
if ! hash nvme; then if ! hash nvme; then
echo "nvme command not found; skipping discovery test" echo "nvme command not found; skipping discovery test"
exit 0 exit 0
fi fi
rdma_device_init if ! rdma_nic_available; then
echo "no NIC for nvmf test"
set -e exit 0
fi
timing_enter discovery timing_enter discovery

View File

@ -31,10 +31,13 @@ function filesystem_test()
done done
} }
rdma_device_init
set -e set -e
if ! rdma_nic_available; then
echo "no NIC for nvmf test"
exit 0
fi
timing_enter fs_test timing_enter fs_test
# Start up the NVMf target in another process # Start up the NVMf target in another process

View File

@ -5,10 +5,13 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/scripts/autotest_common.sh source $rootdir/scripts/autotest_common.sh
source $rootdir/test/nvmf/common.sh source $rootdir/test/nvmf/common.sh
rdma_device_init
set -e set -e
if ! rdma_nic_available; then
echo "no NIC for nvmf test"
exit 0
fi
timing_enter fio timing_enter fio
# Start up the NVMf target in another process # Start up the NVMf target in another process