Browse Source

add too many retries test case

Barak Michener 11 years ago
parent
commit
5fde52a403
1 changed files with 11 additions and 1 deletions
  1. 11 1
      discovery/discovery_test.go

+ 11 - 1
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