Skip to content

Commit

Permalink
Restore: refine split code for both compacted sst files and logs (#56917
Browse files Browse the repository at this point in the history
)

ref #56522
  • Loading branch information
3pointer authored Nov 7, 2024
1 parent fda9d39 commit ef6662e
Show file tree
Hide file tree
Showing 35 changed files with 1,335 additions and 1,394 deletions.
2 changes: 1 addition & 1 deletion br/pkg/conn/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ go_test(
"//br/pkg/config",
"//br/pkg/conn/util",
"//br/pkg/pdutil",
"//br/pkg/utiltest",
"//br/pkg/restore/split",
"//pkg/testkit/testsetup",
"@com_github_docker_go_units//:go-units",
"@com_github_pingcap_errors//:errors",
Expand Down
14 changes: 7 additions & 7 deletions br/pkg/conn/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/br/pkg/conn"
"github.com/pingcap/tidb/br/pkg/conn/util"
"github.com/pingcap/tidb/br/pkg/pdutil"
"github.com/pingcap/tidb/br/pkg/utiltest"
"github.com/pingcap/tidb/br/pkg/restore/split"
"github.com/stretchr/testify/require"
"go.uber.org/multierr"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestGetAllTiKVStoresWithRetryCancel(t *testing.T) {
},
}

fpdc := utiltest.NewFakePDClient(stores, false, nil)
fpdc := split.NewFakePDClient(stores, false, nil)

_, err = conn.GetAllTiKVStoresWithRetry(ctx, fpdc, util.SkipTiFlash)
require.Error(t, err)
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestGetAllTiKVStoresWithUnknown(t *testing.T) {
},
}

fpdc := utiltest.NewFakePDClient(stores, false, nil)
fpdc := split.NewFakePDClient(stores, false, nil)

_, err = conn.GetAllTiKVStoresWithRetry(ctx, fpdc, util.SkipTiFlash)
require.Error(t, err)
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestCheckStoresAlive(t *testing.T) {
},
}

fpdc := utiltest.NewFakePDClient(stores, false, nil)
fpdc := split.NewFakePDClient(stores, false, nil)

kvStores, err := conn.GetAllTiKVStoresWithRetry(ctx, fpdc, util.SkipTiFlash)
require.NoError(t, err)
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestGetAllTiKVStores(t *testing.T) {
}

for _, testCase := range testCases {
pdClient := utiltest.NewFakePDClient(testCase.stores, false, nil)
pdClient := split.NewFakePDClient(testCase.stores, false, nil)
stores, err := util.GetAllTiKVStores(context.Background(), pdClient, testCase.storeBehavior)
if len(testCase.expectedError) != 0 {
require.Error(t, err)
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestGetMergeRegionSizeAndCount(t *testing.T) {
pctx := context.Background()
for _, ca := range cases {
ctx, cancel := context.WithCancel(pctx)
pdCli := utiltest.NewFakePDClient(ca.stores, false, nil)
pdCli := split.NewFakePDClient(ca.stores, false, nil)
require.Equal(t, len(ca.content), len(ca.stores))
count := 0
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -586,7 +586,7 @@ func TestIsLogBackupEnabled(t *testing.T) {
pctx := context.Background()
for _, ca := range cases {
ctx, cancel := context.WithCancel(pctx)
pdCli := utiltest.NewFakePDClient(ca.stores, false, nil)
pdCli := split.NewFakePDClient(ca.stores, false, nil)
require.Equal(t, len(ca.content), len(ca.stores))
count := 0
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/restore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ go_test(
"//br/pkg/conn",
"//br/pkg/mock",
"//br/pkg/pdutil",
"//br/pkg/utiltest",
"//br/pkg/restore/split",
"//pkg/kv",
"//pkg/parser/model",
"//pkg/session",
Expand Down
18 changes: 9 additions & 9 deletions br/pkg/restore/import_mode_switcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/pingcap/tidb/br/pkg/conn"
"github.com/pingcap/tidb/br/pkg/pdutil"
"github.com/pingcap/tidb/br/pkg/restore"
"github.com/pingcap/tidb/br/pkg/utiltest"
"github.com/pingcap/tidb/br/pkg/restore/split"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -74,13 +74,13 @@ func TestRestorePreWork(t *testing.T) {
require.NoError(t, err)
}()

pdClient := utiltest.NewFakePDClient([]*metapb.Store{
pdClient := split.NewFakePDClient([]*metapb.Store{
{
Id: 1,
Address: fmt.Sprintf(":%d", 51111+port),
},
}, false, nil)
pdHTTPCli := utiltest.NewFakePDHTTPClient()
pdHTTPCli := split.NewFakePDHTTPClient()
mgr := &conn.Mgr{
PdController: pdutil.NewPdControllerWithPDClient(
pdClient, pdHTTPCli, &semver.Version{Major: 4, Minor: 0, Patch: 9}),
Expand All @@ -96,17 +96,17 @@ func TestRestorePreWork(t *testing.T) {
_, ok := pdutil.Schedulers[key]
require.True(t, ok)
}
require.Equal(t, len(utiltest.ExistPDCfgGeneratorBefore), len(cfg.ScheduleCfg))
require.Equal(t, len(split.ExistPDCfgGeneratorBefore), len(cfg.ScheduleCfg))
for key, value := range cfg.ScheduleCfg {
expectValue, ok := utiltest.ExistPDCfgGeneratorBefore[key]
expectValue, ok := split.ExistPDCfgGeneratorBefore[key]
require.True(t, ok)
require.Equal(t, expectValue, value)
}
cfgs, err := pdHTTPCli.GetConfig(context.TODO())
require.NoError(t, err)
require.Equal(t, len(utiltest.ExpectPDCfgGeneratorsResult), len(cfg.ScheduleCfg))
require.Equal(t, len(split.ExpectPDCfgGeneratorsResult), len(cfg.ScheduleCfg))
for key, value := range cfgs {
expectValue, ok := utiltest.ExpectPDCfgGeneratorsResult[key[len("schedule."):]]
expectValue, ok := split.ExpectPDCfgGeneratorsResult[key[len("schedule."):]]
require.True(t, ok)
require.Equal(t, expectValue, value)
}
Expand All @@ -123,9 +123,9 @@ func TestRestorePreWork(t *testing.T) {
{
cfgs, err := pdHTTPCli.GetConfig(context.TODO())
require.NoError(t, err)
require.Equal(t, len(utiltest.ExistPDCfgGeneratorBefore), len(cfg.ScheduleCfg))
require.Equal(t, len(split.ExistPDCfgGeneratorBefore), len(cfg.ScheduleCfg))
for key, value := range cfgs {
expectValue, ok := utiltest.ExistPDCfgGeneratorBefore[key[len("schedule."):]]
expectValue, ok := split.ExistPDCfgGeneratorBefore[key[len("schedule."):]]
require.True(t, ok)
require.Equal(t, expectValue, value)
}
Expand Down
54 changes: 0 additions & 54 deletions br/pkg/restore/internal/log_split/BUILD.bazel

This file was deleted.

29 changes: 0 additions & 29 deletions br/pkg/restore/internal/log_split/export_test.go

This file was deleted.

Loading

0 comments on commit ef6662e

Please sign in to comment.