framework

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPEchoServerPort    = "TCPEchoServerPort"
	UDPEchoServerPort    = "UDPEchoServerPort"
	UDSEchoServerAddr    = "UDSEchoServerAddr"
	HTTPSimpleServerPort = "HTTPSimpleServerPort"
)

Variables

View Source
var RunID string

RunID is a unique identifier of the e2e run. Beware that this ID is not the same for all tests in the e2e run, because each Ginkgo node creates it separately.

Functions

func ExpectConsistOf

func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})

ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.

func ExpectContainElements

func ExpectContainElements(actual interface{}, extra interface{}, explain ...interface{})

func ExpectEmpty

func ExpectEmpty(actual interface{}, explain ...interface{})

ExpectEmpty expects actual is empty

func ExpectEqual

func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectEqual expects the specified two are the same, otherwise an exception raises

func ExpectEqualValues

func ExpectEqualValues(actual interface{}, extra interface{}, explain ...interface{})

ExpectEqualValues expects the specified two are the same, it not strict about type

func ExpectEqualValuesWithOffset

func ExpectEqualValuesWithOffset(offset int, actual interface{}, extra interface{}, explain ...interface{})

func ExpectError

func ExpectError(err error, explain ...interface{})

ExpectError expects an error happens, otherwise an exception raises

func ExpectErrorWithOffset

func ExpectErrorWithOffset(offset int, err error, explain ...interface{})

func ExpectHaveKey

func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})

ExpectHaveKey expects the actual map has the key in the keyset

func ExpectNoError

func ExpectNoError(err error, explain ...interface{})

ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.

func ExpectNoErrorWithOffset

func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})

ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").

func ExpectNotContainElements

func ExpectNotContainElements(actual interface{}, extra interface{}, explain ...interface{})

func ExpectNotEqual

func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectNotEqual expects the specified two are not the same, otherwise an exception raises

func ExpectTrue

func ExpectTrue(actual interface{}, explain ...interface{})

func ExpectTrueWithOffset

func ExpectTrueWithOffset(offset int, actual interface{}, explain ...interface{})

func Fail

func Fail(msg string, callerSkip ...int)

Fail is a replacement for ginkgo.Fail which logs the problem as it occurs together with a stack trace and then calls ginkgowrapper.Fail.

func Failf

func Failf(format string, args ...interface{})

Failf logs the fail info, including a stack trace.

func FailfWithOffset

func FailfWithOffset(offset int, format string, args ...interface{})

FailfWithOffset calls "Fail" and logs the error with a stack trace that starts at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").

func Logf

func Logf(format string, args ...interface{})

Logf logs the info.

func NewHTTPRequest

func NewHTTPRequest() *request.Request

func NewRequest

func NewRequest() *request.Request

NewRequest return a default request with default timeout and content.

func PrunedStack

func PrunedStack(skip int) []byte

PrunedStack is a wrapper around debug.Stack() that removes information about the current goroutine and optionally skips some of the initial stack entries. With skip == 0, the returned stack will start with the caller of PruneStack. From the remaining entries it automatically filters out useless ones like entries coming from Ginkgo.

This is a modified copy of PruneStack in https://github.com/onsi/ginkgo/blob/f90f37d87fa6b1dd9625e2b1e83c23ffae3de228/internal/codelocation/code_location.go#L25:

func RegisterCommonFlags

func RegisterCommonFlags(flags *flag.FlagSet)

RegisterCommonFlags registers flags common to all e2e test suites. The flag set can be flag.CommandLine (if desired) or a custom flag set that then gets passed to viperconfig.ViperizeFlags.

The other Register*Flags methods below can be used to add more test-specific flags. However, those settings then get added regardless whether the test is actually in the test suite.

func RemoveCleanupAction

func RemoveCleanupAction(p CleanupActionHandle)

RemoveCleanupAction removes a function that was installed by AddCleanupAction.

func RunCleanupActions

func RunCleanupActions()

RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.

func SpecifiedHTTPBodyHandler

func SpecifiedHTTPBodyHandler(body []byte) http.HandlerFunc

func ValidateTestContext

func ValidateTestContext(t *TestContextType) error

