Documentation ¶
Index ¶
Constants ¶
const ( UserControllerSimple userControllerType = "simple" UserControllerSimulative = "simulative" UserControllerNoop = "noop" )
Available UserController implementations.
Variables ¶
var ( ErrNotRunning = errors.New("LoadTester is not running") ErrNotStopped = errors.New("LoadTester has not stopped") ErrNoUsersLeft = errors.New("no active users left") ErrMaxUsersReached = errors.New("max active users limit reached") ErrInvalidNumUsers = errors.New("numUsers should be > 0") )
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 { ConnectionConfiguration ConnectionConfiguration UserControllerConfiguration UserControllerConfiguration InstanceConfiguration InstanceConfiguration UsersConfiguration UsersConfiguration LogSettings logger.Settings }
func ReadConfig ¶
type ConnectionConfiguration ¶
type ConnectionConfiguration struct { ServerURL string WebSocketURL string AdminEmail string AdminPassword string }
func (*ConnectionConfiguration) IsValid ¶
func (cc *ConnectionConfiguration) IsValid() error
IsValid reports whether a given ConnectionConfiguration is valid or not. Returns an error if the validation fails.
type InstanceConfiguration ¶
type InstanceConfiguration struct { NumTeams int NumChannels int NumTeamAdmins int TeamAdminInterval int }
func (*InstanceConfiguration) IsValid ¶
func (ic *InstanceConfiguration) IsValid() error
IsValid reports whether a given InstanceConfiguration is valid or not. Returns an error if the validation fails.
type LoadTester ¶
type LoadTester struct {
// contains filtered or unexported fields
}
LoadTester is a structure holding all the state needed to run a load-test.
func New ¶
func New(config *Config, nc NewController) (*LoadTester, error)
New creates and initializes a new LoadTester with given config. A factory function is also given to enable the creation of UserController values from within the loadtest package.
func (*LoadTester) AddUsers ¶
func (lt *LoadTester) AddUsers(numUsers int) (int, error)
AddUsers attempts to increment by numUsers the number of concurrently active users. Returns the number of users successfully added.
func (*LoadTester) RemoveUsers ¶
func (lt *LoadTester) RemoveUsers(numUsers int) (int, error)
RemoveUsers attempts to decrement by numUsers the number of concurrently active users. Returns the number of users successfully removed.
func (*LoadTester) Run ¶
func (lt *LoadTester) Run() error
Run starts the execution of a new load-test. It returns an error if called again without stopping the test first.
func (*LoadTester) Status ¶
func (lt *LoadTester) Status() *Status
Status returns information regarding the current state of the load-test.
func (*LoadTester) Stop ¶
func (lt *LoadTester) Stop() error
Stop terminates the current load-test. It returns an error if it is called when the load test has not started.
type NewController ¶
type NewController func(int, chan<- control.UserStatus) (control.UserController, error)
NewController is a factory function that returns a new control.UserController given an id and a channel of control.UserStatus It is passed during LoadTester initialization to provide a way to create concrete UserController values from within the loadtest package without the need of those being passed from the upper layer (the user of this API).
type State ¶
type State int
State determines which state a loadtester is in.
func (State) MarshalJSON ¶
MarshalJSON returns a JSON representation from a State variable.
func (*State) UnmarshalJSON ¶
UnmarshalJSON constructs the state from a JSON string.
type Status ¶
type Status struct { State State // State of the load test. NumUsers int // Number of active users. NumUsersAdded int // Number of users added since the start of the test. NumUsersRemoved int // Number of users removed since the start of the test. NumErrors int64 // Number of errors that have occurred. StartTime time.Time // Time when the load test was started. This only logs the time when the load test was first started, and does not get reset if it was subsequently restarted. }
Status contains various information about the load test.
type UserControllerConfiguration ¶
type UserControllerConfiguration struct { // The type of the UserController to run. // Possible values: // UserControllerSimple - A simple version of a controller. // UserControllerSimulative - A more realistic controller. Type userControllerType // A rate multiplier that will affect the speed at which user actions are // executed by the UserController. // A Rate of < 1.0 will run actions at a faster pace. // A Rate of 1.0 will run actions at the default pace. // A Rate > 1.0 will run actions at a slower pace. Rate float64 }
UserControllerConfiguration holds information about the UserController to run during a load-test.
func (*UserControllerConfiguration) IsValid ¶
func (ucc *UserControllerConfiguration) IsValid() error
IsValid reports whether a given UserControllerConfiguration is valid or not. Returns an error if the validation fails.
type UsersConfiguration ¶
func (*UsersConfiguration) IsValid ¶
func (uc *UsersConfiguration) IsValid() error
IsValid reports whether a given UsersConfiguration is valid or not.