Documentation ¶
Index ¶
- Constants
- Variables
- func AddLink(input string) string
- func Asset(name string) ([]byte, error)
- func AssetDigest(name string) ([sha256.Size]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func AssetString(name string) (string, error)
- func AttachFileToBookmark(u user.User, bookmark *model.ChannelBookmark) error
- func AttachFilesToDraft(u user.User, draft *model.Draft) error
- func AttachFilesToPost(u user.User, post *model.Post) error
- func Digests() (map[string][sha256.Size]byte, error)
- func GeneratePostsSearchTerm(words []string, opts PostsSearchOpts) string
- func GenerateRandomSentences(count int) string
- func MustAsset(name string) []byte
- func MustAssetString(name string) string
- func ParseServerVersion(versionString string) (semver.Version, error)
- func PickIdleTimeMs(minIdleTimeMs, avgIdleTimeMs int, rate float64) time.Duration
- func PickRandomString(strings []string) string
- func PickRandomWord() string
- func RandomEmoji() string
- func RandomLink() string
- func RandomizeTeamDisplayName(name string) string
- func RandomizeUserName(name string) string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func SelectWeighted(weights []int) (int, error)
- type PostsSearchOpts
- type UserAction
- type UserActionResponse
- func AckToPost(u user.User) UserActionResponse
- func AddReaction(u user.User) UserActionResponse
- func ChannelBookmarkEnabled(u user.User) (bool, UserActionResponse)
- func CollapsedThreadsEnabled(u user.User) (bool, UserActionResponse)
- func CreateAckPost(u user.User) UserActionResponse
- func CreateDirectChannel(u user.User) UserActionResponse
- func CreateGroupChannel(u user.User) UserActionResponse
- func CreatePersistentNotificationPost(u user.User) UserActionResponse
- func CreatePost(u user.User) UserActionResponse
- func CreatePostReply(u user.User) UserActionResponse
- func CreatePrivateChannel(u user.User) UserActionResponse
- func CreatePublicChannel(u user.User) UserActionResponse
- func DraftsEnabled(u user.User) (bool, UserActionResponse)
- func EditPost(u user.User) UserActionResponse
- func EmulateUserTyping(t string, cb func(term string) UserActionResponse) UserActionResponse
- func FetchStaticAssets(u user.User) UserActionResponse
- func GetPinnedPosts(u user.User) UserActionResponse
- func GetPreferences(u user.User) UserActionResponse
- func JoinChannel(u user.User) UserActionResponse
- func JoinTeam(u user.User) UserActionResponse
- func LeaveChannel(u user.User) UserActionResponse
- func Login(u user.User) UserActionResponse
- func Logout(u user.User) UserActionResponse
- func MessageExport(u user.User) UserActionResponse
- func Reload(u user.User) UserActionResponse
- func ReloadGQL(u user.User) UserActionResponse
- func RemoveReaction(u user.User) UserActionResponse
- func SearchChannels(u user.User) UserActionResponse
- func SearchPosts(u user.User) UserActionResponse
- func SearchUsers(u user.User) UserActionResponse
- func SignUp(u user.User) UserActionResponse
- func UpdateProfileImage(u user.User) UserActionResponse
- func ViewChannel(u user.User) UserActionResponse
- func ViewUser(u user.User) UserActionResponse
- type UserController
- type UserError
- type UserStatus
Constants ¶
const ( USER_STATUS_UNKNOWN int = iota USER_STATUS_STARTED USER_STATUS_STOPPED USER_STATUS_DONE USER_STATUS_ERROR USER_STATUS_FAILED USER_STATUS_INFO USER_STATUS_WARN )
User status types.
const AssetDebug = false
AssetDebug is true if the assets were built with the debug flag enabled.
Variables ¶
var ( // MinSupportedVersion is, by definition, the third-to-last ESR MinSupportedVersion = semver.MustParse("7.8.0") // UnreleasedVersion is a version guaranteed to be larger than any released // version, useful for actions already added to the load-test but not yet // merged in the server. UnreleasedVersion = semver.Version{Major: math.MaxUint64} )
var ErrInjectActionQueueFull = errors.New("inject action queue full")
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDigest ¶
AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetString ¶
AssetString returns the asset contents as a string (instead of a []byte).
func AttachFileToBookmark ¶ added in v1.23.0
func AttachFileToBookmark(u user.User, bookmark *model.ChannelBookmark) error
func AttachFilesToDraft ¶ added in v1.20.0
AttachFilesToDraft uploads at least one file on behalf of the user, attaching all uploaded files to the draft.
func AttachFilesToPost ¶ added in v1.10.0
AttachFilesToPost uploads at least one file on behalf of the user, attaching all uploaded files to the post.
func GeneratePostsSearchTerm ¶ added in v1.1.0
func GeneratePostsSearchTerm(words []string, opts PostsSearchOpts) string
GeneratePostsSearchTerm generates a posts search term from the given words and options.
func GenerateRandomSentences ¶
GenerateRandomSentences generates random string from test_text file.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func MustAssetString ¶
MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.
func ParseServerVersion ¶ added in v1.20.0
ParseServerVersion finds the semver-compatible version substring in the string returned by the server and tries to parse it
func PickIdleTimeMs ¶ added in v1.2.0
func PickRandomString ¶ added in v1.5.0
PickRandomString returns a random string from the given slice of strings
func PickRandomWord ¶ added in v1.1.0
func PickRandomWord() string
PickRandomWord returns a random word.
func RandomEmoji ¶ added in v1.6.0
func RandomEmoji() string
RandomEmoji returns a random emoji from a list.
func RandomLink ¶ added in v1.23.0
func RandomLink() string
func RandomizeTeamDisplayName ¶
RandomizeTeamDisplayName is a utility function to set a random team display name while keeping the basic pattern unchanged. Assumes the given name has a pattern of team{{number}}[-letter].
func RandomizeUserName ¶
RandomizeUserName is a utility function used by UserController's implementations to randomize a username while keeping a basic pattern unchanged. Assumes the given name has a pattern of {{agent-id}}-{{user-name}}-{{user-number}}. If the pattern is not found it will return the input string unaltered.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory.
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively.
func SelectWeighted ¶
SelectWeighted does a random weighted selection on a given slice of weights.
Types ¶
type PostsSearchOpts ¶ added in v1.1.0
type UserAction ¶
type UserAction func(user.User) UserActionResponse
UserAction is a function that simulates a specific behaviour for the provided user.User. It returns a UserActionResponse.
type UserActionResponse ¶
type UserActionResponse struct { // Info contains a string with information about the action // execution. Info string // Warn contains any warning about the executed action that should be logged. Warn string // Err contains an error when the action failed. Err error }
UserActionResponse is a structure containing information about the result of running a UserAction.
func AckToPost ¶ added in v1.10.0
func AckToPost(u user.User) UserActionResponse
AckToPost acknowledges a random ackPost.
func AddReaction ¶
func AddReaction(u user.User) UserActionResponse
AddReaction adds a reaction by the user to a random post.
func ChannelBookmarkEnabled ¶ added in v1.23.0
func ChannelBookmarkEnabled(u user.User) (bool, UserActionResponse)
func CollapsedThreadsEnabled ¶ added in v1.3.0
func CollapsedThreadsEnabled(u user.User) (bool, UserActionResponse)
func CreateAckPost ¶ added in v1.10.0
func CreateAckPost(u user.User) UserActionResponse
CreateAckPost creates a new post with priority label and acknowledgment in a random channel.
func CreateDirectChannel ¶
func CreateDirectChannel(u user.User) UserActionResponse
CreateDirectChannel creates a direct message channel with a random user from a random team/channel.
func CreateGroupChannel ¶
func CreateGroupChannel(u user.User) UserActionResponse
CreateGroupChannel creates a group channel with 3 random users.
func CreatePersistentNotificationPost ¶ added in v1.10.0
func CreatePersistentNotificationPost(u user.User) UserActionResponse
CreatePersistentNotificationPost creates a persistent notification post.
func CreatePost ¶
func CreatePost(u user.User) UserActionResponse
CreatePost creates a new post in a random channel by the given user.
func CreatePostReply ¶
func CreatePostReply(u user.User) UserActionResponse
CreatePostReply replies to a randomly picked post.
func CreatePrivateChannel ¶
func CreatePrivateChannel(u user.User) UserActionResponse
CreatePrivateChannel creates a private channel in a random team.
func CreatePublicChannel ¶
func CreatePublicChannel(u user.User) UserActionResponse
CreatePublicChannel creates a public channel in a random team.
func DraftsEnabled ¶ added in v1.20.0
func DraftsEnabled(u user.User) (bool, UserActionResponse)
func EmulateUserTyping ¶
func EmulateUserTyping(t string, cb func(term string) UserActionResponse) UserActionResponse
EmulateUserTyping calls cb function for each rune in the input string.
func FetchStaticAssets ¶
func FetchStaticAssets(u user.User) UserActionResponse
FetchStaticAssets parses index.html and fetches static assets mentioned in it
func GetPinnedPosts ¶
func GetPinnedPosts(u user.User) UserActionResponse
GetPinnedPosts fetches the pinned posts in a channel that user is a member of.
func GetPreferences ¶ added in v1.10.0
func GetPreferences(u user.User) UserActionResponse
func JoinChannel ¶
func JoinChannel(u user.User) UserActionResponse
JoinChannel adds the user to the first channel that has been found in the store and which the user is not a member of.
func JoinTeam ¶
func JoinTeam(u user.User) UserActionResponse
JoinTeam adds the given user to the first team that has been found in the store and which the user is not a member of.
func LeaveChannel ¶
func LeaveChannel(u user.User) UserActionResponse
LeaveChannel removes the user from the first channel that has been found in the store and which the user is a member of.
func Login ¶
func Login(u user.User) UserActionResponse
Login authenticates the user with the server and fetches teams, users and channels that are related with the user.
func Logout ¶
func Logout(u user.User) UserActionResponse
Logout disconnects the user from the server and logs out from the server.
func MessageExport ¶ added in v1.3.0
func MessageExport(u user.User) UserActionResponse
MessageExport simulates the given user performing a compliance message export
func Reload ¶
func Reload(u user.User) UserActionResponse
Reload simulates the given user reloading the page while connected to the server by executing the API calls seen during a real page reload.
func ReloadGQL ¶ added in v1.9.0
func ReloadGQL(u user.User) UserActionResponse
ReloadGQL is same as Reload but with the REST calls replaced with GraphQL
func RemoveReaction ¶
func RemoveReaction(u user.User) UserActionResponse
RemoveReaction removes a reaction from a random post which is added by the user.
func SearchChannels ¶
func SearchChannels(u user.User) UserActionResponse
SearchChannels searches for channels by the given user.
func SearchPosts ¶
func SearchPosts(u user.User) UserActionResponse
SearchPosts searches for posts by the given user.
func SearchUsers ¶
func SearchUsers(u user.User) UserActionResponse
SearchUsers searches for users by the given user.
func SignUp ¶
func SignUp(u user.User) UserActionResponse
SignUp signs up the given user to the server.
func UpdateProfileImage ¶
func UpdateProfileImage(u user.User) UserActionResponse
UpdateProfileImage uploads a new profile picture for the given user.
func ViewChannel ¶
func ViewChannel(u user.User) UserActionResponse
ViewChannel performs a view action in a random team/channel for the given user, which will mark all posts as read in the channel.
func ViewUser ¶
func ViewUser(u user.User) UserActionResponse
ViewUser simulates opening a random user profile for the given user.
type UserController ¶
type UserController interface { // Run starts the controller to begin performing the user actions. Run() // SetRate determines the relative speed in which user actions are performed // one after the other. A rate of 1.0 will run the actions in their usual // speed. A rate of 2.0 will slow down the actions by a factor of 2. SetRate(rate float64) error // Stop stops the controller. Stop() // InjectAction allows a named UserAction to be injected that is run once, at the next // available opportunity. These actions can be injected via the coordinator via // CLI or Rest API. InjectAction(actionID string) error }
UserController defines the behavior of a single user in a load test. It contains a very simple interface to just start/stop the actions performed by a user.
type UserError ¶
type UserError struct { // Err contains the error encountered while performing the action. Err error // Origin contains information about where the error originated. Origin string }
UserError is a custom error type used to report user errors.
func NewUserError ¶
NewUserError returns a new UserError object with the given error including location information.
type UserStatus ¶
type UserStatus struct { // ControllerId is the id of the controller. ControllerId int // User is the user who is performing the action. User user.User // Code is an integer code of the status returned. Code int // Info contains any extra information attached with the status. Info string // Warn contains any warnings that should be logged. Warn string // Custom error containing the error encountered and location information. Err error }
UserStatus contains the status of an action performed by a user.