Merge pull request #747 from markdroth/status_interop_test

Add status_code_and_message interop test.
This commit is contained in:
Qi Zhao
2016-10-07 14:21:28 -07:00
committed by GitHub
4 changed files with 160 additions and 49 deletions

View File

@ -70,7 +70,8 @@ var (
per_rpc_creds: large_unary with per rpc token;
oauth2_auth_token: large_unary with oauth2 token auth;
cancel_after_begin: cancellation after metadata has been sent but before payloads are sent;
cancel_after_first_response: cancellation after receiving 1st message from the server.`)
cancel_after_first_response: cancellation after receiving 1st message from the server;
status_code_and_message: status code propagated back to client.`)
// The test CA root cert file
testCAFile = "testdata/ca.pem"
@ -180,6 +181,9 @@ func main() {
case "cancel_after_first_response":
interop.DoCancelAfterFirstResponse(tc)
grpclog.Println("CancelAfterFirstResponse done")
case "status_code_and_message":
interop.DoStatusCodeAndMessage(tc)
grpclog.Println("StatusCodeAndMessage done")
default:
grpclog.Fatal("Unsupported test case: ", *testCase)
}

View File

@ -11,6 +11,7 @@ It is generated from these files:
It has these top-level messages:
Empty
Payload
EchoStatus
SimpleRequest
SimpleResponse
StreamingInputCallRequest
@ -119,6 +120,33 @@ func (m *Payload) GetBody() []byte {
return nil
}
// A protobuf representation for grpc status. This is used by test
// clients to specify a status that the server should attempt to return.
type EchoStatus struct {
Code *int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"`
Message *string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *EchoStatus) Reset() { *m = EchoStatus{} }
func (m *EchoStatus) String() string { return proto.CompactTextString(m) }
func (*EchoStatus) ProtoMessage() {}
func (*EchoStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *EchoStatus) GetCode() int32 {
if m != nil && m.Code != nil {
return *m.Code
}
return 0
}
func (m *EchoStatus) GetMessage() string {
if m != nil && m.Message != nil {
return *m.Message
}
return ""
}
// Unary request.
type SimpleRequest struct {
// Desired payload type in the response from the server.
@ -132,14 +160,16 @@ type SimpleRequest struct {
// Whether SimpleResponse should include username.
FillUsername *bool `protobuf:"varint,4,opt,name=fill_username,json=fillUsername" json:"fill_username,omitempty"`
// Whether SimpleResponse should include OAuth scope.
FillOauthScope *bool `protobuf:"varint,5,opt,name=fill_oauth_scope,json=fillOauthScope" json:"fill_oauth_scope,omitempty"`
XXX_unrecognized []byte `json:"-"`
FillOauthScope *bool `protobuf:"varint,5,opt,name=fill_oauth_scope,json=fillOauthScope" json:"fill_oauth_scope,omitempty"`
// Whether server should return a given status
ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus" json:"response_status,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SimpleRequest) Reset() { *m = SimpleRequest{} }
func (m *SimpleRequest) String() string { return proto.CompactTextString(m) }
func (*SimpleRequest) ProtoMessage() {}
func (*SimpleRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (*SimpleRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *SimpleRequest) GetResponseType() PayloadType {
if m != nil && m.ResponseType != nil {
@ -176,6 +206,13 @@ func (m *SimpleRequest) GetFillOauthScope() bool {
return false
}
func (m *SimpleRequest) GetResponseStatus() *EchoStatus {
if m != nil {
return m.ResponseStatus
}
return nil
}
// Unary response, as configured by the request.
type SimpleResponse struct {
// Payload to increase message size.
@ -191,7 +228,7 @@ type SimpleResponse struct {
func (m *SimpleResponse) Reset() { *m = SimpleResponse{} }
func (m *SimpleResponse) String() string { return proto.CompactTextString(m) }
func (*SimpleResponse) ProtoMessage() {}
func (*SimpleResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (*SimpleResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *SimpleResponse) GetPayload() *Payload {
if m != nil {
@ -224,7 +261,7 @@ type StreamingInputCallRequest struct {
func (m *StreamingInputCallRequest) Reset() { *m = StreamingInputCallRequest{} }
func (m *StreamingInputCallRequest) String() string { return proto.CompactTextString(m) }
func (*StreamingInputCallRequest) ProtoMessage() {}
func (*StreamingInputCallRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (*StreamingInputCallRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *StreamingInputCallRequest) GetPayload() *Payload {
if m != nil {
@ -243,7 +280,7 @@ type StreamingInputCallResponse struct {
func (m *StreamingInputCallResponse) Reset() { *m = StreamingInputCallResponse{} }
func (m *StreamingInputCallResponse) String() string { return proto.CompactTextString(m) }
func (*StreamingInputCallResponse) ProtoMessage() {}
func (*StreamingInputCallResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (*StreamingInputCallResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *StreamingInputCallResponse) GetAggregatedPayloadSize() int32 {
if m != nil && m.AggregatedPayloadSize != nil {
@ -266,7 +303,7 @@ type ResponseParameters struct {
func (m *ResponseParameters) Reset() { *m = ResponseParameters{} }
func (m *ResponseParameters) String() string { return proto.CompactTextString(m) }
func (*ResponseParameters) ProtoMessage() {}
func (*ResponseParameters) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (*ResponseParameters) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *ResponseParameters) GetSize() int32 {
if m != nil && m.Size != nil {
@ -292,14 +329,16 @@ type StreamingOutputCallRequest struct {
// Configuration for each expected response message.
ResponseParameters []*ResponseParameters `protobuf:"bytes,2,rep,name=response_parameters,json=responseParameters" json:"response_parameters,omitempty"`
// Optional input payload sent along with the request.
Payload *Payload `protobuf:"bytes,3,opt,name=payload" json:"payload,omitempty"`
XXX_unrecognized []byte `json:"-"`
Payload *Payload `protobuf:"bytes,3,opt,name=payload" json:"payload,omitempty"`
// Whether server should return a given status
ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus" json:"response_status,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *StreamingOutputCallRequest) Reset() { *m = StreamingOutputCallRequest{} }
func (m *StreamingOutputCallRequest) String() string { return proto.CompactTextString(m) }
func (*StreamingOutputCallRequest) ProtoMessage() {}
func (*StreamingOutputCallRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (*StreamingOutputCallRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *StreamingOutputCallRequest) GetResponseType() PayloadType {
if m != nil && m.ResponseType != nil {
@ -322,6 +361,13 @@ func (m *StreamingOutputCallRequest) GetPayload() *Payload {
return nil
}
func (m *StreamingOutputCallRequest) GetResponseStatus() *EchoStatus {
if m != nil {
return m.ResponseStatus
}
return nil
}
// Server-streaming response, as configured by the request and parameters.
type StreamingOutputCallResponse struct {
// Payload to increase response size.
@ -332,7 +378,7 @@ type StreamingOutputCallResponse struct {
func (m *StreamingOutputCallResponse) Reset() { *m = StreamingOutputCallResponse{} }
func (m *StreamingOutputCallResponse) String() string { return proto.CompactTextString(m) }
func (*StreamingOutputCallResponse) ProtoMessage() {}
func (*StreamingOutputCallResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (*StreamingOutputCallResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *StreamingOutputCallResponse) GetPayload() *Payload {
if m != nil {
@ -344,6 +390,7 @@ func (m *StreamingOutputCallResponse) GetPayload() *Payload {
func init() {
proto.RegisterType((*Empty)(nil), "grpc.testing.Empty")
proto.RegisterType((*Payload)(nil), "grpc.testing.Payload")
proto.RegisterType((*EchoStatus)(nil), "grpc.testing.EchoStatus")
proto.RegisterType((*SimpleRequest)(nil), "grpc.testing.SimpleRequest")
proto.RegisterType((*SimpleResponse)(nil), "grpc.testing.SimpleResponse")
proto.RegisterType((*StreamingInputCallRequest)(nil), "grpc.testing.StreamingInputCallRequest")
@ -748,41 +795,45 @@ var _TestService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("test.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 567 bytes of a gzipped FileDescriptorProto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f5, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x4c,
0x41, 0xfe, 0xb6, 0x89, 0x06, 0x00, 0x00,
// 625 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x54, 0x4d, 0x6f, 0xd3, 0x4c,
0x10, 0x7e, 0x9d, 0x8f, 0x37, 0xcd, 0x24, 0x35, 0xd1, 0x46, 0x15, 0xae, 0x8b, 0x44, 0x65, 0x0e,
0x18, 0x24, 0x02, 0x8a, 0x04, 0x07, 0x0e, 0xa0, 0xd0, 0xa6, 0xa2, 0x52, 0x9b, 0x04, 0x3b, 0x39,
0x47, 0x4b, 0xb2, 0x75, 0x2d, 0x39, 0xb6, 0xb1, 0xd7, 0x88, 0x70, 0xe0, 0xcf, 0xf0, 0x23, 0x38,
0xf0, 0xe7, 0xd8, 0x5d, 0x7f, 0xc4, 0x49, 0x5c, 0x91, 0xf2, 0x75, 0xdb, 0x7d, 0xf6, 0x99, 0x67,
0xe6, 0x99, 0x19, 0x1b, 0x80, 0x92, 0x90, 0x76, 0xfc, 0xc0, 0xa3, 0x1e, 0x6a, 0x5a, 0x81, 0x3f,
0xeb, 0x70, 0xc0, 0x76, 0x2d, 0xad, 0x06, 0xd5, 0xfe, 0xc2, 0xa7, 0x4b, 0xed, 0x02, 0x6a, 0x23,
0xbc, 0x74, 0x3c, 0x3c, 0x47, 0x4f, 0xa0, 0x42, 0x97, 0x3e, 0x51, 0xa4, 0x63, 0x49, 0x97, 0xbb,
0x87, 0x9d, 0x7c, 0x40, 0x27, 0x21, 0x8d, 0x19, 0xc1, 0x10, 0x34, 0x84, 0xa0, 0xf2, 0xde, 0x9b,
0x2f, 0x95, 0x12, 0xa3, 0x37, 0x0d, 0x71, 0xd6, 0x5e, 0x02, 0xf4, 0x67, 0xd7, 0x9e, 0x49, 0x31,
0x8d, 0x42, 0xce, 0x98, 0x79, 0xf3, 0x58, 0xb0, 0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, 0xe2, 0xb0, 0xa3, 0x75, 0xc6, 0xda, 0xef,
0x4b, 0xbd, 0x57, 0xfc, 0x98, 0x34, 0xc0, 0x81, 0x76, 0x41, 0x7f, 0x90, 0xbe, 0x11, 0x74, 0xe3,
0x9e, 0xa9, 0x8f, 0x76, 0x60, 0xc6, 0xb9, 0x9e, 0x49, 0xc8, 0x06, 0xb4, 0xfd, 0x51, 0xa1, 0x87,
0x37, 0x48, 0x6c, 0x7e, 0xc4, 0xaa, 0xfe, 0x73, 0x62, 0x9c, 0x4a, 0xe7, 0xa9, 0xe4, 0xb3, 0xc8,
0x71, 0x4e, 0x23, 0xe6, 0xf6, 0xd3, 0x5f, 0xf3, 0xa4, 0x4b, 0xc2, 0x95, 0xfc, 0x16, 0x3b, 0x57,
0xff, 0x20, 0xd5, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x7f, 0x47, 0xd6, 0x4b, 0x07, 0x00,
0x00,
}

View File

@ -26,6 +26,13 @@ message Payload {
optional bytes body = 2;
}
// A protobuf representation for grpc status. This is used by test
// clients to specify a status that the server should attempt to return.
message EchoStatus {
optional int32 code = 1;
optional string message = 2;
}
// Unary request.
message SimpleRequest {
// Desired payload type in the response from the server.
@ -44,6 +51,9 @@ message SimpleRequest {
// Whether SimpleResponse should include OAuth scope.
optional bool fill_oauth_scope = 5;
// Whether server should return a given status
optional EchoStatus response_status = 7;
}
// Unary response, as configured by the request.
@ -97,6 +107,9 @@ message StreamingOutputCallRequest {
// Optional input payload sent along with the request.
optional Payload payload = 3;
// Whether server should return a given status
optional EchoStatus response_status = 7;
}
// Server-streaming response, as configured by the request and parameters.

View File

@ -454,6 +454,41 @@ func DoCancelAfterFirstResponse(tc testpb.TestServiceClient) {
}
}
// DoStatusCodeAndMessage checks that the status code is propagated back to the client.
func DoStatusCodeAndMessage(tc testpb.TestServiceClient) {
var code int32 = 2
msg := "test status message"
expectedErr := grpc.Errorf(codes.Code(code), msg)
respStatus := &testpb.EchoStatus{
Code: proto.Int32(code),
Message: proto.String(msg),
}
// Test UnaryCall.
req := &testpb.SimpleRequest{
ResponseStatus: respStatus,
}
if _, err := tc.UnaryCall(context.Background(), req); err == nil || err.Error() != expectedErr.Error() {
grpclog.Fatalf("%v.UnaryCall(_, %v) = _, %v, want _, %v", tc, req, err, expectedErr)
}
// Test FullDuplexCall.
stream, err := tc.FullDuplexCall(context.Background())
if err != nil {
grpclog.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
}
streamReq := &testpb.StreamingOutputCallRequest{
ResponseStatus: respStatus,
}
if err := stream.Send(streamReq); err != nil {
grpclog.Fatalf("%v.Send(%v) = %v, want <nil>", stream, streamReq, err)
}
if err := stream.CloseSend(); err != nil {
grpclog.Fatalf("%v.CloseSend() = %v, want <nil>", stream, err)
}
if _, err = stream.Recv(); err.Error() != expectedErr.Error() {
grpclog.Fatalf("%v.Recv() returned error %v, want %v", stream, err, expectedErr)
}
}
type testServer struct {
}
@ -485,6 +520,10 @@ func serverNewPayload(t testpb.PayloadType, size int32) (*testpb.Payload, error)
}
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
status := in.GetResponseStatus()
if status != nil && *status.Code != 0 {
return nil, grpc.Errorf(codes.Code(*status.Code), *status.Message)
}
pl, err := serverNewPayload(in.GetResponseType(), in.GetResponseSize())
if err != nil {
return nil, err
@ -540,6 +579,10 @@ func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServ
if err != nil {
return err
}
status := in.GetResponseStatus()
if status != nil && *status.Code != 0 {
return grpc.Errorf(codes.Code(*status.Code), *status.Message)
}
cs := in.GetResponseParameters()
for _, c := range cs {
if us := c.GetIntervalUs(); us > 0 {