Documentation
¶
Overview ¶
Package loadtest simulates players that connect to a triebwerk server over a websocket or WebTransport, drive around with random human like inputs, shoot and ping. It records what every player receives so a run can be checked against expectations (see Report.Check). Used by cmd/loadtest and by the load test in the game package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
Name string
// contains filtered or unexported fields
}
Bot is one simulated player
type BotReport ¶
type BotReport struct {
Name string
// player ids the server assigned, one per connection
PlayerIDs []int
LostConnections int
RoundsStarted int
RoundsEnded int
StateMessages int
// time between the first and the last state broadcast of every round,
// summed up, used to compute the update rate
ActiveTime time.Duration
// longest gap between two state broadcasts within a round
MaxGap time.Duration
// most player entries in one state broadcast
MaxPlayersSeen int
// player ids that appeared twice in one broadcast
DuplicateIDs int
// own deaths and shots as reported by the server
Deaths int
Shots int
// scoreboards and kill events the server sent, and messages of those
// kinds that did not have the agreed layout
Scoreboards int
Kills int
BadMessages int
// answers to pings
Pongs int
// inputs sent, the number of the last one the server applied, snapshots
// that came after the server had the first input and those among them
// for which no input had arrived in time
InputsSent int
LastAck uint32
Acknowledged int
Starved int
// contains filtered or unexported fields
}
BotReport is what one simulated player saw during a run
func (BotReport) StarvedShare ¶
StarvedShare is the share of ticks for which the server had no input of this player
func (BotReport) UpdateRate ¶
UpdateRate is the number of state broadcasts per second during rounds
type Config ¶
type Config struct {
// Address of the server: ws://localhost:9090/echo for its websocket
// (wss:// with TLS), https://localhost:9090/wt for WebTransport. The
// certificate is not checked, the bots are a test tool.
URL string
Players int
// number of the first player's name (load-00), for two runs against one server
FirstName int
// Tokens of accounts on the master server: the first players say hello
// with one each and play as that account, the others are guests
Tokens []string
// how long every player stays, 0 runs until the context is cancelled
Duration time.Duration
// players that leave once after ReconnectAfter and rejoin 5 seconds later
Reconnect int
ReconnectAfter time.Duration
// players join at a random time within this window, default 3s
Stagger time.Duration
// OneKind makes every player drive the first kind of tank. By default
// the players take the kinds in turn, each in one of its paint jobs.
OneKind bool
// optional hooks, called from the bot goroutines: every snapshot a bot
// receives, and "start" and "end" of rounds with the tick they happened at
OnState func(snapshot protocol.SnapshotMessage)
OnEvent func(event string, tick uint32)
// progress output, default log.Printf, set to a no-op to silence
Logf func(format string, args ...interface{})
// how often progress is logged, 0 disables it
LogInterval time.Duration
}
Config of a load test run
type Expectations ¶
type Expectations struct {
// Scoreboard: every player has to receive names and scores
Scoreboard bool
// all of them in one match at the same time
Players int
// rounds every player has seen end
MinRounds int
// longest allowed pause between two state broadcasts within a round
MaxGap time.Duration
// state broadcasts per second every player has to receive, the server ticks at 30
MinUpdateRate float64
// Inputs: the server has to apply the inputs of every player and answer its pings
Inputs bool
MaxStarvedShare float64
}
Expectations a healthy server has to meet, zero values are not checked
func DefaultExpectations ¶
func DefaultExpectations(players int) Expectations
DefaultExpectations for a run with the given number of players
type Report ¶
Report of a whole run
func (Report) Check ¶
func (r Report) Check(e Expectations) []error
Check returns every violated expectation, nil if the run was healthy
type Runner ¶
Runner holds the bots of one run so they can be observed while it runs