From 94b782e7c9b8740bd6b4f08a5fd3abc002fa79da Mon Sep 17 00:00:00 2001 From: caoming Date: Mon, 18 Feb 2019 09:38:49 +0800 Subject: [PATCH] clientv3/integration: add timeout case. --- .../integration/network_partition_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/clientv3/integration/network_partition_test.go b/clientv3/integration/network_partition_test.go index a67b631ac..b006f6fe9 100644 --- a/clientv3/integration/network_partition_test.go +++ b/clientv3/integration/network_partition_test.go @@ -310,10 +310,19 @@ func TestDropReadUnderNetworkPartition(t *testing.T) { t.Fatalf("expected %v, got %v", rpctypes.ErrLeaderChanged, err) } - ctx, cancel = context.WithTimeout(context.TODO(), 10*time.Second) - _, err = kvc.Get(ctx, "a") - cancel() - if err != nil { - t.Fatalf("expected nil, got %v", err) + for i := 0; i < 5; i++ { + ctx, cancel = context.WithTimeout(context.TODO(), 10*time.Second) + _, err = kvc.Get(ctx, "a") + cancel() + if err != nil { + if err == rpctypes.ErrTimeout { + <-time.After(time.Second) + i++ + continue + } + t.Fatalf("expected nil or timeout, got %v", err) + } + // No error returned and no retry required + break } }