Skip to content

Commit

Permalink
sink(ticdc): remove test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Jan 10, 2023
1 parent 9136575 commit fbd7ebf
Showing 1 changed file with 0 additions and 236 deletions.
236 changes: 0 additions & 236 deletions cdc/sinkv2/eventsink/txn/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1445,239 +1445,3 @@ func TestPrepareBatchDMLs(t *testing.T) {
require.Equal(t, tc.expected, dmls)
}
}

func TestGroupRowsByType(t *testing.T) {
ctx := context.Background()
ms := newMySQLBackendWithoutDB(ctx)
testCases := []struct {
name string
input []*model.RowChangedEvent
maxTxnRow int
}{
{
name: "delete",
input: []*model.RowChangedEvent{
{
StartTs: 418658114257813514,
CommitTs: 418658114257813515,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
PreColumns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 1,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 1,
}},
IndexColumns: [][]int{{1, 2}},
},
{
StartTs: 418658114257813514,
CommitTs: 418658114257813515,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
PreColumns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{1, 2}},
},
{
StartTs: 418658114257813514,
CommitTs: 418658114257813515,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
PreColumns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{1, 2}},
},
{
StartTs: 418658114257813514,
CommitTs: 418658114257813515,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
PreColumns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.UniqueKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{1, 2}},
},
},
maxTxnRow: 2,
},
{
name: "insert",
input: []*model.RowChangedEvent{
{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag | model.HandleKeyFlag,
Value: 1,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag | model.HandleKeyFlag,
Value: 1,
}},
IndexColumns: [][]int{{1, 1}},
},
{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{2, 2}},
},
{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{2, 2}},
},
{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{2, 2}},
},

{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{2, 2}},
},

{
StartTs: 418658114257813516,
CommitTs: 418658114257813517,
Table: &model.TableName{Schema: "common_1", Table: "uk_without_pk"},
Columns: []*model.Column{nil, {
Name: "a1",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}, {
Name: "a3",
Type: mysql.TypeLong,
Flag: model.BinaryFlag | model.MultipleKeyFlag |
model.HandleKeyFlag | model.HandleKeyFlag,
Value: 2,
}},
IndexColumns: [][]int{{2, 2}},
},
},
maxTxnRow: 4,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
event := &eventsink.TxnCallbackableEvent{
Event: &model.SingleTableTxn{Rows: testCases[0].input},
}
colums := tc.input[0].Columns
if len(colums) == 0 {
colums = tc.input[0].PreColumns
}
tableInfo := model.BuildTiDBTableInfo(colums, tc.input[0].IndexColumns)
ms.cfg.MaxTxnRow = tc.maxTxnRow
inserts, updates, deletes := ms.groupRowsByType(event, tableInfo, false)
for _, rows := range inserts {
require.LessOrEqual(t, len(rows), tc.maxTxnRow)
}
for _, rows := range updates {
require.LessOrEqual(t, len(rows), tc.maxTxnRow)
}
for _, rows := range deletes {
require.LessOrEqual(t, len(rows), tc.maxTxnRow)
}
})
}
}

0 comments on commit fbd7ebf

Please sign in to comment.