2017-11-15 18:43:15 +00:00
|
|
|
: ${SPDK_AUTOTEST_X=true}; export SPDK_AUTOTEST_X
|
|
|
|
|
|
|
|
if $SPDK_AUTOTEST_X; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-04-04 16:38:39 +00:00
|
|
|
# Export flag to skip the known bug that exists in librados
|
|
|
|
# Bug is reported on ceph bug tracker with number 24078
|
|
|
|
export ASAN_OPTIONS=new_delete_type_mismatch=0
|
|
|
|
|
2017-08-09 21:55:17 +00:00
|
|
|
PS4=' \t \$ '
|
2015-09-21 15:52:41 +00:00
|
|
|
ulimit -c unlimited
|
|
|
|
|
2018-01-04 17:08:03 +00:00
|
|
|
: ${RUN_NIGHTLY:=0}
|
|
|
|
export RUN_NIGHTLY
|
2016-03-23 20:34:31 +00:00
|
|
|
|
2018-03-15 18:40:13 +00:00
|
|
|
: ${RUN_NIGHTLY_FAILING:=0}
|
|
|
|
export RUN_NIGHTLY_FAILING
|
|
|
|
|
2017-05-02 00:34:15 +00:00
|
|
|
if [[ ! -z $1 ]]; then
|
|
|
|
if [ -f $1 ]; then
|
|
|
|
source $1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-04-25 17:00:20 +00:00
|
|
|
# If certain utilities are not installed, preemptively disable the tests
|
|
|
|
if ! hash ceph; then
|
|
|
|
SPDK_TEST_RBD=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! hash pmempool; then
|
|
|
|
SPDK_TEST_PMDK=0
|
|
|
|
fi
|
|
|
|
|
2017-05-02 00:34:15 +00:00
|
|
|
# Set defaults for missing test config options
|
2017-05-02 00:38:42 +00:00
|
|
|
: ${SPDK_BUILD_DOC=1}; export SPDK_BUILD_DOC
|
2017-06-29 21:38:10 +00:00
|
|
|
: ${SPDK_RUN_CHECK_FORMAT=1}; export SPDK_RUN_CHECK_FORMAT
|
2017-05-31 23:48:02 +00:00
|
|
|
: ${SPDK_RUN_SCANBUILD=1}; export SPDK_RUN_SCANBUILD
|
|
|
|
: ${SPDK_RUN_VALGRIND=1}; export SPDK_RUN_VALGRIND
|
2017-05-24 16:25:45 +00:00
|
|
|
: ${SPDK_TEST_UNITTEST=1}; export SPDK_TEST_UNITTEST
|
2017-05-02 00:34:15 +00:00
|
|
|
: ${SPDK_TEST_ISCSI=1}; export SPDK_TEST_ISCSI
|
2018-03-16 11:49:11 +00:00
|
|
|
: ${SPDK_TEST_ISCSI_INITIATOR=1}; export SPDK_TEST_ISCSI_INITIATOR
|
2017-05-02 00:34:15 +00:00
|
|
|
: ${SPDK_TEST_NVME=1}; export SPDK_TEST_NVME
|
2018-07-10 16:32:30 +00:00
|
|
|
: ${SPDK_TEST_NVME_CLI=1}; export SPDK_TEST_NVME_CLI
|
2017-05-02 00:34:15 +00:00
|
|
|
: ${SPDK_TEST_NVMF=1}; export SPDK_TEST_NVMF
|
2017-07-19 23:22:38 +00:00
|
|
|
: ${SPDK_TEST_RBD=1}; export SPDK_TEST_RBD
|
2017-05-02 00:34:15 +00:00
|
|
|
: ${SPDK_TEST_VHOST=1}; export SPDK_TEST_VHOST
|
|
|
|
: ${SPDK_TEST_BLOCKDEV=1}; export SPDK_TEST_BLOCKDEV
|
|
|
|
: ${SPDK_TEST_IOAT=1}; export SPDK_TEST_IOAT
|
|
|
|
: ${SPDK_TEST_EVENT=1}; export SPDK_TEST_EVENT
|
|
|
|
: ${SPDK_TEST_BLOBFS=1}; export SPDK_TEST_BLOBFS
|
2018-02-23 15:30:59 +00:00
|
|
|
: ${SPDK_TEST_VHOST_INIT=1}; export SPDK_TEST_VHOST_INIT
|
2018-04-03 23:07:39 +00:00
|
|
|
: ${SPDK_TEST_PMDK=1}; export SPDK_TEST_PMDK
|
2017-10-23 15:03:18 +00:00
|
|
|
: ${SPDK_TEST_LVOL=1}; export SPDK_TEST_LVOL
|
2017-08-08 22:58:45 +00:00
|
|
|
: ${SPDK_RUN_ASAN=1}; export SPDK_RUN_ASAN
|
2017-06-29 23:11:35 +00:00
|
|
|
: ${SPDK_RUN_UBSAN=1}; export SPDK_RUN_UBSAN
|
2017-05-02 00:34:15 +00:00
|
|
|
|
2018-06-22 09:16:10 +00:00
|
|
|
if [ -z "$DEPENDENCY_DIR" ]; then
|
|
|
|
export DEPENDENCY_DIR=/home/sys_sgsw
|
|
|
|
else
|
|
|
|
export DEPENDENCY_DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$HUGEMEM" ]; then
|
|
|
|
export HUGEMEM
|
|
|
|
fi
|
|
|
|
|
2017-07-11 16:56:52 +00:00
|
|
|
# pass our valgrind desire on to unittest.sh
|
|
|
|
if [ $SPDK_RUN_VALGRIND -eq 0 ]; then
|
|
|
|
export valgrind=''
|
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
config_params='--enable-debug --enable-werror'
|
2015-10-22 18:26:21 +00:00
|
|
|
|
2018-07-18 19:08:17 +00:00
|
|
|
if echo -e "#include <libunwind.h>\nint main(int argc, char *argv[]) {return 0;}\n" | \
|
|
|
|
gcc -o /dev/null -lunwind -x c - 2>/dev/null; then
|
|
|
|
config_params+=' --enable-log-bt=ERROR'
|
|
|
|
fi
|
|
|
|
|
2018-07-27 18:59:14 +00:00
|
|
|
# RAID is marked experimental and not built by default currently, since it does not
|
|
|
|
# support iov (meaning vhost will not work). But enable it in the build here, to make
|
|
|
|
# sure it gets built and run against a limited set of use cases for now.
|
|
|
|
config_params+=' --with-raid'
|
|
|
|
|
2017-03-23 21:15:38 +00:00
|
|
|
export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
|
2016-11-30 18:20:32 +00:00
|
|
|
|
2018-06-20 08:21:17 +00:00
|
|
|
# On Linux systems, override the default HUGEMEM in scripts/setup.sh to
|
|
|
|
# allocate 8GB in hugepages.
|
|
|
|
# FreeBSD runs a much more limited set of tests, so keep the default 2GB.
|
|
|
|
if [ `uname -s` = "Linux" ]; then
|
|
|
|
export HUGEMEM=8192
|
|
|
|
fi
|
2017-03-07 00:50:39 +00:00
|
|
|
|
2017-11-09 23:33:29 +00:00
|
|
|
DEFAULT_RPC_ADDR=/var/tmp/spdk.sock
|
|
|
|
|
2015-10-03 00:11:56 +00:00
|
|
|
case `uname` in
|
|
|
|
FreeBSD)
|
2017-05-08 22:07:13 +00:00
|
|
|
DPDK_FREEBSD_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang
|
|
|
|
if [ -d $DPDK_FREEBSD_DIR ]; then
|
|
|
|
WITH_DPDK_DIR=$DPDK_FREEBSD_DIR
|
|
|
|
fi
|
2015-10-03 00:11:56 +00:00
|
|
|
MAKE=gmake
|
2015-12-31 17:28:18 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')}
|
2017-12-19 00:01:45 +00:00
|
|
|
SPDK_RUN_ASAN=0
|
|
|
|
SPDK_RUN_UBSAN=0
|
2015-10-03 00:11:56 +00:00
|
|
|
;;
|
|
|
|
Linux)
|
2017-05-08 22:07:13 +00:00
|
|
|
DPDK_LINUX_DIR=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc
|
|
|
|
if [ -d $DPDK_LINUX_DIR ]; then
|
|
|
|
WITH_DPDK_DIR=$DPDK_LINUX_DIR
|
|
|
|
fi
|
2015-10-03 00:11:56 +00:00
|
|
|
MAKE=make
|
2015-12-31 17:28:18 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
|
2017-03-30 19:06:49 +00:00
|
|
|
config_params+=' --enable-coverage'
|
2017-06-29 23:11:35 +00:00
|
|
|
if [ $SPDK_RUN_UBSAN -eq 1 ]; then
|
|
|
|
config_params+=' --enable-ubsan'
|
|
|
|
fi
|
2017-06-12 05:08:19 +00:00
|
|
|
if [ $SPDK_RUN_ASAN -eq 1 ]; then
|
2017-11-15 18:43:15 +00:00
|
|
|
if ldconfig -p | grep -q asan; then
|
2017-06-12 05:08:19 +00:00
|
|
|
config_params+=' --enable-asan'
|
|
|
|
else
|
|
|
|
SPDK_RUN_ASAN=0
|
|
|
|
fi
|
|
|
|
fi
|
2015-10-03 00:11:56 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown OS in $0"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-05-08 22:07:13 +00:00
|
|
|
# By default, --with-dpdk is not set meaning the SPDK build will use the DPDK submodule.
|
|
|
|
# If a DPDK installation is found in a well-known location though, WITH_DPDK_DIR will be
|
|
|
|
# set which will override the default and use that DPDK installation instead.
|
|
|
|
if [ ! -z "$WITH_DPDK_DIR" ]; then
|
|
|
|
config_params+=" --with-dpdk=$WITH_DPDK_DIR"
|
|
|
|
fi
|
|
|
|
|
2016-06-06 21:44:30 +00:00
|
|
|
if [ -f /usr/include/infiniband/verbs.h ]; then
|
2017-03-30 19:06:49 +00:00
|
|
|
config_params+=' --with-rdma'
|
2016-06-06 21:44:30 +00:00
|
|
|
fi
|
|
|
|
|
2017-09-29 08:49:51 +00:00
|
|
|
if [ -f /usr/include/libpmemblk.h ]; then
|
2018-04-03 23:07:39 +00:00
|
|
|
config_params+=' --with-pmdk'
|
|
|
|
else
|
|
|
|
# PMDK not installed so disable PMDK tests explicitly here
|
|
|
|
SPDK_TEST_PMDK=0; export SPDK_TEST_PMDK
|
2017-09-29 08:49:51 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
if [ -d /usr/src/fio ]; then
|
|
|
|
config_params+=' --with-fio=/usr/src/fio'
|
|
|
|
fi
|
|
|
|
|
2018-06-22 09:16:10 +00:00
|
|
|
if [ -d ${DEPENDENCY_DIR}/vtune_codes ]; then
|
|
|
|
config_params+=' --with-vtune='${DEPENDENCY_DIR}'/vtune_codes'
|
2017-12-20 20:20:11 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ]; then
|
|
|
|
config_params+=' --with-rbd'
|
|
|
|
fi
|
|
|
|
|
2017-12-04 17:07:04 +00:00
|
|
|
if [ -d /usr/include/iscsi ]; then
|
|
|
|
libiscsi_version=`grep LIBISCSI_API_VERSION /usr/include/iscsi/iscsi.h | head -1 | awk '{print $3}' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}'`
|
|
|
|
if [ $libiscsi_version -ge 20150621 ]; then
|
|
|
|
config_params+=' --with-iscsi-initiator'
|
2018-03-16 11:49:11 +00:00
|
|
|
else
|
|
|
|
export SPDK_TEST_ISCSI_INITIATOR=0
|
2017-12-04 17:07:04 +00:00
|
|
|
fi
|
2018-03-16 11:49:11 +00:00
|
|
|
else
|
|
|
|
export SPDK_TEST_ISCSI_INITIATOR=0
|
2017-12-04 17:07:04 +00:00
|
|
|
fi
|
2018-03-16 11:49:11 +00:00
|
|
|
|
2018-07-10 16:32:30 +00:00
|
|
|
if [ ! -d "${DEPENDENCY_DIR}/nvme-cli" ]; then
|
|
|
|
export SPDK_TEST_NVME_CLI=0
|
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
export config_params
|
|
|
|
|
2015-10-09 00:22:39 +00:00
|
|
|
if [ -z "$output_dir" ]; then
|
|
|
|
if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then
|
|
|
|
output_dir=.
|
|
|
|
else
|
|
|
|
output_dir=$rootdir/../output
|
|
|
|
fi
|
|
|
|
export output_dir
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
function timing() {
|
|
|
|
direction="$1"
|
|
|
|
testname="$2"
|
|
|
|
|
|
|
|
now=$(date +%s)
|
|
|
|
|
|
|
|
if [ "$direction" = "enter" ]; then
|
2015-10-08 19:40:44 +00:00
|
|
|
export timing_stack="${timing_stack};${now}"
|
|
|
|
export test_stack="${test_stack};${testname}"
|
2015-09-21 15:52:41 +00:00
|
|
|
else
|
2015-10-08 19:40:44 +00:00
|
|
|
child_time=$(grep "^${test_stack:1};" $output_dir/timing.txt | awk '{s+=$2} END {print s}')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
start_time=$(echo "$timing_stack" | sed -e 's@^.*;@@')
|
|
|
|
timing_stack=$(echo "$timing_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
elapsed=$((now - start_time - child_time))
|
|
|
|
echo "${test_stack:1} $elapsed" >> $output_dir/timing.txt
|
|
|
|
|
|
|
|
test_stack=$(echo "$test_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function timing_enter() {
|
2016-12-02 18:26:28 +00:00
|
|
|
set +x
|
2015-09-21 15:52:41 +00:00
|
|
|
timing "enter" "$1"
|
2016-12-02 18:26:28 +00:00
|
|
|
set -x
|
2015-09-21 15:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function timing_exit() {
|
2016-12-02 18:26:28 +00:00
|
|
|
set +x
|
2015-09-21 15:52:41 +00:00
|
|
|
timing "exit" "$1"
|
2016-12-02 18:26:28 +00:00
|
|
|
set -x
|
2015-09-21 15:52:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
function timing_finish() {
|
|
|
|
flamegraph='/usr/local/FlameGraph/flamegraph.pl'
|
|
|
|
if [ -x "$flamegraph" ]; then
|
|
|
|
"$flamegraph" \
|
|
|
|
--title 'Build Timing' \
|
|
|
|
--nametype 'Step:' \
|
|
|
|
--countname seconds \
|
|
|
|
$output_dir/timing.txt \
|
|
|
|
>$output_dir/timing.svg
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-12-18 21:20:41 +00:00
|
|
|
function create_test_list() {
|
|
|
|
grep -rsh --exclude="autotest_common.sh" --exclude="$rootdir/test/common/autotest_common.sh" -e "report_test_completion" $rootdir | sed 's/report_test_completion//g; s/[[:blank:]]//g; s/"//g;' > $output_dir/all_tests.txt || true
|
|
|
|
}
|
|
|
|
|
|
|
|
function report_test_completion() {
|
|
|
|
echo "$1" >> $output_dir/test_completions.txt
|
|
|
|
}
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
function process_core() {
|
|
|
|
ret=0
|
2017-03-21 18:22:11 +00:00
|
|
|
for core in $(find . -type f \( -name 'core*' -o -name '*.core' \)); do
|
2015-12-02 20:10:54 +00:00
|
|
|
exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/")
|
2018-08-02 11:34:59 +00:00
|
|
|
if [[ ! -f "$exe" ]]; then
|
|
|
|
exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+")
|
|
|
|
fi
|
2015-09-21 15:52:41 +00:00
|
|
|
echo "exe for $core is $exe"
|
|
|
|
if [[ ! -z "$exe" ]]; then
|
|
|
|
if hash gdb; then
|
2017-06-06 23:13:29 +00:00
|
|
|
gdb -batch -ex "thread apply all bt full" $exe $core
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
cp $exe $output_dir
|
|
|
|
fi
|
|
|
|
mv $core $output_dir
|
|
|
|
chmod a+r $output_dir/$core
|
|
|
|
ret=1
|
|
|
|
done
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
function waitforlisten() {
|
2017-11-09 23:33:29 +00:00
|
|
|
# $1 = process pid
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-20 17:54:53 +00:00
|
|
|
rpc_addr="${2:-$DEFAULT_RPC_ADDR}"
|
|
|
|
|
|
|
|
echo "Waiting for process to start up and listen on UNIX domain socket $rpc_addr..."
|
2017-11-09 23:33:29 +00:00
|
|
|
# turn off trace for this loop
|
|
|
|
set +x
|
|
|
|
ret=1
|
|
|
|
while [ $ret -ne 0 ]; do
|
|
|
|
# if the process is no longer running, then exit the script
|
|
|
|
# since it means the application crashed
|
|
|
|
if ! kill -s 0 $1; then
|
2018-03-07 18:27:02 +00:00
|
|
|
exit 1
|
2017-11-09 23:33:29 +00:00
|
|
|
fi
|
2018-04-25 16:16:08 +00:00
|
|
|
|
|
|
|
namespace=$(ip netns identify $1)
|
|
|
|
if [ -n "$namespace" ]; then
|
|
|
|
ns_cmd="ip netns exec $namespace"
|
|
|
|
fi
|
|
|
|
|
2018-04-04 19:47:52 +00:00
|
|
|
if hash ss; then
|
2018-04-25 16:16:08 +00:00
|
|
|
if $ns_cmd ss -lx | grep -q $rpc_addr; then
|
2018-04-04 19:47:52 +00:00
|
|
|
ret=0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# if system doesn't have ss, just assume it has netstat
|
2018-04-25 16:16:08 +00:00
|
|
|
if $ns_cmd netstat -an -x | grep -iw LISTENING | grep -q $rpc_addr; then
|
2018-04-04 19:47:52 +00:00
|
|
|
ret=0
|
|
|
|
fi
|
2016-08-03 21:37:16 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -x
|
|
|
|
}
|
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
function waitfornbd() {
|
|
|
|
nbd_name=$1
|
2017-07-06 02:41:57 +00:00
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
for ((i=1; i<=20; i++)); do
|
|
|
|
if grep -q -w $nbd_name /proc/partitions; then
|
2017-11-06 18:33:48 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
sleep 0.1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# The nbd device is now recognized as a block device, but there can be
|
|
|
|
# a small delay before we can start I/O to that block device. So loop
|
|
|
|
# here trying to read the first block of the nbd block device to a temp
|
|
|
|
# file. Note that dd returns success when reading an empty file, so we
|
|
|
|
# need to check the size of the output file instead.
|
|
|
|
for ((i=1; i<=20; i++)); do
|
|
|
|
dd if=/dev/$nbd_name of=/tmp/nbdtest bs=4096 count=1 iflag=direct
|
|
|
|
size=`stat -c %s /tmp/nbdtest`
|
|
|
|
rm -f /tmp/nbdtest
|
|
|
|
if [ "$size" != "0" ]; then
|
2017-07-06 02:41:57 +00:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
sleep 0.1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-06-07 15:49:44 +00:00
|
|
|
function killprocess() {
|
|
|
|
# $1 = process pid
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "killing process with pid $1"
|
|
|
|
kill $1
|
2016-09-13 17:46:07 +00:00
|
|
|
wait $1
|
2016-06-07 15:49:44 +00:00
|
|
|
}
|
2016-07-21 22:54:23 +00:00
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
function iscsicleanup() {
|
|
|
|
echo "Cleaning up iSCSI connection"
|
|
|
|
iscsiadm -m node --logout || true
|
|
|
|
iscsiadm -m node -o delete || true
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_iscsi_service() {
|
|
|
|
if cat /etc/*-release | grep Ubuntu; then
|
|
|
|
service open-iscsi stop
|
|
|
|
else
|
|
|
|
service iscsid stop
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function start_iscsi_service() {
|
|
|
|
if cat /etc/*-release | grep Ubuntu; then
|
|
|
|
service open-iscsi start
|
|
|
|
else
|
|
|
|
service iscsid start
|
|
|
|
fi
|
|
|
|
}
|
2016-10-06 16:57:09 +00:00
|
|
|
|
2016-11-16 18:18:40 +00:00
|
|
|
function rbd_setup() {
|
2018-04-16 13:12:23 +00:00
|
|
|
# $1 = monitor ip address
|
2018-04-25 16:16:08 +00:00
|
|
|
# $2 = name of the namespace
|
2018-04-16 13:12:23 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "No monitor IP address provided for ceph"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-04-25 16:16:08 +00:00
|
|
|
if [ -n "$2" ]; then
|
|
|
|
if ip netns list | grep "$2"; then
|
|
|
|
NS_CMD="ip netns exec $2"
|
|
|
|
else
|
|
|
|
echo "No namespace $2 exists"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2018-04-16 13:12:23 +00:00
|
|
|
|
2017-08-09 00:21:24 +00:00
|
|
|
if hash ceph; then
|
2018-03-28 21:47:11 +00:00
|
|
|
export PG_NUM=128
|
2017-07-19 23:22:38 +00:00
|
|
|
export RBD_POOL=rbd
|
|
|
|
export RBD_NAME=foo
|
2018-04-25 16:16:08 +00:00
|
|
|
$NS_CMD $rootdir/scripts/ceph/start.sh $1
|
2018-03-28 21:47:11 +00:00
|
|
|
|
2018-04-25 16:16:08 +00:00
|
|
|
$NS_CMD ceph osd pool create $RBD_POOL $PG_NUM || true
|
|
|
|
$NS_CMD rbd create $RBD_NAME --size 1000
|
2016-11-16 18:18:40 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function rbd_cleanup() {
|
2017-08-09 00:21:24 +00:00
|
|
|
if hash ceph; then
|
2018-02-27 17:30:22 +00:00
|
|
|
$rootdir/scripts/ceph/stop.sh || true
|
2016-11-16 18:18:40 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-25 03:58:35 +00:00
|
|
|
function start_stub() {
|
2018-04-17 00:34:01 +00:00
|
|
|
# Disable ASLR for multi-process testing. SPDK does support using DPDK multi-process,
|
2018-06-21 08:15:17 +00:00
|
|
|
# but ASLR can still be unreliable in some cases.
|
|
|
|
# We will reenable it again after multi-process testing is complete in kill_stub()
|
2018-04-17 00:34:01 +00:00
|
|
|
echo 0 > /proc/sys/kernel/randomize_va_space
|
2017-05-25 03:58:35 +00:00
|
|
|
$rootdir/test/app/stub/stub $1 &
|
|
|
|
stubpid=$!
|
|
|
|
echo Waiting for stub to ready for secondary processes...
|
2017-05-25 22:26:18 +00:00
|
|
|
while ! [ -e /var/run/spdk_stub0 ]; do
|
|
|
|
sleep 1s
|
2017-05-25 03:58:35 +00:00
|
|
|
done
|
2018-04-16 23:57:42 +00:00
|
|
|
# dump process memory map contents to help debug random ASLR failures
|
2018-05-18 17:45:36 +00:00
|
|
|
pmap -pX $stubpid || pmap -x $stubpid || true
|
2017-05-25 03:58:35 +00:00
|
|
|
echo done.
|
|
|
|
}
|
|
|
|
|
|
|
|
function kill_stub() {
|
|
|
|
kill $stubpid
|
2017-06-30 14:48:53 +00:00
|
|
|
wait $stubpid
|
2017-06-22 06:30:02 +00:00
|
|
|
rm -f /var/run/spdk_stub0
|
2018-04-17 00:34:01 +00:00
|
|
|
# Re-enable ASLR now that we are done with multi-process testing
|
|
|
|
# Note: "1" enables ASLR w/o randomizing data segments, "2" adds data segment
|
|
|
|
# randomizing and is the default on all recent Linux kernels
|
|
|
|
echo 2 > /proc/sys/kernel/randomize_va_space
|
2017-05-25 03:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-10-06 16:57:09 +00:00
|
|
|
function run_test() {
|
2016-12-02 18:26:28 +00:00
|
|
|
set +x
|
2018-03-13 05:57:41 +00:00
|
|
|
local test_type="$(echo $1 | tr 'a-z' 'A-Z')"
|
|
|
|
shift
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2018-03-13 05:57:41 +00:00
|
|
|
echo "START TEST $test_type $@"
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2016-12-02 18:26:28 +00:00
|
|
|
set -x
|
2016-12-07 02:21:23 +00:00
|
|
|
time "$@"
|
2016-12-02 18:26:28 +00:00
|
|
|
set +x
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2018-03-13 05:57:41 +00:00
|
|
|
echo "END TEST $test_type $@"
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2016-12-02 18:26:28 +00:00
|
|
|
set -x
|
2016-10-06 16:57:09 +00:00
|
|
|
}
|
2017-02-20 19:32:49 +00:00
|
|
|
|
|
|
|
function print_backtrace() {
|
2017-11-15 18:43:15 +00:00
|
|
|
local shell_options="$-"
|
2017-02-20 19:32:49 +00:00
|
|
|
set +x
|
|
|
|
echo "========== Backtrace start: =========="
|
|
|
|
echo ""
|
|
|
|
for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
|
|
|
|
local func="${FUNCNAME[$i]}"
|
|
|
|
local line_nr="${BASH_LINENO[$((i - 1))]}"
|
2017-10-25 19:32:37 +00:00
|
|
|
local src="${BASH_SOURCE[$i]}"
|
2017-02-20 19:32:49 +00:00
|
|
|
echo "in $src:$line_nr -> $func()"
|
|
|
|
echo " ..."
|
2017-11-15 18:43:15 +00:00
|
|
|
nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^$line_nr[^0-9]" | \
|
2017-03-08 19:46:31 +00:00
|
|
|
sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g"
|
2017-02-20 19:32:49 +00:00
|
|
|
echo " ..."
|
|
|
|
done
|
|
|
|
echo ""
|
|
|
|
echo "========== Backtrace end =========="
|
2017-11-15 18:43:15 +00:00
|
|
|
[[ "$shell_options" =~ x ]] && set -x
|
2017-02-20 19:32:49 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
function part_dev_by_gpt () {
|
2018-02-01 18:36:49 +00:00
|
|
|
if [ $(uname -s) = Linux ] && hash sgdisk && modprobe nbd; then
|
2017-07-17 07:45:46 +00:00
|
|
|
conf=$1
|
|
|
|
devname=$2
|
|
|
|
rootdir=$3
|
2017-08-11 22:06:17 +00:00
|
|
|
operation=$4
|
2017-12-11 06:56:40 +00:00
|
|
|
local nbd_path=/dev/nbd0
|
|
|
|
local rpc_server=/var/tmp/spdk-gpt-bdevs.sock
|
2017-07-17 07:45:46 +00:00
|
|
|
|
|
|
|
if [ ! -e $conf ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2017-08-11 22:06:17 +00:00
|
|
|
if [ -z "$operation" ]; then
|
|
|
|
operation="create"
|
|
|
|
fi
|
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
cp $conf ${conf}.gpt
|
|
|
|
echo "[Gpt]" >> ${conf}.gpt
|
|
|
|
echo " Disable Yes" >> ${conf}.gpt
|
|
|
|
|
2017-12-11 06:56:40 +00:00
|
|
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -c ${conf}.gpt &
|
2017-07-17 07:45:46 +00:00
|
|
|
nbd_pid=$!
|
|
|
|
echo "Process nbd pid: $nbd_pid"
|
2017-12-11 06:56:40 +00:00
|
|
|
waitforlisten $nbd_pid $rpc_server
|
|
|
|
|
|
|
|
# Start bdev as a nbd device
|
|
|
|
$rootdir/scripts/rpc.py -s "$rpc_server" start_nbd_disk $devname $nbd_path
|
|
|
|
|
|
|
|
waitfornbd ${nbd_path:5}
|
2017-11-03 18:22:05 +00:00
|
|
|
|
|
|
|
if [ "$operation" = create ]; then
|
2017-12-11 06:56:40 +00:00
|
|
|
parted -s $nbd_path mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
|
2017-11-29 16:18:30 +00:00
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
# change the GUID to SPDK GUID value
|
2017-11-29 16:18:30 +00:00
|
|
|
SPDK_GPT_GUID=`grep SPDK_GPT_PART_TYPE_GUID $rootdir/lib/bdev/gpt/gpt.h \
|
|
|
|
| awk -F "(" '{ print $2}' | sed 's/)//g' \
|
|
|
|
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'`
|
2017-12-11 06:56:40 +00:00
|
|
|
sgdisk -t 1:$SPDK_GPT_GUID $nbd_path
|
|
|
|
sgdisk -t 2:$SPDK_GPT_GUID $nbd_path
|
2017-11-03 18:22:05 +00:00
|
|
|
elif [ "$operation" = reset ]; then
|
|
|
|
# clear the partition table
|
2017-12-11 06:56:40 +00:00
|
|
|
dd if=/dev/zero of=$nbd_path bs=4096 count=8 oflag=direct
|
2017-07-17 07:45:46 +00:00
|
|
|
fi
|
2017-11-03 18:22:05 +00:00
|
|
|
|
2018-07-23 01:39:50 +00:00
|
|
|
$rootdir/scripts/rpc.py -s "$rpc_server" stop_nbd_disk $nbd_path
|
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
killprocess $nbd_pid
|
|
|
|
rm -f ${conf}.gpt
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-20 14:11:47 +00:00
|
|
|
function discover_bdevs()
|
|
|
|
{
|
|
|
|
local rootdir=$1
|
|
|
|
local config_file=$2
|
2017-12-04 21:30:34 +00:00
|
|
|
local rpc_server=/var/tmp/spdk-discover-bdevs.sock
|
2017-07-20 14:11:47 +00:00
|
|
|
|
|
|
|
if [ ! -e $config_file ]; then
|
|
|
|
echo "Invalid Configuration File: $config_file"
|
|
|
|
return -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Start the bdev service to query for the list of available
|
|
|
|
# bdevs.
|
2018-03-19 12:40:58 +00:00
|
|
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -s 1024 -g \
|
|
|
|
-c $config_file &>/dev/null &
|
2017-07-20 14:11:47 +00:00
|
|
|
stubpid=$!
|
|
|
|
while ! [ -e /var/run/spdk_bdev0 ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Get all of the bdevs
|
2017-11-20 17:28:59 +00:00
|
|
|
if [ -z "$rpc_server" ]; then
|
2017-09-12 13:47:30 +00:00
|
|
|
$rootdir/scripts/rpc.py get_bdevs
|
|
|
|
else
|
2017-11-20 17:28:59 +00:00
|
|
|
$rootdir/scripts/rpc.py -s "$rpc_server" get_bdevs
|
2017-09-12 13:47:30 +00:00
|
|
|
fi
|
2017-07-20 14:11:47 +00:00
|
|
|
|
|
|
|
# Shut down the bdev service
|
|
|
|
kill $stubpid
|
|
|
|
wait $stubpid
|
|
|
|
rm -f /var/run/spdk_bdev0
|
|
|
|
}
|
|
|
|
|
2018-04-16 20:28:16 +00:00
|
|
|
function waitforblk()
|
|
|
|
{
|
|
|
|
local i=0
|
|
|
|
while ! lsblk -l -o NAME | grep -q -w $1; do
|
|
|
|
[ $i -lt 15 ] || break
|
|
|
|
i=$[$i+1]
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! lsblk -l -o NAME | grep -q -w $1; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-14 23:31:43 +00:00
|
|
|
function fio_config_gen()
|
|
|
|
{
|
|
|
|
local config_file=$1
|
|
|
|
local workload=$2
|
|
|
|
|
|
|
|
if [ -e "$config_file" ]; then
|
|
|
|
echo "Configuration File Already Exists!: $config_file"
|
|
|
|
return -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$workload" ]; then
|
|
|
|
workload=randrw
|
|
|
|
fi
|
|
|
|
|
|
|
|
touch $1
|
|
|
|
|
|
|
|
cat > $1 << EOL
|
|
|
|
[global]
|
|
|
|
thread=1
|
|
|
|
group_reporting=1
|
|
|
|
direct=1
|
|
|
|
norandommap=1
|
|
|
|
percentile_list=50:99:99.9:99.99:99.999
|
|
|
|
time_based=1
|
|
|
|
ramp_time=0
|
|
|
|
EOL
|
|
|
|
|
|
|
|
if [ "$workload" == "verify" ]; then
|
|
|
|
echo "verify=sha1" >> $config_file
|
|
|
|
echo "rw=randwrite" >> $config_file
|
2017-07-19 21:55:03 +00:00
|
|
|
elif [ "$workload" == "trim" ]; then
|
|
|
|
echo "rw=trimwrite" >> $config_file
|
2017-07-14 23:31:43 +00:00
|
|
|
else
|
|
|
|
echo "rw=$workload" >> $config_file
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function fio_config_add_job()
|
|
|
|
{
|
|
|
|
config_file=$1
|
|
|
|
filename=$2
|
|
|
|
|
|
|
|
if [ ! -e "$config_file" ]; then
|
|
|
|
echo "Configuration File Doesn't Exist: $config_file"
|
|
|
|
return -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$filename" ]; then
|
|
|
|
echo "No filename provided"
|
|
|
|
return -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "[job_$filename]" >> $config_file
|
|
|
|
echo "filename=$filename" >> $config_file
|
|
|
|
}
|
|
|
|
|
2017-12-08 14:56:31 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2018-02-28 16:42:12 +00:00
|
|
|
function autotest_cleanup()
|
|
|
|
{
|
|
|
|
$rootdir/scripts/setup.sh reset
|
|
|
|
}
|
|
|
|
|
2018-04-26 23:46:08 +00:00
|
|
|
function freebsd_update_contigmem_mod()
|
|
|
|
{
|
|
|
|
if [ `uname` = FreeBSD ]; then
|
|
|
|
kldunload contigmem.ko || true
|
|
|
|
cp -f $rootdir/dpdk/build/kmod/contigmem.ko /boot/modules/
|
|
|
|
cp -f $rootdir/dpdk/build/kmod/contigmem.ko /boot/kernel/
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-20 19:32:49 +00:00
|
|
|
set -o errtrace
|
|
|
|
trap "trap - ERR; print_backtrace >&2" ERR
|