testgateway

package
v1.3.3-hotfix-maintenance Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 32 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildProcessGateway

type ChildProcessGateway struct {
	HTTPClient       *http.Client
	JaegerAgent      *testutils.MockAgent
	TChannelClient   zanzibar.TChannelCaller
	M3Service        *testM3Server.FakeM3Service
	MetricsWaitGroup lib.WaitAtLeast
	RealHTTPAddr     string
	RealHTTPHost     string
	RealHTTPPort     int
	RealTChannelAddr string
	RealTChannelHost string
	RealTChannelPort int
	ContextExtractor zanzibar.ContextExtractor
	ContextMetrics   zanzibar.ContextMetrics
	ContextLogger    zanzibar.ContextLogger
	// contains filtered or unexported fields
}

ChildProcessGateway for testing

func (*ChildProcessGateway) AllLogs

func (gateway *ChildProcessGateway) AllLogs() map[string][]LogMessage

AllLogs ...

func (*ChildProcessGateway) Close

func (gateway *ChildProcessGateway) Close()

Close test gateway

func (*ChildProcessGateway) Config added in v0.4.3

func (gateway *ChildProcessGateway) Config() *zanzibar.StaticConfig

Config returns static config loaded from file + seed config

func (*ChildProcessGateway) HTTPBackends

func (gateway *ChildProcessGateway) HTTPBackends() map[string]*testBackend.TestHTTPBackend

HTTPBackends returns the HTTP backends

func (*ChildProcessGateway) HTTPPort

func (gateway *ChildProcessGateway) HTTPPort() int

HTTPPort ...

func (*ChildProcessGateway) Logs

func (gateway *ChildProcessGateway) Logs(
	level string,
	msg string,
) []LogMessage

Logs ...

func (*ChildProcessGateway) MakeRequest

func (gateway *ChildProcessGateway) MakeRequest(
	method string,
	url string,
	headers map[string]string,
	body io.Reader,
) (*http.Response, error)

MakeRequest helper

func (*ChildProcessGateway) MakeRequestWithHeaderValues added in v0.6.5

func (gateway *ChildProcessGateway) MakeRequestWithHeaderValues(
	method string,
	url string,
	headers zanzibar.Header,
	body io.Reader,
) (*http.Response, error)

MakeRequestWithHeaderValues helper

func (*ChildProcessGateway) MakeTChannelRequest

func (gateway *ChildProcessGateway) MakeTChannelRequest(
	ctx context.Context,
	thriftService string,
	method string,
	headers map[string]string,
	req, res zanzibar.RWTStruct,
) (bool, map[string]string, error)

MakeTChannelRequest helper

func (*ChildProcessGateway) TChannelBackends

func (gateway *ChildProcessGateway) TChannelBackends() map[string]*testBackend.TestTChannelBackend

TChannelBackends returns the TChannel backends

type LogMessage

type LogMessage map[string]interface{}

LogMessage is a json log record parsed into map.

type MalformedStdoutError

type MalformedStdoutError struct {
	Type       string
	StdoutLine string
	Message    string
}

MalformedStdoutError is used when the child process has unexpected stdout

func (*MalformedStdoutError) Error

func (err *MalformedStdoutError) Error() string

type Options

type Options struct {
	TestBinary            string
	ConfigFiles           []string
	LogWhitelist          map[string]bool
	KnownHTTPBackends     []string
	KnownTChannelBackends []string
	CountMetrics          bool
	// If MaxMetrics is set we only collect the first N metrics upto
	// the max metrics amount.
	MaxMetrics            int
	EnableRuntimeMetrics  bool
	JaegerDisable         bool
	JaegerFlushMillis     int64
	TChannelClientMethods map[string]string
	Backends              []*testBackend.TestTChannelBackend
}

Options used to create TestGateway

type TestGateway

type TestGateway interface {
	MakeRequest(
		method string,
		url string,
		headers map[string]string,
		body io.Reader,
	) (*http.Response, error)
	// MakeRequestWithHeaderValues is an alternate version of `MakeRequest` that uses `zanzibar.Header`
	// instead of a `map[string]string` to represent headers. This allows us to fetch multiple values
	// for a given header key.
	MakeRequestWithHeaderValues(
		method string,
		url string,
		headers zanzibar.Header,
		body io.Reader,
	) (*http.Response, error)
	MakeTChannelRequest(
		ctx context.Context,
		thriftService string,
		method string,
		headers map[string]string,
		req, resp zanzibar.RWTStruct,
	) (bool, map[string]string, error)
	HTTPBackends() map[string]*testBackend.TestHTTPBackend
	TChannelBackends() map[string]*testBackend.TestTChannelBackend
	HTTPPort() int
	Logs(level string, msg string) []LogMessage
	// AllLogs() returns a map of msg to a list of LogMessage
	AllLogs() map[string][]LogMessage

	Close()
	Config() *zanzibar.StaticConfig
}

TestGateway interface

func CreateGateway

func CreateGateway(
	t *testing.T,
	conf map[string]interface{},
	opts *Options,
) (TestGateway, error)

CreateGateway bootstrap gateway for testing

Jump to

Keyboard shortcuts

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