From 75df5fec18403a97dde9d350c77d548cbd0857bc Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 19 Feb 2020 16:37:50 +0100 Subject: [PATCH] test/blobfs: Dump *_db_bench.txt to stderr in case db_bench fails Since both stdout and stderr of the db_bench run is redirected to a file, xtrace won't write out anything of value in case said run fails. Example: https://ci.spdk.io/public_build/autotest-per-patch_4071.html To avoid looking into the file directly, try to locate last .txt that was written out and dump its contents to stderr to increase the visibility of what might have caused the failure. Change-Id: Ic4873626e979130f2722a4f2d5266d93bc2bde76 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/959 Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- test/blobfs/rocksdb/rocksdb.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/blobfs/rocksdb/rocksdb.sh b/test/blobfs/rocksdb/rocksdb.sh index 8f660e002..5fef7725c 100755 --- a/test/blobfs/rocksdb/rocksdb.sh +++ b/test/blobfs/rocksdb/rocksdb.sh @@ -4,6 +4,17 @@ testdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $testdir/../../..) source $rootdir/test/common/autotest_common.sh +dump_db_bench_on_err() { + # Fetch std dump of the last run_step that might have failed + [[ -e $db_bench ]] || return 0 + + # Dump entire *.txt to stderr to clearly see what might have failed + xtrace_disable + mapfile -t step_map <"$db_bench" + printf '%s\n' "${step_map[@]/#/* $step (FAILED)}" >&2 + xtrace_restore +} + run_step() { if [ -z "$1" ]; then echo run_step called with no parameter @@ -16,9 +27,10 @@ run_step() { --spdk_cache_size=$CACHE_SIZE EOL + db_bench=$1_db_bench.txt echo -n Start $1 test phase... - /usr/bin/time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$1"_db_bench.txt - DB_BENCH_FILE=$(grep /dev/shm "$1"_db_bench.txt | cut -f 6 -d ' ') + /usr/bin/time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$db_bench" + DB_BENCH_FILE=$(grep /dev/shm "$db_bench" | cut -f 6 -d ' ') gzip $DB_BENCH_FILE mv $DB_BENCH_FILE.gz "$1"_trace.gz chmod 644 "$1"_trace.gz @@ -55,7 +67,7 @@ $rootdir/scripts/gen_nvme.sh > $ROCKSDB_CONF echo "[Global]" >> $ROCKSDB_CONF echo "TpointGroupMask 0x80" >> $ROCKSDB_CONF -trap 'run_bsdump; rm -f $ROCKSDB_CONF; exit 1' SIGINT SIGTERM EXIT +trap 'dump_db_bench_on_err; run_bsdump; rm -f $ROCKSDB_CONF; exit 1' SIGINT SIGTERM EXIT if [ -z "$SKIP_MKFS" ]; then run_test "blobfs_mkfs" $rootdir/test/blobfs/mkfs/mkfs $ROCKSDB_CONF Nvme0n1