Skip to content

Commit

Permalink
clientv3/integration: test on lease close
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Feb 2, 2016
1 parent c1bea4e commit 5ebd7b0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func TestLeaseKeepAlive(t *testing.T) {
defer clus.Terminate(t)

lapi := clientv3.NewLease(clus.RandClient())
defer lapi.Close()

resp, err := lapi.Create(context.Background(), 10)
if err != nil {
Expand All @@ -114,10 +113,21 @@ func TestLeaseKeepAlive(t *testing.T) {
t.Errorf("failed to keepalive lease %v", kerr)
}

kresp := <-rc
kresp, ok := <-rc
if !ok {
t.Errorf("chan is closed, want not closed")
}

if kresp.ID != resp.ID {
t.Errorf("ID = %x, want %x", kresp.ID, resp.ID)
}

lapi.Close()

_, ok = <-rc
if ok {
t.Errorf("chan is not closed, want lease Close() closes chan")
}
}

// TODO: add a client that can connect to all the members of cluster via unix sock.
Expand All @@ -132,7 +142,6 @@ func TestLeaseKeepAliveHandleFailure(t *testing.T) {

// TODO: change this line to get a cluster client
lapi := clientv3.NewLease(clus.RandClient())
defer lapi.Close()

resp, err := lapi.Create(context.Background(), 10)
if err != nil {
Expand Down Expand Up @@ -165,4 +174,11 @@ func TestLeaseKeepAliveHandleFailure(t *testing.T) {
if kresp.ID != resp.ID {
t.Errorf("ID = %x, want %x", kresp.ID, resp.ID)
}

lapi.Close()

_, ok = <-rc
if ok {
t.Errorf("chan is not closed, want lease Close() closes chan")
}
}

0 comments on commit 5ebd7b0

Please sign in to comment.