Skip to content

Commit

Permalink
tests: fix unstable test in ddl puller test (#2566) (#2591)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Aug 20, 2021
1 parent b221a81 commit e90a108
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cdc/owner/ddl_puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (s *ddlPullerSuite) TestPuller(c *check.C) {
resolvedTs, ddl = p.FrontDDL()
c.Assert(resolvedTs, check.Equals, uint64(15))
c.Assert(ddl, check.IsNil)

mockPuller.appendResolvedTs(20)
waitResolvedTsGrowing(c, p, 16)
resolvedTs, ddl = p.FrontDDL()
Expand All @@ -161,6 +162,9 @@ func (s *ddlPullerSuite) TestPuller(c *check.C) {
resolvedTs, ddl = p.PopFrontDDL()
c.Assert(resolvedTs, check.Equals, uint64(16))
c.Assert(ddl.ID, check.Equals, int64(1))

// DDL could be processed with a delay, wait here for a pending DDL job is added
waitResolvedTsGrowing(c, p, 18)
resolvedTs, ddl = p.PopFrontDDL()
c.Assert(resolvedTs, check.Equals, uint64(18))
c.Assert(ddl.ID, check.Equals, int64(2))
Expand Down Expand Up @@ -217,6 +221,8 @@ func (s *ddlPullerSuite) TestPuller(c *check.C) {
c.Assert(ddl, check.IsNil)
}

// waitResolvedTsGrowing can wait the first DDL reaches targetTs or if no pending
// DDL, DDL resolved ts reaches targetTs.
func waitResolvedTsGrowing(c *check.C, p DDLPuller, targetTs model.Ts) {
err := retry.Do(context.Background(), func() error {
resolvedTs, _ := p.FrontDDL()
Expand Down

0 comments on commit e90a108

Please sign in to comment.