control

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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 types.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

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

func AssetDigest(name string) ([sha256.Size]byte, error)

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

func AssetDir(name string) ([]string, error)

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

func AssetInfo(name string) (os.FileInfo, error)

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 AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func GenerateRandomSentences

func GenerateRandomSentences(count int) string

GenerateRandomSentences generates random string from test_text file.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RandomizeTeamDisplayName

func RandomizeTeamDisplayName(name string) string

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

func RandomizeUserName(name string) string

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

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

Types

type Config

type Config interface {
	// IsValid reports whether the Config is valid or not.
	// Returns an error if the validation fails.
	IsValid() error
}

Config is an abstraction over Config structures provided by UserController implementations.

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
	// Err contains an error when the action failed.
	Err error
}

UserActionResponse is a structure containing information about the result of running a UserAction.

func AddReaction

func AddReaction(u user.User) UserActionResponse

AddReaction adds a reaction by the user to a random post.

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 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 EditPost

func EditPost(u user.User) UserActionResponse

EditPost updates a post.

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 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 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 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()
}

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

func NewUserError(err error) *UserError

NewUserError returns a new UserError object with the given error including location information.

func (*UserError) Error

func (e *UserError) Error() string

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
	// Custom error containing the error encountered and location information.
	Err error
}

UserStatus contains the status of an action performed by a user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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