Skip to content

Commit

Permalink
*: further adaptation to PD HTTP client (#48606)
Browse files Browse the repository at this point in the history
ref #35319
  • Loading branch information
JmPotato authored Nov 20, 2023
1 parent 5ac833e commit 95759f4
Show file tree
Hide file tree
Showing 50 changed files with 238 additions and 511 deletions.
24 changes: 12 additions & 12 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7119,26 +7119,26 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sha256 = "285edca3320cc8847aceffb5d5471fe7483c49f66795622f71ed819c72635d00",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20231114060955-8fc8a528217e",
sha256 = "548df2ca5c27559e3318b97b4cb91703d5c253410e7f9fa0eb926e2d3aa28b59",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20231116051730-1c2351c28173",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231114060955-8fc8a528217e.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231114060955-8fc8a528217e.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231114060955-8fc8a528217e.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231114060955-8fc8a528217e.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231116051730-1c2351c28173.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231116051730-1c2351c28173.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231116051730-1c2351c28173.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231116051730-1c2351c28173.zip",
],
)
go_repository(
name = "com_github_tikv_pd_client",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/pd/client",
sha256 = "cb510944ce56555f005fff2d891af3fefa667f37955779b89c35fd40f51deace",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20231114041114-86831ce71865",
sha256 = "014bb8796797b8b5cecc22866a1aab8491e3718c540168ac91257cf7f220cc84",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20231117041718-dda748abe55d",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231114041114-86831ce71865.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231114041114-86831ce71865.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231114041114-86831ce71865.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231114041114-86831ce71865.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231117041718-dda748abe55d.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231117041718-dda748abe55d.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231117041718-dda748abe55d.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231117041718-dda748abe55d.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ go_test(
"//pkg/testkit/testsetup",
"//pkg/util/dbutil",
"//pkg/util/mock",
"//pkg/util/pdapi",
"@com_github_data_dog_go_sqlmock//:go-sqlmock",
"@com_github_go_sql_driver_mysql//:mysql",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@com_github_tikv_pd_client//http",
"@io_etcd_go_etcd_client_v3//:client",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
Expand Down
6 changes: 3 additions & 3 deletions br/pkg/lightning/common/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"testing"

"github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/pkg/util/pdapi"
"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client/http"
)

