8000 fix(e2e): Reduce flakiness of TestGRPC_GetBlockResults by jmalicevic · Pull Request #2367 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(e2e): Reduce flakiness of TestGRPC_GetBlockResults #2367

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

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/e2e/tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ func TestBlock_Header(t *testing.T) {
first := status.SyncInfo.EarliestBlockHeight
last := status.SyncInfo.LatestBlockHeight
if node.RetainBlocks > 0 {
first++ // avoid race conditions with block pruning
// This was done in case pruning is activated.
// As it happens in the background this lowers the chances
// that the block at height=first will be pruned by the time we test
// this. If this test starts to fail often, it is worth revisiting this logic.
// To reproduce this failure locally, it is advised to set the storage.pruning.interval
// to 1s instead of 10s.
first += int64(node.RetainBlocks) // avoid race conditions with block pruning
}

for _, block := range blocks {
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/tests/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ func TestGRPC_GetBlockResults(t *testing.T) {
first := status.SyncInfo.EarliestBlockHeight
last := status.SyncInfo.LatestBlockHeight
if node.RetainBlocks > 0 {
first++
// This was done in case pruning is activated.
// As it happens in the background this lowers the chances
// that the block at height=first will be pruned by the time we test
// this. If this test starts to fail often, it is worth revisiting this logic.
// To reproduce this failure locally, it is advised to set the storage.pruning.interval
// to 1s instead of 10s.
first += int64(node.RetainBlocks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, correct me if am wrong. The assumption here is that at most node.RetainBlocks blocks are committed during the execution of this test. Because when setting RetainBlock, the application will ask to retain blocks up to height retainHeight = int64(height - app.cfg.RetainBlocks + 1), from the app execution. So each block we are increasing the retain height by 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes your logic is correct.

}

ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute)
Expand Down Expand Up @@ -136,7 +142,7 @@ func TestGRPC_GetBlockResults(t *testing.T) {
errorCases := []struct {
requestHeight int64
}{
{first - 2},
{first - int64(node.RetainBlocks) - 2},
{last + 100000},
}

Expand Down
8 changes: 7 additions & 1 deletion test/e2e/tests/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ func TestValidator_Sets(t *testing.T) {

// skip first block if node is pruning blocks, to avoid race conditions
if node.RetainBlocks > 0 {
first++
// This was done in case pruning is activated.
// As it happens in the background this lowers the chances
// that the block at height=first will be pruned by the time we test
// this. If this test starts to fail often, it is worth revisiting this logic.
// To reproduce this failure locally, it is advised to set the storage.pruning.interval
// to 1s instead of 10s.
first += int64(node.RetainBlocks)
}

valSchedule := newValidatorSchedule(*node.Testnet)
Expand Down
0