mirror of https://github.com/tikv/client-go.git
*: remove dangling gocheck usages (#167)
Signed-off-by: tison <wander4096@gmail.com> Co-authored-by: disksing <i@disksing.com>
This commit is contained in:
parent
0d5c54ffe6
commit
2e98d94911
|
@ -41,7 +41,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/pingcap/check"
|
|
||||||
"github.com/pingcap/errors"
|
"github.com/pingcap/errors"
|
||||||
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
||||||
"github.com/pingcap/tidb/store/mockstore/unistore"
|
"github.com/pingcap/tidb/store/mockstore/unistore"
|
||||||
|
@ -55,11 +54,6 @@ import (
|
||||||
"github.com/tikv/client-go/v2/util"
|
"github.com/tikv/client-go/v2/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestT(t *testing.T) {
|
|
||||||
CustomVerboseFlag = true
|
|
||||||
TestingT(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAsyncCommit(t *testing.T) {
|
func TestAsyncCommit(t *testing.T) {
|
||||||
suite.Run(t, new(testAsyncCommitSuite))
|
suite.Run(t, new(testAsyncCommitSuite))
|
||||||
}
|
}
|
||||||
|
@ -74,7 +68,7 @@ type testAsyncCommitCommon struct {
|
||||||
|
|
||||||
func (s *testAsyncCommitCommon) setUpTest() {
|
func (s *testAsyncCommitCommon) setUpTest() {
|
||||||
if *mockstore.WithTiKV {
|
if *mockstore.WithTiKV {
|
||||||
s.store = NewTestStoreT(s.T())
|
s.store = NewTestStore(s.T())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ninedraft/israce v0.0.3
|
github.com/ninedraft/israce v0.0.3
|
||||||
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
|
|
||||||
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
|
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
|
||||||
github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd
|
github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd
|
||||||
github.com/pingcap/kvproto v0.0.0-20210611081648-a215b4e61d2f
|
github.com/pingcap/kvproto v0.0.0-20210611081648-a215b4e61d2f
|
||||||
|
|
|
@ -59,7 +59,7 @@ type testIsolationSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testIsolationSuite) SetupSuite() {
|
func (s *testIsolationSuite) SetupSuite() {
|
||||||
s.store = NewTestStoreT(s.T())
|
s.store = NewTestStore(s.T())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testIsolationSuite) TearDownSuite() {
|
func (s *testIsolationSuite) TearDownSuite() {
|
||||||
|
|
|
@ -66,7 +66,7 @@ type testLockSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testLockSuite) SetupTest() {
|
func (s *testLockSuite) SetupTest() {
|
||||||
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testLockSuite) TearDownTest() {
|
func (s *testLockSuite) TearDownTest() {
|
||||||
|
|
|
@ -56,7 +56,7 @@ type testSafePointSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testSafePointSuite) SetupSuite() {
|
func (s *testSafePointSuite) SetupSuite() {
|
||||||
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
s.prefix = fmt.Sprintf("seek_%d", time.Now().Unix())
|
s.prefix = fmt.Sprintf("seek_%d", time.Now().Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ type testScanMockSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testScanMockSuite) TestScanMultipleRegions() {
|
func (s *testScanMockSuite) TestScanMultipleRegions() {
|
||||||
store := tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
store := tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
defer store.Close()
|
defer store.Close()
|
||||||
|
|
||||||
txn, err := store.Begin()
|
txn, err := store.Begin()
|
||||||
|
@ -81,7 +81,7 @@ func (s *testScanMockSuite) TestScanMultipleRegions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testScanMockSuite) TestReverseScan() {
|
func (s *testScanMockSuite) TestReverseScan() {
|
||||||
store := tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
store := tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
defer store.Close()
|
defer store.Close()
|
||||||
|
|
||||||
txn, err := store.Begin()
|
txn, err := store.Begin()
|
||||||
|
|
|
@ -62,7 +62,7 @@ type testScanSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testScanSuite) SetupSuite() {
|
func (s *testScanSuite) SetupSuite() {
|
||||||
s.store = NewTestStoreT(s.T())
|
s.store = NewTestStore(s.T())
|
||||||
s.recordPrefix = []byte("prefix")
|
s.recordPrefix = []byte("prefix")
|
||||||
s.rowNums = append(s.rowNums, 1, scanBatchSize, scanBatchSize+1, scanBatchSize*3)
|
s.rowNums = append(s.rowNums, 1, scanBatchSize, scanBatchSize+1, scanBatchSize*3)
|
||||||
// Avoid using async commit logic.
|
// Avoid using async commit logic.
|
||||||
|
|
|
@ -63,7 +63,7 @@ type testSnapshotSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testSnapshotSuite) SetupSuite() {
|
func (s *testSnapshotSuite) SetupSuite() {
|
||||||
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
s.prefix = fmt.Sprintf("snapshot_%d", time.Now().Unix())
|
s.prefix = fmt.Sprintf("snapshot_%d", time.Now().Unix())
|
||||||
s.rowNums = append(s.rowNums, 1, 100, 191)
|
s.rowNums = append(s.rowNums, 1, 100, 191)
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ type testStoreSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testStoreSuite) SetupTest() {
|
func (s *testStoreSuite) SetupTest() {
|
||||||
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
|
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testStoreSuite) TearDownTest() {
|
func (s *testStoreSuite) TearDownTest() {
|
||||||
|
|
|
@ -59,7 +59,7 @@ type testTiclientSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testTiclientSuite) SetupSuite() {
|
func (s *testTiclientSuite) SetupSuite() {
|
||||||
s.store = NewTestStoreT(s.T())
|
s.store = NewTestStore(s.T())
|
||||||
s.prefix = fmt.Sprintf("ticlient_%d", time.Now().Unix())
|
s.prefix = fmt.Sprintf("ticlient_%d", time.Now().Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
. "github.com/pingcap/check"
|
|
||||||
"github.com/pingcap/errors"
|
"github.com/pingcap/errors"
|
||||||
"github.com/pingcap/tidb/kv"
|
"github.com/pingcap/tidb/kv"
|
||||||
txndriver "github.com/pingcap/tidb/store/driver/txn"
|
txndriver "github.com/pingcap/tidb/store/driver/txn"
|
||||||
|
@ -57,39 +56,8 @@ var (
|
||||||
pdAddrs = flag.String("pd-addrs", "127.0.0.1:2379", "pd addrs")
|
pdAddrs = flag.String("pd-addrs", "127.0.0.1:2379", "pd addrs")
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewTestStoreT creates a KVStore for testing purpose.
|
|
||||||
// It accepts `*testing.T` instead of `check.C`.
|
|
||||||
func NewTestStoreT(t *testing.T) *tikv.KVStore {
|
|
||||||
if !flag.Parsed() {
|
|
||||||
flag.Parse()
|
|
||||||
}
|
|
||||||
|
|
||||||
if *mockstore.WithTiKV {
|
|
||||||
addrs := strings.Split(*pdAddrs, ",")
|
|
||||||
pdClient, err := pd.NewClient(addrs, pd.SecurityOption{})
|
|
||||||
require.Nil(t, err)
|
|
||||||
var securityConfig config.Security
|
|
||||||
tlsConfig, err := securityConfig.ToTLSConfig()
|
|
||||||
require.Nil(t, err)
|
|
||||||
spKV, err := tikv.NewEtcdSafePointKV(addrs, tlsConfig)
|
|
||||||
require.Nil(t, err)
|
|
||||||
store, err := tikv.NewKVStore("test-store", &tikv.CodecPDClient{Client: pdClient}, spKV, tikv.NewRPCClient(securityConfig))
|
|
||||||
require.Nil(t, err)
|
|
||||||
err = clearStorage(store)
|
|
||||||
require.Nil(t, err)
|
|
||||||
return store
|
|
||||||
}
|
|
||||||
client, pdClient, cluster, err := unistore.New("")
|
|
||||||
require.Nil(t, err)
|
|
||||||
unistore.BootstrapWithSingleStore(cluster)
|
|
||||||
store, err := tikv.NewTestTiKVStore(client, pdClient, nil, nil, 0)
|
|
||||||
require.Nil(t, err)
|
|
||||||
return store
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewTestStore creates a KVStore for testing purpose.
|
// NewTestStore creates a KVStore for testing purpose.
|
||||||
// TODO: remove it after we get rid of pingcap/check.
|
func NewTestStore(t *testing.T) *tikv.KVStore {
|
||||||
func NewTestStore(c *C) *tikv.KVStore {
|
|
||||||
if !flag.Parsed() {
|
if !flag.Parsed() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
@ -97,23 +65,23 @@ func NewTestStore(c *C) *tikv.KVStore {
|
||||||
if *mockstore.WithTiKV {
|
if *mockstore.WithTiKV {
|
||||||
addrs := strings.Split(*pdAddrs, ",")
|
addrs := strings.Split(*pdAddrs, ",")
|
||||||
pdClient, err := pd.NewClient(addrs, pd.SecurityOption{})
|
pdClient, err := pd.NewClient(addrs, pd.SecurityOption{})
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
var securityConfig config.Security
|
var securityConfig config.Security
|
||||||
tlsConfig, err := securityConfig.ToTLSConfig()
|
tlsConfig, err := securityConfig.ToTLSConfig()
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
spKV, err := tikv.NewEtcdSafePointKV(addrs, tlsConfig)
|
spKV, err := tikv.NewEtcdSafePointKV(addrs, tlsConfig)
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
store, err := tikv.NewKVStore("test-store", &tikv.CodecPDClient{Client: pdClient}, spKV, tikv.NewRPCClient(securityConfig))
|
store, err := tikv.NewKVStore("test-store", &tikv.CodecPDClient{Client: pdClient}, spKV, tikv.NewRPCClient(securityConfig))
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
err = clearStorage(store)
|
err = clearStorage(store)
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
client, pdClient, cluster, err := unistore.New("")
|
client, pdClient, cluster, err := unistore.New("")
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
unistore.BootstrapWithSingleStore(cluster)
|
unistore.BootstrapWithSingleStore(cluster)
|
||||||
store, err := tikv.NewTestTiKVStore(client, pdClient, nil, nil, 0)
|
store, err := tikv.NewTestTiKVStore(client, pdClient, nil, nil, 0)
|
||||||
c.Assert(err, IsNil)
|
require.Nil(t, err)
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,21 +35,13 @@ package tikvrpc
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/pingcap/check"
|
|
||||||
"github.com/pingcap/kvproto/pkg/tikvpb"
|
"github.com/pingcap/kvproto/pkg/tikvpb"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestT(t *testing.T) {
|
func TestBatchResponse(t *testing.T) {
|
||||||
TestingT(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
type testBatchCommand struct{}
|
|
||||||
|
|
||||||
var _ = SerialSuites(&testBatchCommand{})
|
|
||||||
|
|
||||||
func (s *testBatchCommand) TestBatchResponse(c *C) {
|
|
||||||
resp := &tikvpb.BatchCommandsResponse_Response{}
|
resp := &tikvpb.BatchCommandsResponse_Response{}
|
||||||
batchResp, err := FromBatchCommandsResponse(resp)
|
batchResp, err := FromBatchCommandsResponse(resp)
|
||||||
c.Assert(batchResp == nil, IsTrue)
|
assert.Nil(t, batchResp)
|
||||||
c.Assert(err != nil, IsTrue)
|
assert.NotNil(t, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue