From b7dc6cc6041cdbafc44a880e92d1f7bbbe8457d1 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 9 Sep 2016 08:22:41 +0900 Subject: [PATCH] e2e: test 'lease timetolive' --- e2e/ctl_v3_lease_test.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/e2e/ctl_v3_lease_test.go b/e2e/ctl_v3_lease_test.go index 20936ae08..d27060a64 100644 --- a/e2e/ctl_v3_lease_test.go +++ b/e2e/ctl_v3_lease_test.go @@ -21,8 +21,35 @@ import ( "testing" ) -func TestCtlV3LeaseKeepAlive(t *testing.T) { testCtl(t, leaseTestKeepAlive) } -func TestCtlV3LeaseRevoke(t *testing.T) { testCtl(t, leaseTestRevoke) } +func TestCtlV3LeaseGrantTimeToLive(t *testing.T) { testCtl(t, leaseTestGrantTimeToLive) } +func TestCtlV3LeaseKeepAlive(t *testing.T) { testCtl(t, leaseTestKeepAlive) } +func TestCtlV3LeaseRevoke(t *testing.T) { testCtl(t, leaseTestRevoke) } + +func leaseTestGrantTimeToLive(cx ctlCtx) { + id, err := ctlV3LeaseGrant(cx, 10) + if err != nil { + cx.t.Fatal(err) + } + + cmdArgs := append(cx.PrefixArgs(), "lease", "timetolive", id, "--keys") + proc, err := spawnCmd(cmdArgs) + if err != nil { + cx.t.Fatal(err) + } + line, err := proc.Expect(" granted with TTL(") + if err != nil { + cx.t.Fatal(err) + } + if err = proc.Close(); err != nil { + cx.t.Fatal(err) + } + if !strings.Contains(line, ", attached keys") { + cx.t.Fatalf("expected 'attached keys', got %q", line) + } + if !strings.Contains(line, id) { + cx.t.Fatalf("expected leaseID %q, got %q", id, line) + } +} func leaseTestKeepAlive(cx ctlCtx) { // put with TTL 10 seconds and keep-alive