func respondPathHandler(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -94,8 +94,8 @@ func TestWithHost(t *testing.T) {
false,
},
{
fmt.Sprintf("http://127.0.0.1:2379%s", pdapi.Stores),
fmt.Sprintf("127.0.0.1:2379%s", pdapi.Stores),
fmt.Sprintf("http://127.0.0.1:2379%s", pd.Stores),
fmt.Sprintf("127.0.0.1:2379%s", pd.Stores),
false,
},
{
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/importer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ go_library(
"//pkg/util/etcd",
"//pkg/util/extsort",
"//pkg/util/mock",
"//pkg/util/pdapi",
"//pkg/util/regexpr-router",
"//pkg/util/set",
"@com_github_coreos_go_semver//semver",
Expand All @@ -90,6 +89,7 @@ go_library(
"@com_github_tikv_client_go_v2//config",
"@com_github_tikv_client_go_v2//util",
"@com_github_tikv_pd_client//:client",
"@com_github_tikv_pd_client//http",
"@io_etcd_go_etcd_client_v3//:client",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
Expand Down Expand Up @@ -163,7 +163,6 @@ go_test(
"//pkg/util/dbutil",
"//pkg/util/extsort",
"//pkg/util/mock",
"//pkg/util/pdapi",
"//pkg/util/promutil",
"//pkg/util/table-filter",
"//pkg/util/table-router",
Expand All @@ -179,6 +178,7 @@ go_test(
"@com_github_tikv_client_go_v2//config",
"@com_github_tikv_client_go_v2//testutils",
"@com_github_tikv_pd_client//:client",
"@com_github_tikv_pd_client//http",
"@com_github_xitongsys_parquet_go//writer",
"@com_github_xitongsys_parquet_go_source//buffer",
"@io_etcd_go_etcd_client_v3//:client",
Expand Down
8 changes: 4 additions & 4 deletions br/pkg/lightning/importer/get_pre_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ import (
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/dbterror"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/pingcap/tidb/pkg/util/pdapi"
pd "github.com/tikv/pd/client"
pdhttp "github.com/tikv/pd/client/http"
"go.uber.org/zap"
"golang.org/x/exp/maps"
)
Expand Down Expand Up @@ -237,7 +237,7 @@ func (g *TargetInfoGetterImpl) GetTargetSysVariablesForImport(ctx context.Contex
// It uses the PD interface through TLS to get the information.
func (g *TargetInfoGetterImpl) GetReplicationConfig(ctx context.Context) (*pdtypes.ReplicationConfig, error) {
result := new(pdtypes.ReplicationConfig)
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdapi.ReplicateConfig, &result); err != nil {
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdhttp.ReplicateConfig, &result); err != nil {
return nil, errors.Trace(err)
}
return result, nil
Expand All @@ -248,7 +248,7 @@ func (g *TargetInfoGetterImpl) GetReplicationConfig(ctx context.Context) (*pdtyp
// It uses the PD interface through TLS to get the information.
func (g *TargetInfoGetterImpl) GetStorageInfo(ctx context.Context) (*pdtypes.StoresInfo, error) {
result := new(pdtypes.StoresInfo)
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdapi.Stores, result); err != nil {
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdhttp.Stores, result); err != nil {
return nil, errors.Trace(err)
}
return result, nil
Expand All @@ -259,7 +259,7 @@ func (g *TargetInfoGetterImpl) GetStorageInfo(ctx context.Context) (*pdtypes.Sto
// It uses the PD interface through TLS to get the information.
func (g *TargetInfoGetterImpl) GetEmptyRegionsInfo(ctx context.Context) (*pdtypes.RegionsInfo, error) {
result := new(pdtypes.RegionsInfo)
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdapi.EmptyRegions, &result); err != nil {
if err := g.tls.WithHost(g.pdCli.GetLeaderAddr()).GetJSON(ctx, pdhttp.EmptyRegions, &result); err != nil {
return nil, errors.Trace(err)
}
return result, nil
Expand Down
6 changes: 3 additions & 3 deletions br/pkg/lightning/importer/table_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ import (
"github.com/pingcap/tidb/pkg/table/tables"
"github.com/pingcap/tidb/pkg/types"
tmock "github.com/pingcap/tidb/pkg/util/mock"
"github.com/pingcap/tidb/pkg/util/pdapi"
"github.com/pingcap/tidb/pkg/util/promutil"
filter "github.com/pingcap/tidb/pkg/util/table-filter"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/client-go/v2/testutils"
pd "github.com/tikv/pd/client"
pdhttp "github.com/tikv/pd/client/http"
"go.uber.org/mock/gomock"
)

Expand Down Expand Up @@ -1324,9 +1324,9 @@ func (s *tableRestoreSuite) TestCheckClusterRegion() {
for i, ca := range testCases {
server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
var err error
if req.URL.Path == pdapi.Stores {
if req.URL.Path == pdhttp.Stores {
_, err = w.Write(mustMarshal(ca.stores))
} else if req.URL.Path == pdapi.EmptyRegions {
} else if req.URL.Path == pdhttp.EmptyRegions {
_, err = w.Write(mustMarshal(ca.emptyRegions))
} else {
w.WriteHeader(http.StatusNotFound)
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/tikv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ go_library(
"//br/pkg/version",
"//pkg/kv",
"//pkg/parser/model",
"//pkg/util/pdapi",
"@com_github_coreos_go_semver//semver",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_kvproto//pkg/debugpb",
"@com_github_pingcap_kvproto//pkg/import_sstpb",
"@com_github_pingcap_kvproto//pkg/kvrpcpb",
"@com_github_tikv_client_go_v2//util",
"@com_github_tikv_pd_client//http",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
Expand All @@ -37,9 +37,9 @@ go_test(
deps = [
":tikv",
"//br/pkg/lightning/common",
"//pkg/util/pdapi",
"@com_github_coreos_go_semver//semver",
"@com_github_pingcap_kvproto//pkg/import_sstpb",
"@com_github_stretchr_testify//require",
"@com_github_tikv_pd_client//http",
],
)
4 changes: 2 additions & 2 deletions br/pkg/lightning/tikv/tikv.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
"github.com/pingcap/tidb/br/pkg/version"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/util/pdapi"
"github.com/tikv/client-go/v2/util"
pd "github.com/tikv/pd/client/http"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
Expand Down Expand Up @@ -125,7 +125,7 @@ func ForAllStores(
Store Store
}
}
err := tls.GetJSON(ctx, pdapi.Stores, &stores)
err := tls.GetJSON(ctx, pd.Stores, &stores)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions br/pkg/lightning/tikv/tikv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/pingcap/kvproto/pkg/import_sstpb"
"github.com/pingcap/tidb/br/pkg/lightning/common"
kv "github.com/pingcap/tidb/br/pkg/lightning/tikv"
"github.com/pingcap/tidb/pkg/util/pdapi"
"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client/http"
)

var (
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestCheckPDVersion(t *testing.T) {
ctx := context.Background()

mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
require.Equal(t, pdapi.Version, req.URL.Path)
require.Equal(t, pd.Version, req.URL.Path)
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte(version))
require.NoError(t, err)
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestCheckTiKVVersion(t *testing.T) {
ctx := context.Background()

mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
require.Equal(t, pdapi.Stores, req.URL.Path)
require.Equal(t, pd.Stores, req.URL.Path)
w.WriteHeader(http.StatusOK)

stores := make([]map[string]interface{}, 0, len(versions))
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/pdutil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/store/pdtypes",
"//pkg/tablecodec",
"//pkg/util/codec",
"//pkg/util/pdapi",
"@com_github_coreos_go_semver//semver",
"@com_github_docker_go_units//:go-units",
"@com_github_google_uuid//:uuid",
Expand All @@ -24,6 +23,7 @@ go_library(
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_log//:log",
"@com_github_tikv_pd_client//:client",
"@com_github_tikv_pd_client//http",
"@org_golang_google_grpc//:grpc",
"@org_uber_go_zap//:zap",
],
Expand All @@ -43,11 +43,11 @@ go_test(
"//pkg/store/pdtypes",
"//pkg/testkit/testsetup",
"//pkg/util/codec",
"//pkg/util/pdapi",
"@com_github_coreos_go_semver//semver",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/metapb",
"@com_github_stretchr_testify//require",
"@com_github_tikv_pd_client//http",
"@org_uber_go_goleak//:goleak",
],
)
Loading

0 comments on commit 95759f4

Please sign in to comment.