Skip to content

Commit

Permalink
integration: drain keepalives in TestLeaseKeepAliveCloseAfterDisconne…
Browse files Browse the repository at this point in the history
…ctRevoke

Fixes etcd-io#5900
  • Loading branch information
Anthony Romano committed Jul 19, 2016
1 parent a61862a commit 27a3076
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {
if kerr != nil {
t.Fatal(kerr)
}
if kresp := <-rc; kresp.ID != resp.ID {
kresp := <-rc
if kresp.ID != resp.ID {
t.Fatalf("ID = %x, want %x", kresp.ID, resp.ID)
}

Expand All @@ -374,13 +375,14 @@ func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {

clus.Members[0].Restart(t)

select {
case ka, ok := <-rc:
if ok {
t.Fatalf("unexpected keepalive %v", ka)
// some keep-alives may still be buffered; drain until close
timer := time.After(time.Duration(kresp.TTL) * time.Second)
for kresp != nil {
select {
case kresp = <-rc:
case <-timer:
t.Fatalf("keepalive channel did not close")
}
case <-time.After(5 * time.Second):
t.Fatalf("keepalive channel did not close")
}
}

Expand Down

0 comments on commit 27a3076

Please sign in to comment.