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

Fix tests race condition and improve gas multiplier for tests #203

Merged
merged 1 commit into from
Apr 5, 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test-single-integration:

.PHONY: test-relayer
test-relayer:
cd $(RELAYER_DIR) && go clean -testcache && go test -v -mod=readonly -parallel=20 -timeout 1m ./...
cd $(RELAYER_DIR) && go clean -testcache && go test -v -mod=readonly -parallel=20 -timeout 30m -race ./...

.PHONY: test-contract
test-contract:
Expand Down
10 changes: 9 additions & 1 deletion integration-tests/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ func DeployAndInstantiateContractV110(
Amount: issueFee.Amount.AddRaw(2_000_000),
})

contactCfg := coreum.DefaultContractClientConfig(sdk.AccAddress(nil))

// integration tests are running in parallel producing the high load on the chain, as a result, periodically,
// with default gas adjustments, the tests might fail because of estimation delay and feemodel gas price change
// the custom gas adjustment config prevents the failure
contactCfg.GasAdjustment = 1.5
contactCfg.GasPriceAdjustment = sdk.MustNewDecFromStr("1.5")

contractClient := coreum.NewContractClient(
coreum.DefaultContractClientConfig(sdk.AccAddress(nil)),
contactCfg,
chains.Log,
chains.Coreum.ClientContext,
)
Expand Down
3 changes: 2 additions & 1 deletion relayer/runner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/CoreumFoundation/coreumbridge-xrpl/relayer/runner"
)

//nolint:tparallel // the test is parallel, but test cases are not
func TestInitAndReadConfig(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -60,7 +61,7 @@ func TestInitAndReadConfig(t *testing.T) {
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(tt *testing.T) {
tt.Parallel()
// not parallel intentionally top prevent race

// create temp dir to store the config
tempDir := tt.TempDir()
Expand Down
16 changes: 8 additions & 8 deletions relayer/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/CoreumFoundation/coreum-tools/pkg/parallel"
Expand Down Expand Up @@ -48,12 +49,6 @@ func (c *counter) Start(ctx context.Context) error {
func Test_taskWithRestartOnError(t *testing.T) {
t.Parallel()

zapLogger, err := logger.NewZapLogger(logger.ZapLoggerConfig{
Level: "error",
Format: logger.YamlConsoleLoggerFormat,
})
require.NoError(t, err)

tests := []struct {
name string
runTimeout time.Duration
Expand Down Expand Up @@ -97,11 +92,16 @@ func Test_taskWithRestartOnError(t *testing.T) {

c := newCounter()

err = parallel.Run(ctx, func(ctx context.Context, spawn parallel.SpawnFn) error {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
logMock := logger.NewAnyLogMock(ctrl)
logMock.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

err := parallel.Run(ctx, func(ctx context.Context, spawn parallel.SpawnFn) error {
spawn(tc.name, parallel.Continue, func(ctx context.Context) error {
tsk := taskWithRestartOnError(
c.Start,
zapLogger,
logMock,
tc.exitOnError,
tc.retryDelay,
)
Expand Down
Loading