loadtest

package
v4.3.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 12 Imported by: 4

README

Load Test for Khan API

This application performs a random sequence of a specified amount of operations on a remote Khan API server, with a specified time interval between two consecutive operations. It also allows multiple goroutines for local concurrency (multiple concurrent random sequences). Usage: ../khan loadtest --help

Game parameters

Khan does not offer a route to get game information, so the membership level for application and the maximum number of members per clan are defined under the key loadtest.game within ../config/local.yaml:

loadtest:
  game:
    membershipLevel: "member"
    maxMembers: 50

Or setting the following environment variables:

KHAN_LOADTEST_GAME_MEMBERSHIPLEVEL (default: "")
KHAN_LOADTEST_GAME_MAXMEMBERS (default: 0)

Client parameters

Client parameters are defined under the key loadtest.client within ../config/local.yaml:

loadtest:
  client:
    url: "http://localhost:8080"
    gameid: "epiccardgame"

Or setting the following environment variables:

KHAN_LOADTEST_CLIENT_URL: URL including protocol (http/https) and port to remote Khan API server (default: "")
KHAN_LOADTEST_CLIENT_USER: basic auth username (default: "")
KHAN_LOADTEST_CLIENT_PASS: basic auth password (default: "")
KHAN_LOADTEST_CLIENT_GAMEID: game public ID (default: "")
KHAN_LOADTEST_CLIENT_TIMEOUT: nanoseconds to wait before timing out a request (default: 500 ms)
KHAN_LOADTEST_CLIENT_MAXIDLECONNS: max keep-alive connections to keep among all hosts (default: 100)
KHAN_LOADTEST_CLIENT_MAXIDLECONNSPERHOST: max keep-alive connections to keep per-host (default: 2)

Operation parameters

The amount of operations per sequence/goroutine, the time interval between two consecutive operations and the configurations for the operations themselves are defined under the key loadtest.operations within ../config/local.yaml:

loadtest:
  operations:
    amount: 1
    interval:
      duration: "1s"
    updateSharedClanScore:
      probability: 1
    createPlayer:
      probability: 1
    createClan:
      probability: 1
      autoJoin: "false"
    retrieveClan:
      probability: 1
    leaveClan:
      probability: 1
    transferClanOwnership:
      probability: 1
    applyForMembership:
      probability: 1
    selfDeleteMembership:
      probability: 1
    searchClans:
      probability: 1
    retrieveClansSummaries:
      probability: 1

Or setting the following environment variables:

KHAN_LOADTEST_OPERATIONS_AMOUNT (default: 0)
KHAN_LOADTEST_OPERATIONS_INTERVAL_DURATION (default: 0)
KHAN_LOADTEST_OPERATIONS_UPDATESHAREDCLANSCORE_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_CREATEPLAYER_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_CREATECLAN_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_CREATECLAN_AUTOJOIN (default: true)
KHAN_LOADTEST_OPERATIONS_RETRIEVECLAN_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_LEAVECLAN_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_TRANSFERCLANOWNERSHIP_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_APPLYFORMEMBERSHIP_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_SELFDELETEMEMBERSHIP_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_SEARCHCLANS_PROBABILITY (default: 1)
KHAN_LOADTEST_OPERATIONS_RETRIEVECLANSSUMMARIES_PROBABILITY (default: 1)

Operations with clans shared among different load test processes

Some operations are targeted to a set of clans that should be shared among different processes/goroutines. One of these operations is supposed to test the most common sequence of requests (updatePlayer, then getClan, then updateClan) in its most common use case, which is a number of different clients updating the score of a particular clan within its metadata field. Use the file ../config/loadTestSharedClans.yaml to specify the list of public IDs for shared clans:

clans:
- "clan1publicID"
- "clan2publicID"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRandomWords

func LoadRandomWords()

LoadRandomWords loads random words into memory for random clan name generation

Types

type App

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

App represents a load test application

func GetApp

func GetApp(configFile, sharedClansFile string, logger zap.Logger) *App

GetApp returns a new app

func (*App) Run

func (app *App) Run() error

Run executes the load test suite

type GenericError

type GenericError struct {
	Type        string
	Description string
}

GenericError represents a generic error

func (*GenericError) Error

func (e *GenericError) Error() string

type UnorderedStringMap

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

UnorderedStringMap represents a map from strings to interface{}s that can be looped using zero-based indexes with order based on previously executed Set/Remove operations

func NewUnorderedStringMap

func NewUnorderedStringMap() *UnorderedStringMap

NewUnorderedStringMap returns a new UnorderedStringMap

func (*UnorderedStringMap) Get

func (d *UnorderedStringMap) Get(key string) interface{}

Get returns the interface{} content for a key

func (*UnorderedStringMap) GetKey

func (d *UnorderedStringMap) GetKey(idx int) (string, error)

GetKey returns the string key at the specified integer index

func (*UnorderedStringMap) GetValue

func (d *UnorderedStringMap) GetValue(idx int) (interface{}, error)

GetValue returns the interface{} content at the specified integer index

func (*UnorderedStringMap) Has

func (d *UnorderedStringMap) Has(key string) bool

Has returns a boolean telling whether a string is in the key space or not

func (*UnorderedStringMap) Len

func (d *UnorderedStringMap) Len() int

Len returns the number of elements

func (*UnorderedStringMap) Remove

func (d *UnorderedStringMap) Remove(key string)

Remove removes a string key

func (*UnorderedStringMap) Set

func (d *UnorderedStringMap) Set(key string, content interface{})

Set maps a string to a value

type UnorderedStringMapOutOfBoundsError

type UnorderedStringMapOutOfBoundsError struct {
	Size  int
	Index int
}

UnorderedStringMapOutOfBoundsError represents the error when trying to read unexisting position in the key space

func (*UnorderedStringMapOutOfBoundsError) Error

Jump to

Keyboard shortcuts

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