diff --git a/integration_tests/2pc_test.go b/integration_tests/2pc_test.go index a76729288b..1052c853a4 100644 --- a/integration_tests/2pc_test.go +++ b/integration_tests/2pc_test.go @@ -50,7 +50,6 @@ import ( "github.com/ninedraft/israce" "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/kvrpcpb" - drivertxn "github.com/pingcap/tidb/store/driver/txn" "github.com/pkg/errors" "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/config" @@ -1089,12 +1088,23 @@ func (s *testCommitterSuite) TestPessimisticLockPrimary() { s.Equal(tikverr.ErrLockWaitTimeout, errors.Unwrap(waitErr)) } +type kvFilter struct{} + +func (f kvFilter) IsUnnecessaryKeyValue(key, value []byte, flags kv.KeyFlags) (bool, error) { + untouched := bytes.Equal(key, []byte("t00000001_i000000001")) + if untouched && flags.HasPresumeKeyNotExists() { + return false, errors.New("unexpected path the untouched key value with PresumeKeyNotExists flag") + } + return untouched, nil +} + func (s *testCommitterSuite) TestResolvePessimisticLock() { untouchedIndexKey := []byte("t00000001_i000000001") untouchedIndexValue := []byte{0, 0, 0, 0, 0, 0, 0, 1, 49} noValueIndexKey := []byte("t00000001_i000000002") + txn := s.begin() - txn.SetKVFilter(drivertxn.TiDBKVFilter{}) + txn.SetKVFilter(kvFilter{}) err := txn.Set(untouchedIndexKey, untouchedIndexValue) s.Nil(err) lockCtx := kv.NewLockCtx(txn.StartTS(), kv.LockNoWait, time.Now()) diff --git a/integration_tests/delete_range_test.go b/integration_tests/delete_range_test.go index 48aa305b3e..07901d4eac 100644 --- a/integration_tests/delete_range_test.go +++ b/integration_tests/delete_range_test.go @@ -41,7 +41,6 @@ import ( "sort" "testing" - "github.com/pingcap/tidb/store/mockstore/mockcopr" "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/testutils" "github.com/tikv/client-go/v2/tikv" @@ -58,7 +57,7 @@ type testDeleteRangeSuite struct { } func (s *testDeleteRangeSuite) SetupTest() { - client, cluster, pdClient, err := testutils.NewMockTiKV("", mockcopr.NewCoprRPCHandler()) + client, cluster, pdClient, err := testutils.NewMockTiKV("", nil) s.Require().Nil(err) testutils.BootstrapWithMultiRegions(cluster, []byte("b"), []byte("c"), []byte("d")) s.cluster = cluster diff --git a/integration_tests/isolation_test.go b/integration_tests/isolation_test.go index 01f9b613dc..254fb45088 100644 --- a/integration_tests/isolation_test.go +++ b/integration_tests/isolation_test.go @@ -32,6 +32,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !race // +build !race package tikv_test @@ -44,8 +45,9 @@ import ( "testing" "time" - "github.com/pingcap/tidb/kv" + "github.com/pkg/errors" "github.com/stretchr/testify/suite" + kverr "github.com/tikv/client-go/v2/error" "github.com/tikv/client-go/v2/tikv" "github.com/tikv/client-go/v2/txnkv/transaction" ) @@ -123,7 +125,8 @@ func (s *testIsolationSuite) GetWithRetry(k []byte) readRecord { value: val, } } - s.True(kv.IsTxnRetryableError(err)) + var e *kverr.ErrRetryable + s.True(errors.As(err, &e)) } } diff --git a/integration_tests/range_task_test.go b/integration_tests/range_task_test.go index 23f2754a8d..3e703c2fe3 100644 --- a/integration_tests/range_task_test.go +++ b/integration_tests/range_task_test.go @@ -41,7 +41,6 @@ import ( "sort" "testing" - "github.com/pingcap/tidb/store/mockstore/mockcopr" "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/kv" "github.com/tikv/client-go/v2/testutils" @@ -86,7 +85,7 @@ func (s *testRangeTaskSuite) SetupTest() { } allRegionRanges = append(allRegionRanges, makeRange("z", "")) - client, cluster, pdClient, err := testutils.NewMockTiKV("", mockcopr.NewCoprRPCHandler()) + client, cluster, pdClient, err := testutils.NewMockTiKV("", nil) s.Require().Nil(err) testutils.BootstrapWithMultiRegions(cluster, splitKeys...) s.cluster = cluster diff --git a/integration_tests/raw/rawkv_test.go b/integration_tests/raw/rawkv_test.go index 07e45b1a6b..9342eb8a5a 100644 --- a/integration_tests/raw/rawkv_test.go +++ b/integration_tests/raw/rawkv_test.go @@ -40,7 +40,6 @@ import ( "fmt" "testing" - "github.com/pingcap/tidb/store/mockstore/unistore" "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/rawkv" "github.com/tikv/client-go/v2/testutils" @@ -59,9 +58,10 @@ type testRawKVSuite struct { } func (s *testRawKVSuite) SetupTest() { - client, pdClient, cluster, err := unistore.New("") + client, cluster, pdClient, err := testutils.NewMockTiKV("", nil) + s.Require().NoError(err) s.Require().Nil(err) - unistore.BootstrapWithSingleStore(cluster) + testutils.BootstrapWithSingleStore(cluster) s.cluster = cluster s.client = rawkv.ClientProbe{Client: &rawkv.Client{}} s.client.SetPDClient(pdClient) diff --git a/integration_tests/raw/util_test.go b/integration_tests/raw/util_test.go index 364774e4e1..f3c130c6aa 100644 --- a/integration_tests/raw/util_test.go +++ b/integration_tests/raw/util_test.go @@ -47,5 +47,9 @@ var ( ) func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) + opts := []goleak.Option{ + goleak.IgnoreTopFunction("github.com/pingcap/goleveldb/leveldb.(*DB).mpoolDrain"), + } + + goleak.VerifyTestMain(m, opts...) } diff --git a/integration_tests/split_test.go b/integration_tests/split_test.go index 427ff9f97d..d3ecb4671d 100644 --- a/integration_tests/split_test.go +++ b/integration_tests/split_test.go @@ -41,7 +41,6 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/pingcap/tidb/store/mockstore/mockcopr" "github.com/pkg/errors" "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/testutils" @@ -62,7 +61,7 @@ type testSplitSuite struct { } func (s *testSplitSuite) SetupTest() { - client, cluster, pdClient, err := testutils.NewMockTiKV("", mockcopr.NewCoprRPCHandler()) + client, cluster, pdClient, err := testutils.NewMockTiKV("", nil) s.Require().Nil(err) testutils.BootstrapWithSingleStore(cluster) s.cluster = cluster diff --git a/integration_tests/ticlient_test.go b/integration_tests/ticlient_test.go index 25f75ee87c..d799d4f25a 100644 --- a/integration_tests/ticlient_test.go +++ b/integration_tests/ticlient_test.go @@ -36,13 +36,14 @@ package tikv_test import ( "context" + "errors" "fmt" "testing" "time" "github.com/ninedraft/israce" - "github.com/pingcap/tidb/kv" "github.com/stretchr/testify/suite" + kverr "github.com/tikv/client-go/v2/error" tikvstore "github.com/tikv/client-go/v2/kv" "github.com/tikv/client-go/v2/tikv" ) @@ -150,7 +151,8 @@ func (s *testTiclientSuite) TestLargeRequest() { s.NotNil(err) err = txn.Commit(context.Background()) s.Nil(err) - s.False(kv.IsTxnRetryableError(err)) + var retryableErr *kverr.ErrRetryable + s.False(errors.As(err, &retryableErr)) } func (s *testTiclientSuite) TestSplitRegionIn2PC() { @@ -199,7 +201,7 @@ func (s *testTiclientSuite) TestSplitRegionIn2PC() { txn := s.beginTxn() if m == "pessimistic" { txn.SetPessimistic(true) - lockCtx := &kv.LockCtx{} + lockCtx := &tikvstore.LockCtx{} lockCtx.ForUpdateTS = txn.StartTS() keys := make([][]byte, 0, preSplitThresholdInTest) for i := 0; i < preSplitThresholdInTest; i++ {