clientv3/integration: add timeout case.

This commit is contained in:
caoming 2019-02-18 09:38:49 +08:00
parent 784daa0498
commit 94b782e7c9

View File

@ -310,10 +310,19 @@ func TestDropReadUnderNetworkPartition(t *testing.T) {
t.Fatalf("expected %v, got %v", rpctypes.ErrLeaderChanged, err) t.Fatalf("expected %v, got %v", rpctypes.ErrLeaderChanged, err)
} }
ctx, cancel = context.WithTimeout(context.TODO(), 10*time.Second) for i := 0; i < 5; i++ {
_, err = kvc.Get(ctx, "a") ctx, cancel = context.WithTimeout(context.TODO(), 10*time.Second)
cancel() _, err = kvc.Get(ctx, "a")
if err != nil { cancel()
t.Fatalf("expected nil, got %v", err) 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
} }
} }