Simplify test

This commit is contained in:
Vladimir Mihailenco 2018-02-27 16:09:55 +02:00
parent cac7aa8c36
commit e075ad33d3
1 changed files with 4 additions and 19 deletions

View File

@ -157,30 +157,15 @@ var _ = Describe("Client", func() {
}) })
It("should retry with backoff", func() { It("should retry with backoff", func() {
Expect(client.Close()).NotTo(HaveOccurred())
// use up all the available connections to force a fail
connectionHogClient := redis.NewClient(&redis.Options{
Addr: redisAddr,
MaxRetries: 1,
})
defer connectionHogClient.Close()
for i := 0; i <= 1002; i++ {
connectionHogClient.Pool().NewConn()
}
clientNoRetry := redis.NewClient(&redis.Options{ clientNoRetry := redis.NewClient(&redis.Options{
Addr: redisAddr, Addr: ":1234",
PoolSize: 1, MaxRetries: 0,
MaxRetryBackoff: -1,
}) })
defer clientNoRetry.Close() defer clientNoRetry.Close()
clientRetry := redis.NewClient(&redis.Options{ clientRetry := redis.NewClient(&redis.Options{
Addr: redisAddr, Addr: ":1234",
MaxRetries: 5, MaxRetries: 5,
PoolSize: 1,
MaxRetryBackoff: 128 * time.Millisecond, MaxRetryBackoff: 128 * time.Millisecond,
}) })
defer clientRetry.Close() defer clientRetry.Close()
@ -195,7 +180,7 @@ var _ = Describe("Client", func() {
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
elapseRetry := time.Since(startRetry) elapseRetry := time.Since(startRetry)
Expect(elapseRetry > elapseNoRetry).To(BeTrue()) Expect(elapseRetry).To(BeNumerically(">", elapseNoRetry, 10*time.Millisecond))
}) })
It("should update conn.UsedAt on read/write", func() { It("should update conn.UsedAt on read/write", func() {