From 899177339007c4418b7933db9e952d97a005e92b Mon Sep 17 00:00:00 2001 From: Maciej Wawryk Date: Fri, 10 Jul 2020 14:15:45 +0200 Subject: [PATCH] test/bdevperf: test config file Signed-off-by: Maciej Wawryk Signed-off-by: Tomasz Zawadzki Change-Id: I6a92345e1c3fae1f7f8b77bc68e0f715e7ac9ed9 Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3291 Community-CI: Mellanox Build Bot Reviewed-by: Karol Latecki Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- autotest.sh | 1 + test/bdev/bdevperf/common.sh | 33 +++++++++++++++++++++++++ test/bdev/bdevperf/conf.json | 25 +++++++++++++++++++ test/bdev/bdevperf/test_config.sh | 41 +++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 test/bdev/bdevperf/common.sh create mode 100644 test/bdev/bdevperf/conf.json create mode 100755 test/bdev/bdevperf/test_config.sh diff --git a/autotest.sh b/autotest.sh index 9a53db689..13d117c9e 100755 --- a/autotest.sh +++ b/autotest.sh @@ -173,6 +173,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then run_test "blockdev_general" test/bdev/blockdev.sh run_test "bdev_raid" test/bdev/bdev_raid.sh + run_test "bdevperf_config" test/bdev/bdevperf/test_config.sh if [[ $(uname -s) == Linux ]]; then run_test "spdk_dd" test/dd/dd.sh fi diff --git a/test/bdev/bdevperf/common.sh b/test/bdev/bdevperf/common.sh new file mode 100644 index 000000000..eade380a3 --- /dev/null +++ b/test/bdev/bdevperf/common.sh @@ -0,0 +1,33 @@ +bdevperf=$rootdir/test/bdev/bdevperf/bdevperf + +function create_job() { + local job_section=$1 + local rw=$2 + local filename=$3 + + if [[ $job_section == "global" ]]; then + cat <<- EOF >> "$testdir"/test.conf + [global] + filename=${filename} + EOF + fi + job="[${job_section}]" + echo $global + cat <<- EOF >> "$testdir"/test.conf + ${job} + filename=${filename} + bs=1024 + rwmixread=70 + rw=${rw} + iodepth=256 + cpumask=0xff + EOF +} + +function get_num_jobs() { + echo "$1" | grep -oE "Using job config with [0-9]+ jobs" | grep -oE "[0-9]+" +} + +function cleanup() { + rm -f $testdir/test.conf +} diff --git a/test/bdev/bdevperf/conf.json b/test/bdev/bdevperf/conf.json new file mode 100644 index 000000000..c58407f38 --- /dev/null +++ b/test/bdev/bdevperf/conf.json @@ -0,0 +1,25 @@ +{ + "subsystems": [ + { + "subsystem": "bdev", + "config": [ + { + "method": "bdev_malloc_create", + "params": { + "name": "Malloc0", + "num_blocks": 102400, + "block_size": 512 + } + }, + { + "method": "bdev_malloc_create", + "params": { + "name": "Malloc1", + "num_blocks": 102400, + "block_size": 512 + } + } + ] + } + ] +} diff --git a/test/bdev/bdevperf/test_config.sh b/test/bdev/bdevperf/test_config.sh new file mode 100755 index 000000000..911d4e27d --- /dev/null +++ b/test/bdev/bdevperf/test_config.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../../..) +source $rootdir/test/common/autotest_common.sh +source $testdir/common.sh + +jsonconf=$testdir/conf.json +testconf=$testdir/test.conf + +trap 'cleanup; exit 1' SIGINT SIGTERM EXIT +#Test inheriting filename and rw_mode parameters from global section. +create_job "global" "read" "Malloc0" +create_job "job0" +create_job "job1" +create_job "job2" +create_job "job3" +bdevperf_output=$($bdevperf -t 2 --json $jsonconf -j $testconf 2>&1) +[[ $(get_num_jobs "$bdevperf_output") == "4" ]] + +bdevperf_output=$($bdevperf -C -t 2 --json $jsonconf -j $testconf) + +cleanup +#Test missing global section. +create_job "job0" "write" "Malloc0" +create_job "job1" "write" "Malloc0" +create_job "job2" "write" "Malloc0" +bdevperf_output=$($bdevperf -t 2 --json $jsonconf -j $testconf 2>&1) +[[ $(get_num_jobs "$bdevperf_output") == "3" ]] + +cleanup +#Test inheriting multiple filenames and rw_mode parameters from global section. +create_job "global" "rw" "Malloc0:Malloc1" +create_job "job0" +create_job "job1" +create_job "job2" +create_job "job3" +bdevperf_output=$($bdevperf -t 2 --json $jsonconf -j $testconf 2>&1) +[[ $(get_num_jobs "$bdevperf_output") == "4" ]] +cleanup +trap - SIGINT SIGTERM EXIT