/**
 * Verify that goroutines waiting on a depleted pool get served when a checked out object is
 * invalidated.
 *
 * JIRA: POOL-240
 */
Verify that goroutines waiting on a depleted pool get served when a checked out object is
invalidated.


/ ** * Verify that goroutines waiting on a depleted pool get served when a checked out object is * invalidated . * * JIRA : POOL - 240 * /
func (suit *PoolTestSuite) TestInvalidateFreesCapacity() {
	suit.pool.Config.MaxTotal = 2
	suit.pool.Config.MaxWaitMillis = 500
	suit.pool.Config.BlockWhenExhausted = true
	ch1 := waitTestGoroutine(suit.pool, 5000)
	obj := suit.NoErrorWithResult(suit.pool.BorrowObject())
	ch2 := waitTestGoroutine(suit.pool, 100)
	sleep(20)
	suit.NoError(suit.pool.InvalidateObject(obj))
	sleep(600) 
	result2 := <-ch2
	close(ch2)
	if result2.error != nil {
		suit.Fail(result2.error.Error())
	}
	<-ch1
	close(ch1)
}
func ( suit * PoolTestSuite ) TestInvalidateFreesCapacity ( ) { suit . pool . Config . MaxTotal = 2 suit . pool . Config . MaxWaitMillis = 500 suit . pool . Config . BlockWhenExhausted = true ch1 := waitTestGoroutine ( suit . pool , 5000 ) obj := suit . NoErrorWithResult ( suit . pool . BorrowObject ( ) ) ch2 := waitTestGoroutine ( suit . pool , 100 ) sleep ( 20 ) suit . NoError ( suit . pool . InvalidateObject ( obj ) ) sleep ( 600 ) result2 := <- ch2 close ( ch2 ) if result2 . error != nil { suit . Fail ( result2 . error . Error ( ) ) } <- ch1 close ( ch1 ) }
Verify that goroutines waiting on a depleted pool get served when a checked out object is
invalidated.
Verify that goroutines waiting on a depleted pool get served when a checked out object is invalidated .
// Borrow an instance and hold if for 5 seconds // Borrow another instance // Launch another goroutine - will block, but fail in 500 ms // Invalidate the object borrowed by suit goroutine - should allow goroutine2 to create // Wait for goroutine2 to timeout