Page MenuHomePhabricator

Generalized ibd.sh to provide a logging tool for running similar types of tests
ClosedPublic

Authored by jasonbcox on Sep 5 2019, 18:58.

Details

Summary

This generalized script is useful for running tests on bitcoind "to completion" where
the indication of such comes from looking at the logs.

Test Plan
./bitcoind-exit-on-log.sh -h  # shows help message
./bitcoind-exit-on-log.sh --grep "Loading banlist"  # success
LOG_FILE=~/.bitcoin/testnet3/debug.log ./bitcoind-exit-on-log.sh --grep "Loading banlist" --params "-testnet"  # success

mycallback(){ ./bitcoin-cli getbestblockhash; }
export -f mycallback
./bitcoind-exit-on-log.sh --grep "Leaving InitialBlockDownload" --callback mycallback  # success, with best block hash output

Also test IBD on this diff via TeamCity.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
exit-on-log
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 7350
Build 12743: Bitcoin ABC Buildbot (legacy)
Build 12742: arc lint + arc unit

Event Timeline

One last lint issue in ibd.sh...

Fabien requested changes to this revision.Sep 9 2019, 06:43
Fabien added a subscriber: Fabien.

Please add braces around the variables everywhere.
What is the use case apart from the IBD script ?

contrib/devtools/bitcoind-exit-on-log.sh
82

Nit: use braces ${BITCOIND_PARAMS}. $BITCOIND is already a valid variable !

106

Use -n instead.

This revision now requires changes to proceed.Sep 9 2019, 06:43

What is the use case apart from the IBD script ?

Some examples that I plan to use it for include testing time-to-completion for various features (initial spin-up, reindexing, etc).

Fixes according to feedback.

This revision is now accepted and ready to land.Sep 10 2019, 06:24

Rebased + fixed up verbose logging (set -x) on the new script.

Fabien requested changes to this revision.Sep 11 2019, 06:22

If you want my opinion I would have simply set -x from the very beginning of the script (set -euxo pipefail) and only disable it around the sleep loop.
This script is intended to be run by the CI server, so every trace can be useful in case there is a bug in the script, and the detected parameters are no exception. This has a different purpose than an echo statement which is more of a UI for the script.

contrib/devtools/bitcoind-exit-on-log.sh
119 ↗(On Diff #11184)

Oups, you replaced LOG_PID with IBD_PID during the rebase !

This revision now requires changes to proceed.Sep 11 2019, 06:22

Disable verbose logging while printing the help message, otherwise it's impossible to read.

This revision is now accepted and ready to land.Sep 11 2019, 15:44