]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/autotest.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / autotest.sh
CommitLineData
7c673cae
FG
1#!/usr/bin/env bash
2
7c673cae 3rootdir=$(readlink -f $(dirname $0))
9f95a23c
TL
4
5# In autotest_common.sh all tests are disabled by default.
6# If the configuration of tests is not provided, no tests will be carried out.
7if [[ ! -f $1 ]]; then
8 echo "ERROR: SPDK test configuration not specified"
9 exit 1
10fi
11
12source "$1"
11fdf7f2 13source "$rootdir/test/common/autotest_common.sh"
7c673cae
FG
14source "$rootdir/test/nvmf/common.sh"
15
f67539c2
TL
16# always test with SPDK shared objects.
17export SPDK_LIB_DIR="$rootdir/build/lib"
18export DPDK_LIB_DIR="$rootdir/dpdk/build/lib"
19export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SPDK_LIB_DIR:$DPDK_LIB_DIR
7c673cae
FG
20
21if [ $EUID -ne 0 ]; then
22 echo "$0 must be run as root"
23 exit 1
24fi
25
26if [ $(uname -s) = Linux ]; then
27 # set core_pattern to a known value to avoid ABRT, systemd-coredump, etc.
28 echo "core" > /proc/sys/kernel/core_pattern
9f95a23c 29
f67539c2
TL
30 # Make sure that the hugepage state for our VM is fresh so we don't fail
31 # hugepage allocation. Allow time for this action to complete.
32 echo 1 > /proc/sys/vm/drop_caches
33 sleep 3
34
9f95a23c
TL
35 # make sure nbd (network block device) driver is loaded if it is available
36 # this ensures that when tests need to use nbd, it will be fully initialized
37 modprobe nbd || true
7c673cae
FG
38fi
39
11fdf7f2 40trap "process_core; autotest_cleanup; exit 1" SIGINT SIGTERM EXIT
7c673cae
FG
41
42timing_enter autotest
43
11fdf7f2
TL
44create_test_list
45
7c673cae 46src=$(readlink -f $(dirname $0))
f67539c2 47out=$output_dir
7c673cae
FG
48cd $src
49
11fdf7f2
TL
50./scripts/setup.sh status
51
52freebsd_update_contigmem_mod
53
7c673cae 54if hash lcov; then
11fdf7f2
TL
55 # setup output dir for unittest.sh
56 export UT_COVERAGE=$out/ut_coverage
7c673cae
FG
57 export LCOV_OPTS="
58 --rc lcov_branch_coverage=1
59 --rc lcov_function_coverage=1
60 --rc genhtml_branch_coverage=1
61 --rc genhtml_function_coverage=1
62 --rc genhtml_legend=1
63 --rc geninfo_all_blocks=1
64 "
65 export LCOV="lcov $LCOV_OPTS --no-external"
11fdf7f2
TL
66 # Print lcov version to log
67 $LCOV -v
7c673cae 68 # zero out coverage data
f67539c2 69 $LCOV -q -c -i -t "Baseline" -d $src -o $out/cov_base.info
7c673cae
FG
70fi
71
72# Make sure the disks are clean (no leftover partition tables)
73timing_enter cleanup
11fdf7f2
TL
74# Remove old domain socket pathname just in case
75rm -f /var/tmp/spdk*.sock
7c673cae 76
9f95a23c
TL
77# Load the kernel driver
78./scripts/setup.sh reset
7c673cae 79
9f95a23c
TL
80# Let the kernel discover any filesystems or partitions
81sleep 10
82
83if [ $(uname -s) = Linux ]; then
84 # OCSSD devices drivers don't support IO issues by kernel so
85 # detect OCSSD devices and blacklist them (unbind from any driver).
86 # If test scripts want to use this device it needs to do this explicitly.
87 #
88 # If some OCSSD device is bound to other driver than nvme we won't be able to
89 # discover if it is OCSSD or not so load the kernel driver first.
90
f67539c2 91 while IFS= read -r -d '' dev; do
9f95a23c 92 # Send Open Channel 2.0 Geometry opcode "0xe2" - not supported by NVMe device.
f67539c2 93 if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read > /dev/null; then
9f95a23c
TL
94 bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))"
95 echo "INFO: blacklisting OCSSD device: $dev ($bdf)"
96 PCI_BLACKLIST+=" $bdf"
97 OCSSD_PCI_DEVICES+=" $bdf"
98 fi
f67539c2 99 done < <(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+' -print0)
11fdf7f2 100
9f95a23c
TL
101 export OCSSD_PCI_DEVICES
102
103 # Now, bind blacklisted devices to pci-stub module. This will prevent
104 # automatic grabbing these devices when we add device/vendor ID to
105 # proper driver.
106 if [[ -n "$PCI_BLACKLIST" ]]; then
f67539c2 107 # shellcheck disable=SC2097,SC2098
9f95a23c 108 PCI_WHITELIST="$PCI_BLACKLIST" \
f67539c2
TL
109 PCI_BLACKLIST="" \
110 DRIVER_OVERRIDE="pci-stub" \
9f95a23c
TL
111 ./scripts/setup.sh
112
113 # Export our blacklist so it will take effect during next setup.sh
114 export PCI_BLACKLIST
115 fi
116fi
117
f67539c2
TL
118# Revert NVMe namespaces to default state
119nvme_namespace_revert
120
9f95a23c
TL
121# Delete all leftover lvols and gpt partitions
122# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD
123# Filter out nvme with partitions - the "p*" suffix
124for dev in $(ls /dev/nvme*n* | grep -v p || true); do
125 dd if=/dev/zero of="$dev" bs=1M count=1
126done
127
128sync
129
7c673cae
FG
130timing_exit cleanup
131
132# set up huge pages
133timing_enter afterboot
134./scripts/setup.sh
135timing_exit afterboot
136
137timing_enter nvmf_setup
138rdma_device_init
139timing_exit nvmf_setup
140
9f95a23c 141if [[ $SPDK_TEST_CRYPTO -eq 1 || $SPDK_TEST_REDUCE -eq 1 ]]; then
11fdf7f2
TL
142 if grep -q '#define SPDK_CONFIG_IGB_UIO_DRIVER 1' $rootdir/include/spdk/config.h; then
143 ./scripts/qat_setup.sh igb_uio
144 else
145 ./scripts/qat_setup.sh
146 fi
147fi
7c673cae 148
f67539c2
TL
149# Revert existing OPAL to factory settings that may have been left from earlier failed tests.
150# This ensures we won't hit any unexpected failures due to NVMe SSDs being locked.
151opal_revert_cleanup
152
7c673cae
FG
153#####################
154# Unit Tests
155#####################
156
11fdf7f2 157if [ $SPDK_TEST_UNITTEST -eq 1 ]; then
f67539c2
TL
158 run_test "unittest" ./test/unit/unittest.sh
159 run_test "env" test/env/env.sh
11fdf7f2 160fi
7c673cae 161
9f95a23c
TL
162if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
163 timing_enter lib
7c673cae 164
f67539c2
TL
165 run_test "rpc" test/rpc/rpc.sh
166 run_test "rpc_client" test/rpc_client/rpc_client.sh
167 run_test "json_config" ./test/json_config/json_config.sh
168 run_test "alias_rpc" test/json_config/alias_rpc/alias_rpc.sh
169 run_test "spdkcli_tcp" test/spdkcli/tcp.sh
170 run_test "dpdk_mem_utility" test/dpdk_memory_utility/test_dpdk_mem_info.sh
171 run_test "event" test/event/event.sh
7c673cae 172
9f95a23c 173 if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then
f67539c2
TL
174 run_test "blockdev_general" test/bdev/blockdev.sh
175 run_test "bdev_raid" test/bdev/bdev_raid.sh
176 run_test "bdevperf_config" test/bdev/bdevperf/test_config.sh
177 if [[ $(uname -s) == Linux ]]; then
178 run_test "spdk_dd" test/dd/dd.sh
9f95a23c 179 fi
7c673cae 180 fi
7c673cae 181
9f95a23c 182 if [ $SPDK_TEST_JSON -eq 1 ]; then
f67539c2 183 run_test "test_converter" test/config_converter/test_converter.sh
9f95a23c 184 fi
11fdf7f2 185
9f95a23c 186 if [ $SPDK_TEST_NVME -eq 1 ]; then
f67539c2
TL
187 run_test "blockdev_nvme" test/bdev/blockdev.sh "nvme"
188 run_test "blockdev_nvme_gpt" test/bdev/blockdev.sh "gpt"
189 run_test "nvme" test/nvme/nvme.sh
190 if [[ $SPDK_TEST_NVME_CLI -eq 1 ]]; then
191 run_test "nvme_cli" test/nvme/spdk_nvme_cli.sh
9f95a23c 192 fi
f67539c2
TL
193 if [[ $SPDK_TEST_NVME_CUSE -eq 1 ]]; then
194 run_test "nvme_cuse" test/nvme/cuse/nvme_cuse.sh
195 fi
196 run_test "nvme_rpc" test/nvme/nvme_rpc.sh
9f95a23c
TL
197 # Only test hotplug without ASAN enabled. Since if it is
198 # enabled, it catches SEGV earlier than our handler which
199 # breaks the hotplug logic.
f67539c2
TL
200 if [ $SPDK_RUN_ASAN -eq 0 ]; then
201 run_test "nvme_hotplug" test/nvme/hotplug.sh intel
202 fi
9f95a23c 203 fi
11fdf7f2 204
9f95a23c 205 if [ $SPDK_TEST_IOAT -eq 1 ]; then
f67539c2 206 run_test "ioat" test/ioat/ioat.sh
9f95a23c 207 fi
11fdf7f2 208
9f95a23c 209 timing_exit lib
11fdf7f2 210
9f95a23c 211 if [ $SPDK_TEST_ISCSI -eq 1 ]; then
f67539c2
TL
212 run_test "iscsi_tgt_posix" ./test/iscsi_tgt/iscsi_tgt.sh posix
213 run_test "spdkcli_iscsi" ./test/spdkcli/iscsi.sh
11fdf7f2 214
9f95a23c 215 # Run raid spdkcli test under iSCSI since blockdev tests run on systems that can't run spdkcli yet
f67539c2
TL
216 run_test "spdkcli_raid" test/spdkcli/raid.sh
217 fi
218
219 if [ $SPDK_TEST_VPP -eq 1 ]; then
220 run_test "iscsi_tgt_vpp" ./test/iscsi_tgt/iscsi_tgt.sh vpp
9f95a23c 221 fi
11fdf7f2 222
9f95a23c 223 if [ $SPDK_TEST_BLOBFS -eq 1 ]; then
f67539c2
TL
224 run_test "rocksdb" ./test/blobfs/rocksdb/rocksdb.sh
225 run_test "blobstore" ./test/blobstore/blobstore.sh
226 run_test "blobfs" ./test/blobfs/blobfs.sh
227 run_test "hello_blob" $SPDK_EXAMPLE_DIR/hello_blob \
228 examples/blob/hello_world/hello_blob.json
7c673cae 229 fi
7c673cae 230
9f95a23c 231 if [ $SPDK_TEST_NVMF -eq 1 ]; then
f67539c2
TL
232 # The NVMe-oF run test cases are split out like this so that the parser that compiles the
233 # list of all tests can properly differentiate them. Please do not merge them into one line.
234 if [ "$SPDK_TEST_NVMF_TRANSPORT" = "rdma" ]; then
235 run_test "nvmf_rdma" ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT
236 run_test "spdkcli_nvmf_rdma" ./test/spdkcli/nvmf.sh
237 elif [ "$SPDK_TEST_NVMF_TRANSPORT" = "tcp" ]; then
238 run_test "nvmf_tcp" ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT
239 run_test "spdkcli_nvmf_tcp" ./test/spdkcli/nvmf.sh
240 run_test "nvmf_identify_passthru" test/nvmf/target/identify_passthru.sh --transport=$SPDK_TEST_NVMF_TRANSPORT
241 elif [ "$SPDK_TEST_NVMF_TRANSPORT" = "fc" ]; then
242 run_test "nvmf_fc" ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT
243 run_test "spdkcli_nvmf_fc" ./test/spdkcli/nvmf.sh
244 else
245 echo "unknown NVMe transport, please specify rdma, tcp, or fc."
246 exit 1
247 fi
9f95a23c 248 fi
7c673cae 249
9f95a23c 250 if [ $SPDK_TEST_VHOST -eq 1 ]; then
f67539c2 251 run_test "vhost" ./test/vhost/vhost.sh
9f95a23c 252 fi
11fdf7f2 253
9f95a23c 254 if [ $SPDK_TEST_LVOL -eq 1 ]; then
f67539c2
TL
255 run_test "lvol2" ./test/lvol/lvol2.sh
256 run_test "blob_io_wait" ./test/blobstore/blob_io_wait/blob_io_wait.sh
9f95a23c 257 fi
7c673cae 258
9f95a23c
TL
259 if [ $SPDK_TEST_VHOST_INIT -eq 1 ]; then
260 timing_enter vhost_initiator
f67539c2
TL
261 run_test "vhost_blockdev" ./test/vhost/initiator/blockdev.sh
262 run_test "spdkcli_virtio" ./test/spdkcli/virtio.sh
263 run_test "vhost_shared" ./test/vhost/shared/shared.sh
264 run_test "vhost_fuzz" ./test/vhost/fuzz/fuzz.sh
9f95a23c
TL
265 timing_exit vhost_initiator
266 fi
7c673cae 267
9f95a23c 268 if [ $SPDK_TEST_PMDK -eq 1 ]; then
f67539c2
TL
269 run_test "blockdev_pmem" ./test/bdev/blockdev.sh "pmem"
270 run_test "pmem" ./test/pmem/pmem.sh -x
271 run_test "spdkcli_pmem" ./test/spdkcli/pmem.sh
9f95a23c 272 fi
11fdf7f2 273
9f95a23c 274 if [ $SPDK_TEST_RBD -eq 1 ]; then
f67539c2
TL
275 run_test "blockdev_rbd" ./test/bdev/blockdev.sh "rbd"
276 run_test "spdkcli_rbd" ./test/spdkcli/rbd.sh
9f95a23c 277 fi
11fdf7f2 278
9f95a23c 279 if [ $SPDK_TEST_OCF -eq 1 ]; then
f67539c2
TL
280 run_test "ocf" ./test/ocf/ocf.sh
281 fi
282
283 if [ $SPDK_TEST_FTL -eq 1 ]; then
284 run_test "ftl" ./test/ftl/ftl.sh
285 fi
286
287 if [ $SPDK_TEST_VMD -eq 1 ]; then
288 run_test "vmd" ./test/vmd/vmd.sh
9f95a23c 289 fi
11fdf7f2 290
f67539c2
TL
291 if [ $SPDK_TEST_REDUCE -eq 1 ]; then
292 run_test "compress_qat" ./test/compress/compress.sh "qat"
293 run_test "compress_isal" ./test/compress/compress.sh "isal"
294 fi
295
296 if [ $SPDK_TEST_OPAL -eq 1 ]; then
297 run_test "nvme_opal" ./test/nvme/nvme_opal.sh
298 fi
299
300 if [ $SPDK_TEST_CRYPTO -eq 1 ]; then
301 run_test "blockdev_crypto_aesni" ./test/bdev/blockdev.sh "crypto_aesni"
302 # Proceed with the test only if QAT devices are in place
303 if [[ $(lspci -d:37c8) ]]; then
304 run_test "blockdev_crypto_qat" ./test/bdev/blockdev.sh "crypto_qat"
305 fi
9f95a23c 306 fi
11fdf7f2
TL
307fi
308
7c673cae 309timing_enter cleanup
11fdf7f2 310autotest_cleanup
7c673cae
FG
311timing_exit cleanup
312
313timing_exit autotest
314chmod a+r $output_dir/timing.txt
315
316trap - SIGINT SIGTERM EXIT
317
318# catch any stray core files
319process_core
320
321if hash lcov; then
322 # generate coverage data and combine with baseline
f67539c2
TL
323 $LCOV -q -c -d $src -t "$(hostname)" -o $out/cov_test.info
324 $LCOV -q -a $out/cov_base.info -a $out/cov_test.info -o $out/cov_total.info
11fdf7f2
TL
325 $LCOV -q -r $out/cov_total.info '*/dpdk/*' -o $out/cov_total.info
326 $LCOV -q -r $out/cov_total.info '/usr/*' -o $out/cov_total.info
327 git clean -f "*.gcda"
328 rm -f cov_base.info cov_test.info OLD_STDOUT OLD_STDERR
7c673cae 329fi