Browse Source

clientv3/integration: drain keepalives before waiting for leader loss

500ms keepalive delay on proxy side causes client to sometimes send
a second keepalive since it waits more than 500ms for the first response.

Fixes #7658
Anthony Romano 8 years ago
parent
commit
f6d0dda187
1 changed files with 6 additions and 0 deletions
  1. 6 0
      clientv3/integration/lease_test.go

+ 6 - 0
clientv3/integration/lease_test.go

@@ -729,6 +729,12 @@ func TestLeaseWithRequireLeader(t *testing.T) {
 	}
 
 	clus.Members[1].Stop(t)
+	// kaReqLeader may issue multiple requests while waiting for the first
+	// response from proxy server; drain any stray keepalive responses
+	time.Sleep(100 * time.Millisecond)
+	for len(kaReqLeader) > 0 {
+		<-kaReqLeader
+	}
 
 	select {
 	case resp, ok := <-kaReqLeader: