Skip to content

Commit

Permalink
try fix the test case
Browse files Browse the repository at this point in the history
Signed-off-by: hillium <yujuncen@pingcap.com>
  • Loading branch information
YuJuncen committed Aug 26, 2024
1 parent 6c998ef commit 095f623
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 7 additions & 1 deletion br/pkg/storage/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ func SaveJSONEffectsToTmp(es []Effect) (string, error) {
// Save the json to a subdir so user can redirect the output path by symlinking...
tmp, err := os.CreateTemp(path.Join(os.TempDir(), "tidb_br"), "br-effects-*.json")
if err != nil {
return "", err
return "", errors.Trace(err)
}
if err := JSONEffects(es, tmp); err != nil {
return "", err
}
if err := tmp.Sync(); err != nil {
return "", errors.Trace(err)
}
if err := tmp.Close(); err != nil {
return "", errors.Trace(err)
}
return tmp.Name(), nil
}

Expand Down
6 changes: 3 additions & 3 deletions br/pkg/stream/stream_metas.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func (m MigrationExt) MergeAndMigrateTo(
}
}
}
result.MigratedTo = m.MigrateTo(ctx, newBase, MTMaybeSkipTruncateLog(!config.alwaysRunTruncate && canSkipTruncate))
result.MigratedTo = m.migrateTo(ctx, newBase, MTMaybeSkipTruncateLog(!config.alwaysRunTruncate && canSkipTruncate))
return
}

Expand All @@ -773,10 +773,10 @@ func MTMaybeSkipTruncateLog(cond bool) MigrateToOpt {
return func(*migToOpt) {}
}

// MigrateTo migrates to a migration.
// migrateTo migrates to a migration.
// If encountered some error during executing some operation, the operation will be put
// to the new BASE, which can be retryed then.
func (m MigrationExt) MigrateTo(ctx context.Context, mig *pb.Migration, opts ...MigrateToOpt) MigratedTo {
func (m MigrationExt) migrateTo(ctx context.Context, mig *pb.Migration, opts ...MigrateToOpt) MigratedTo {
opt := migToOpt{}
for _, o := range opts {
o(&opt)
Expand Down
12 changes: 6 additions & 6 deletions br/pkg/stream/stream_metas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ func TestBasicMigration(t *testing.T) {
requireMigrationsEqual(t, resE, res)

ctx := context.Background()
mg := est.MigrateTo(ctx, res)
mg := est.migrateTo(ctx, res)

newBaseE := mig(mLogDel("00002.meta", spans("00001.log", 1024, sp(0, 42), sp(42, 18))))
require.Empty(t, mg.Warnings)
Expand All @@ -2586,7 +2586,7 @@ func TestBasicMigration(t *testing.T) {

delRem := mig(mLogDel("00002.meta", spans("00001.log", 1024, sp(60, 1024-60))))
newNewBase := MergeMigrations(mg.NewBase, delRem)
mg = est.MigrateTo(ctx, newNewBase)
mg = est.migrateTo(ctx, newNewBase)
require.Empty(t, mg.Warnings)
requireMigrationsEqual(t, mg.NewBase, mig())
}
Expand Down Expand Up @@ -2697,7 +2697,7 @@ func TestRemoveCompaction(t *testing.T) {
mTruncatedTo(30),
))

mg := est.MigrateTo(ctx, merged)
mg := est.migrateTo(ctx, merged)
requireMigrationsEqual(t, mg.NewBase, mig(
mCompaction(cDir(1), aDir(1), 10, 40),
mCompaction(cDir(2), aDir(2), 35, 50),
Expand Down Expand Up @@ -2758,7 +2758,7 @@ func TestRetryRemoveCompaction(t *testing.T) {

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/br/pkg/storage/local_delete_file_err", `1*return("this disk will never forget")`))
est := MigerationExtension(s)
mg := est.MigrateTo(ctx, mig1)
mg := est.migrateTo(ctx, mig1)
require.Len(t, mg.Warnings, 1)
require.Error(t, mg.Warnings[0], "this disk will never forget")
requireMigrationsEqual(t, mg.NewBase, mig(
Expand All @@ -2767,7 +2767,7 @@ func TestRetryRemoveCompaction(t *testing.T) {
mDstrPfx(cDir(1), aDir(1)),
))

mg = est.MigrateTo(ctx, mg.NewBase)
mg = est.migrateTo(ctx, mg.NewBase)
require.Empty(t, mg.Warnings)
requireMigrationsEqual(t, mg.NewBase, mig(
mCompaction(placeholder(cDir(2)), placeholder(aDir(2)), 28, 32),
Expand Down Expand Up @@ -2804,7 +2804,7 @@ func TestWithSimpleTruncate(t *testing.T) {
est := MigerationExtension(s)
m := mig(mTruncatedTo(65))
var res MigratedTo
effs := est.DryRun(func(me MigrationExt) { res = me.MigrateTo(ctx, m) })
effs := est.DryRun(func(me MigrationExt) { res = me.migrateTo(ctx, m) })

require.Empty(t, res.Warnings)
for _, eff := range effs {
Expand Down

0 comments on commit 095f623

Please sign in to comment.