Merge pull request #132 from iamqizhao/err-fix
fix a malformed error status
This commit is contained in:
Коммит
fd70cd320a
2
call.go
2
call.go
|
@ -147,7 +147,7 @@ func Invoke(ctx context.Context, method string, args, reply proto.Message, cc *C
|
||||||
// This was a retry; return the error from the last attempt.
|
// This was a retry; return the error from the last attempt.
|
||||||
return toRPCErr(lastErr)
|
return toRPCErr(lastErr)
|
||||||
}
|
}
|
||||||
return Errorf(codes.Internal, "%v", err)
|
return toRPCErr(err)
|
||||||
}
|
}
|
||||||
stream, err = sendRPC(ctx, callHdr, t, args, topts)
|
stream, err = sendRPC(ctx, callHdr, t, args, topts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -301,6 +301,18 @@ func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, tc testpb.TestService
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTimeoutOnDeadServer(t *testing.T) {
|
||||||
|
s, tc := setUp(false, math.MaxUint32)
|
||||||
|
s.Stop()
|
||||||
|
// Set -1 as the timeout to make sure if transportMonitor gets error
|
||||||
|
// notification in time the failure path of the 1st invoke of
|
||||||
|
// ClientConn.wait hits the deadline exceeded error.
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), -1)
|
||||||
|
if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); grpc.Code(err) != codes.DeadlineExceeded {
|
||||||
|
t.Fatalf("TestService/EmptyCall(%v, _) = _, error %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestEmptyUnary(t *testing.T) {
|
func TestEmptyUnary(t *testing.T) {
|
||||||
s, tc := setUp(true, math.MaxUint32)
|
s, tc := setUp(true, math.MaxUint32)
|
||||||
defer s.Stop()
|
defer s.Stop()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче