yarpctest

package
v1.32.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Actions

func Actions(actions ...api.Action) api.Action

Actions will wrap a list of actions in a sequential executor.

func Body

func Body(msg string) api.RequestOption

Body sets the body on a request to the raw representation of the msg field.

func ClientStreamActions added in v1.27.0

func ClientStreamActions(actions ...api.ClientStreamAction) api.ClientStreamRequestOption

ClientStreamActions combines a series of client stream actions into actions that will be applied when the StreamRequest is run.

func CloseStream added in v1.27.0

func CloseStream() api.ClientStreamAction

CloseStream is an action to close a client stream.

func ConcurrentAction added in v1.27.0

func ConcurrentAction(action Action, threads int) api.Action

ConcurrentAction will call the provided action in n concurrent threads at the same time.

func EchoHandler

func EchoHandler(mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

EchoHandler is a Unary Handler that will echo the body of the request into the response.

func EchoHandlerWithPrefix

func EchoHandlerWithPrefix(prefix string, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

EchoHandlerWithPrefix will echo the request it receives into the response, but, it will insert a prefix in front of the message.

func EchoStreamHandler added in v1.27.0

func EchoStreamHandler() api.ProcOption

EchoStreamHandler is a Bidirectional Stream Handler that will echo any request that is sent to it.

func ErrorHandler

func ErrorHandler(err error, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

ErrorHandler will always return an Error.

func GRPCRequest

func GRPCRequest(options ...api.RequestOption) api.Action

GRPCRequest creates a new grpc unary request.

func GRPCService

func GRPCService(options ...api.ServiceOption) api.Lifecycle

GRPCService will create a runnable GRPC service.

func GRPCStreamRequest added in v1.27.0

func GRPCStreamRequest(options ...api.ClientStreamRequestOption) api.Action

GRPCStreamRequest creates a new grpc stream request.

func GiveAndWantLargeBodyIsEchoed

func GiveAndWantLargeBodyIsEchoed(numOfBytes int) api.RequestOption

GiveAndWantLargeBodyIsEchoed creates an extremely large random byte buffer and validates that the body is echoed back to the response.

func GiveTimeout added in v1.27.0

func GiveTimeout(duration time.Duration) api.RequestOption

GiveTimeout will set the timeout for the request.

func HTTPRequest

func HTTPRequest(options ...api.RequestOption) api.Action

HTTPRequest creates a new YARPC http request.

func HTTPService

func HTTPService(options ...api.ServiceOption) api.Lifecycle

HTTPService will create a runnable HTTP service.

func Lifecycles

func Lifecycles(l ...api.Lifecycle) api.Lifecycle

Lifecycles is a wrapper around a list of Lifecycle definitions.

func Name

func Name(name string) *types.Name

Name is a shared option across services and procedures. It can be used as input in the constructor of both types.

func NewPortProvider

func NewPortProvider(t testing.TB) *types.PortProvider

NewPortProvider creates an object that can be used to synchronize ports in yarpctest infrastructure. Ports can be acquired through the "Port" function which will create new ports for the test based on the id passed into the function.

func OrderedRequestHandler

func OrderedRequestHandler(options ...api.HandlerOption) *types.OrderedHandler

OrderedRequestHandler will execute a series of Handlers in the order they are passed in. If the number of requests does not match, it will return an unknown error.

func OrderedStreamHandler added in v1.27.0

func OrderedStreamHandler(actions ...api.ServerStreamAction) api.ProcOption

OrderedStreamHandler is a bidirectional stream handler that can apply stream actions in a specified order.

func Port

func Port(port uint16) *types.Port

Port is a shared option across services and requests. It can be embedded in the constructor of both types.

func Proc

func Proc(options ...api.ProcOption) api.ServiceOption

Proc will create a new Procedure that can be included in a Service.

func Procedure

func Procedure(procedure string) *types.Procedure

Procedure specifies the "procedure" header for a request. It is a shared option across different requests.

func RecvStreamErr added in v1.27.0

func RecvStreamErr(wantErrMsgs ...string) *types.RecvStreamMsg

RecvStreamErr waits to receive a message on a client stream. It expects an error.

func RecvStreamMsg added in v1.27.0

func RecvStreamMsg(wantMsg string) *types.RecvStreamMsg

RecvStreamMsg waits to receive a message on a client stream.

func RepeatAction added in v1.27.0

func RepeatAction(action Action, times int) api.Action

RepeatAction will call the provided action a set number of times (the action must be idempotent).

func SendStreamDecodeErrorAndExpectError added in v1.27.0

func SendStreamDecodeErrorAndExpectError(decodeErr error, wantErrMsgs ...string) *types.SendStreamMsg

SendStreamDecodeErrorAndExpectError induces a decode error on the stream message and asserts on the result.

func SendStreamMsg added in v1.27.0

func SendStreamMsg(sendMsg string) *types.SendStreamMsg

SendStreamMsg sends a message to a stream.

func SendStreamMsgAndExpectError added in v1.27.0

func SendStreamMsgAndExpectError(sendMsg string, wantErrMsgs ...string) *types.SendStreamMsg

SendStreamMsgAndExpectError sends a message on a stream and asserts on the error returned.

func Service

func Service(service string) *types.Service

Service specifies the "service" header for a request. It is a shared option across different requests.

func ShardKey

func ShardKey(key string) *types.ShardKey

ShardKey specifies that "shard key" header for a request. It is a shared option across different requests.

func StaticHandler

func StaticHandler(msg string, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

StaticHandler will always return the same response.

func StreamHandlerError added in v1.27.0

func StreamHandlerError(err error) api.ServerStreamAction

StreamHandlerError is an action to return an error from a ServerStream handler.

func TChannelRequest

func TChannelRequest(options ...api.RequestOption) api.Action

TChannelRequest creates a new tchannel request.

func TChannelService

func TChannelService(options ...api.ServiceOption) api.Lifecycle

TChannelService will create a runnable TChannel service.

func UnaryOutboundMiddleware added in v1.32.0

func UnaryOutboundMiddleware(mw ...middleware.UnaryOutbound) api.RequestOption

UnaryOutboundMiddleware sets unary outbound middleware for a request.

Multiple invocations will append to existing middleware.

func WantError

func WantError(errMsg string) api.RequestOption

WantError creates an assertion on the request response to validate the error.

func WantHeader

func WantHeader(key, value string) *types.WantHeader

WantHeader will set up a header assertion for request/response headers.

func WantRespBody

func WantRespBody(body string) api.RequestOption

WantRespBody will assert that the response body matches at the end of the request.

func WantStreamError added in v1.27.0

func WantStreamError(wantErrMsgs ...string) api.ClientStreamRequestOption

WantStreamError asserts that the stream request had an error immediately.

func WithHeader

func WithHeader(key, value string) *types.GiveHeader

WithHeader will send headers for requests and responses.

Types

type Action

type Action api.Action

Action is the interface for applying actions (Requests) in tests.

type Lifecycle

type Lifecycle api.Lifecycle

Lifecycle is the interface for creating/starting/stopping lifecycles (Services) in tests.

Directories

Path Synopsis
Package api is for all interfaces and patterns that need to be implemented to interact with the yarpctest api, but not the explicit types we'll use to make requests, or the types that we'll use directly in tests.
Package api is for all interfaces and patterns that need to be implemented to interact with the yarpctest api, but not the explicit types we'll use to make requests, or the types that we'll use directly in tests.
Package types are for objects in the yarpctest API that implement multiple interfaces.
Package types are for objects in the yarpctest API that implement multiple interfaces.

Jump to

Keyboard shortcuts

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