types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

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
	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 Task

type Task interface {
	Config() any
	Timeout() time.Duration

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

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 TaskIndex

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 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 TaskScheduler interface {
	GetTaskState(taskIndex TaskIndex) TaskState
	GetTaskCount() uint64
	GetAllTasks() []TaskIndex
	GetRootTasks() []TaskIndex
	GetAllCleanupTasks() []TaskIndex
	GetRootCleanupTasks() []TaskIndex
}

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 TaskStatus struct {
	Index           TaskIndex
	ParentIndex     TaskIndex
	IsStarted       bool
	IsRunning       bool
	IsSkipped       bool
	StartTime       time.Time
	StopTime        time.Time
	Result          TaskResult
	Error           error
	Logger          logger.LogReader
	Progress        float64
	ProgressMessage string
}

type Test

type Test interface {
	RunID() uint64
	TestID() string
	Name() string
	StartTime() time.Time
	StopTime() time.Time
	Timeout() time.Duration
	Status() TestStatus
	GetTaskScheduler() TaskScheduler
	AbortTest(skipCleanup bool)
}

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 TestDescriptor interface {
	ID() string
	Source() string
	BasePath() string
	Config() *TestConfig
	Vars() Variables
	Err() error
}

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 TestRunner interface {
	Test
	Validate() error
	Run(ctx context.Context) error
	Logger() logrus.FieldLogger
	GetTestVariables() Variables
}

type TestSchedule

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

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