test

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package test implements mock driver

Index

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 uint32 `json:"cpu_limit"` // Number of available virtual CPUs, 0 - unlimited
	RAMLimit uint32 `json:"ram_limit"` // Amount of available virtual RAM (GB), 0 - unlimited

	CPUOverbook uint32 `json:"cpu_overbook"` // How many CPUs available for overbook
	RAMOverbook uint32 `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

func (*Config) Apply

func (c *Config) Apply(config []byte) error

Apply takes json and applies it to the config structure

func (*Config) Validate

func (c *Config) Validate() (err error)

Validate makes sure the config have the required defaults & that the required fields are set

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver implements provider.Driver interface

func (*Driver) Allocate

Allocate - pretends to Allocate (actually not) the Resource

func (*Driver) AvailableCapacity

func (d *Driver) AvailableCapacity(nodeUsage typesv2.Resources, req typesv2.LabelDefinition) int64

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 typesv2.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

func (d *Driver) IsRemote() bool

IsRemote needed to detect the out-of-node resources managed by this driver

func (*Driver) Name

func (d *Driver) Name() string

Name returns name of the driver

func (*Driver) Prepare

func (d *Driver) Prepare(config []byte) error

Prepare initializes the driver

func (*Driver) SetName

func (d *Driver) SetName(name string)

Name returns name of the gate

func (*Driver) Status

func (d *Driver) Status(res typesv2.ApplicationResource) (string, error)

Status shows status of the resource

func (*Driver) ValidateDefinition

func (*Driver) ValidateDefinition(def typesv2.LabelDefinition) error

ValidateDefinition checks LabelDefinition is ok

type Factory

type Factory struct{}

Factory implements provider.DriverFactory interface

func (*Factory) Name

func (*Factory) Name() string

Name shows name of the driver factory

func (*Factory) New

func (f *Factory) New() provider.Driver

New creates new provider driver

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

func (*Options) Apply

func (o *Options) Apply(options util.UnparsedJSON) error

Apply takes json and applies it to the options structure

func (*Options) Validate

func (o *Options) Validate() error

Validate makes sure the options have the required defaults & that the required fields are set

type TaskSnapshot

type TaskSnapshot struct {
	*typesv2.ApplicationTask     `json:"-"` // Info about the requested task
	*typesv2.LabelDefinition     `json:"-"` // Info about the used label definition
	*typesv2.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) Name

func (*TaskSnapshot) Name() string

Name shows name of the task

func (*TaskSnapshot) SetInfo

SetInfo defines the task environment

Jump to

Keyboard shortcuts

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