Skip to content

Commit

Permalink
BR: fix Unit test TestconfigureRestoreClient (#35214)
Browse files Browse the repository at this point in the history
close #35209
  • Loading branch information
WizardXiao authored Jun 8, 2022
1 parent c8fcad4 commit 7846d1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ bazel_prepare:
bazel_test: failpoint-enable bazel_ci_prepare
bazel --output_user_root=/home/jenkins/.tidb/tmp test --config=ci \
-- //... -//cmd/... -//tests/graceshutdown/... \
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/lightning/log:log_test -//br/pkg/task:task_test
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/lightning/log:log_test


bazel_coverage_test: failpoint-enable bazel_ci_prepare
bazel --output_user_root=/home/jenkins/.tidb/tmp coverage --config=ci --@io_bazel_rules_go//go/config:cover_format=go_cover \
-- //... -//cmd/... -//tests/graceshutdown/... \
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/lightning/log:log_test -//br/pkg/task:task_test
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/lightning/log:log_test

bazel_build: bazel_ci_prepare
mkdir -p bin
Expand Down
20 changes: 15 additions & 5 deletions br/pkg/task/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/golang/protobuf/proto"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/kvproto/pkg/encryptionpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/tidb/br/pkg/conn"
"github.com/pingcap/tidb/br/pkg/metautil"
"github.com/pingcap/tidb/br/pkg/restore"
Expand All @@ -20,6 +21,8 @@ import (
"github.com/pingcap/tidb/statistics/handle"
"github.com/pingcap/tidb/tablecodec"
"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client"
"google.golang.org/grpc/keepalive"
)

func TestRestoreConfigAdjust(t *testing.T) {
Expand All @@ -32,7 +35,15 @@ func TestRestoreConfigAdjust(t *testing.T) {
require.Equal(t, conn.DefaultMergeRegionSizeBytes, cfg.MergeSmallRegionSizeBytes)
}

func TestconfigureRestoreClient(t *testing.T) {
type mockPDClient struct {
pd.Client
}

func (m mockPDClient) GetAllStores(ctx context.Context, opts ...pd.GetStoreOption) ([]*metapb.Store, error) {
return []*metapb.Store{}, nil
}

func TestConfigureRestoreClient(t *testing.T) {
cfg := Config{
Concurrency: 1024,
}
Expand All @@ -44,13 +55,12 @@ func TestconfigureRestoreClient(t *testing.T) {
RestoreCommonConfig: restoreComCfg,
DdlBatchSize: 128,
}
client := &restore.Client{}

client := restore.NewRestoreClient(mockPDClient{}, nil, keepalive.ClientParameters{}, false)
ctx := context.Background()
err := configureRestoreClient(ctx, client, restoreCfg)
require.NoError(t, err)
require.Equal(t, client.GetBatchDdlSize(), 128)
require.True(t, true, client.IsOnline())
require.Equal(t, uint(128), client.GetBatchDdlSize())
require.True(t, client.IsOnline())
}

func TestCheckRestoreDBAndTable(t *testing.T) {
Expand Down

0 comments on commit 7846d1e

Please sign in to comment.