From 5fde52a403a36b9c689b9b0e3dadc1ca17fa9c1a Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Wed, 8 Oct 2014 21:58:19 -0400 Subject: [PATCH] add too many retries test case --- discovery/discovery_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/discovery/discovery_test.go b/discovery/discovery_test.go index d50f20f81..0f43304fa 100644 --- a/discovery/discovery_test.go +++ b/discovery/discovery_test.go @@ -108,7 +108,7 @@ func TestCheckCluster(t *testing.T) { c := &clientWithResp{rs: rs} d := discovery{cluster: cluster, id: 1, c: c} - cRetry := &clientWithRetry{failTimes: 2} + cRetry := &clientWithRetry{failTimes: 3} cRetry.rs = rs dRetry := discovery{cluster: cluster, id: 1, c: cRetry, timeoutTimescale: time.Millisecond * 2} @@ -294,6 +294,16 @@ func TestSortableNodes(t *testing.T) { } } +func TestRetryFailure(t *testing.T) { + cluster := "1000" + c := &clientWithRetry{failTimes: 4} + d := discovery{cluster: cluster, id: 1, c: c, timeoutTimescale: time.Millisecond * 2} + _, _, err := d.checkCluster() + if err != ErrTooManyRetries { + t.Errorf("err = %v, want %v", err, ErrTooManyRetries) + } +} + type clientWithResp struct { rs []*client.Response w client.Watcher