-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unit test flake TestHistoricalConfDetailsTxIndex
#9549
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Makefile
Outdated
|
||
#? 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: commented out code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
scripts/unit-test-flake-hunter.sh
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we pipe the output of go clean
into the make
command? Shouldn't that just be &&
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah fixed
@@ -163,7 +163,7 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, | |||
} | |||
|
|||
var conn *chain.BitcoindConn | |||
err := wait.NoError(func() error { | |||
err = wait.NoError(func() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: belongs to previous commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
@@ -4,6 +4,7 @@ import ( | |||
"fmt" | |||
"os/exec" | |||
"path/filepath" | |||
"strings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: belongs into the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome fixed, thanks a lot!
routing/chainview/interface_test.go
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extract this code block into a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
c1062c2
to
e2c9e58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so nice 🔥
@@ -178,6 +178,48 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, | |||
} | |||
t.Cleanup(conn.Stop) | |||
|
|||
// Assert that the connection with the miner is made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/due unknown reason/due to an unknown reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
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
bitcoind
node and thebtcd
node (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,