Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asddongmen committed Dec 26, 2022
1 parent a7c087a commit a92c641
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions cdc/sinkv2/eventsink/txn/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1462,10 +1462,12 @@ func TestGroupRowsByType(t *testing.T) {
ctx := context.Background()
ms := newMySQLBackendWithoutDB(ctx)
testCases := []struct {
name string
input []*model.RowChangedEvent
maxTxnRow int
}{
{ // delete event
{
name: "delete",
input: []*model.RowChangedEvent{
{
StartTs: 418658114257813514,
Expand Down Expand Up @@ -1546,7 +1548,8 @@ func TestGroupRowsByType(t *testing.T) {
},
maxTxnRow: 2,
},
{ // insert event
{
name: "insert",
input: []*model.RowChangedEvent{
{
StartTs: 418658114257813516,
Expand Down Expand Up @@ -1667,24 +1670,26 @@ func TestGroupRowsByType(t *testing.T) {
},
}
for _, tc := range testCases {
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)
}
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 a92c641

Please sign in to comment.