Merge pull request #10378 from johncming/net-partition

clientv3/integration: add timeout case.
This commit is contained in:
Xiang Li 2019-02-19 18:36:44 +08:00 committed by GitHub
commit bf9444b32d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,10 +310,19 @@ func TestDropReadUnderNetworkPartition(t *testing.T) {
t.Fatalf("expected %v, got %v", rpctypes.ErrLeaderChanged, 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 {
t.Fatalf("expected nil, got %v", err)
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
}
}