Fix unit test flake TestHistoricalConfDetailsTxIndex - #9549
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
5eecae6 to
0efa79e
Compare
guggero
left a comment
There was a problem hiding this comment.
Thanks a lot for investigating!
The changes look good to me 💯
Interestingly enough it looks like TestFilteredChainView in routing/chainview now fails constantly. Perhaps we were able to turn a flake into an error and with that be able to fix two things at once? Which would be a huge win.
|
|
||
| #? flakehunter-parallel: Run the integration tests continuously until one fails, running up to ITEST_PARALLELISM test tranches in parallel (default 4) | ||
| flakehunter-parallel: | ||
| # while [ $$? -eq 0 ]; do GOTRACEBACK=all $(UNIT) -count=1; done |
| counter=0 | ||
|
|
||
| # Run the command in a loop until it fails. | ||
| while output=$(go clean -testcache | make unit-debug log="stdlog trace" pkg=$pkg case=$case timeout=$timeout 2>&1); do |
There was a problem hiding this comment.
Why do we pipe the output of go clean into the make command? Shouldn't that just be &&?
|
|
||
| var conn *chain.BitcoindConn | ||
| err := wait.NoError(func() error { | ||
| err = wait.NoError(func() error { |
There was a problem hiding this comment.
nit: belongs to previous commit.
| "fmt" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" |
There was a problem hiding this comment.
nit: belongs into the next commit.
This commit adds a script to hunt flakes for a specific unit test with trace logs. Also rename the make commands to make them more clear on whether it's a unit test, itest, or paralleled itest.
The config used for the miner is updated to skip banning and debug. For bitcoind, the config is updated to use a unique port for P2P conn.
Make sure the shutdown of `bitcoind` is finished without any errors.
We change how the `bitcoind` node connects to the miner by creating a temp RPC client and use it to connect to the miner. In addition we also assert the connection is made.
0efa79e to
7ec907a
Compare
Yeah glad they are now at least deterministic - pushed a fix, let's see if it passes. |
46a52b6 to
c1062c2
Compare
guggero
left a comment
There was a problem hiding this comment.
Awesome fixed, thanks a lot!
| // dedicated miner to generate blocks, cause re-orgs, etc. We'll set up | ||
| // this node with a chain length of 125, so we have plenty of BTC to | ||
| // play around with. | ||
| node := unittest.NewMiner(t, netParams, []string{"--txindex"}, true, 25) |
There was a problem hiding this comment.
nit: extract this code block into a function?
c1062c2 to
e2c9e58
Compare
ellemouton
left a comment
There was a problem hiding this comment.
Epic epic epic!!! Very nice investigation & beautiful PR ✨
lgtm after linter fix
| @$(call print, "Flake hunting unit tests.") | ||
| while [ $$? -eq 0 ]; do GOTRACEBACK=all $(UNIT) -count=1; done | ||
| #? flakehunter-unit: Run the unit tests continuously until one fails | ||
| flakehunter-unit: |
| } | ||
| t.Cleanup(conn.Stop) | ||
|
|
||
| // Assert that the connection with the miner is made. |
| // Reconnect the miner and the chain backend. | ||
| // | ||
| // NOTE: The connection should have been made before we perform | ||
| // the `syncNotifierWithMiner`. However, due unknown reason, the |
There was a problem hiding this comment.
nit: s/due unknown reason/due to an unknown reason
In this commit we document an unexpected behavior found when connecting a bitcoind node to a btcd node. We mitigate this in our test by reconnecting the nodes when the connection is broken. We also limit the connection made from `bitcoind` to be v1 only.
Prepares for the following commit where we assert the chain backend is synced to the miner.
This commit makes sure the bitcoind node is synced to the miner when initialized and returned from `NewBitcoindBackend`.
So each test has its own miner and chainView.
e2c9e58 to
cfa4341
Compare
Fix a long standing flake found in our unit test,
It turns out the peer connection between the
bitcoindnode and thebtcdnode (miner) is broken, causing the chain backend to never be synced. This unexpected behavior only happens when the test runs multiple times (ranging from 50-ish to 200-ish). To reproduce, remove the second-to-last commit and run,