From 255944bf519f42434dc831eee1f4fef2ee54503d Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Mon, 13 Jan 2020 11:20:14 -0800 Subject: [PATCH 1/2] clientv3/integration: expect "ErrCompacted" in "TestKVCompact" Making tests more strict Signed-off-by: Gyuho Lee --- clientv3/integration/kv_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/clientv3/integration/kv_test.go b/clientv3/integration/kv_test.go index 8ee28dd96..8e409b936 100644 --- a/clientv3/integration/kv_test.go +++ b/clientv3/integration/kv_test.go @@ -665,12 +665,23 @@ func TestKVCompact(t *testing.T) { wchan := wcli.Watch(ctx, "foo", clientv3.WithRev(3)) - if wr := <-wchan; wr.CompactRevision != 7 { + wr := <-wchan + if wr.CompactRevision != 7 { t.Fatalf("wchan CompactRevision got %v, want 7", wr.CompactRevision) } - if wr, ok := <-wchan; ok { + if !wr.Canceled { + t.Fatalf("expected canceled watcher on compacted revision, got %v", wr.Canceled) + } + if wr.Err() != rpctypes.ErrCompacted { + t.Fatalf("watch response error expected %v, got %v", rpctypes.ErrCompacted, wr.Err()) + } + wr, ok := <-wchan + if ok { t.Fatalf("wchan got %v, expected closed", wr) } + if wr.Err() != nil { + t.Fatalf("watch response error expected nil, got %v", wr.Err()) + } _, err = kv.Compact(ctx, 1000) if err == nil || err != rpctypes.ErrFutureRev { From 091b84f154d9c7ebbeffc47b96e356b0a2254a1e Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Fri, 17 Jan 2020 12:04:10 -0800 Subject: [PATCH 2/2] clientv3/integration: fix "TestLeaseKeepAliveNotFound" with "default" select, the failure case will never be selected Signed-off-by: Gyuho Lee --- clientv3/integration/lease_test.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/clientv3/integration/lease_test.go b/clientv3/integration/lease_test.go index 84f18d529..439e683f4 100644 --- a/clientv3/integration/lease_test.go +++ b/clientv3/integration/lease_test.go @@ -268,16 +268,10 @@ func TestLeaseKeepAliveNotFound(t *testing.T) { <-lchs[0].ch if _, ok := <-lchs[0].ch; !ok { - t.Fatalf("closed keepalive on wrong lease") + t.Fatal("closed keepalive on wrong lease") } - - timec := time.After(5 * time.Second) - for range lchs[1].ch { - select { - case <-timec: - t.Fatalf("revoke did not close keep alive") - default: - } + if _, ok := <-lchs[1].ch; ok { + t.Fatal("expected closed keepalive") } }