types

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 8 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    *helper.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 {
	Config() interface{}
	Timeout() time.Duration

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

type TaskContext

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

type TaskDescriptor

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

type TaskIndex added in v0.0.10

type TaskIndex uint64

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 helper.Duration `yaml:"timeout" json:"timeout"`
	// The optional id of the task (for result access via tasks.<task-id>).
	ID string `yaml:"id" json:"id"`
	// The optional condition to run the task.
	If string `yaml:"if" json:"if"`
}

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, taskIndex TaskIndex, taskWatchFn func(ctx context.Context, cancelFn context.CancelFunc, taskIndex TaskIndex)) error
	WatchTaskPass(ctx context.Context, cancelFn context.CancelFunc, taskIndex TaskIndex)
	GetTaskState(taskIndex TaskIndex) TaskState
	GetTaskCount() int
	GetAllTasks() []TaskIndex
	GetRootTasks() []TaskIndex
	GetAllCleanupTasks() []TaskIndex
	GetRootCleanupTasks() []TaskIndex
}

type TaskServices added in v0.0.3

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

type TaskState added in v0.0.10

type TaskState interface {
	Index() TaskIndex
	ParentIndex() TaskIndex
	ID() string
	Name() string
	Title() string
	Description() string
	Config() interface{}
	Timeout() time.Duration
	GetTaskStatus() *TaskStatus
	GetTaskStatusVars() Variables
	GetTaskVars() Variables
	GetTaskResultUpdateChan(oldResult TaskResult) <-chan bool
}

type TaskStatus

type TaskStatus struct {
	Index       TaskIndex
	ParentIndex TaskIndex
	IsStarted   bool
	IsRunning   bool
	IsSkipped   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      helper.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{})
	SetDefaultVar(name string, value interface{})
	GetSubScope(name string) Variables
	SetSubScope(name string, subScope Variables)
	NewScope() Variables
	GetVarsMap(varsMap map[string]any, skipParent bool) 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