control

package
v0.19.1 Latest Latest
Warning

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

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

Documentation

Overview

Package control provides the test control and management interface.

Package control provides the test control and management interface.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFactory = errors.New("factory is not set")
View Source
var ErrNoSuch = errors.New("no such")

Functions

This section is empty.

Types

type Controller

type Controller struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Controller executes jobs in parallel.

func New

func New(opts ...Option) (*Controller, error)

New creates a new Controller.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context) <-chan Event

type ErrorEvent

type ErrorEvent struct {
	Err error
	// contains filtered or unexported fields
}

ErrorEvent is an error event.

func NewErrorEvent

func NewErrorEvent(err error) ErrorEvent

NewError wraps an error into an ErrorEvent. It uses time.Now() as the time when the event happened.

func (ErrorEvent) Error

func (e ErrorEvent) Error() string

func (ErrorEvent) Time

func (e ErrorEvent) Time() time.Time

func (ErrorEvent) Unwrap

func (e ErrorEvent) Unwrap() error

type Event

type Event interface {
	Time() time.Time // Time when the event happened.
}

Event provides information regarding test execution.

type Job

type Job struct {
	// ID is the unique identifier of the job.
	ID string

	// Name is the fully qualified name of the test or control function.
	Name string

	// Args is the list of arguments to pass to the test.
	Args []string

	// Timeout is the duration after which the job will be stopped.
	Timeout time.Duration

	// Module Parameters
	ModulePars map[string]string

	// Dir specifies the working directory for the job.
	Dir string

	// Env specifies the environment variables to pass to the job.
	Env []string

	// Config provides the project configuration
	*project.Config
}

Job describes the test or control function to be executed.

func NewJob

func NewJob(name string, conf *project.Config) *Job

func UnwrapJob

func UnwrapJob(e Event) *Job

UnwrapJob returns the job that caused the event or nil if no such job is available.

type JobError

type JobError struct {
	*Job
	Err error
}

JobError describes an error that occurred during the execution of a test or control function.

func (*JobError) Error

func (e *JobError) Error() string

func (*JobError) Unwrap

func (e *JobError) Unwrap() error

type LogEvent

type LogEvent struct {
	Text string

	*Job
	// contains filtered or unexported fields
}

LogEvent is an event that provided additional information about the test execution.

func NewLogEvent

func NewLogEvent(job *Job, text string) LogEvent

func (LogEvent) Time

func (e LogEvent) Time() time.Time

type Option

type Option func(*Controller) error

func MaxWorkers

func MaxWorkers(n int) Option

func WithFactory

func WithFactory(f RunnerFactory) Option

type Runner

type Runner interface {
	Run(context.Context) <-chan Event
}

A Runner runs one or multiple jobs and emits Events

type RunnerFactory

type RunnerFactory func() (Runner, error)

RunnerFactory creates a new Runner.

type StartEvent

type StartEvent struct {
	Name string

	*Job
	// contains filtered or unexported fields
}

StartEvent is an event that is emitted when the test is started.

func NewStartEvent

func NewStartEvent(job *Job, name string) StartEvent

NewStartEvent creates a new StartEvent.

func (StartEvent) Time

func (e StartEvent) Time() time.Time

type StopEvent

type StopEvent struct {
	Name    string
	Verdict string
	Begin   time.Time

	*Job
	// contains filtered or unexported fields
}

StopEvent is an event that is emitted when the test is stopped.

func NewStopEvent

func NewStopEvent(job *Job, name string, verdict string) StopEvent

NewStopEvent creates a new StopEvent.

func (StopEvent) Time

func (e StopEvent) Time() time.Time

type TestPlan

type TestPlan struct {

	// Controls is a ordered list of fully qualified control functions.
	Controls []string

	// Tests is a ordered list of fully qualified test case names.
	Tests []string
	// contains filtered or unexported fields
}

A TestPlan is a ordered collection of test cases and runtime parameters.

func NewTestPlan

func NewTestPlan(conf *project.Config) (*TestPlan, error)

NewTestPlan parses the TTCN-3 sources provided in the given project configuration and crestes an empty test plan. Syntax errors in the TTCN-3 source files are ignored. The given configuration must not be nil.

func (*TestPlan) Add

func (tp *TestPlan) Add(name string) error

Add adds the given test case to the test plan.

func (*TestPlan) Next

func (tp *TestPlan) Next() *Job

Next returns the next Job to be executed. If there are no more jobs, nil is returned.

type TickerEvent

type TickerEvent struct {
	*Job
	// contains filtered or unexported fields
}

TickerEvent is an event that is emitted periodically during the test execution.

func NewTickerEvent

func NewTickerEvent(job *Job) TickerEvent

NewTickerEvent creates a new TickerEvent.

func (TickerEvent) Time

func (e TickerEvent) Time() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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