@@ -377,9 +377,9 @@ var _ = Describe("conns reaper", func() {
377377 Expect (connPool .Len ()).To (Equal (6 ))
378378 Expect (connPool .IdleLen ()).To (Equal (6 ))
379379
380- connPool .ReapStaleConns ()
381- Expect (connPool . Len ()). To ( Equal ( 3 ))
382- Expect (connPool . IdleLen () ).To (Equal (3 ))
380+ n , err := connPool .ReapStaleConns ()
381+ Expect (err ). NotTo ( HaveOccurred ( ))
382+ Expect (n ).To (Equal (3 ))
383383 })
384384
385385 AfterEach (func () {
@@ -396,9 +396,9 @@ var _ = Describe("conns reaper", func() {
396396 })
397397
398398 It ("does not reap fresh connections" , func () {
399- connPool .ReapStaleConns ()
400- Expect (connPool . Len ()). To ( Equal ( 3 ))
401- Expect (connPool . IdleLen ()) .To (Equal (3 ))
399+ n , err := connPool .ReapStaleConns ()
400+ Expect (err ). NotTo ( HaveOccurred ( ))
401+ Expect (n ) .To (Equal (0 ))
402402 })
403403
404404 It ("stale connections are closed" , func () {
@@ -670,8 +670,7 @@ var _ = Describe("dynamic update", func() {
670670
671671 time .Sleep (time .Millisecond * 5 ) // wait for 5ms for idle conn to be created
672672
673- // all get request should hit and new idle connections created
674- Expect (int (connPool .Stats ().Hits )).To (Equal (minIdleConns + 1 ))
673+ Expect (int (connPool .Stats ().Hits )).To (Equal (minIdleConns + 1 )) // all get request should hit and new idle connections created
675674 Expect (connPool .IdleLen ()).To (Equal (minIdleConns + 1 ))
676675 })
677676
@@ -694,10 +693,7 @@ var _ = Describe("dynamic update", func() {
694693
695694 getConnsExpectNoErr (connPool , minIdleConns ) // use all connections
696695
697- time .Sleep (time .Millisecond * 5 ) // wait for 5ms for idle conn to be created
698-
699- // all get request should hit and new idle connections created
700- Expect (int (connPool .Stats ().Hits )).To (Equal (minIdleConns ))
696+ Expect (int (connPool .Stats ().Hits )).To (Equal (minIdleConns )) // all get request should hit and new idle connections created
701697 Expect (connPool .IdleLen ()).To (Equal (minIdleConns - 1 ))
702698 })
703699
@@ -800,10 +796,6 @@ var _ = Describe("dynamic update", func() {
800796 assert := func (idleTimeout time.Duration ) {
801797 It ("check" , func () {
802798 connPool .SetIdleTimeout (idleTimeout )
803- getPutOneConn (connPool ) // create one conn
804-
805- time .Sleep (time .Millisecond * 50 )
806-
807799 cn := getPutOneConn (connPool ) // Idle stale check is impacted by conn last used time
808800 expiredAfter := cn .UsedAt ().Add (idleTimeout ).Sub (time .Now ())
809801
@@ -836,7 +828,7 @@ var _ = Describe("dynamic update", func() {
836828 MaxIdleConns : 2 ,
837829 IdleTimeout : idleTimeout ,
838830 })
839- defer connPool . Close ()
831+
840832 getPutOneConn (connPool ) // create one conn
841833 Expect (connPool .IdleLen ()).To (Equal (1 ))
842834
0 commit comments