Documentation
¶
Overview ¶
Package test implements mock driver
Index ¶
- type Config
- type Driver
- func (d *Driver) Allocate(def types.LabelDefinition, _ map[string]any) (*types.ApplicationResource, error)
- func (d *Driver) AvailableCapacity(nodeUsage types.Resources, req types.LabelDefinition) int64
- func (d *Driver) Deallocate(res *types.ApplicationResource) error
- func (d *Driver) GetTask(name, options string) provider.DriverTask
- func (d *Driver) IsRemote() bool
- func (d *Driver) Name() string
- func (d *Driver) Prepare(config []byte) error
- func (d *Driver) SetName(name string)
- func (d *Driver) Status(res *types.ApplicationResource) (string, error)
- func (*Driver) ValidateDefinition(def types.LabelDefinition) error
- type Factory
- type Options
- type TaskSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
IsRemote bool `json:"is_remote"` // Pretend to be remote or not to check the local node limits
WorkspacePath string `json:"workspace_path"` // Where to place the files of running resources
CPULimit uint `json:"cpu_limit"` // Number of available virtual CPUs, 0 - unlimited
RAMLimit uint `json:"ram_limit"` // Amount of available virtual RAM (GB), 0 - unlimited
CPUOverbook uint `json:"cpu_overbook"` // How many CPUs available for overbook
RAMOverbook uint `json:"ram_overbook"` // How much RAM (GB) available for overbook
FailConfigApply uint8 `json:"fail_config_apply"` // Fail on config Apply (0 - not, 1-254 random, 255-yes)
FailConfigValidate uint8 `json:"fail_config_validate"` // Fail on config Validation (0 - not, 1-254 random, 255-yes)
FailStatus uint8 `json:"fail_status"` // Fail on Status (0 - not, 1-254 random, 255-yes)
FailSnapshot uint8 `json:"fail_snapshot"` // Fail on Snapshot (0 - not, 1-254 random, 255-yes)
FailDeallocate uint8 `json:"fail_deallocate"` // Fail on Deallocate (0 - not, 1-254 random, 255-yes)
}
Config - node driver configuration
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements provider.Driver interface
func (*Driver) Allocate ¶
func (d *Driver) Allocate(def types.LabelDefinition, _ map[string]any) (*types.ApplicationResource, error)
Allocate - pretends to Allocate (actually not) the Resource
func (*Driver) AvailableCapacity ¶
AvailableCapacity allows Fish to ask the driver about it's capacity (free slots) of a specific definition
func (*Driver) Deallocate ¶
func (d *Driver) Deallocate(res *types.ApplicationResource) error
Deallocate the resource
func (*Driver) GetTask ¶
func (d *Driver) GetTask(name, options string) provider.DriverTask
GetTask returns task struct by name
func (*Driver) IsRemote ¶
IsRemote needed to detect the out-of-node resources managed by this driver
func (*Driver) Status ¶
func (d *Driver) Status(res *types.ApplicationResource) (string, error)
Status shows status of the resource
func (*Driver) ValidateDefinition ¶
func (*Driver) ValidateDefinition(def types.LabelDefinition) error
ValidateDefinition checks LabelDefinition is ok
type Options ¶
type Options struct {
FailOptionsApply uint8 `json:"fail_options_apply"` // Fail on options Apply (0 - not, 1-254 random, 255-yes)
FailOptionsValidate uint8 `json:"fail_options_validate"` // Fail on options Validate (0 - not, 1-254 random, 255-yes)
FailAvailableCapacity uint8 `json:"fail_available_capacity"` // Fail on executing AvailableCapacity (0 - not, 1-254 random, 255-yes)
FailAllocate uint8 `json:"fail_allocate"` // Fail on Allocate (0 - not, 1-254 random, 255-yes)
DelayAvailableCapacity float32 `json:"delay_available_capacity"` // Amount of seconds to sleep within AvailableCapacity request
DelayAllocate float32 `json:"delay_allocate"` // Amount of seconds to sleep within Allocation request
}
Options for testing
type TaskSnapshot ¶
type TaskSnapshot struct {
*types.ApplicationTask `json:"-"` // Info about the requested task
*types.LabelDefinition `json:"-"` // Info about the used label definition
*types.ApplicationResource `json:"-"` // Info about the processed resource
Full bool `json:"full"` // Make full (all disks including OS image), or just the additional disks snapshot
// contains filtered or unexported fields
}
TaskSnapshot implements test snapshot task
func (*TaskSnapshot) Clone ¶
func (t *TaskSnapshot) Clone() provider.DriverTask
Clone copies task to use it
func (*TaskSnapshot) Execute ¶
func (t *TaskSnapshot) Execute() (result []byte, err error)
Execute runs the task
func (*TaskSnapshot) SetInfo ¶
func (t *TaskSnapshot) SetInfo(task *types.ApplicationTask, def *types.LabelDefinition, res *types.ApplicationResource)
SetInfo defines the task environment