mirror of https://github.com/tikv/client-go.git
clean up test utilities (#223)
Signed-off-by: disksing <i@disksing.com>
This commit is contained in:
parent
d8c7ea50ab
commit
f4a87d3b4a
|
|
@ -8,13 +8,11 @@ require (
|
||||||
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-20210712050333-b66fdbd6bfd5
|
github.com/pingcap/kvproto v0.0.0-20210712050333-b66fdbd6bfd5
|
||||||
github.com/pingcap/parser v0.0.0-20210707071004-31c87e37af5c
|
github.com/pingcap/parser v0.0.0-20210707071004-31c87e37af5c
|
||||||
github.com/pingcap/tidb v1.1.0-beta.0.20210702041526-83acf6a4ac28
|
github.com/pingcap/tidb v1.1.0-beta.0.20210713072132-d696ce33a79e
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/tikv/client-go/v2 v2.0.0
|
github.com/tikv/client-go/v2 v2.0.0
|
||||||
github.com/tikv/pd v1.1.0-beta.0.20210323121136-78679e5e209d
|
github.com/tikv/pd v1.1.0-beta.0.20210323121136-78679e5e209d
|
||||||
go.uber.org/goleak v1.1.10
|
go.uber.org/goleak v1.1.10
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/pingcap/tidb => github.com/hanfei1991/tidb v1.0.1-0.20210712061812-27b38561e681
|
|
||||||
|
|
||||||
replace github.com/tikv/client-go/v2 => ../
|
replace github.com/tikv/client-go/v2 => ../
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.12.1 h1:zCy2xE9ablevUOrUZc3Dl72Dt+ya2FNAvC2yLYMHzi4=
|
github.com/grpc-ecosystem/grpc-gateway v1.12.1 h1:zCy2xE9ablevUOrUZc3Dl72Dt+ya2FNAvC2yLYMHzi4=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
|
github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
|
||||||
github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69/go.mod h1:YLEMZOtU+AZ7dhN9T/IpGhXVGly2bvkJQ+zxj3WeVQo=
|
github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69/go.mod h1:YLEMZOtU+AZ7dhN9T/IpGhXVGly2bvkJQ+zxj3WeVQo=
|
||||||
github.com/hanfei1991/tidb v1.0.1-0.20210712061812-27b38561e681 h1:YHateRrJ7gARmABFDp1C6PptXa7fzQjgnz/WX+3Q9eM=
|
|
||||||
github.com/hanfei1991/tidb v1.0.1-0.20210712061812-27b38561e681/go.mod h1:JFDQNfRCRYGH+ZlBeI7Idh870p2vkqb8BXXFK6c0T0s=
|
|
||||||
github.com/hashicorp/go-uuid v0.0.0-20180228145832-27454136f036/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v0.0.0-20180228145832-27454136f036/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
|
@ -438,6 +436,8 @@ github.com/pingcap/parser v0.0.0-20210707071004-31c87e37af5c/go.mod h1:Ek0mLKEqU
|
||||||
github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI=
|
github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI=
|
||||||
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3 h1:A9KL9R+lWSVPH8IqUuH1QSTRJ5FGoY1bT2IcfPKsWD8=
|
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3 h1:A9KL9R+lWSVPH8IqUuH1QSTRJ5FGoY1bT2IcfPKsWD8=
|
||||||
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3/go.mod h1:tckvA041UWP+NqYzrJ3fMgC/Hw9wnmQ/tUkp/JaHly8=
|
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3/go.mod h1:tckvA041UWP+NqYzrJ3fMgC/Hw9wnmQ/tUkp/JaHly8=
|
||||||
|
github.com/pingcap/tidb v1.1.0-beta.0.20210713072132-d696ce33a79e h1:2ECwaLCOeG+9vpndk0jGOyv2kOscQbSCxW+l1vcniQE=
|
||||||
|
github.com/pingcap/tidb v1.1.0-beta.0.20210713072132-d696ce33a79e/go.mod h1:VzQZEwPMWZISKvtmE9YbAnYFAzpZLK7puFvVJw5AKPY=
|
||||||
github.com/pingcap/tidb-dashboard v0.0.0-20210312062513-eef5d6404638/go.mod h1:OzFN8H0EDMMqeulPhPMw2i2JaiZWOKFQ7zdRPhENNgo=
|
github.com/pingcap/tidb-dashboard v0.0.0-20210312062513-eef5d6404638/go.mod h1:OzFN8H0EDMMqeulPhPMw2i2JaiZWOKFQ7zdRPhENNgo=
|
||||||
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg=
|
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg=
|
||||||
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
|
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,6 @@ func TestNewIterator(t *testing.T) {
|
||||||
// FnKeyCmp is the function for iterator the keys
|
// FnKeyCmp is the function for iterator the keys
|
||||||
type FnKeyCmp func(key []byte) bool
|
type FnKeyCmp func(key []byte) bool
|
||||||
|
|
||||||
// TODO: remove it since it is duplicated with kv.NextUtil
|
|
||||||
// NextUntil applies FnKeyCmp to each entry of the iterator until meets some condition.
|
// NextUntil applies FnKeyCmp to each entry of the iterator until meets some condition.
|
||||||
// It will stop when fn returns true, or iterator is invalid or an error occurs.
|
// It will stop when fn returns true, or iterator is invalid or an error occurs.
|
||||||
func NextUntil(it Iterator, fn FnKeyCmp) error {
|
func NextUntil(it Iterator, fn FnKeyCmp) error {
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
// Copyright 2021 TiKV Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cluster
|
|
||||||
|
|
||||||
import "github.com/tikv/client-go/v2/internal/mockstore/cluster"
|
|
||||||
|
|
||||||
// For backward campatibility.
|
|
||||||
// TODO: remove it.
|
|
||||||
|
|
||||||
// Cluster simulates a TiKV cluster.
|
|
||||||
type Cluster = cluster.Cluster
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
// Copyright 2021 TiKV Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package mocktikv
|
|
||||||
|
|
||||||
import "github.com/tikv/client-go/v2/internal/mockstore/mocktikv"
|
|
||||||
|
|
||||||
// For backward campatibility.
|
|
||||||
// TODO: remove it.
|
|
||||||
|
|
||||||
// CoprRPCHandler is the interface to handle coprocessor RPC commands.
|
|
||||||
type CoprRPCHandler = mocktikv.CoprRPCHandler
|
|
||||||
|
|
||||||
// MVCCStore is a mvcc key-value storage.
|
|
||||||
type MVCCStore = mocktikv.MVCCStore
|
|
||||||
|
|
||||||
// MustNewMVCCStore creates a MVCCStore for testing.
|
|
||||||
var MustNewMVCCStore = mocktikv.MustNewMVCCStore
|
|
||||||
|
|
||||||
// Pair is a KV pair read from MvccStore or an error if any occurs.
|
|
||||||
type Pair = mocktikv.Pair
|
|
||||||
|
|
||||||
// Cluster simulates a TiKV cluster.
|
|
||||||
type Cluster = mocktikv.Cluster
|
|
||||||
|
|
||||||
// RPCClient sends kv RPC calls to mock cluster.
|
|
||||||
type RPCClient = mocktikv.RPCClient
|
|
||||||
|
|
||||||
// Session stores session scope rpc data.
|
|
||||||
type Session = mocktikv.Session
|
|
||||||
|
|
||||||
// NewTiKVAndPDClient creates a TiKV client and PD client from options.
|
|
||||||
var NewTiKVAndPDClient = mocktikv.NewTiKVAndPDClient
|
|
||||||
|
|
||||||
// BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.
|
|
||||||
var BootstrapWithSingleStore = mocktikv.BootstrapWithSingleStore
|
|
||||||
|
|
||||||
// BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.
|
|
||||||
var BootstrapWithMultiStores = mocktikv.BootstrapWithMultiStores
|
|
||||||
|
|
||||||
// BootstrapWithMultiRegions initializes a Cluster with multiple Regions and 1
|
|
||||||
// Store. The number of Regions will be len(splitKeys) + 1.
|
|
||||||
var BootstrapWithMultiRegions = mocktikv.BootstrapWithMultiRegions
|
|
||||||
|
|
||||||
// ErrLocked is returned when trying to Read/Write on a locked key. Client should
|
|
||||||
// backoff or cleanup the lock then retry.
|
|
||||||
type ErrLocked = mocktikv.ErrLocked
|
|
||||||
|
|
@ -35,9 +35,7 @@ package tikv
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pingcap/errors"
|
"github.com/pingcap/errors"
|
||||||
"github.com/pingcap/failpoint"
|
|
||||||
"github.com/tikv/client-go/v2/internal/locate"
|
"github.com/tikv/client-go/v2/internal/locate"
|
||||||
"github.com/tikv/client-go/v2/util"
|
|
||||||
pd "github.com/tikv/pd/client"
|
pd "github.com/tikv/pd/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -64,19 +62,3 @@ func NewTestTiKVStore(client Client, pdClient pd.Client, clientHijack func(Clien
|
||||||
tikvStore.mock = true
|
tikvStore.mock = true
|
||||||
return tikvStore, errors.Trace(err)
|
return tikvStore, errors.Trace(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockCommitErrorEnable exports for gofail testing.
|
|
||||||
func MockCommitErrorEnable() {
|
|
||||||
failpoint.Enable(`tikvclient/mockCommitErrorOpt`, "return(true)")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockCommitErrorDisable exports for gofail testing.
|
|
||||||
func MockCommitErrorDisable() {
|
|
||||||
failpoint.Disable(`tikvclient/mockCommitErrorOpt`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMockCommitErrorEnable exports for gofail testing.
|
|
||||||
func IsMockCommitErrorEnable() bool {
|
|
||||||
_, err := util.EvalFailpoint(`mockCommitErrorOpt`)
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue