Skip to content

Commit

Permalink
cherry pick pingcap#33384 to release-5.4
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
WangLe1321 committed Apr 28, 2022
1 parent 8f7f248 commit 52b4e72
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions br/pkg/restore/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ import (
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/meta/autoid"
"github.com/pingcap/tidb/parser/model"
<<<<<<< HEAD
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testleak"
=======
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/parser/types"
"github.com/pingcap/tidb/testkit"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
>>>>>>> 11db01105... br: Ignore ddl jobs with empty query or blacklist type when exec restore (#33384)
"github.com/tikv/client-go/v2/oracle"
)

Expand Down Expand Up @@ -260,10 +252,7 @@ func (s *testRestoreSchemaSuite) TestFilterDDLJobsV2(c *C) {
c.Assert(len(ddlJobs), Equals, 7)
}

func TestDB_ExecDDL(t *testing.T) {
s, clean := createRestoreSchemaSuite(t)
defer clean()

func (s *testRestoreSchemaSuite) TestDB_ExecDDL(c *C) {
ctx := context.Background()
ddlJobs := []*model.Job{
{
Expand All @@ -278,16 +267,16 @@ func TestDB_ExecDDL(t *testing.T) {
},
}

db, _, err := restore.NewDB(gluetidb.New(), s.mock.Storage, "STRICT")
require.NoError(t, err)
db, err := restore.NewDB(gluetidb.New(), s.mock.Storage)
c.Assert(err, IsNil)

for _, ddlJob := range ddlJobs {
err = db.ExecDDL(ctx, ddlJob)
assert.NoError(t, err)
c.Assert(err, IsNil)
}
}

func TestFilterDDLJobByRules(t *testing.T) {
func (s *testRestoreSchemaSuite) TestFilterDDLJobByRules(c *C) {
ddlJobs := []*model.Job{
{
Type: model.ActionSetTiFlashReplica,
Expand Down Expand Up @@ -328,8 +317,8 @@ func TestFilterDDLJobByRules(t *testing.T) {

ddlJobs = restore.FilterDDLJobByRules(ddlJobs, restore.DDLJobBlockListRule)

require.Equal(t, len(expectedDDLTypes), len(ddlJobs))
c.Assert(len(ddlJobs), Equals, len(expectedDDLTypes))
for i, ddlJob := range ddlJobs {
assert.Equal(t, expectedDDLTypes[i], ddlJob.Type)
c.Assert(ddlJob.Type, Equals, expectedDDLTypes[i])
}
}

0 comments on commit 52b4e72

Please sign in to comment.