Types

type CleanupActionHandle

type CleanupActionHandle *int

CleanupActionHandle is an integer pointer type for handling cleanup action

func AddCleanupAction

func AddCleanupAction(fn func()) CleanupActionHandle

AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite(). The hooks are called in last-in-first-out order.

type EnsureFunc

type EnsureFunc func(*request.Response) bool

func ExpectResponseCode

func ExpectResponseCode(code int) EnsureFunc

type FRPClient

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

type Framework

type Framework struct {
	TempDirectory string
	// contains filtered or unexported fields
}

func NewDefaultFramework

func NewDefaultFramework() *Framework

func NewFramework

func NewFramework(opt Options) *Framework

func (*Framework) AfterEach

func (f *Framework) AfterEach()

func (*Framework) AllocPort

func (f *Framework) AllocPort() int

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach create a temp directory.

func (*Framework) FRPClient

func (f *Framework) FRPClient(port int) *FRPClient

func (*Framework) GenerateConfigFile

func (f *Framework) GenerateConfigFile(content string) string

func (*Framework) PortByName

func (f *Framework) PortByName(name string) int

func (*Framework) ReleasePort

func (f *Framework) ReleasePort(port int)

func (*Framework) RenderTemplates

func (f *Framework) RenderTemplates(templates []string) (outs []string, ports map[string]int, err error)

RenderTemplates alloc all ports for port names placeholder.

func (*Framework) RunFrpc

func (f *Framework) RunFrpc(args ...string) (*process.Process, string, error)

func (*Framework) RunFrps

func (f *Framework) RunFrps(args ...string) (*process.Process, string, error)

func (*Framework) RunProcesses

func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []string) ([]*process.Process, []*process.Process)

RunProcesses run multiple processes from templates. The first template should always be frps.

func (*Framework) RunServer

func (f *Framework) RunServer(portName string, s server.Server)

func (*Framework) SetEnvs

func (f *Framework) SetEnvs(envs []string)

func (*Framework) WriteTempFile

func (f *Framework) WriteTempFile(name string, content string) string

type MockServers

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

func NewMockServers

func NewMockServers(portAllocator *port.Allocator) *MockServers

func (*MockServers) Close

func (m *MockServers) Close()

func (*MockServers) GetParam

func (m *MockServers) GetParam(key string) interface{}

func (*MockServers) GetTemplateParams

func (m *MockServers) GetTemplateParams() map[string]interface{}

func (*MockServers) Run

func (m *MockServers) Run() error

type Options

type Options struct {
	TotalParallelNode int
	CurrentNodeIndex  int
	FromPortIndex     int
	ToPortIndex       int
}

type RequestExpect

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

func NewRequestExpect

func NewRequestExpect(f *Framework) *RequestExpect

func (*RequestExpect) Do

func (e *RequestExpect) Do() (*request.Response, error)

func (*RequestExpect) Ensure

func (e *RequestExpect) Ensure(fns ...EnsureFunc)

func (*RequestExpect) ExpectError

func (e *RequestExpect) ExpectError(expectErr bool) *RequestExpect

func (*RequestExpect) ExpectResp

func (e *RequestExpect) ExpectResp(resp []byte) *RequestExpect

func (*RequestExpect) Explain

func (e *RequestExpect) Explain(explain ...interface{}) *RequestExpect

func (*RequestExpect) Port

func (e *RequestExpect) Port(port int) *RequestExpect

func (*RequestExpect) PortName

func (e *RequestExpect) PortName(name string) *RequestExpect

func (*RequestExpect) Protocol

func (e *RequestExpect) Protocol(protocol string) *RequestExpect

func (*RequestExpect) Request

func (e *RequestExpect) Request(req *request.Request) *RequestExpect

func (*RequestExpect) RequestModify

func (e *RequestExpect) RequestModify(f func(r *request.Request)) *RequestExpect

type TestContextType

type TestContextType struct {
	FRPClientPath string
	FRPServerPath string
	LogLevel      string
	Debug         bool
}
var TestContext TestContextType

Directories

Path Synopsis
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.

Jump to

Keyboard shortcuts

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