mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
integration: don't expect lease not found error for TestV3GetNonExistLease
This commit is contained in:
parent
bcfbb096e2
commit
0d08ffa282
@ -334,8 +334,7 @@ func TestV3PutOnNonExistLease(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestV3GetNonExistLease tests the case where the non exist lease is report as lease not found error using LeaseTimeToLive()
|
// TestV3GetNonExistLease ensures client retriving nonexistent lease on a follower doesn't result node panic
|
||||||
// A bug was found when a non leader etcd server returns nil instead of lease not found error which caues the server to crash.
|
|
||||||
// related issue https://github.com/coreos/etcd/issues/6537
|
// related issue https://github.com/coreos/etcd/issues/6537
|
||||||
func TestV3GetNonExistLease(t *testing.T) {
|
func TestV3GetNonExistLease(t *testing.T) {
|
||||||
defer testutil.AfterTest(t)
|
defer testutil.AfterTest(t)
|
||||||
@ -344,16 +343,28 @@ func TestV3GetNonExistLease(t *testing.T) {
|
|||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
lc := toGRPC(clus.RandClient()).Lease
|
||||||
|
lresp, err := lc.LeaseGrant(ctx, &pb.LeaseGrantRequest{TTL: 10})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to create lease %v", err)
|
||||||
|
}
|
||||||
|
_, err = lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
leaseTTLr := &pb.LeaseTimeToLiveRequest{
|
leaseTTLr := &pb.LeaseTimeToLiveRequest{
|
||||||
ID: 123,
|
ID: lresp.ID,
|
||||||
Keys: true,
|
Keys: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, client := range clus.clients {
|
for _, client := range clus.clients {
|
||||||
_, err := toGRPC(client).Lease.LeaseTimeToLive(ctx, leaseTTLr)
|
resp, err := toGRPC(client).Lease.LeaseTimeToLive(ctx, leaseTTLr)
|
||||||
if !eqErrGRPC(err, rpctypes.ErrGRPCLeaseNotFound) {
|
if err != nil {
|
||||||
t.Errorf("err = %v, want %v", err, rpctypes.ErrGRPCLeaseNotFound)
|
t.Fatalf("expected non nil error, but go %v", err)
|
||||||
|
}
|
||||||
|
if resp.TTL != -1 {
|
||||||
|
t.Fatalf("expected TTL to be -1, but got %v \n", resp.TTL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user