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 <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/959
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2020-02-19 16:37:50 +01:00 committed by Tomasz Zawadzki
parent 03842fd950
commit 75df5fec18

View File

@ -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