grpchantesting

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package grpchantesting helps with testing implementations of alternate gRPC transports. Its main value is in a method that, given a channel, will ensure the channel behaves correctly under various conditions.

It tests successful RPCs, failures, timeouts and client-side cancellations. It also covers all kinds of RPCs: unary, client-streaming, server-streaming and bidirectional-streaming. It can optionally test full-duplex bidi streams if the underlying channel supports that.

The channel must be connected to a server that exposes the test server implementation contained in this package: &grpchantesting.TestServer{}

Package grpchantesting is a generated protocol buffer package.

It is generated from these files:

test.proto

It has these top-level messages:

Message

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlerTestService

func RegisterHandlerTestService(reg grpchan.ServiceRegistry, srv TestServiceServer)

func RegisterTestServiceServer

func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer)

func RunChannelTestCases

func RunChannelTestCases(t *testing.T, ch grpchan.Channel, supportsFullDuplex bool)

RunChannelTestCases runs numerous test cases to exercise the behavior of the given channel. The server side of the channel needs to have a *TestServer (in this package) registered to provide the implementation of fsgrpc.TestService (proto in this package). If the channel does not support full-duplex communication, it must provide at least half-duplex support for bidirectional streams.

The test cases will be defined as child tests by invoking t.Run on the given *testing.T.

Types

type Message

type Message struct {
	Payload      []byte                 `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
	Count        int32                  `protobuf:"varint,2,opt,name=count" json:"count,omitempty"`
	Code         int32                  `protobuf:"varint,3,opt,name=code" json:"code,omitempty"`
	DelayMillis  int32                  `protobuf:"varint,4,opt,name=delay_millis,json=delayMillis" json:"delay_millis,omitempty"`
	Headers      map[string]string      `` /* 134-byte string literal not displayed */
	Trailers     map[string]string      `` /* 136-byte string literal not displayed */
	ErrorDetails []*google_protobuf.Any `protobuf:"bytes,7,rep,name=error_details,json=errorDetails" json:"error_details,omitempty"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetCode

func (m *Message) GetCode() int32

func (*Message) GetCount

func (m *Message) GetCount() int32

func (*Message) GetDelayMillis

func (m *Message) GetDelayMillis() int32

func (*Message) GetErrorDetails

func (m *Message) GetErrorDetails() []*google_protobuf.Any

func (*Message) GetHeaders

func (m *Message) GetHeaders() map[string]string

func (*Message) GetPayload

func (m *Message) GetPayload() []byte

func (*Message) GetTrailers

func (m *Message) GetTrailers() map[string]string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type TestServer

type TestServer struct{}

TestServer has default responses to the various kinds of methods.

func (*TestServer) BidiStream

func (s *TestServer) BidiStream(str TestService_BidiStreamServer) error

BidiStream implements the TestService server interface.

func (*TestServer) ClientStream

func (s *TestServer) ClientStream(cs TestService_ClientStreamServer) error

ClientStream implements the TestService server interface.

func (*TestServer) ServerStream

func (s *TestServer) ServerStream(req *Message, ss TestService_ServerStreamServer) error

ServerStream implements the TestService server interface.

func (*TestServer) Unary

func (s *TestServer) Unary(ctx context.Context, req *Message) (*Message, error)

Unary implements the TestService server interface.

func (*TestServer) UseExternalMessageTwice

func (s *TestServer) UseExternalMessageTwice(ctx context.Context, in *empty.Empty) (*empty.Empty, error)

UseExternalMessageTwice implements the TestService server interface.

type TestServiceClient

type TestServiceClient interface {
	Unary(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
	ClientStream(ctx context.Context, opts ...grpc.CallOption) (TestService_ClientStreamClient, error)
	ServerStream(ctx context.Context, in *Message, opts ...grpc.CallOption) (TestService_ServerStreamClient, error)
	BidiStream(ctx context.Context, opts ...grpc.CallOption) (TestService_BidiStreamClient, error)
	// UseExternalMessageTwice is here purely to test the protoc-gen-grpchan plug-in
	UseExternalMessageTwice(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
}

func NewTestServiceChannelClient

func NewTestServiceChannelClient(ch grpchan.Channel) TestServiceClient

func NewTestServiceClient

func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient

type TestServiceServer

type TestServiceServer interface {
	Unary(context.Context, *Message) (*Message, error)
	ClientStream(TestService_ClientStreamServer) error
	ServerStream(*Message, TestService_ServerStreamServer) error
	BidiStream(TestService_BidiStreamServer) error
	// UseExternalMessageTwice is here purely to test the protoc-gen-grpchan plug-in
	UseExternalMessageTwice(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error)
}

type TestService_BidiStreamClient

type TestService_BidiStreamClient interface {
	Send(*Message) error
	Recv() (*Message, error)
	grpc.ClientStream
}

type TestService_BidiStreamServer

type TestService_BidiStreamServer interface {
	Send(*Message) error
	Recv() (*Message, error)
	grpc.ServerStream
}

type TestService_ClientStreamClient

type TestService_ClientStreamClient interface {
	Send(*Message) error
	CloseAndRecv() (*Message, error)
	grpc.ClientStream
}

type TestService_ClientStreamServer

type TestService_ClientStreamServer interface {
	SendAndClose(*Message) error
	Recv() (*Message, error)
	grpc.ServerStream
}

type TestService_ServerStreamClient

type TestService_ServerStreamClient interface {
	Recv() (*Message, error)
	grpc.ClientStream
}

type TestService_ServerStreamServer

type TestService_ServerStreamServer interface {
	Send(*Message) error
	grpc.ServerStream
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL