bundleclient

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package bundleclient provides a client of test bundles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalCommand

func LocalCommand(exec string, proxy bool, cc *target.ConnCache) *genericexec.SSHCmd

LocalCommand creates a SSH command to run exec on the target specified by cc.

Types

type Client

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

Client is a gRPC protocol client to a test bundle.

func New

func New(cmd genericexec.Cmd, msgTimeOut time.Duration, bundlePath string) *Client

New creates a new Client.

func NewLocal

func NewLocal(bundle, bundleDir string, proxy bool, cc *target.ConnCache, msgTimeout time.Duration) *Client

NewLocal creates a bundle client to the local bundle.

func (*Client) BundlePath

func (c *Client) BundlePath() string

BundlePath returns the bundle path.

func (*Client) RunFixture

func (c *Client) RunFixture(ctx context.Context, name string, cfg *protocol.RunFixtureConfig, out RunFixtureOutput) (_ *FixtureTicket, retErr error)

RunFixture requests a test bundle to set up a fixture. After successful return of RunFixture, a caller must call FixtureTicket.TearDown to tear down the fixture.

func (*Client) RunTests

func (c *Client) RunTests(ctx context.Context, bcfg *protocol.BundleConfig, rcfg *protocol.RunConfig, out RunTestsOutput, recursive bool)

RunTests requests to run tests according to the given RunConfig. Test execution events are streamed back via out. See RunTestsOutput for details.

type FixtureTicket

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

FixtureTicket tracks the state of a fixture set up by Client.RunFixture.

func (*FixtureTicket) StartFixtureState

func (t *FixtureTicket) StartFixtureState() *protocol.StartFixtureState

StartFixtureState returns a StartFixtureState suitable to drive local test bundles.

func (*FixtureTicket) TearDown

func (t *FixtureTicket) TearDown(ctx context.Context) (retErr error)

TearDown tears down a fixture set up by Client.RunFixture and releases resources associated with the fixture. For a valid instance of FixtureTicket, TearDown must be called exactly once.

type RunFixtureOutput

type RunFixtureOutput interface {
	EntityLog(ctx context.Context, ev *protocol.EntityLogEvent) error
	EntityError(ctx context.Context, ev *protocol.EntityErrorEvent) error
}

RunFixtureOutput is implemented by callers of RunFixture to receive fixture execution events.

type RunTestsOutput

type RunTestsOutput interface {
	// RunStart is called exactly once at the beginning of an overall test
	// execution.
	RunStart(ctx context.Context) error

	// EntityStart is called when an entity starts.
	EntityStart(ctx context.Context, ev *protocol.EntityStartEvent) error
	// EntityLog is called with an entity log.
	EntityLog(ctx context.Context, ev *protocol.EntityLogEvent) error
	// EntityError is called with an entity error.
	EntityError(ctx context.Context, ev *protocol.EntityErrorEvent) error
	// EntityEnd is called when an entity finishes.
	EntityEnd(ctx context.Context, ev *protocol.EntityEndEvent) error
	// EntityCopyEnd is called when copy of output files completes after an entity
	// finishes.
	EntityCopyEnd(ctx context.Context, ev *protocol.EntityCopyEndEvent) error
	// RunLog is called with a log not associated with an entity.
	RunLog(ctx context.Context, ev *protocol.RunLogEvent) error
	// StackOperation is called to request remote fixture stack operation.
	// This is called when a local bundle needs remote fixture operation.
	StackOperation(ctx context.Context, req *protocol.StackOperationRequest) *protocol.StackOperationResponse

	// RunEnd is called exactly once at the end of an overall test execution.
	// If any other method returns a non-nil error, test execution is aborted
	// immediately and RunEnd is called with the error.
	RunEnd(ctx context.Context, err error)
}

RunTestsOutput is implemented by callers of RunTests to receive test execution events.

Its methods (except RunStart and RunEnd) are called on receiving a corresponding test execution event. In case of errors, they can be called in an inconsistent way (e.g. EntityEnd is not called after EntityStart due to a test crash). RunTestsOutput implementations must be prepared to handle such error cases correctly.

All methods except RunEnd can return an error, which leads to immediate abort of the test execution and subsequent RunEnd call.

Jump to

Keyboard shortcuts

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