regression_test.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. #!/usr/bin/env bash
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. # The RocksDB regression test script.
  4. # REQUIREMENT: must be able to run make db_bench in the current directory
  5. #
  6. # This script will do the following things in order:
  7. #
  8. # 1. check out the specified rocksdb commit.
  9. # 2. build db_bench using the specified commit
  10. # 3. setup test directory $TEST_PATH. If not specified, then the test directory
  11. # will be "/tmp/rocksdb/regression_test"
  12. # 4. run set of benchmarks on the specified host
  13. # (can be either locally or remotely)
  14. # 5. generate report in the $RESULT_PATH. If RESULT_PATH is not specified,
  15. # RESULT_PATH will be set to $TEST_PATH/current_time
  16. #
  17. # = Examples =
  18. # * Run the regression test using rocksdb commit abcdef that outputs results
  19. # and temp files in "/my/output/dir"
  20. #r
  21. # TEST_PATH=/my/output/dir COMMIT_ID=abcdef ./tools/regression_test.sh
  22. #
  23. # * Run the regression test on a remost host under "/my/output/dir" directory
  24. # and stores the result locally in "/my/benchmark/results" using commit
  25. # abcdef and with the rocksdb options specified in /my/path/to/OPTIONS-012345
  26. # with 1000000000 keys in each benchmark in the regression test where each
  27. # key and value are 100 and 900 bytes respectively:
  28. #
  29. # REMOTE_USER_AT_HOST=yhchiang@my.remote.host \
  30. # TEST_PATH=/my/output/dir \
  31. # RESULT_PATH=/my/benchmark/results \
  32. # COMMIT_ID=abcdef \
  33. # OPTIONS_FILE=/my/path/to/OPTIONS-012345 \
  34. # NUM_KEYS=1000000000 \
  35. # KEY_SIZE=100 \
  36. # VALUE_SIZE=900 \
  37. # ./tools/regression_test.sh
  38. #
  39. # = Regression test environmental parameters =
  40. # DEBUG: If true, then the script will not build db_bench if db_bench already
  41. # exists
  42. # Default: 0
  43. # TEST_MODE: If 1, run fillseqdeterminstic and benchmarks both
  44. # if 0, only run fillseqdeterministc
  45. # if 2, only run benchmarks
  46. # Default: 1
  47. # TEST_PATH: the root directory of the regression test.
  48. # Default: "/tmp/rocksdb/regression_test"
  49. # !!! NOTE !!! - a DB will also be saved in $TEST_PATH/../db
  50. # RESULT_PATH: the directory where the regression results will be generated.
  51. # Default: "$TEST_PATH/current_time"
  52. # REMOTE_USER_AT_HOST: If set, then test will run on the specified host under
  53. # TEST_PATH directory and outputs test results locally in RESULT_PATH
  54. # The REMOTE_USER_AT_HOST should follow the format user-id@host.name
  55. # DB_PATH: the path where the rocksdb database will be created during the
  56. # regression test. Default: $TEST_PATH/db
  57. # WAL_PATH: the path where the rocksdb WAL will be outputed.
  58. # Default: $TEST_PATH/wal
  59. # OPTIONS_FILE: If specified, then the regression test will use the specified
  60. # file to initialize the RocksDB options in its benchmarks. Note that
  61. # this feature only work for commits after 88acd93 or rocksdb version
  62. # later than 4.9.
  63. # DELETE_TEST_PATH: If true, then the test directory will be deleted
  64. # after the script ends.
  65. # Default: 0
  66. #
  67. # = db_bench parameters =
  68. # NUM_THREADS: The number of concurrent foreground threads that will issue
  69. # database operations in the benchmark. Default: 16.
  70. # NUM_KEYS: The key range that will be used in the entire regression test.
  71. # Default: 1G.
  72. # NUM_OPS: The number of operations (reads, writes, or deletes) that will
  73. # be issued in EACH thread.
  74. # Default: $NUM_KEYS / $NUM_THREADS
  75. # KEY_SIZE: The size of each key in bytes in db_bench. Default: 100.
  76. # VALUE_SIZE: The size of each value in bytes in db_bench. Default: 900.
  77. # CACHE_SIZE: The size of RocksDB block cache used in db_bench. Default: 1G
  78. # STATISTICS: If 1, then statistics is on in db_bench. Default: 0.
  79. # COMPRESSION_RATIO: The compression ratio of the key generated in db_bench.
  80. # Default: 0.5.
  81. # HISTOGRAM: If 1, then the histogram feature on performance feature is on.
  82. # STATS_PER_INTERVAL: If 1, then the statistics will be reported for every
  83. # STATS_INTERVAL_SECONDS seconds. Default 1.
  84. # STATS_INTERVAL_SECONDS: If STATS_PER_INTERVAL is set to 1, then statistics
  85. # will be reported for every STATS_INTERVAL_SECONDS. Default 60.
  86. # MAX_BACKGROUND_FLUSHES: The maxinum number of concurrent flushes in
  87. # db_bench. Default: 4.
  88. # MAX_BACKGROUND_COMPACTIONS: The maximum number of concurrent compactions
  89. # in db_bench. Default: 16.
  90. # NUM_HIGH_PRI_THREADS: The number of high-pri threads available for
  91. # concurrent flushes in db_bench. Default: 4.
  92. # NUM_LOW_PRI_THREADS: The number of low-pri threads available for
  93. # concurrent compactions in db_bench. Default: 16.
  94. # SEEK_NEXTS: Controls how many Next() will be called after seek.
  95. # Default: 10.
  96. # SEED: random seed that controls the randomness of the benchmark.
  97. # Default: $( date +%s )
  98. #==============================================================================
  99. # CONSTANT
  100. #==============================================================================
  101. TITLE_FORMAT="%40s,%25s,%30s,%7s,%9s,%8s,"
  102. TITLE_FORMAT+="%10s,%13s,%14s,%11s,%12s,"
  103. TITLE_FORMAT+="%7s,%11s,"
  104. TITLE_FORMAT+="%9s,%10s,%10s,%10s,%10s,%10s,%5s,"
  105. TITLE_FORMAT+="%5s,%5s,%5s" # time
  106. TITLE_FORMAT+="\n"
  107. DATA_FORMAT="%40s,%25s,%30s,%7s,%9s,%8s,"
  108. DATA_FORMAT+="%10s,%13.0f,%14s,%11s,%12s,"
  109. DATA_FORMAT+="%7s,%11s,"
  110. DATA_FORMAT+="%9.0f,%10.0f,%10.0f,%10.0f,%10.0f,%10.0f,%5.0f,"
  111. DATA_FORMAT+="%5.0f,%5.0f,%5.0f" # time
  112. DATA_FORMAT+="\n"
  113. # In case of async_io, $1 is benchmark_asyncio
  114. MAIN_PATTERN="${1%%_*}""[[:blank:]]+:.*[[:blank:]]+([0-9\.]+)[[:blank:]]+ops/sec"
  115. PERC_PATTERN="Percentiles: P50: ([0-9\.]+) P75: ([0-9\.]+) "
  116. PERC_PATTERN+="P99: ([0-9\.]+) P99.9: ([0-9\.]+) P99.99: ([0-9\.]+)"
  117. #==============================================================================
  118. function main {
  119. TEST_ROOT_DIR=${TEST_PATH:-"/tmp/rocksdb/regression_test"}
  120. init_arguments $TEST_ROOT_DIR
  121. build_db_bench_and_ldb
  122. setup_test_directory
  123. if [ $TEST_MODE -le 1 ]; then
  124. test_remote "test -d $ORIGIN_PATH"
  125. if [[ $? -ne 0 ]]; then
  126. echo "Building DB..."
  127. # compactall alone will not print ops or threads, which will fail update_report
  128. run_db_bench "fillseq,compactall" $NUM_KEYS 1 0 0
  129. # only save for future use on success
  130. test_remote "mv $DB_PATH $ORIGIN_PATH"
  131. fi
  132. fi
  133. if [ $TEST_MODE -ge 1 ]; then
  134. build_checkpoint
  135. # run_db_bench benchmark_name NUM_OPS NUM_THREADS USED_EXISTING_DB UPDATE_REPORT ASYNC_IO
  136. run_db_bench "seekrandom_asyncio" $NUM_OPS $NUM_THREADS 1 1 true
  137. run_db_bench "multireadrandom_asyncio" $NUM_OPS $NUM_THREADS 1 1 true
  138. run_db_bench "readrandom"
  139. run_db_bench "readwhilewriting"
  140. run_db_bench "deleterandom"
  141. run_db_bench "seekrandom"
  142. run_db_bench "seekrandomwhilewriting"
  143. run_db_bench "multireadrandom"
  144. fi
  145. cleanup_test_directory $TEST_ROOT_DIR
  146. echo ""
  147. echo "Benchmark completed! Results are available in $RESULT_PATH"
  148. }
  149. ############################################################################
  150. function init_arguments {
  151. K=1024
  152. M=$((1024 * K))
  153. G=$((1024 * M))
  154. current_time=$(date +"%F-%H:%M:%S")
  155. RESULT_PATH=${RESULT_PATH:-"$1/results/$current_time"}
  156. COMMIT_ID=`hg id -i 2>/dev/null || git rev-parse HEAD 2>/dev/null || echo 'unknown'`
  157. SUMMARY_FILE="$RESULT_PATH/SUMMARY.csv"
  158. DB_PATH=${3:-"$1/db"}
  159. ORIGIN_PATH=${ORIGIN_PATH:-"$(dirname $(dirname $DB_PATH))/db"}
  160. WAL_PATH=${4:-""}
  161. if [ -z "$REMOTE_USER_AT_HOST" ]; then
  162. DB_BENCH_DIR=${5:-"."}
  163. else
  164. DB_BENCH_DIR=${5:-"$1/db_bench"}
  165. fi
  166. DEBUG=${DEBUG:-0}
  167. TEST_MODE=${TEST_MODE:-1}
  168. SCP=${SCP:-"scp"}
  169. SSH=${SSH:-"ssh"}
  170. NUM_THREADS=${NUM_THREADS:-16}
  171. NUM_KEYS=${NUM_KEYS:-$((1 * G))} # key range
  172. NUM_OPS=${NUM_OPS:-$(($NUM_KEYS / $NUM_THREADS))}
  173. KEY_SIZE=${KEY_SIZE:-100}
  174. VALUE_SIZE=${VALUE_SIZE:-900}
  175. CACHE_SIZE=${CACHE_SIZE:-$((1 * G))}
  176. STATISTICS=${STATISTICS:-0}
  177. COMPRESSION_RATIO=${COMPRESSION_RATIO:-0.5}
  178. HISTOGRAM=${HISTOGRAM:-1}
  179. NUM_MULTI_DB=${NUM_MULTI_DB:-1}
  180. STATS_PER_INTERVAL=${STATS_PER_INTERVAL:-1}
  181. STATS_INTERVAL_SECONDS=${STATS_INTERVAL_SECONDS:-600}
  182. MAX_BACKGROUND_FLUSHES=${MAX_BACKGROUND_FLUSHES:-4}
  183. MAX_BACKGROUND_COMPACTIONS=${MAX_BACKGROUND_COMPACTIONS:-16}
  184. NUM_HIGH_PRI_THREADS=${NUM_HIGH_PRI_THREADS:-4}
  185. NUM_LOW_PRI_THREADS=${NUM_LOW_PRI_THREADS:-16}
  186. DELETE_TEST_PATH=${DELETE_TEST_PATH:-0}
  187. SEEK_NEXTS=${SEEK_NEXTS:-10}
  188. SEED=${SEED:-$( date +%s )}
  189. MULTIREAD_BATCH_SIZE=${MULTIREAD_BATCH_SIZE:-128}
  190. MULTIREAD_STRIDE=${MULTIREAD_STRIDE:-12}
  191. PERF_LEVEL=${PERF_LEVEL:-1}
  192. }
  193. # $1 --- benchmark name
  194. # $2 --- number of operations. Default: $NUM_OPS
  195. # $3 --- number of threads. Default $NUM_THREADS
  196. # $4 --- use_existing_db. Default: 1
  197. # $5 --- update_report. Default: 1
  198. # $6 --- async_io. Default: False
  199. function run_db_bench {
  200. # Make sure no other db_bench is running. (Make sure command succeeds if pidof
  201. # command exists but finds nothing.)
  202. pids_cmd='pidof db_bench || pidof --version > /dev/null'
  203. # But first, make best effort to kill any db_bench that have run for more
  204. # than 12 hours, as that indicates a hung or runaway process.
  205. kill_old_cmd='for PID in $(pidof db_bench); do [ "$(($(stat -c %Y /proc/$PID) + 43200))" -lt "$(date +%s)" ] && echo "Killing old db_bench $PID" && kill $PID && sleep 5 && kill -9 $PID && sleep 5; done; pidof --version > /dev/null'
  206. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  207. pids_cmd="$SSH $REMOTE_USER_AT_HOST '$pids_cmd'"
  208. kill_old_cmd="$SSH $REMOTE_USER_AT_HOST '$kill_old_cmd'"
  209. fi
  210. eval $kill_old_cmd
  211. exit_on_error $? "$kill_old_cmd"
  212. pids_output="$(eval $pids_cmd)"
  213. exit_on_error $? "$pids_cmd"
  214. if [ "$pids_output" != "" ]; then
  215. echo "Stopped regression_test.sh as there're still recent db_bench "
  216. echo "processes running: $pids_output"
  217. echo "Clean up test directory"
  218. cleanup_test_directory $TEST_ROOT_DIR
  219. exit 2
  220. fi
  221. # Build db_bench command
  222. ops=${2:-$NUM_OPS}
  223. threads=${3:-$NUM_THREADS}
  224. USE_EXISTING_DB=${4:-1}
  225. UPDATE_REPORT=${5:-1}
  226. async_io=${6:-false}
  227. seek_nexts=$SEEK_NEXTS
  228. if [ "$async_io" == "true" ]; then
  229. if ! [ -z "$SEEK_NEXTS_ASYNC_IO" ]; then
  230. seek_nexts=$SEEK_NEXTS_ASYNC_IO
  231. fi
  232. fi
  233. echo ""
  234. echo "======================================================================="
  235. echo "Benchmark $1"
  236. echo "======================================================================="
  237. echo ""
  238. db_bench_error=0
  239. options_file_arg=$(setup_options_file)
  240. echo "$options_file_arg"
  241. # In case of async_io, benchmark is benchmark_asyncio
  242. db_bench_type=${1%%_*}
  243. # use `which time` to avoid using bash's internal time command
  244. db_bench_cmd="\$(which time) -p $DB_BENCH_DIR/db_bench \
  245. --benchmarks=$db_bench_type --db=$DB_PATH --wal_dir=$WAL_PATH \
  246. --use_existing_db=$USE_EXISTING_DB \
  247. --perf_level=$PERF_LEVEL \
  248. --disable_auto_compactions \
  249. --threads=$threads \
  250. --num=$NUM_KEYS \
  251. --reads=$ops \
  252. --writes=$ops \
  253. --deletes=$ops \
  254. --key_size=$KEY_SIZE \
  255. --value_size=$VALUE_SIZE \
  256. --cache_size=$CACHE_SIZE \
  257. --statistics=$STATISTICS \
  258. $options_file_arg \
  259. --compression_ratio=$COMPRESSION_RATIO \
  260. --histogram=$HISTOGRAM \
  261. --seek_nexts=$seek_nexts \
  262. --stats_per_interval=$STATS_PER_INTERVAL \
  263. --stats_interval_seconds=$STATS_INTERVAL_SECONDS \
  264. --max_background_flushes=$MAX_BACKGROUND_FLUSHES \
  265. --num_multi_db=$NUM_MULTI_DB \
  266. --max_background_compactions=$MAX_BACKGROUND_COMPACTIONS \
  267. --num_high_pri_threads=$NUM_HIGH_PRI_THREADS \
  268. --num_low_pri_threads=$NUM_LOW_PRI_THREADS \
  269. --seed=$SEED \
  270. --multiread_batched=true \
  271. --batch_size=$MULTIREAD_BATCH_SIZE \
  272. --multiread_stride=$MULTIREAD_STRIDE \
  273. --async_io=$async_io"
  274. if [ "$async_io" == "true" ]; then
  275. db_bench_cmd="$db_bench_cmd $(set_async_io_parameters) "
  276. fi
  277. db_bench_cmd=" $db_bench_cmd 2>&1"
  278. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  279. echo "Running benchmark remotely on $REMOTE_USER_AT_HOST"
  280. db_bench_cmd="$SSH $REMOTE_USER_AT_HOST '$db_bench_cmd'"
  281. fi
  282. echo db_bench_cmd="$db_bench_cmd"
  283. # Run the db_bench command
  284. eval $db_bench_cmd | tee -a "$RESULT_PATH/$1"
  285. exit_on_error ${PIPESTATUS[0]} db_bench
  286. if [ $UPDATE_REPORT -ne 0 ]; then
  287. update_report "$1" "$RESULT_PATH/$1" $ops $threads
  288. fi
  289. }
  290. function set_async_io_parameters {
  291. options=" --duration=500"
  292. # Below parameters are used in case of async_io only.
  293. # 1. If you want to run below parameters for all benchmarks, it should be
  294. # specify in OPTIONS_FILE instead of exporting them.
  295. # 2. Below exported var takes precedence over OPTIONS_FILE.
  296. if ! [ -z "$MAX_READAHEAD_SIZE" ]; then
  297. options="$options --max_auto_readahead_size=$MAX_READAHEAD_SIZE "
  298. fi
  299. if ! [ -z "$INITIAL_READAHEAD_SIZE" ]; then
  300. options="$options --initial_auto_readahead_size=$INITIAL_READAHEAD_SIZE "
  301. fi
  302. if ! [ -z "$NUM_READS_FOR_READAHEAD_SIZE" ]; then
  303. options="$options --num_file_reads_for_auto_readahead=$NUM_READS_FOR_READAHEAD_SIZE "
  304. fi
  305. echo $options
  306. }
  307. function build_checkpoint {
  308. cmd_prefix=""
  309. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  310. cmd_prefix="$SSH $REMOTE_USER_AT_HOST "
  311. fi
  312. if [ $NUM_MULTI_DB -gt 1 ]; then
  313. dirs=$($cmd_prefix find $ORIGIN_PATH -type d -links 2)
  314. for dir in $dirs; do
  315. db_index=$(basename $dir)
  316. echo "Building checkpoints: $ORIGIN_PATH/$db_index -> $DB_PATH/$db_index ..."
  317. $cmd_prefix $DB_BENCH_DIR/ldb checkpoint --checkpoint_dir=$DB_PATH/$db_index \
  318. --db=$ORIGIN_PATH/$db_index --try_load_options 2>&1
  319. exit_on_error $?
  320. done
  321. else
  322. # checkpoint cannot build in directory already exists
  323. $cmd_prefix rm -rf $DB_PATH
  324. echo "Building checkpoint: $ORIGIN_PATH -> $DB_PATH ..."
  325. $cmd_prefix $DB_BENCH_DIR/ldb checkpoint --checkpoint_dir=$DB_PATH \
  326. --db=$ORIGIN_PATH --try_load_options 2>&1
  327. exit_on_error $?
  328. fi
  329. }
  330. function multiply {
  331. echo "$1 * $2" | bc
  332. }
  333. # $1 --- name of the benchmark
  334. # $2 --- the filename of the output log of db_bench
  335. function update_report {
  336. # In case of async_io, benchmark is benchmark_asyncio
  337. db_bench_type=${1%%_*}
  338. main_result=`cat $2 | grep $db_bench_type`
  339. exit_on_error $?
  340. perc_statement=`cat $2 | grep Percentile`
  341. exit_on_error $?
  342. # Obtain micros / op
  343. [[ $main_result =~ $MAIN_PATTERN ]]
  344. ops_per_s=${BASH_REMATCH[1]}
  345. # Obtain percentile information
  346. [[ $perc_statement =~ $PERC_PATTERN ]]
  347. perc[0]=${BASH_REMATCH[1]} # p50
  348. perc[1]=${BASH_REMATCH[2]} # p75
  349. perc[2]=${BASH_REMATCH[3]} # p99
  350. perc[3]=${BASH_REMATCH[4]} # p99.9
  351. perc[4]=${BASH_REMATCH[5]} # p99.99
  352. # Parse the output of the time command
  353. real_sec=`tail -3 $2 | grep real | awk '{print $2}'`
  354. user_sec=`tail -3 $2 | grep user | awk '{print $2}'`
  355. sys_sec=`tail -3 $2 | grep sys | awk '{print $2}'`
  356. (printf "$DATA_FORMAT" \
  357. $COMMIT_ID $1 $REMOTE_USER_AT_HOST $NUM_MULTI_DB $NUM_KEYS $KEY_SIZE $VALUE_SIZE \
  358. $(multiply $COMPRESSION_RATIO 100) \
  359. $3 $4 $CACHE_SIZE \
  360. $MAX_BACKGROUND_FLUSHES $MAX_BACKGROUND_COMPACTIONS \
  361. $ops_per_s \
  362. $(multiply ${perc[0]} 1000) \
  363. $(multiply ${perc[1]} 1000) \
  364. $(multiply ${perc[2]} 1000) \
  365. $(multiply ${perc[3]} 1000) \
  366. $(multiply ${perc[4]} 1000) \
  367. $DEBUG \
  368. $real_sec \
  369. $user_sec \
  370. $sys_sec \
  371. >> $SUMMARY_FILE)
  372. exit_on_error $?
  373. }
  374. function exit_on_error {
  375. if [ $1 -ne 0 ]; then
  376. echo ""
  377. echo "ERROR: Benchmark did not complete successfully."
  378. if ! [ -z "$2" ]; then
  379. echo "Failure command: $2"
  380. fi
  381. echo "Partial results are output to $RESULT_PATH"
  382. echo "ERROR" >> $SUMMARY_FILE
  383. exit $1
  384. fi
  385. }
  386. function build_db_bench_and_ldb {
  387. echo "Building db_bench & ldb ..."
  388. make clean
  389. exit_on_error $?
  390. DEBUG_LEVEL=0 make db_bench ldb -j32
  391. exit_on_error $?
  392. }
  393. function run_remote {
  394. test_remote "$1"
  395. exit_on_error $? "$1"
  396. }
  397. function test_remote {
  398. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  399. cmd="$SSH $REMOTE_USER_AT_HOST '$1'"
  400. else
  401. cmd="$1"
  402. fi
  403. eval "$cmd"
  404. }
  405. function run_local {
  406. eval "$1"
  407. exit_on_error $? "$1"
  408. }
  409. function setup_options_file {
  410. if ! [ -z "$OPTIONS_FILE" ]; then
  411. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  412. options_file="$DB_BENCH_DIR/OPTIONS_FILE"
  413. run_local "$SCP $OPTIONS_FILE $REMOTE_USER_AT_HOST:$options_file"
  414. else
  415. options_file="$OPTIONS_FILE"
  416. fi
  417. echo "--options_file=$options_file"
  418. fi
  419. echo ""
  420. }
  421. function setup_test_directory {
  422. echo "Deleting old regression test directories and creating new ones"
  423. run_local 'test "$DB_PATH" != "."'
  424. run_remote "rm -rf $DB_PATH"
  425. if [ "$DB_BENCH_DIR" != "." ]; then
  426. run_remote "rm -rf $DB_BENCH_DIR"
  427. fi
  428. run_local 'test "$RESULT_PATH" != "."'
  429. run_local "rm -rf $RESULT_PATH"
  430. if ! [ -z "$WAL_PATH" ]; then
  431. run_remote "rm -rf $WAL_PATH"
  432. run_remote "mkdir -p $WAL_PATH"
  433. fi
  434. run_remote "mkdir -p $DB_PATH"
  435. run_remote "mkdir -p $DB_BENCH_DIR"
  436. run_remote "ls -l $DB_BENCH_DIR"
  437. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  438. shopt -s nullglob # allow missing librocksdb*.so* for static lib build
  439. run_local "tar cz db_bench ldb librocksdb*.so* | $SSH $REMOTE_USER_AT_HOST 'cd $DB_BENCH_DIR/ && tar xzv'"
  440. shopt -u nullglob
  441. fi
  442. run_local "mkdir -p $RESULT_PATH"
  443. (printf $TITLE_FORMAT \
  444. "commit id" "benchmark" "user@host" "num-dbs" "key-range" "key-size" \
  445. "value-size" "compress-rate" "ops-per-thread" "num-threads" "cache-size" \
  446. "flushes" "compactions" \
  447. "ops-per-s" "p50" "p75" "p99" "p99.9" "p99.99" "debug" \
  448. "real-sec" "user-sec" "sys-sec" \
  449. >> $SUMMARY_FILE)
  450. exit_on_error $?
  451. }
  452. function cleanup_test_directory {
  453. if [ $DELETE_TEST_PATH -ne 0 ]; then
  454. echo "Clear old regression test directories and creating new ones"
  455. run_remote "rm -rf $DB_PATH"
  456. run_remote "rm -rf $WAL_PATH"
  457. if ! [ -z "$REMOTE_USER_AT_HOST" ]; then
  458. run_remote "rm -rf $DB_BENCH_DIR"
  459. fi
  460. run_remote "rm -rf $1"
  461. else
  462. echo "------------ DEBUG MODE ------------"
  463. echo "DB PATH: $DB_PATH"
  464. echo "WAL PATH: $WAL_PATH"
  465. fi
  466. }
  467. ############################################################################
  468. # shellcheck disable=SC2068
  469. main $@