Page MenuHomePhabricator

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

Authored by jasonbcox on Thu, Sep 5, 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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jasonbcox created this revision.Thu, Sep 5, 18:58
jasonbcox planned changes to this revision.Thu, Sep 5, 18:58
jasonbcox updated this revision to Diff 11137.Fri, Sep 6, 16:45

Rebase + fix lint issues

jasonbcox updated this revision to Diff 11138.Fri, Sep 6, 16:47

One last lint issue in ibd.sh...

Fabien requested changes to this revision.Mon, Sep 9, 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 ↗(On Diff #11138)

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

106 ↗(On Diff #11138)

Use -n instead.

This revision now requires changes to proceed.Mon, Sep 9, 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).

jasonbcox updated this revision to Diff 11165.Mon, Sep 9, 17:36

Fixes according to feedback.

Fabien accepted this revision.Tue, Sep 10, 06:24
This revision is now accepted and ready to land.Tue, Sep 10, 06:24
jasonbcox updated this revision to Diff 11184.Tue, Sep 10, 21:03

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

Fabien requested changes to this revision.Wed, Sep 11, 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.Wed, Sep 11, 06:22
jasonbcox updated this revision to Diff 11202.Wed, Sep 11, 15:39

Fix bad rebase

jasonbcox updated this revision to Diff 11203.Wed, Sep 11, 15:41

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

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