run

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0, MIT Imports: 20 Imported by: 69

Documentation

Index

Constants

View Source
const (
	StateInitializedGlobal   = sync.State("initialized_global")
	StateInitializedGroupFmt = "initialized_group_%s"
)
View Source
const (
	// These ports are the HTTP ports we'll attempt to bind to. If this instance
	// is running in a Docker container, binding to 6060 is safe. If it's a
	// local:exec run, these ports belong to the host, so starting more than one
	// instance will lead to a collision. Therefore we fallback to 0.
	HTTPPort         = 6060
	HTTPPortFallback = 0
)

Variables

View Source
var HTTPListenAddr string

HTTPListenAddr will be set to the listener address _before_ the test case is invoked. If we were unable to start the listener, this value will be "".

View Source
var InitSyncClientFactory = func(ctx context.Context, env *runtime.RunEnv) sync.Client {

	return sync.MustBoundClient(ctx, env)
}

InitSyncClientFactory is the function that will be called to initialize a sync client as part of an InitContext.

Replaced in testing.

Functions

func HandlePanics

func HandlePanics()

HandlePanics should be called in a defer at the top of any goroutine that the test plan spawns, so that panics from children goroutine are propagated to the main goroutine, where they will be handled by run.Invoke and recorded as a CRASH event. The test will end immediately.

func Invoke

func Invoke(fn interface{})

Invoke runs the passed test-case and reports the result.

Supported function signatures are TestCaseFn and InitializedTestCaseFn. Refer to their respective godocs for more info.

func InvokeMap

func InvokeMap(cases map[string]interface{})

InvokeMap takes a map of test case names and their functions, and calls the matched test case, or panics if the name is unrecognised.

Supported function signatures are TestCaseFn and InitializedTestCaseFn. Refer to their respective godocs for more info.

Types

type InitContext

type InitContext struct {
	SyncClient sync.Client
	NetClient  *network.Client
	GlobalSeq  int64
	GroupSeq   int64
	// contains filtered or unexported fields
}

InitContext encapsulates a sync client, a net client, and global and group-scoped seq numbers assigned to this test instance by the sync service.

The states we signal to acquire the global and group-scoped seq numbers are:

  • initialized_global
  • initialized_group_<id>

func (*InitContext) MustWaitAllInstancesInitialized

func (ic *InitContext) MustWaitAllInstancesInitialized(ctx context.Context)

MustWaitAllInstancesInitialized calls WaitAllInstancesInitialized, and panics if it errors.

func (*InitContext) MustWaitGroupInstancesInitialized

func (ic *InitContext) MustWaitGroupInstancesInitialized(ctx context.Context)

MustWaitGroupInstancesInitialized calls WaitGroupInstancesInitialized, and panics if it errors.

func (*InitContext) WaitAllInstancesInitialized

func (ic *InitContext) WaitAllInstancesInitialized(ctx context.Context) error

WaitAllInstancesInitialized waits for all instances to initialize.

func (*InitContext) WaitGroupInstancesInitialized

func (ic *InitContext) WaitGroupInstancesInitialized(ctx context.Context) error

WaitGroupInstancesInitialized waits for all group instances to initialize.

type InitializedTestCaseFn

type InitializedTestCaseFn = func(env *runtime.RunEnv, initCtx *InitContext) error

InitializedTestCaseFn allows users to indicate they want a basic initialization routine to be run before yielding control to the test case function itself.

The initialization routine is common scaffolding that gets repeated across the test plans we've seen. We package it here in an attempt to keep your code DRY.

It consists of:

  1. Initializing a sync client, bound to the runenv.
  2. Initializing a net client.
  3. Waiting for the network to initialize.
  4. Claiming a global sequence number.
  5. Claiming a group-scoped sequence number.

The injected InitContext is a bundle containing the result, and you can use its objects in your test logic. In fact, you don't need to close them (sync client, net client), as the SDK manages that for you.

type PanicPayload added in v0.2.6

type PanicPayload struct {
	RecoverObj      interface{}
	DebugStacktrace string
}

type ProfilesCloseFn added in v0.3.0

type ProfilesCloseFn = func() error

type TestCaseFn

type TestCaseFn = func(env *runtime.RunEnv) error

Jump to

Keyboard shortcuts

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