coordinator

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotRunning  = errors.New("coordinator is not running")
	ErrNotStopped  = errors.New("coordinator has not stopped")
	ErrAlreadyDone = errors.New("coordinator is already done")
)

State related errors.

View Source
var ErrInvalidState = errors.New("unknown state")

ErrInvalidState is returned when an unknown state variable is encoded/decoded.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ClusterConfig defines the load-test agent cluster configuration.
	ClusterConfig cluster.LoadAgentClusterConfig
	// MonitorConfig holds the performance monitor configuration.
	MonitorConfig performance.MonitorConfig
	// The number of active users to increment at each iteration of the feedback loop.
	// It should be proportional to the maximum number of users expected to test.
	NumUsersInc int `default:"8" validate:"range:(0,]"`
	// The number of users to decrement at each iteration of the feedback loop.
	// It should be proportional to the maximum number of users expected to test.
	NumUsersDec int `default:"8" validate:"range:(0,]"`
	// The number of seconds to wait after a performance degradation alert before
	// incrementing or decrementing users again.
	RestTimeSec int `default:"2" validate:"range:(0,]"`
	LogSettings logger.Settings
}

Config holds the necessary information to drive a cluster of load-test agents performing a load-test on a target instance.

func ReadConfig

func ReadConfig(configFilePath string) (*Config, error)

ReadConfig reads the configuration file from the given string. If the string is empty, it will return a config with default values.

type Coordinator

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

Coordinator is the object used to coordinate a cluster of load-test agents.

func New

func New(config *Config, ltConfig loadtest.Config, log *mlog.Logger) (*Coordinator, error)

New creates and initializes a new Coordinator for the given config. The ltConfig parameter is used to create and configure load-test agents. An error is returned if the initialization fails.

func (*Coordinator) InjectAction added in v1.10.0

func (c *Coordinator) InjectAction(actionID string) error

InjectAction injects an action into all the agents that is run once, at the next possible opportunity.

func (*Coordinator) Run

func (c *Coordinator) Run() (<-chan struct{}, error)

Run starts a cluster of load-test agents. It returns a channel to signal when the coordinator is done. It returns an error if the coordinator is not in Stopped state.

func (*Coordinator) Status

func (c *Coordinator) Status() (Status, error)

Status returns the coordinator's status.

func (*Coordinator) Stop

func (c *Coordinator) Stop() error

Stop stops the coordinator. It returns an error in case of failure.

type State

type State int

State determines which state a Coordinator is in.

const (
	Stopped State = iota
	Running
	Done
)

Different possible states of a Coordinator.

func (State) MarshalJSON

func (s State) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation from a State variable.

func (State) String

func (s State) String() string

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(b []byte) error

UnmarshalJSON constructs the state from a JSON string.

type Status

type Status struct {
	State          State     // State of Coordinator.
	StartTime      time.Time // Time when Coordinator has started.
	StopTime       time.Time // Time when Coordinator has stopped.
	ActiveUsers    int       // Total number of currently active users across the load-test agents cluster.
	NumErrors      int64     // Total number of errors received from the load-test agents cluster.
	SupportedUsers int       // Number of supported users.
}

Status contains various information about Coordinator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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