From 1c834e747bc5de12b0053f16dcc68c6707eca6c3 Mon Sep 17 00:00:00 2001 From: disksing Date: Thu, 1 Jul 2021 11:03:55 +0800 Subject: [PATCH] *: update tidb and cleanup unused code (#196) --- integration_tests/1pc_test.go | 5 +-- integration_tests/async_commit_fail_test.go | 7 ++-- integration_tests/async_commit_test.go | 7 ++-- integration_tests/go.mod | 2 +- integration_tests/go.sum | 4 +- integration_tests/snapshot_fail_test.go | 5 +-- integration_tests/ticlient_test.go | 3 +- integration_tests/util_test.go | 6 +-- mockstore/test_suite.go | 42 --------------------- retry/retry.go | 25 ------------ unionstore/unionstore.go | 35 ----------------- 11 files changed, 17 insertions(+), 124 deletions(-) delete mode 100644 mockstore/test_suite.go delete mode 100644 retry/retry.go delete mode 100644 unionstore/unionstore.go diff --git a/integration_tests/1pc_test.go b/integration_tests/1pc_test.go index 89d16eb0..43905d16 100644 --- a/integration_tests/1pc_test.go +++ b/integration_tests/1pc_test.go @@ -38,7 +38,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/tikv/client-go/v2/metrics" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/oracle" "github.com/tikv/client-go/v2/tikv" "github.com/tikv/client-go/v2/util" @@ -198,7 +197,7 @@ func (s *testOnePCSuite) Test1PCIsolation() { func (s *testOnePCSuite) Test1PCDisallowMultiRegion() { // This test doesn't support tikv mode. - if *mockstore.WithTiKV { + if *withTiKV { return } @@ -266,7 +265,7 @@ func (s *testOnePCSuite) Test1PCLinearizability() { func (s *testOnePCSuite) Test1PCWithMultiDC() { // It requires setting placement rules to run with TiKV - if *mockstore.WithTiKV { + if *withTiKV { return } diff --git a/integration_tests/async_commit_fail_test.go b/integration_tests/async_commit_fail_test.go index 2dfb635e..9915eec3 100644 --- a/integration_tests/async_commit_fail_test.go +++ b/integration_tests/async_commit_fail_test.go @@ -44,7 +44,6 @@ import ( "github.com/pingcap/parser/terror" "github.com/stretchr/testify/suite" tikverr "github.com/tikv/client-go/v2/error" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/tikv" "github.com/tikv/client-go/v2/util" ) @@ -69,7 +68,7 @@ func (s *testAsyncCommitFailSuite) TearDownTest() { // committing primary region task. func (s *testAsyncCommitFailSuite) TestFailAsyncCommitPrewriteRpcErrors() { // This test doesn't support tikv mode because it needs setting failpoint in unistore. - if *mockstore.WithTiKV { + if *withTiKV { return } @@ -101,7 +100,7 @@ func (s *testAsyncCommitFailSuite) TestFailAsyncCommitPrewriteRpcErrors() { func (s *testAsyncCommitFailSuite) TestAsyncCommitPrewriteCancelled() { // This test doesn't support tikv mode because it needs setting failpoint in unistore. - if *mockstore.WithTiKV { + if *withTiKV { return } @@ -161,7 +160,7 @@ func (s *testAsyncCommitFailSuite) TestPointGetWithAsyncCommit() { func (s *testAsyncCommitFailSuite) TestSecondaryListInPrimaryLock() { // This test doesn't support tikv mode. - if *mockstore.WithTiKV { + if *withTiKV { return } diff --git a/integration_tests/async_commit_test.go b/integration_tests/async_commit_test.go index ee45d0f8..73fdf713 100644 --- a/integration_tests/async_commit_test.go +++ b/integration_tests/async_commit_test.go @@ -46,7 +46,6 @@ import ( "github.com/pingcap/tidb/store/mockstore/unistore" "github.com/stretchr/testify/suite" tikverr "github.com/tikv/client-go/v2/error" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/mockstore/cluster" "github.com/tikv/client-go/v2/oracle" "github.com/tikv/client-go/v2/tikv" @@ -67,7 +66,7 @@ type testAsyncCommitCommon struct { } func (s *testAsyncCommitCommon) setUpTest() { - if *mockstore.WithTiKV { + if *withTiKV { s.store = NewTestStore(s.T()) return } @@ -228,7 +227,7 @@ func (s *testAsyncCommitSuite) lockKeysWithAsyncCommit(keys, values [][]byte, pr func (s *testAsyncCommitSuite) TestCheckSecondaries() { // This test doesn't support tikv mode. - if *mockstore.WithTiKV { + if *withTiKV { return } @@ -435,7 +434,7 @@ func (s *testAsyncCommitSuite) TestAsyncCommitLinearizability() { // TestAsyncCommitWithMultiDC tests that async commit can only be enabled in global transactions func (s *testAsyncCommitSuite) TestAsyncCommitWithMultiDC() { // It requires setting placement rules to run with TiKV - if *mockstore.WithTiKV { + if *withTiKV { return } diff --git a/integration_tests/go.mod b/integration_tests/go.mod index 77ef8108..27bc1a28 100644 --- a/integration_tests/go.mod +++ b/integration_tests/go.mod @@ -8,7 +8,7 @@ require ( github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd github.com/pingcap/kvproto v0.0.0-20210611081648-a215b4e61d2f github.com/pingcap/parser v0.0.0-20210618053735-57843e8185c4 - github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4 + github.com/pingcap/tidb v1.1.0-beta.0.20210630084325-e8af6eb0adec github.com/stretchr/testify v1.7.0 github.com/tikv/client-go/v2 v2.0.0 github.com/tikv/pd v1.1.0-beta.0.20210323121136-78679e5e209d diff --git a/integration_tests/go.sum b/integration_tests/go.sum index 1d7ba7a2..0601b610 100644 --- a/integration_tests/go.sum +++ b/integration_tests/go.sum @@ -433,8 +433,8 @@ github.com/pingcap/parser v0.0.0-20210618053735-57843e8185c4/go.mod h1:xZC8I7bug 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/go.mod h1:tckvA041UWP+NqYzrJ3fMgC/Hw9wnmQ/tUkp/JaHly8= -github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4 h1:x087K40I4zm9hUo7BmJk1q52O7DPPmv8tfnDXIYHkBU= -github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4/go.mod h1:bszEbe/WvvmVFNh4BVjyb/8YDjlA7IxweZLQy+EVBmk= +github.com/pingcap/tidb v1.1.0-beta.0.20210630084325-e8af6eb0adec h1:tXST/5Q0YnPOm70meDfkxCvwK39+aN2fdQOSDEw0+Ko= +github.com/pingcap/tidb v1.1.0-beta.0.20210630084325-e8af6eb0adec/go.mod h1:6lc1Xx//CQuv5mdJmxKVtxA3dT5FUbRk3aOrtaqqJBA= 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/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= diff --git a/integration_tests/snapshot_fail_test.go b/integration_tests/snapshot_fail_test.go index 28ad1730..0b342757 100644 --- a/integration_tests/snapshot_fail_test.go +++ b/integration_tests/snapshot_fail_test.go @@ -42,7 +42,6 @@ import ( "github.com/pingcap/tidb/store/mockstore/unistore" "github.com/stretchr/testify/suite" tikverr "github.com/tikv/client-go/v2/error" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/tikv" ) @@ -84,7 +83,7 @@ func (s *testSnapshotFailSuite) TearDownTest() { func (s *testSnapshotFailSuite) TestBatchGetResponseKeyError() { // Meaningless to test with tikv because it has a mock key error - if *mockstore.WithTiKV { + if *withTiKV { return } @@ -112,7 +111,7 @@ func (s *testSnapshotFailSuite) TestBatchGetResponseKeyError() { func (s *testSnapshotFailSuite) TestScanResponseKeyError() { // Meaningless to test with tikv because it has a mock key error - if *mockstore.WithTiKV { + if *withTiKV { return } diff --git a/integration_tests/ticlient_test.go b/integration_tests/ticlient_test.go index b13ec8a7..97dfa3f0 100644 --- a/integration_tests/ticlient_test.go +++ b/integration_tests/ticlient_test.go @@ -42,7 +42,6 @@ import ( "github.com/pingcap/tidb/kv" "github.com/stretchr/testify/suite" tikvstore "github.com/tikv/client-go/v2/kv" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/tikv" ) @@ -153,7 +152,7 @@ func (s *testTiclientSuite) TestLargeRequest() { } func (s *testTiclientSuite) TestSplitRegionIn2PC() { - if *mockstore.WithTiKV { + if *withTiKV { s.T().Skip("scatter will timeout with single node TiKV") } if israce.Race { diff --git a/integration_tests/util_test.go b/integration_tests/util_test.go index e80939a2..45b38142 100644 --- a/integration_tests/util_test.go +++ b/integration_tests/util_test.go @@ -46,14 +46,14 @@ import ( "github.com/pingcap/tidb/store/mockstore/unistore" "github.com/stretchr/testify/require" "github.com/tikv/client-go/v2/config" - "github.com/tikv/client-go/v2/mockstore" "github.com/tikv/client-go/v2/tikv" "github.com/tikv/client-go/v2/util/codec" pd "github.com/tikv/pd/client" ) var ( - pdAddrs = flag.String("pd-addrs", "127.0.0.1:2379", "pd addrs") + 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") ) // NewTestStore creates a KVStore for testing purpose. @@ -62,7 +62,7 @@ func NewTestStore(t *testing.T) *tikv.KVStore { flag.Parse() } - if *mockstore.WithTiKV { + if *withTiKV { addrs := strings.Split(*pdAddrs, ",") pdClient, err := pd.NewClient(addrs, pd.SecurityOption{}) require.Nil(t, err) diff --git a/mockstore/test_suite.go b/mockstore/test_suite.go deleted file mode 100644 index e4e98c6a..00000000 --- a/mockstore/test_suite.go +++ /dev/null @@ -1,42 +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. - -// NOTE: The code in this file is based on code from the -// TiDB project, licensed under the Apache License v 2.0 -// -// https://github.com/pingcap/tidb/tree/cc5e161ac06827589c4966674597c137cc9e809c/store/tikv/mockstore/test_suite.go -// - -// Copyright 2018 PingCAP, Inc. -// -// 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 mockstore - -import ( - "flag" -) - -var ( - // WithTiKV is the flag which indicates whether it runs with tikv. - WithTiKV = flag.Bool("with-tikv", false, "run tests with TiKV cluster started. (not use the mock server)") -) diff --git a/retry/retry.go b/retry/retry.go deleted file mode 100644 index f5c6ae71..00000000 --- a/retry/retry.go +++ /dev/null @@ -1,25 +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 retry - -import "github.com/tikv/client-go/v2/internal/retry" - -// Re-export internal/retry for compatibility. -// TODO: Remove it. - -// NewNoopBackoff create a Backoffer do nothing just return error directly -var NewNoopBackoff = retry.NewNoopBackoff - -// BoTiFlashRPC is the backoff config for TiFlash RPCs. -var BoTiFlashRPC = retry.BoTiFlashRPC diff --git a/unionstore/unionstore.go b/unionstore/unionstore.go deleted file mode 100644 index 93223680..00000000 --- a/unionstore/unionstore.go +++ /dev/null @@ -1,35 +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 unionstore - -import "github.com/tikv/client-go/v2/internal/unionstore" - -// Re-export internal/unionstore for compatibility. -// TODO: Remove it. - -// Getter is the interface for the Get method. -type Getter = unionstore.Getter - -// Iterator is the interface for a iterator on KV store. -type Iterator = unionstore.Iterator - -// MemDB is rollbackable Red-Black Tree optimized for transaction states buffer use scenario. -// You can think MemDB is a combination of two separate tree map, one for key => value and another for key => keyFlags. -// -// The value map is rollbackable, that means you can use the `Staging`, `Release` and `Cleanup` API to safely modify KVs. -// -// The flags map is not rollbackable. There are two types of flag, persistent and non-persistent. -// When discarding a newly added KV in `Cleanup`, the non-persistent flags will be cleared. -// If there are persistent flags associated with key, we will keep this key in node without value. -type MemDB = unionstore.MemDB