types

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: GPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

type Coordinator interface {
	Logger() logrus.FieldLogger
	LogScope() *logger.LogScope
	ClientPool() *clients.ClientPool
	WalletManager() *wallet.Manager
	ValidatorNames() *names.ValidatorNames
	GlobalVariables() Variables

	LoadTests(ctx context.Context)
	AddTestDescriptor(testDescriptor TestDescriptor) error
	GetTestDescriptors() []TestDescriptor
	GetTestByRunID(runID uint64) Test
	GetTestQueue() []Test
	GetTestHistory() []Test
	ScheduleTest(descriptor TestDescriptor, configOverrides map[string]any, allowDuplicate bool) (Test, error)
}

type ExternalTestConfig added in v0.0.4

type ExternalTestConfig struct {
	ID         string                 `yaml:"id" json:"id"`
	File       string                 `yaml:"file" json:"file"`
	Name       string                 `yaml:"name" json:"name"`
	Timeout    *human.Duration        `yaml:"timeout" json:"timeout"`
	Config     map[string]interface{} `yaml:"config" json:"config"`
	ConfigVars map[string]string      `yaml:"configVars" json:"configVars"`
	Schedule   *TestSchedule          `yaml:"schedule" json:"schedule"`
}

type Task

type Task interface {
	Name() string
	Title() string
	Description() string

	Config() interface{}
	Logger() logrus.FieldLogger
	Timeout() time.Duration

	LoadConfig() error
	Execute(ctx context.Context) error
}

type TaskContext

type TaskContext struct {
	Scheduler TaskScheduler
	Index     uint64
	Vars      Variables
	Logger    *logger.LogScope
	NewTask   func(options *TaskOptions, variables Variables) (Task, error)
	SetResult func(result TaskResult)
}

type TaskDescriptor

type TaskDescriptor struct {
	Name        string
	Description string
	Config      interface{}
	NewTask     func(ctx *TaskContext, options *TaskOptions) (Task, error)
}

type TaskOptions

type TaskOptions struct {
	// The name of the task to run.
	Name string `yaml:"name" json:"name"`
	// The configuration object of the task.
	Config *helper.RawMessage `yaml:"config" json:"config"`
	// The configuration settings to consume from runtime variables.
	ConfigVars map[string]string `yaml:"configVars" json:"configVars"`
	// The title of the task - this is used to describe the task to the user.
	Title string `yaml:"title" json:"title"`
	// Timeout defines the max time waiting for the condition to be met.
	Timeout human.Duration `yaml:"timeout" json:"timeout"`
}

type TaskResult

type TaskResult uint8
const (
	TaskResultNone    TaskResult = 0
	TaskResultSuccess TaskResult = 1
	TaskResultFailure TaskResult = 2
)

type TaskScheduler

type TaskScheduler interface {
	GetServices() TaskServices
	ParseTaskOptions(rawtask *helper.RawMessage) (*TaskOptions, error)
	ExecuteTask(ctx context.Context, task Task, taskWatchFn func(ctx context.Context, cancelFn context.CancelFunc, task Task)) error
	WatchTaskPass(ctx context.Context, cancelFn context.CancelFunc, task Task)
	GetTaskCount() int
	GetAllTasks() []Task
	GetRootTasks() []Task
	GetAllCleanupTasks() []Task
	GetRootCleanupTasks() []Task
	GetTaskStatus(task Task) *TaskStatus
	GetTaskResultUpdateChan(task Task, oldResult TaskResult) <-chan bool
}

type TaskServices added in v0.0.3

type TaskServices interface {
	ClientPool() *clients.ClientPool
	WalletManager() *wallet.Manager
	ValidatorNames() *names.ValidatorNames
}

type TaskStatus

type TaskStatus struct {
	Index       uint64
	ParentIndex uint64
	IsStarted   bool
	IsRunning   bool
	StartTime   time.Time
	StopTime    time.Time
	Result      TaskResult
	Error       error
	Logger      *logger.LogScope
}

type Test

type Test interface {
	Validate() error
	Run(ctx context.Context) error
	RunID() uint64
	TestID() string
	Name() string
	StartTime() time.Time
	StopTime() time.Time
	Timeout() time.Duration
	Percent() float64
	Status() TestStatus
	Logger() logrus.FieldLogger
	AbortTest(skipCleanup bool)
	GetTaskScheduler() TaskScheduler
	GetTestVariables() Variables
}

type TestConfig added in v0.0.4

type TestConfig struct {
	ID           string                 `yaml:"id" json:"id"`
	Name         string                 `yaml:"name" json:"name"`
	Timeout      human.Duration         `yaml:"timeout" json:"timeout"`
	Config       map[string]interface{} `yaml:"config" json:"config"`
	ConfigVars   map[string]string      `yaml:"configVars" json:"configVars"`
	Tasks        []helper.RawMessage    `yaml:"tasks" json:"tasks"`
	CleanupTasks []helper.RawMessage    `yaml:"cleanupTasks" json:"cleanupTasks"`
	Schedule     *TestSchedule          `yaml:"schedule" json:"schedule"`
}

type TestDescriptor added in v0.0.4

type TestDescriptor interface {
	ID() string
	Source() string
	Config() *TestConfig
	Vars() Variables
	Err() error
}

type TestSchedule added in v0.0.4

type TestSchedule struct {
	Startup bool     `yaml:"startup" json:"startup"`
	Cron    []string `yaml:"cron" json:"cron"`
}

type TestStatus

type TestStatus string
const (
	TestStatusPending TestStatus = "pending"
	TestStatusRunning TestStatus = "running"
	TestStatusSuccess TestStatus = "success"
	TestStatusFailure TestStatus = "failure"
	TestStatusSkipped TestStatus = "skipped"
	TestStatusAborted TestStatus = "aborted"
)

type Variables

type Variables interface {
	GetVar(name string) interface{}
	LookupVar(name string) (interface{}, bool)
	ResolveQuery(query string) (interface{}, bool, error)
	SetVar(name string, value interface{})
	NewScope() Variables
	GetVarsMap() map[string]any
	ResolvePlaceholders(str string) string
	ConsumeVars(config interface{}, consumeMap map[string]string) error
	CopyVars(source Variables, copyMap map[string]string) error
}

Jump to

Keyboard shortcuts

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