Documentation
¶
Index ¶
- type Coordinator
- type ExternalTestConfig
- type Task
- type TaskContext
- type TaskDescriptor
- type TaskIndex
- type TaskOptions
- type TaskOutputDefinition
- type TaskResult
- type TaskScheduler
- type TaskSchedulerRunner
- type TaskServices
- type TaskState
- type TaskStatus
- type Test
- type TestConfig
- type TestDescriptor
- type TestRegistry
- type TestRunner
- type TestSchedule
- type TestStatus
- type Variables
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator interface {
Logger() logrus.FieldLogger
LogReader() logger.LogReader
Database() *db.Database
ClientPool() *clients.ClientPool
WalletManager() *txmgr.Spamoor
ValidatorNames() *names.ValidatorNames
GlobalVariables() Variables
TestRegistry() TestRegistry
EventBus() *events.EventBus
GetTestByRunID(runID uint64) Test
GetTestQueue() []Test
GetTestHistory(testID string, firstRunID uint64, offset uint64, limit uint64) ([]Test, uint64)
ScheduleTest(descriptor TestDescriptor, configOverrides map[string]any, allowDuplicate bool, skipQueue bool) (TestRunner, error)
DeleteTestRun(runID uint64) error
}
type ExternalTestConfig ¶
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"`
YamlSource string `yaml:"-" json:"-"` // Raw YAML source (for API-registered tests)
}
type TaskContext ¶
type TaskContext struct {
Scheduler TaskSchedulerRunner
Index TaskIndex
Vars Variables
Outputs Variables
Logger *logger.LogScope
NewTask func(options *TaskOptions, variables Variables) (TaskIndex, error)
SetResult func(result TaskResult)
ReportProgress func(percent float64, message string)
EmitEvent func(eventType string, data any)
}
type TaskDescriptor ¶
type TaskDescriptor struct {
Name string
Aliases []string
Description string
Category string
Config any
Outputs []TaskOutputDefinition
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 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 TaskOutputDefinition ¶
type TaskOutputDefinition struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
}
TaskOutputDefinition describes an output that a task can produce.
type TaskResult ¶
type TaskResult uint8
const ( TaskResultNone TaskResult = 0 TaskResultSuccess TaskResult = 1 TaskResultFailure TaskResult = 2 )
type TaskScheduler ¶
type TaskSchedulerRunner ¶
type TaskSchedulerRunner interface {
TaskScheduler
GetServices() TaskServices
GetTestRunID() uint64
GetTestRunCtx() context.Context
ParseTaskOptions(rawtask helper.IRawMessage) (*TaskOptions, error)
ExecuteTask(ctx context.Context, taskIndex TaskIndex, taskWatchFn func(ctx context.Context, cancelFn context.CancelFunc, taskIndex TaskIndex)) error
}
type TaskServices ¶
type TaskServices interface {
Database() *db.Database
ClientPool() *clients.ClientPool
WalletManager() *txmgr.Spamoor
ValidatorNames() *names.ValidatorNames
EventBus() *events.EventBus
}
type TaskState ¶
type TaskState interface {
Index() TaskIndex
ParentIndex() TaskIndex
ID() string
Name() string
Title() string
Description() string
Config() any
Timeout() time.Duration
GetTaskStatus() *TaskStatus
GetTaskStatusVars() Variables
GetScopeOwner() TaskIndex
GetTaskResultUpdateChan(oldResult TaskResult) <-chan bool
}
type TaskStatus ¶
type TestConfig ¶
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 ¶
type TestRegistry ¶
type TestRegistry interface {
AddLocalTest(testConfig *TestConfig) (TestDescriptor, error)
AddLocalTestWithYaml(testConfig *TestConfig, yamlSource string) (TestDescriptor, error)
AddExternalTest(ctx context.Context, extTestConfig *ExternalTestConfig) (TestDescriptor, error)
DeleteTest(testID string) error
GetTestDescriptors() []TestDescriptor
}
type TestRunner ¶
type TestSchedule ¶
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
}
Click to show internal directories.
Click to hide internal directories.