From ba7bb6e7237f50f69d4ae08425c2e3e50bdf085a Mon Sep 17 00:00:00 2001 From: lidezhu Date: Mon, 30 Dec 2024 15:09:13 +0800 Subject: [PATCH] add test case for create tables --- .../schemastore/persist_storage_test.go | 186 +++++++++++++++++- 1 file changed, 184 insertions(+), 2 deletions(-) diff --git a/logservice/schemastore/persist_storage_test.go b/logservice/schemastore/persist_storage_test.go index fa7c5c4b4..d624e7349 100644 --- a/logservice/schemastore/persist_storage_test.go +++ b/logservice/schemastore/persist_storage_test.go @@ -965,7 +965,82 @@ func TestApplyDDLJobs(t *testing.T) { []uint64{1010}, nil, nil, - nil, + []FetchTableTriggerDDLEventsTestCase{ + { + startTs: 1000, + limit: 10, + result: []commonEvent.DDLEvent{ + { + Type: byte(model.ActionCreateTables), + FinishedTs: 1010, + BlockedTables: &commonEvent.InfluencedTables{ + InfluenceType: commonEvent.InfluenceTypeNormal, + TableIDs: []int64{0}, + }, + NeedAddedTables: []commonEvent.Table{ + { + SchemaID: 100, + TableID: 301, + }, + { + SchemaID: 100, + TableID: 302, + }, + { + SchemaID: 100, + TableID: 303, + }, + }, + TableNameChange: &commonEvent.TableNameChange{ + AddName: []commonEvent.SchemaTableName{ + { + SchemaName: "test", + TableName: "t1", + }, + { + SchemaName: "test", + TableName: "t2", + }, + { + SchemaName: "test", + TableName: "t3", + }, + }, + }, + }, + }, + }, + // filter t2 and t3 + { + tableFilter: buildTableFilterByNameForTest("test", "t1"), + startTs: 1000, + limit: 10, + result: []commonEvent.DDLEvent{ + { + Type: byte(model.ActionCreateTables), + FinishedTs: 1010, + BlockedTables: &commonEvent.InfluencedTables{ + InfluenceType: commonEvent.InfluenceTypeNormal, + TableIDs: []int64{0}, + }, + NeedAddedTables: []commonEvent.Table{ + { + SchemaID: 100, + TableID: 301, + }, + }, + TableNameChange: &commonEvent.TableNameChange{ + AddName: []commonEvent.SchemaTableName{ + { + SchemaName: "test", + TableName: "t1", + }, + }, + }, + }, + }, + }, + }, }, // test create tables for partition table { @@ -1041,7 +1116,114 @@ func TestApplyDDLJobs(t *testing.T) { []uint64{1010}, nil, nil, - nil, + []FetchTableTriggerDDLEventsTestCase{ + { + startTs: 1000, + limit: 10, + result: []commonEvent.DDLEvent{ + { + Type: byte(model.ActionCreateTables), + FinishedTs: 1010, + BlockedTables: &commonEvent.InfluencedTables{ + InfluenceType: commonEvent.InfluenceTypeNormal, + TableIDs: []int64{0}, + }, + NeedAddedTables: []commonEvent.Table{ + { + SchemaID: 100, + TableID: 301, + }, + { + SchemaID: 100, + TableID: 302, + }, + { + SchemaID: 100, + TableID: 303, + }, + { + SchemaID: 100, + TableID: 401, + }, + { + SchemaID: 100, + TableID: 402, + }, + { + SchemaID: 100, + TableID: 403, + }, + { + SchemaID: 100, + TableID: 501, + }, + { + SchemaID: 100, + TableID: 502, + }, + { + SchemaID: 100, + TableID: 503, + }, + }, + TableNameChange: &commonEvent.TableNameChange{ + AddName: []commonEvent.SchemaTableName{ + { + SchemaName: "test", + TableName: "t1", + }, + { + SchemaName: "test", + TableName: "t2", + }, + { + SchemaName: "test", + TableName: "t3", + }, + }, + }, + }, + }, + }, + // filter t2 and t3 + { + tableFilter: buildTableFilterByNameForTest("test", "t1"), + startTs: 1000, + limit: 10, + result: []commonEvent.DDLEvent{ + { + Type: byte(model.ActionCreateTables), + FinishedTs: 1010, + BlockedTables: &commonEvent.InfluencedTables{ + InfluenceType: commonEvent.InfluenceTypeNormal, + TableIDs: []int64{0}, + }, + NeedAddedTables: []commonEvent.Table{ + { + SchemaID: 100, + TableID: 301, + }, + { + SchemaID: 100, + TableID: 302, + }, + { + SchemaID: 100, + TableID: 303, + }, + }, + TableNameChange: &commonEvent.TableNameChange{ + AddName: []commonEvent.SchemaTableName{ + { + SchemaName: "test", + TableName: "t1", + }, + }, + }, + }, + }, + }, + }, }, }