Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzix authored and ti-chi-bot committed Sep 1, 2021
1 parent 9b50faf commit f51ba5c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cdc/puller/sorter/memory_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package sorter
import (
"runtime"
"sync/atomic"
"time"

"github.com/pingcap/check"
"github.com/pingcap/ticdc/cdc/model"
Expand Down Expand Up @@ -54,12 +55,24 @@ func (s *memoryBackendSuite) TestNoLeaking(c *check.C) {
c.Assert(err, check.IsNil)
}

runtime.GC()
for i := 0; i < 10; i++ {
runtime.GC()
if atomic.LoadInt64(&objCount) <= 5000 {
break
}
time.Sleep(100 * time.Millisecond)
}
c.Assert(atomic.LoadInt64(&objCount), check.LessEqual, int64(5000))

err = rdr.resetAndClose()
c.Assert(err, check.IsNil)

runtime.GC()
for i := 0; i < 10; i++ {
runtime.GC()
if atomic.LoadInt64(&objCount) == 0 {
break
}
time.Sleep(100 * time.Millisecond)
}
c.Assert(atomic.LoadInt64(&objCount), check.Equals, int64(0))
}

0 comments on commit f51ba5c

Please sign in to comment.