From 12d3e4e47302a3b299d5359c27c7da698fa0e5d9 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 21 Feb 2017 13:09:43 -0800 Subject: [PATCH] integration: test keepalives for short TTLs --- clientv3/integration/lease_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/clientv3/integration/lease_test.go b/clientv3/integration/lease_test.go index dde8ddd4b..029765ee8 100644 --- a/clientv3/integration/lease_test.go +++ b/clientv3/integration/lease_test.go @@ -151,6 +151,30 @@ func TestLeaseKeepAlive(t *testing.T) { } } +func TestLeaseKeepAliveOneSecond(t *testing.T) { + defer testutil.AfterTest(t) + + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) + defer clus.Terminate(t) + + cli := clus.Client(0) + + resp, err := cli.Grant(context.Background(), 1) + if err != nil { + t.Errorf("failed to create lease %v", err) + } + rc, kerr := cli.KeepAlive(context.Background(), resp.ID) + if kerr != nil { + t.Errorf("failed to keepalive lease %v", kerr) + } + + for i := 0; i < 3; i++ { + if _, ok := <-rc; !ok { + t.Errorf("chan is closed, want not closed") + } + } +} + // TODO: add a client that can connect to all the members of cluster via unix sock. // TODO: test handle more complicated failures. func TestLeaseKeepAliveHandleFailure(t *testing.T) {