integration/rpctest: improve rpctest harness - #2571
Conversation
14d655f to
e5dfa5d
Compare
74ffcc5 to
466eeb7
Compare
e05176c to
f4b587b
Compare
|
For now I think that we achieved what was proposed. Ready for review again. Thanks to @TechLateef for providing several fixes and improvements. |
fb75252 to
e7fe6fd
Compare
TechLateef
left a comment
There was a problem hiding this comment.
nit: Since this PR touches a number of different areas, would it make sense to split it into a few logically grouped commits? I think it would make the review a bit easier to follow and align with the project's recommendation of keeping changes in small, reviewable commits.
Yes, it makes sense. |
The usage of option structs allows cleaner calls when the default behavior is needed and also allows future extensions without breaking the API.
e7fe6fd to
de122dc
Compare
|
@TechLateef, I've improved the commit history, as requested. |
4814d98 to
0694cb1
Compare
rpctest.New was removed and rpctest.New2 renamed to rpctest.New, fixed broken tests due to the API change.
With the signal option, we make it possible to skip sending the shutdown signal to the node, allowing the test of cases where we expect the node shutting down by itself.
Node restart support was implemented by creating the node instance on harness SetUp instead of New, this way we can also run the same node several times with a different set of arguments, allowing more test cases to happen. An option `NoRPCClientAndWallet` was added to simplify test cases where for some reason the RPC Client won't connect to the instance. Options `SkipCleanup` and `NoSignal` added to tear down procedure, enabling the node to be restarted while the state is kept and also allowing the test of cases where the node should shutdown by itself instead of being shutdown upon receiving a signal. Tests covering node restart and exit error code implemented and added to the harness test table.
There are cases where the RPC will work, but the wallet would not be able to finish sync up to best height, or we don't have reasons to wait for the sync to finish. Setting `NoWalletWait` to true allow us to skip waiting the wallet and speed up tests, or even avoid blocking forever.
Previously, each time harness setup was executed, a new goroutine was launched to handle the wallet updates, but the channel keeping the goroutine alive was never closed, causing goroutine leakage. The memwallet implementation was changed and now the memwallet goroutine is stopped when harness teardown is called. A test was added to assert that there's no goroutine leaks between harness setup and teardown.
The debug stream allows the register of debug events which are broadcasted to debug clients. The `debug` tag switches between the real and the nop implementation, so that there's no cost of sending debug events in production.
Now, when btcd is compiled with the `debug` tag and the flag --debugstream=<host:port> is passed to btcd, the debug stream server will be started, allowing btcd to broadcast debug events. When the harness option `DebugHandler` callback is set, the harness will connect with the debug stream, and the debug events can be handled by the callback.
The change allow us to see the name and status of the tests running, while also allowing to filter the tests by regexp instead of having to comment when we want to test a single test case in isolation. TestHarness previouly contained lines not wrapped to 80 columns.
Since the blocks are generated only when both CreateTestChain and NumMatureOutputs are set, there's no obvious reason to keep both. The code was simplified by ignoring the CreateTestChain option.
The previous commit made CreateTestChain option useless, so this commit cleans up the codebase by effectively removing the option and all the references to it.
0694cb1 to
56762b2
Compare
|
I think that the current PR is doing too many things, causing difficulties to review the changes. So I'll close this PR and open smaller ones. |
Change Description
The main motivation of this PR is to improve the process of writing integration
tests, currently there's no way to write complex tests in a simple way.
As discussed in #2560.
Changes
without cleaning up node data, enabling the test of scenarios where btcd
exits with error or scenarios where the node should be restarted.
called.
of having to pass multiple zero values to get default initialization.
The debug event stream is replaced by a NOP implementation when the compile tag
debug is not defined, so that the compiler can optimize out all the debug event
broadcast calls. Also, the hidden flag --debugstream=host:port should be used
to start the event stream.
There's also bugfixes, the complete changelog is in the commit message.
Steps to Test
Pull Request Checklist
Testing
Code Style and Documentation
📝 Please see our Contribution Guidelines for further guidance.