ddl: make test stable (#3091)
This commit is contained in:
@ -60,25 +60,27 @@ func (s *testDDLSuite) TestReorg(c *C) {
|
||||
err = ctx.Txn().Commit()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
done := make(chan struct{})
|
||||
rowCount := int64(10)
|
||||
f := func() error {
|
||||
d.setReorgRowCount(rowCount)
|
||||
time.Sleep(4 * testLease)
|
||||
close(done)
|
||||
return nil
|
||||
}
|
||||
job := &model.Job{}
|
||||
err = d.runReorgJob(job, f)
|
||||
c.Assert(err, NotNil)
|
||||
|
||||
<-done
|
||||
// Make sure the function of f is returned.
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
err = d.runReorgJob(job, f)
|
||||
// The longest to wait for 5 seconds to make sure the function of f is returned.
|
||||
for i := 0; i < 1000; i++ {
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
err = d.runReorgJob(job, f)
|
||||
if err == nil {
|
||||
c.Assert(job.RowCount, Equals, rowCount)
|
||||
c.Assert(d.reorgRowCount, Equals, int64(0))
|
||||
break
|
||||
}
|
||||
}
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(job.RowCount, Equals, rowCount)
|
||||
c.Assert(d.reorgRowCount, Equals, int64(0))
|
||||
|
||||
d.Stop()
|
||||
err = d.runReorgJob(job, func() error {
|
||||
|
||||
Reference in New Issue
Block a user