Merge pull request #5976 from heyitsanthony/fix-kadc

integration: drain keepalives in TestLeaseKeepAliveCloseAfterDisconnectRevoke
This commit is contained in:
Anthony Romano 2016-07-18 20:21:44 -07:00 committed by GitHub
commit fcc96c9ebd

View File

@ -359,7 +359,8 @@ func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {
if kerr != nil { if kerr != nil {
t.Fatal(kerr) 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) t.Fatalf("ID = %x, want %x", kresp.ID, resp.ID)
} }
@ -374,13 +375,14 @@ func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {
clus.Members[0].Restart(t) clus.Members[0].Restart(t)
select { // some keep-alives may still be buffered; drain until close
case ka, ok := <-rc: timer := time.After(time.Duration(kresp.TTL) * time.Second)
if ok { for kresp != nil {
t.Fatalf("unexpected keepalive %v", ka) 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")
} }
} }