clientv3: fix KeepAliveOnce return error message

This commit is contained in:
lolynx 2016-04-11 08:13:36 +08:00
parent 345bdc3db6
commit e3fd246414
2 changed files with 10 additions and 0 deletions

View File

@ -23,6 +23,8 @@ import (
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/pkg/testutil"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
)
func TestLeaseGrant(t *testing.T) {
@ -92,6 +94,11 @@ func TestLeaseKeepAliveOnce(t *testing.T) {
if err != nil {
t.Errorf("failed to keepalive lease %v", err)
}
_, err = lapi.KeepAliveOnce(context.Background(), clientv3.LeaseID(0))
if grpc.Code(err) != codes.NotFound {
t.Errorf("invalid error returned %v", err)
}
}
func TestLeaseKeepAlive(t *testing.T) {

View File

@ -181,6 +181,9 @@ func (l *lessor) KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAlive
if err == nil {
return resp, err
}
if isHalted(ctx, err) {
return resp, err
}
nerr := l.switchRemoteAndStream(err)
if nerr != nil {