Skip to content

Commit

Permalink
test: make TestReplicaReadAccessPathByGenError stable (#1243)
Browse files Browse the repository at this point in the history
* test: make TestReplicaReadAccessPathByGenError stable

Signed-off-by: zyguan <[email protected]>

* reduce maxAccessErrCnt

Signed-off-by: zyguan <[email protected]>

---------

Signed-off-by: zyguan <[email protected]>
  • Loading branch information
zyguan authored Mar 22, 2024
1 parent ddf00f1 commit 08aa706
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/locate/replica_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pingcap/kvproto/pkg/errorpb"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/log"
"github.com/pkg/errors"
"github.com/stretchr/testify/suite"
"github.com/tikv/client-go/v2/config"
Expand All @@ -31,6 +32,7 @@ import (
"github.com/tikv/client-go/v2/tikvrpc"
"github.com/tikv/client-go/v2/util/israce"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

type testReplicaSelectorSuite struct {
Expand Down Expand Up @@ -2508,12 +2510,16 @@ func TestReplicaReadAccessPathByLearnerCase(t *testing.T) {
func TestReplicaReadAccessPathByGenError(t *testing.T) {
s := new(testReplicaSelectorSuite)
s.SetupTest(t)
defer s.TearDownTest()
defer func(lv zapcore.Level) {
log.SetLevel(lv)
s.TearDownTest()
}(log.GetLevel())
log.SetLevel(zapcore.ErrorLevel)

maxAccessErrCnt := 6
maxAccessErrCnt := 4
if israce.RaceEnabled {
// When run this test with race, it will take a long time, so we reduce the maxAccessErrCnt to 3 to speed up test to avoid timeout.
maxAccessErrCnt = 3
maxAccessErrCnt = 2
}
totalValidCaseCount := 0
totalCaseCount := 0
Expand Down

0 comments on commit 08aa706

Please sign in to comment.