processor

package
v0.0.0-...-15a9a0c Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package processor provides the test execution event processor.

Processor consists of single Preprocessor and multiple Handlers. Processor first passes through test execution events to Preprocessor, which in turn pass them down to Handlers.

Preprocessor performs several preprocessing. One of the most important ones is to ensure consistency of test events by possibly generating artificial test events. For example, in case of runner crashes, we may not receive an EntityEnd event corresponding to an EntityStart event received earlier. In such case, Preprocessor generates artificial EntityError/EntityEnd events so that every Handler doesn't need to handle such exceptional cases.

Handlers implement general processing. Handlers are isolated from each other, that is, a behavior of one Handler does not affect that of another Handler. Most processing should go to Handlers instead of Preprocessor unless it is strictly necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCopyAndPassThroughHandler

func NewCopyAndPassThroughHandler(pass func(*protocol.RunTestsResponse) error, pull func(srv, dest string) error) *passThroughHandler

NewCopyAndPassThroughHandler creates a handler which copies bundle output files, and passes bundle messages to the pass callback. It stalls EntityCopyEnd message until file copies are finished.

func NewCopyOutputHandler

func NewCopyOutputHandler(pull PullFunc) *copyOutputHandler

NewCopyOutputHandler creates a handler which copies test output files to the host system when a test finishes.

func NewFailFastHandler

func NewFailFastHandler(counter *failfast.Counter) *failFastHandler

NewFailFastHandler creates a handler which aborts test execution if tests fail too often.

func NewLoggingHandler

func NewLoggingHandler(resDir string, multiplexer *logging.MultiLogger, client *reporting.RPCClient) *loggingHandler

NewLoggingHandler creates a new loggingHandler. multiplexer should be a MultiLogger all logs from the processor (including the preprocessor and all handlers) are sent to; in other words, multiplexer should be attached to the context passed to Processor method calls. loggingHandler will add/remove additional loggers to/from multiplexer to save per-entity logs.

func NewRPCResultsHandler

func NewRPCResultsHandler(client *reporting.RPCClient) *rpcResultsHandler

NewRPCResultsHandler creates a handler which streams test results by gRPC.

func NewStackOperationHandler

func NewStackOperationHandler(handle HandleStack) *stackOperationHandler

NewStackOperationHandler creates a handler which handles stack operations.

func NewStreamedResultsHandler

func NewStreamedResultsHandler(resDir string) *streamedResultsHandler

NewStreamedResultsHandler creates a handler which saves results to a file progressively.

func NewTimingHandler

func NewTimingHandler() *timingHandler

NewTimingHandler creates a handler which records timing information via context.Context.

Types

type DiagnoseFunc

type DiagnoseFunc func(ctx context.Context, outDir string) string

DiagnoseFunc is a function called after a run error is encountered while reading test results to get additional information about the cause of the error. An empty string should be returned if additional information is unavailable. outDir is a path to a directory where extra output files can be written.

type HandleStack

HandleStack handles fixture stack operation. It should handle requests to operate remote fixture stack.

type Handler

type Handler interface {
	RunStart(ctx context.Context) error
	EntityStart(ctx context.Context, ei *entityInfo) error
	EntityLog(ctx context.Context, ei *entityInfo, l *logEntry) error
	EntityError(ctx context.Context, ei *entityInfo, e *errorEntry) error
	EntityEnd(ctx context.Context, ei *entityInfo, r *entityResult) error
	EntityCopyEnd(ctx context.Context, ei *entityInfo) error
	RunLog(ctx context.Context, l *logEntry) error
	RunEnd(ctx context.Context)
	StackOperation(ctx context.Context, req *protocol.StackOperationRequest) *protocol.StackOperationResponse
}

Handler handles processor events.

type Processor

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

Processor processes entity execution events.

func New

func New(resDir string, diagnose DiagnoseFunc, handlers []Handler) *Processor

New creates a new Processor. resDir is a path to the directory where test execution results are written.

func (Processor) EntityCopyEnd

func (p Processor) EntityCopyEnd(ctx context.Context, ev *protocol.EntityCopyEndEvent) error

func (Processor) EntityEnd

func (p Processor) EntityEnd(ctx context.Context, ev *protocol.EntityEndEvent) error

func (Processor) EntityError

func (p Processor) EntityError(ctx context.Context, ev *protocol.EntityErrorEvent) error

func (Processor) EntityLog

func (p Processor) EntityLog(ctx context.Context, ev *protocol.EntityLogEvent) error

func (Processor) EntityStart

func (p Processor) EntityStart(ctx context.Context, ev *protocol.EntityStartEvent) error

func (Processor) FatalError

func (p Processor) FatalError() error

FatalError returns a fatal error of the overall test execution if any.

An error is considered fatal only if it should prevent the caller from retrying test execution any further. An example fatal error is that we've seen more test failures than allowed by the -maxtestfailures flag and should abort test execution immediately.

Most errors are considered non-fatal and should be retried, e.g. test bundle crashes. Anyway, regardless of whether a test execution error is fatal or not, it's also reported as a test error so that it is visible in test results.

func (*Processor) Results

func (p *Processor) Results() []*resultsjson.Result

Results returns test results.

func (Processor) RunEnd

func (p Processor) RunEnd(ctx context.Context, runErr error)

func (Processor) RunLog

func (p Processor) RunLog(ctx context.Context, ev *protocol.RunLogEvent) error

func (Processor) RunStart

func (p Processor) RunStart(ctx context.Context) error

func (Processor) StackOperation

func (p Processor) StackOperation(ctx context.Context, req *protocol.StackOperationRequest) *protocol.StackOperationResponse

type PullFunc

type PullFunc func(src, dst string) error

PullFunc is a function that pulls test output files to the local file system. It should be passed to processor.New to specify how to pull output files. Note that a source file path might be on a remote machine if the test runner is running on a remote machine. A destination file path is always on the host file system.

Jump to

Keyboard shortcuts

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