From 4547b81fa950584c711ada2692213c63c7245300 Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 10 Mar 2021 15:35:45 +0800 Subject: [PATCH 1/2] ddl: make TestNotifyDDLJob stable --- ddl/ddl_worker_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ddl/ddl_worker_test.go b/ddl/ddl_worker_test.go index daf6f94cf92f5..60fd7dd0d74e3 100644 --- a/ddl/ddl_worker_test.go +++ b/ddl/ddl_worker_test.go @@ -102,6 +102,11 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) { ) defer d.Stop() getFirstNotificationAfterStartDDL(d) + // Ensure that the notification is not handled by worker's "start". + d.cancel() + for _, worker := range d.workers { + worker.close() + } job := &model.Job{ SchemaID: 1, @@ -127,6 +132,7 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) { default: c.Fatal("do not get the add index job notification") } + // Test the notification mechanism that the owner and the server receiving the DDL request are not on the same TiDB. // And the etcd client is nil. d1 := testNewDDLAndStart( @@ -135,8 +141,13 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) { WithStore(store), WithLease(testLease), ) - getFirstNotificationAfterStartDDL(d1) defer d1.Stop() + getFirstNotificationAfterStartDDL(d1) + // Ensure that the notification is not handled by worker's "start". + d1.cancel() + for _, worker := range d1.workers { + worker.close() + } d1.ownerManager.RetireOwner() d1.asyncNotifyWorker(job) job.Type = model.ActionCreateTable From 05b686ed1fa9fd3fdd3d83570d0f0b437035a6fd Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 11 Mar 2021 11:17:24 +0800 Subject: [PATCH 2/2] Update ddl/ddl_worker_test.go Co-authored-by: Arenatlx --- ddl/ddl_worker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddl/ddl_worker_test.go b/ddl/ddl_worker_test.go index 60fd7dd0d74e3..6e745820b04b9 100644 --- a/ddl/ddl_worker_test.go +++ b/ddl/ddl_worker_test.go @@ -102,7 +102,7 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) { ) defer d.Stop() getFirstNotificationAfterStartDDL(d) - // Ensure that the notification is not handled by worker's "start". + // Ensure that the notification is not handled in workers `start` function. d.cancel() for _, worker := range d.workers { worker.close()