mirror of https://github.com/grpc/grpc-go.git
tightened some rpcErr loose ends and revised some tests
This commit is contained in:
parent
5c27dd6a7a
commit
57c1951dc9
6
call.go
6
call.go
|
|
@ -137,15 +137,15 @@ func Invoke(ctx context.Context, method string, args, reply proto.Message, cc *C
|
|||
)
|
||||
// TODO(zhaoq): Need a formal spec of retry strategy for non-failfast rpcs.
|
||||
if lastErr != nil && c.failFast {
|
||||
return lastErr
|
||||
return toRPCErr(lastErr)
|
||||
}
|
||||
t, ts, err = cc.wait(ctx, ts)
|
||||
if err != nil {
|
||||
if lastErr != nil {
|
||||
// This was a retry; return the error from the last attempt.
|
||||
return lastErr
|
||||
return toRPCErr(lastErr)
|
||||
}
|
||||
return err
|
||||
return Errorf(codes.Internal, "%v", err)
|
||||
}
|
||||
stream, err = sendRPC(ctx, callHdr, t, args, topts)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -233,8 +233,24 @@ func TestReconnectTimeout(t *testing.T) {
|
|||
t.Fatalf("Failed to dial to the server %q: %v", addr, err)
|
||||
}
|
||||
lis.Close()
|
||||
// Sleep till reconnect times out.
|
||||
time.Sleep(2 * timeOut)
|
||||
tc := testpb.NewTestServiceClient(conn)
|
||||
waitC := make(chan struct{})
|
||||
go func() {
|
||||
defer close(waitC)
|
||||
argSize := 271828
|
||||
respSize := 314159
|
||||
req := &testpb.SimpleRequest{
|
||||
ResponseType: testpb.PayloadType_COMPRESSABLE.Enum(),
|
||||
ResponseSize: proto.Int32(int32(respSize)),
|
||||
Payload: newPayload(testpb.PayloadType_COMPRESSABLE, int32(argSize)),
|
||||
}
|
||||
_, err := tc.UnaryCall(context.Background(), req)
|
||||
if err != grpc.Errorf(codes.Internal, "%v", grpc.ErrClientConnClosing) {
|
||||
t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, %v", err, grpc.Errorf(codes.Internal, "%v", grpc.ErrClientConnClosing))
|
||||
}
|
||||
}()
|
||||
// Block untill reconnect times out.
|
||||
<-waitC
|
||||
if err := conn.Close(); err != grpc.ErrClientConnClosing {
|
||||
t.Fatalf("%v.Close() = %v, want %v", conn, err, grpc.ErrClientConnClosing)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue