proxytest

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

test framework for proxy-wasm-go-sdk

With proxytest build tag, you can test your extension with the official command:

go test -tags=proxytest ./... 

This framework simulates the expected behavior of Envoyproxy, and you can test your extensions without running Envoy. For detail, see examples/*/main_test.go.

Note that we have not covered all the functionality, and the API is very likely to change in the future.

Documentation

Index

Constants

View Source
const (
	RootContextID uint32 = 1 // TODO: support multiple rootContext
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmulatorOption added in v0.0.5

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

func NewEmulatorOption added in v0.0.5

func NewEmulatorOption() *EmulatorOption

func (*EmulatorOption) WithNewRootContext added in v0.0.5

func (o *EmulatorOption) WithNewRootContext(f func(uint32) proxywasm.RootContext) *EmulatorOption

func (*EmulatorOption) WithPluginConfiguration added in v0.0.5

func (o *EmulatorOption) WithPluginConfiguration(data []byte) *EmulatorOption

func (*EmulatorOption) WithVMConfiguration added in v0.0.5

func (o *EmulatorOption) WithVMConfiguration(data []byte) *EmulatorOption

type HostEmulator added in v0.0.5

type HostEmulator interface {
	Done()

	// Root
	StartVM() types.OnVMStartStatus
	StartPlugin() types.OnPluginStartStatus
	FinishVM() bool
	GetCalloutAttributesFromContext(contextID uint32) []HttpCalloutAttribute
	CallOnHttpCallResponse(contextID uint32, headers types.Headers, trailers types.Trailers, body []byte)
	GetCounterMetric(name string) (uint64, error)
	GetGaugeMetric(name string) (uint64, error)
	GetHistogramMetric(name string) (uint64, error)
	GetLogs(level types.LogLevel) []string
	GetTickPeriod() uint32
	Tick()
	GetQueueSize(queueID uint32) int

	// network
	InitializeConnection() (contextID uint32, action types.Action)
	CallOnUpstreamData(contextID uint32, data []byte) types.Action
	CallOnDownstreamData(contextID uint32, data []byte) types.Action
	CloseUpstreamConnection(contextID uint32)
	CloseDownstreamConnection(contextID uint32)
	CompleteConnection(contextID uint32)

	// http
	InitializeHttpContext() (contextID uint32)
	CallOnResponseHeaders(contextID uint32, headers types.Headers, endOfStream bool) types.Action
	CallOnResponseBody(contextID uint32, body []byte, endOfStream bool) types.Action
	CallOnResponseTrailers(contextID uint32, trailers types.Trailers) types.Action
	CallOnRequestHeaders(contextID uint32, headers types.Headers, endOfStream bool) types.Action
	CallOnRequestTrailers(contextID uint32, trailers types.Trailers) types.Action
	CallOnRequestBody(contextID uint32, body []byte, endOfStream bool) types.Action
	CompleteHttpContext(contextID uint32)
	GetCurrentHttpStreamAction(contextID uint32) types.Action
	GetSentLocalResponse(contextID uint32) *LocalHttpResponse
	CallOnLogForAccessLogger(requestHeaders, responseHeaders types.Headers)
}

func NewHostEmulator added in v0.0.5

func NewHostEmulator(opt *EmulatorOption) HostEmulator

type HttpCalloutAttribute added in v0.0.5

type HttpCalloutAttribute struct {
	CalloutID uint32
	Upstream  string
	Headers   types.Headers
	Trailers  types.Trailers
	Body      []byte
}

type LocalHttpResponse

type LocalHttpResponse struct {
	StatusCode       uint32
	StatusCodeDetail string
	Data             []byte
	Headers          types.Headers
	GRPCStatus       int32
}

Jump to

Keyboard shortcuts

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