Skip to content

Commit

Permalink
ddl: make TestNotifyDDLJob stable (#23232)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Mar 11, 2021
1 parent 07b19e0 commit f21c7dd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ func (s *testDDLSuite) TestNotifyDDLJob(c *C) {
)
defer d.Stop()
getFirstNotificationAfterStartDDL(d)
// Ensure that the notification is not handled in workers `start` function.
d.cancel()
for _, worker := range d.workers {
worker.close()
}

job := &model.Job{
SchemaID: 1,
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit f21c7dd

Please sign in to comment.