Documentation ¶
Index ¶
Constants ¶
const ( UserControllerSimple userControllerType = "simple" UserControllerSimulative = "simulative" UserControllerNoop = "noop" UserControllerGenerative = "generative" UserControllerCluster = "cluster" )
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 ¶
ReadConfig reads the configuration file from the given string. If the string is empty, it will return a config with default values.
type ConnectionConfiguration ¶
type ConnectionConfiguration struct { ServerURL string `default:"http://localhost:8065" validate:"url"` WebSocketURL string `default:"ws://localhost:8065" validate:"url"` AdminEmail string `default:"sysadmin@sample.mattermost.com" validate:"email"` AdminPassword string `default:"Sys@dmin-sample1" validate:"notempty"` }
type InstanceConfiguration ¶
type InstanceConfiguration struct { // The target number of teams to be created. NumTeams int64 `default:"2" validate:"range:[0,]"` // The target number of channels to be created. NumChannels int64 `default:"10" validate:"range:[0,]"` // The target number of posts to be created. NumPosts int64 `default:"0" validate:"range:[0,]"` // The target number of reactions to be created. NumReactions int64 `default:"0" validate:"range:[0,]"` // The percentage of replies to be created. PercentReplies float64 `default:"0.5" validate:"range:[0,1]"` // The percentage of public channels to be created. PercentPublicChannels float64 `default:"0.2" validate:"range:[0,1]"` // The percentage of private channels to be created. PercentPrivateChannels float64 `default:"0.1" validate:"range:[0,1]"` // The percentage of direct channels to be created. PercentDirectChannels float64 `default:"0.6" validate:"range:[0,1]"` // The percentage of group channels to be created. PercentGroupChannels float64 `default:"0.1" validate:"range:[0,1]"` }
InstanceConfiguration holds information about the data to be populated during the init process.
func (*InstanceConfiguration) IsValid ¶
func (c *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, log *mlog.Logger) (*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 RatesDistribution ¶
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 int64 // Number of active users. NumUsersAdded int64 // Number of users added since the start of the test. NumUsersRemoved int64 // Number of users removed since the start of the test. NumUsersStopped int64 // Number of users that stopped running. 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. // UserControllerNoop // UserControllerGenerative - A controller used to generate data. Type userControllerType `default:"simulative" validate:"oneof:{simple,simulative,noop,cluster,generative}"` // A distribution of rate multipliers 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. RatesDistribution []RatesDistribution `default_len:"1"` }
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.