Skip to content
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

test: investigate test failure due to wal log #22679

Merged
merged 22 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
11 changes: 11 additions & 0 deletions store/v2/db/pebbledb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewPebbleDB(name, dataDir string) (*PebbleDB, error) {

func NewPebbleDBWithOpts(name, dataDir string, opts coreserver.DynamicConfig) (*PebbleDB, error) {
do := &pebble.Options{
Logger: &fatalLogger{}, // pebble info logs are messing up the logs (not a cosmossdk.io/log logger)
MaxConcurrentCompactions: func() int { return 3 }, // default 1
}

Expand Down Expand Up @@ -301,3 +302,13 @@ func (b *pebbleDBBatch) Close() error {
func (b *pebbleDBBatch) GetByteSize() (int, error) {
return b.batch.Len(), nil
}

type fatalLogger struct {
pebble.Logger
}

func (*fatalLogger) Fatalf(format string, args ...interface{}) {
pebble.DefaultLogger.Fatalf(format, args...)
}

func (*fatalLogger) Infof(format string, args ...interface{}) {}
15 changes: 4 additions & 11 deletions tests/systemtests/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -68,16 +67,10 @@ func TestExportCmd_WithHeight(t *testing.T) {
}

for _, tc := range testCases {
res := cli.RunCommandWithArgs(tc.args...)
// PebbleDB logs are printed directly to stderr.
// Cosmos-DB and Store/v2 do not provide a way to override the logger.
// This isn't problematic in a real-world scenario, but it makes it hard to test the output.
// https://github.com/cockroachdb/pebble/blob/v1.1.2/internal/base/logger.go#L26-L40
// We trim the output to get the JSON part only
if i := strings.Index(res, "{"); i > 0 {
res = res[i:]
}

res := cli.
WithRunErrorsIgnored().
WithRunSingleOutput(). // pebbledb prints logs to stderr, we cannot override the logger in store/v2 and cosmos-db. This isn't problematic in a real-world scenario, but it makes it hard to test the output
RunCommandWithArgs(tc.args...)
height := gjson.Get(res, "initial_height").Int()
if tc.expZeroHeight {
require.Equal(t, height, int64(0))
Expand Down
4 changes: 0 additions & 4 deletions tests/systemtests/snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
)

func TestSnapshots(t *testing.T) {
t.Skip("Skip snapshots test, flaky due to pebbledb logs on CI")

systest.Sut.ResetChain(t)
cli := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)
systest.Sut.StartChain(t)
Expand Down Expand Up @@ -80,8 +78,6 @@ func TestSnapshots(t *testing.T) {
}

func TestPrune(t *testing.T) {
t.Skip("Skip snapshots test, flaky due to pebbledb logs on CI")

systest.Sut.ResetChain(t)
cli := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)

Expand Down
Loading