testutils

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllTransportTypes are all TransportTypes,
	AllTransportTypes = []TransportType{
		TransportTypeHTTP,
		TransportTypeTChannel,
		TransportTypeGRPC,
	}
)

Functions

func AssertClientAndServerCounters added in v1.49.0

func AssertClientAndServerCounters(t *testing.T, counterAssertions []CounterAssertion, clientSnapshot, serverSnapshot *metrics.Root)

AssertClientAndServerCounters asserts expected counters on client and server snapshots

func AssertClientAndServerHistograms added in v1.49.0

func AssertClientAndServerHistograms(t *testing.T, histogramAssertions []HistogramAssertion,
	clientSnapshot, serverSnapshot *metrics.Root)

AssertClientAndServerHistograms asserts expected histograms on client and server snapshots

func AssertCounters added in v1.49.0

func AssertCounters(t *testing.T, counterAssertions []CounterAssertion, snapshot []metrics.Snapshot)

AssertCounters asserts expected counters with metrics snapshot

func AssertHistograms added in v1.49.0

func AssertHistograms(t *testing.T, histogramAssertions []HistogramAssertion, snapshot []metrics.HistogramSnapshot)

AssertHistograms asserts expected histograms with histogram snapshot

func NewClientDispatcher

func NewClientDispatcher(transportType TransportType, config *DispatcherConfig, logger *zap.Logger) (*yarpc.Dispatcher, error)

NewClientDispatcher returns a new client Dispatcher.

HTTP always will be configured as an outbound for Oneway. gRPC always will be configured as an outbound for Stream.

func NewServerDispatcher

func NewServerDispatcher(procedures []transport.Procedure, config *DispatcherConfig, logger *zap.Logger) (*yarpc.Dispatcher, error)

NewServerDispatcher returns a new server Dispatcher.

func WithClientInfo

func WithClientInfo(serviceName string, procedures []transport.Procedure, transportType TransportType, logger *zap.Logger, f func(*ClientInfo) error) (err error)

WithClientInfo wraps a function by setting up a client and server dispatcher and giving the function the client configuration to use in tests for the given TransportType.

The server dispatcher will be brought up using all TransportTypes and with the serviceName. The client dispatcher will be brought up using the given TransportType for Unary, HTTP for Oneway, and the serviceName with a "-client" suffix.

Types

type ClientInfo

type ClientInfo struct {
	ClientConfig   transport.ClientConfig
	GRPCClientConn *ggrpc.ClientConn
	ContextWrapper *grpcctx.ContextWrapper
}

ClientInfo holds the client info for testing.

type CounterAssertion added in v1.49.0

type CounterAssertion struct {
	Name  string
	Tags  map[string]string
	Value int
}

CounterAssertion holds expected counter metric

type DispatcherConfig

type DispatcherConfig struct {
	// contains filtered or unexported fields
}

DispatcherConfig is the configuration for a Dispatcher.

func NewDispatcherConfig

func NewDispatcherConfig(serviceName string) (*DispatcherConfig, error)

NewDispatcherConfig returns a new DispatcherConfig with assigned ports.

func (*DispatcherConfig) GetPort

func (d *DispatcherConfig) GetPort(transportType TransportType) (uint16, error)

GetPort gets the port for the TransportType.

func (*DispatcherConfig) GetServiceName

func (d *DispatcherConfig) GetServiceName() string

GetServiceName gets the service name.

type HistogramAssertion added in v1.49.0

type HistogramAssertion struct {
	Name  string
	Tags  map[string]string
	Value []int64

	// Values are not compared, rather length of values is asserted
	IgnoreValueCompare bool
	ValueLength        int
}

HistogramAssertion holds expected histogram metric

type TransportType

type TransportType int

TransportType is a transport type.

const (
	// TransportTypeHTTP represents using HTTP.
	TransportTypeHTTP TransportType = iota
	// TransportTypeTChannel represents using TChannel.
	TransportTypeTChannel
	// TransportTypeGRPC represents using GRPC.
	TransportTypeGRPC
)

func ParseTransportType

func ParseTransportType(s string) (TransportType, error)

ParseTransportType parses a transport type from a string.

func (TransportType) String

func (t TransportType) String() string

String returns a string representation of t.

Jump to

Keyboard shortcuts

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