Skip to content

Commit

Permalink
*: update client-go and update mocktikv usages (pingcap#25911)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored Jul 9, 2021
1 parent eedb191 commit c6680e9
Show file tree
Hide file tree
Showing 33 changed files with 176 additions and 134 deletions.
6 changes: 3 additions & 3 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testleak"
dto "github.com/prometheus/client_model/go"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

func TestT(t *testing.T) {
Expand All @@ -62,7 +62,7 @@ func TestT(t *testing.T) {
var _ = Suite(&testSuite{})

type testSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
domain *domain.Domain
*parser.Parser
Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *testSuite) SetUpSuite(c *C) {
useMockTikv := *mockTikv
if useMockTikv {
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testutil"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

var _ = Suite(&testIntegrationSuite1{&testIntegrationSuite{}})
Expand All @@ -60,7 +60,7 @@ var _ = Suite(&testIntegrationSuite6{&testIntegrationSuite{}})

type testIntegrationSuite struct {
lease time.Duration
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
dom *domain.Domain
ctx sessionctx.Context
Expand All @@ -72,7 +72,7 @@ func setupIntegrationSuite(s *testIntegrationSuite, c *C) {
ddl.SetWaitTimeWhenErrorOccurred(0)

s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import (
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testutil"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

const (
Expand All @@ -86,7 +86,7 @@ const defaultBatchSize = 1024
const defaultReorgBatchSize = 256

type testDBSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
dom *domain.Domain
schemaName string
Expand All @@ -107,7 +107,7 @@ func setUpSuite(s *testDBSuite, c *C) {
ddl.SetWaitTimeWhenErrorOccurred(0)

s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions ddl/failtest/fail_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testleak"
. "github.com/pingcap/tidb/util/testutil"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

func TestT(t *testing.T) {
Expand All @@ -63,7 +63,7 @@ func TestT(t *testing.T) {
var _ = SerialSuites(&testFailDBSuite{})

type testFailDBSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
lease time.Duration
store kv.Storage
dom *domain.Domain
Expand All @@ -78,7 +78,7 @@ func (s *testFailDBSuite) SetUpSuite(c *C) {
ddl.SetWaitTimeWhenErrorOccurred(1 * time.Microsecond)
var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
. "github.com/pingcap/tidb/util/testutil"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

// Make it serial because config is modified in test cases.
Expand All @@ -61,7 +61,7 @@ var _ = Suite(&testIntegrationSuite7{&testIntegrationSuite{}})
type testSerialSuite struct {
CommonHandleSuite
store kv.Storage
cluster cluster.Cluster
cluster testutils.Cluster
dom *domain.Domain
}

Expand All @@ -76,7 +76,7 @@ func (s *testSerialSuite) SetUpSuite(c *C) {

var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions executor/aggfuncs/aggfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/pingcap/tidb/util/hack"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/set"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

const (
Expand All @@ -61,7 +61,7 @@ func TestT(t *testing.T) {
type testSuite struct {
*parser.Parser
ctx sessionctx.Context
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
domain *domain.Domain
}
Expand All @@ -71,7 +71,7 @@ func (s *testSuite) SetUpSuite(c *C) {
s.ctx = mock.NewContext()
s.ctx.GetSessionVars().StmtCtx.TimeZone = time.Local
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
14 changes: 7 additions & 7 deletions executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/israce"
"github.com/pingcap/tidb/util/testkit"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
)
Expand Down Expand Up @@ -288,9 +288,9 @@ func (s *testSuite1) TestAnalyzeIndexExtractTopN(c *C) {
}

func (s *testFastAnalyze) TestAnalyzeFastSample(c *C) {
var cls cluster.Cluster
var cls testutils.Cluster
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
cls = c
}),
Expand Down Expand Up @@ -395,9 +395,9 @@ func checkHistogram(sc *stmtctx.StatementContext, hg *statistics.Histogram) (boo
}

func (s *testFastAnalyze) TestFastAnalyze(c *C) {
var cls cluster.Cluster
var cls testutils.Cluster
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
cls = c
}),
Expand Down Expand Up @@ -714,9 +714,9 @@ func (s *testFastAnalyze) TestFastAnalyzeRetryRowCount(c *C) {
return cli
}

var cls cluster.Cluster
var cls testutils.Cluster
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
cls = c
}),
Expand Down
10 changes: 5 additions & 5 deletions executor/chunk_size_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/testkit"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
)
Expand Down Expand Up @@ -67,7 +67,7 @@ func (c *testSlowClient) GetDelay(regionID uint64) time.Duration {
}

// manipulateCluster splits this cluster's region by splitKeys and returns regionIDs after split
func manipulateCluster(cluster cluster.Cluster, splitKeys [][]byte) []uint64 {
func manipulateCluster(cluster testutils.Cluster, splitKeys [][]byte) []uint64 {
if len(splitKeys) == 0 {
return nil
}
Expand Down Expand Up @@ -113,7 +113,7 @@ type testChunkSizeControlKit struct {
dom *domain.Domain
tk *testkit.TestKit
client *testSlowClient
cluster cluster.Cluster
cluster testutils.Cluster
}

type testChunkSizeControlSuite struct {
Expand All @@ -135,7 +135,7 @@ func (s *testChunkSizeControlSuite) SetUpSuite(c *C) {

var err error
kit.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
kit.cluster = c
}),
Expand All @@ -157,7 +157,7 @@ func (s *testChunkSizeControlSuite) SetUpSuite(c *C) {
}

func (s *testChunkSizeControlSuite) getKit(name string) (
kv.Storage, *domain.Domain, *testkit.TestKit, *testSlowClient, cluster.Cluster) {
kv.Storage, *domain.Domain, *testkit.TestKit, *testSlowClient, testutils.Cluster) {
x := s.m[name]
return x.store, x.dom, x.tk, x.client, x.cluster
}
Expand Down
14 changes: 7 additions & 7 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ import (
"github.com/pingcap/tidb/util/testutil"
"github.com/pingcap/tidb/util/timeutil"
"github.com/pingcap/tipb/go-tipb"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/testutils"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
"google.golang.org/grpc"
Expand Down Expand Up @@ -168,13 +168,13 @@ type testStaleTxnSuite struct{ *baseTestSuite }
type testCoprCache struct {
store kv.Storage
dom *domain.Domain
cls cluster.Cluster
cls testutils.Cluster
}
type testPrepareSuite struct{ testData testutil.TestData }
type testResourceTagSuite struct{ *baseTestSuite }

type baseTestSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
domain *domain.Domain
*parser.Parser
Expand All @@ -189,7 +189,7 @@ func (s *baseTestSuite) SetUpSuite(c *C) {
useMockTikv := *mockTikv
if useMockTikv {
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down Expand Up @@ -5707,7 +5707,7 @@ func (s *testSuite) TestOOMPanicAction(c *C) {
type testRecoverTable struct {
store kv.Storage
dom *domain.Domain
cluster cluster.Cluster
cluster testutils.Cluster
cli *regionProperityClient
}

Expand All @@ -5722,7 +5722,7 @@ func (s *testRecoverTable) SetUpSuite(c *C) {
var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClientHijacker(hijackClient),
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down Expand Up @@ -7362,7 +7362,7 @@ func (s *testCoprCache) SetUpSuite(c *C) {
}
var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cls = c
}),
Expand Down
6 changes: 3 additions & 3 deletions executor/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import (
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/util/testkit"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

var _ = SerialSuites(&testTableSampleSuite{})

type testTableSampleSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
domain *domain.Domain
}
Expand All @@ -43,7 +43,7 @@ func (s *testTableSampleSuite) SetUpSuite(c *C) {
useMockTikv := *mockTikv
if useMockTikv {
store, err := mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
6 changes: 3 additions & 3 deletions executor/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import (
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testutil"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
)
Expand All @@ -81,7 +81,7 @@ var _ = SerialSuites(&seqTestSuite{})
var _ = SerialSuites(&seqTestSuite1{})

type seqTestSuite struct {
cluster cluster.Cluster
cluster testutils.Cluster
store kv.Storage
domain *domain.Domain
*parser.Parser
Expand All @@ -96,7 +96,7 @@ func (s *seqTestSuite) SetUpSuite(c *C) {
if useMockTikv {
var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
s.cluster = c
}),
Expand Down
4 changes: 2 additions & 2 deletions executor/tiflash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/pingcap/tidb/util/israce"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testleak"
"github.com/tikv/client-go/v2/mockstore/cluster"
"github.com/tikv/client-go/v2/testutils"
)

type tiflashTestSuite struct {
Expand All @@ -49,7 +49,7 @@ type tiflashTestSuite struct {
func (s *tiflashTestSuite) SetUpSuite(c *C) {
var err error
s.store, err = mockstore.NewMockStore(
mockstore.WithClusterInspector(func(c cluster.Cluster) {
mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockCluster := c.(*unistore.Cluster)
_, _, region1 := mockstore.BootstrapWithSingleStore(c)
tiflashIdx := 0
Expand Down
Loading

0 comments on commit c6680e9

Please sign in to comment.