Skip to content

Commit

Permalink
store/tikv: make test stable by running TestPanicInRecvLoop unparal…
Browse files Browse the repository at this point in the history
…lel with others (#11572) (#11579)
  • Loading branch information
sre-bot authored Aug 2, 2019
1 parent 67a532f commit 4cbe840
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
15 changes: 14 additions & 1 deletion store/tikv/client_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,24 @@ import (
"github.com/pingcap/tidb/store/tikv/tikvrpc"
)

type testClientFailSuite struct {
OneByOneSuite
}

func (s *testClientFailSuite) SetUpSuite(c *C) {
// This lock make testClientFailSuite runs exclusively.
withTiKVGlobalLock.Lock()
}

func (s testClientFailSuite) TearDownSuite(c *C) {
withTiKVGlobalLock.Unlock()
}

func setGrpcConnectionCount(count uint) {
config.GetGlobalConfig().TiKVClient.GrpcConnectionCount = count
}

func (s *testClientSuite) TestPanicInRecvLoop(c *C) {
func (s *testClientFailSuite) TestPanicInRecvLoop(c *C) {
c.Assert(failpoint.Enable("github.com/pingcap/tidb/store/tikv/panicInFailPendingRequests", `panic`), IsNil)
c.Assert(failpoint.Enable("github.com/pingcap/tidb/store/tikv/gotErrorInRecvLoop", `return("0")`), IsNil)

Expand Down
1 change: 1 addition & 0 deletions store/tikv/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type testClientSuite struct {
}

var _ = Suite(&testClientSuite{})
var _ = Suite(&testClientFailSuite{})

func setMaxBatchSize(size uint) {
config.GetGlobalConfig().TiKVClient.MaxBatchSize = size
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/ticlient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

var (
withTiKVGlobalLock sync.Mutex
withTiKVGlobalLock sync.RWMutex
withTiKV = flag.Bool("with-tikv", false, "run tests with TiKV cluster started. (not use the mock server)")
pdAddrs = flag.String("pd-addrs", "127.0.0.1:2379", "pd addrs")
)
Expand Down
11 changes: 7 additions & 4 deletions store/tikv/tikv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@ import (
)

// OneByOneSuite is a suite, When with-tikv flag is true, there is only one storage, so the test suite have to run one by one.
type OneByOneSuite struct {
}
type OneByOneSuite struct{}

func (s OneByOneSuite) SetUpSuite(c *C) {
func (s *OneByOneSuite) SetUpSuite(c *C) {
if *withTiKV {
withTiKVGlobalLock.Lock()
} else {
withTiKVGlobalLock.RLock()
}
}

func (s OneByOneSuite) TearDownSuite(c *C) {
func (s *OneByOneSuite) TearDownSuite(c *C) {
if *withTiKV {
withTiKVGlobalLock.Unlock()
} else {
withTiKVGlobalLock.RUnlock()
}
}

Expand Down

0 comments on commit 4cbe840

Please sign in to comment.