Documentation ¶
Overview ¶
Package framework is a package helping setting up end-to-end testing across a Kubernetes cluster.
Index ¶
- Constants
- Variables
- func FleetReadyCount(amount int32) func(fleet *agonesv1.Fleet) bool
- func GetAllocation(f *agonesv1.Fleet) *allocationv1.GameServerAllocation
- func ParseTestFlags() error
- func SendGameServerTCP(gs *agonesv1.GameServer, msg string) (string, error)
- func SendGameServerTCPToPort(gs *agonesv1.GameServer, portName string, msg string) (string, error)
- func SendGameServerUDP(gs *agonesv1.GameServer, msg string) (string, error)
- func SendGameServerUDPToPort(gs *agonesv1.GameServer, portName string, msg string) (string, error)
- func SendTCP(address, msg string) (string, error)
- func SendUDP(address, msg string) (string, error)
- type Framework
- func (f *Framework) AssertFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(fleet *agonesv1.Fleet) bool)
- func (f *Framework) CleanUp(ns string) error
- func (f *Framework) CreateAndApplyAllocation(t *testing.T, flt *agonesv1.Fleet) *allocationv1.GameServerAllocation
- func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *agonesv1.GameServer) (*agonesv1.GameServer, error)
- func (f *Framework) CreateNamespace(namespace string) error
- func (f *Framework) DefaultGameServer(namespace string) *agonesv1.GameServer
- func (f *Framework) DeleteNamespace(namespace string) error
- func (f *Framework) ListGameServersFromFleet(flt *agonesv1.Fleet) ([]agonesv1.GameServer, error)
- func (f *Framework) NewStatsCollector(name, version string) *StatsCollector
- func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, ...)
- func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(fleet *agonesv1.Fleet) bool) error
- func (f *Framework) WaitForFleetGameServerListCondition(flt *agonesv1.Fleet, cond func(servers []agonesv1.GameServer) bool) error
- func (f *Framework) WaitForFleetGameServersCondition(flt *agonesv1.Fleet, cond func(server *agonesv1.GameServer) bool) error
- func (f *Framework) WaitForGameServerState(gs *agonesv1.GameServer, state agonesv1.GameServerState, timeout time.Duration) (*agonesv1.GameServer, error)
- func (f *Framework) WaitForGameServerStateWithLogger(logger *logrus.Entry, gs *agonesv1.GameServer, state agonesv1.GameServerState, ...) (*agonesv1.GameServer, error)
- type StatsCollector
Constants ¶
const ( AutoCleanupLabelKey = "agones.dev/e2e-test-auto-cleanup" AutoCleanupLabelValue = "true" )
special labels that can be put on pods to trigger automatic cleanup.
Variables ¶
var NamespaceLabel = map[string]string{"owner": "e2e-test"}
NamespaceLabel is the label that is put on all namespaces that are created for e2e tests.
Functions ¶
func FleetReadyCount ¶ added in v0.5.0
FleetReadyCount returns the ready count in a fleet
func GetAllocation ¶ added in v0.12.0
func GetAllocation(f *agonesv1.Fleet) *allocationv1.GameServerAllocation
GetAllocation returns a GameServerAllocation that is looking for a Ready GameServer from this fleet.
func ParseTestFlags ¶ added in v1.6.0
func ParseTestFlags() error
ParseTestFlags Parses go test flags separately because pflag package ignores flags with '-test.' prefix Related issues: https://github.com/spf13/pflag/issues/63 https://github.com/spf13/pflag/issues/238
func SendGameServerTCP ¶ added in v1.9.0
func SendGameServerTCP(gs *agonesv1.GameServer, msg string) (string, error)
SendGameServerTCP sends a message to a gameserver and returns its reply finds the first tcp port from the spec to send the message to, returns error if no Ports were allocated
func SendGameServerTCPToPort ¶ added in v1.9.0
SendGameServerTCPToPort sends a message to a gameserver at the named port and returns its reply returns error if no Ports were allocated or a port of the specified name doesn't exist
func SendGameServerUDP ¶ added in v0.9.0
func SendGameServerUDP(gs *agonesv1.GameServer, msg string) (string, error)
SendGameServerUDP sends a message to a gameserver and returns its reply finds the first udp port from the spec to send the message to, returns error if no Ports were allocated
func SendGameServerUDPToPort ¶ added in v1.5.0
SendGameServerUDPToPort sends a message to a gameserver at the named port and returns its reply returns error if no Ports were allocated or a port of the specified name doesn't exist
Types ¶
type Framework ¶
type Framework struct { KubeClient kubernetes.Interface AgonesClient versioned.Interface GameServerImage string PullSecret string StressTestLevel int PerfOutputDir string Version string Namespace string }
Framework is a testing framework
func New ¶
New setups a testing framework using a kubeconfig path and the game server image to use for testing.
func NewFromFlags ¶ added in v1.4.0
NewFromFlags sets up the testing framework with the standard command line flags.
func NewWithRates ¶ added in v1.5.0
NewWithRates setups a testing framework using a kubeconfig path and the game server image to use for load testing with QPS and Burst overwrites.
func (*Framework) AssertFleetCondition ¶ added in v1.1.0
func (f *Framework) AssertFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(fleet *agonesv1.Fleet) bool)
AssertFleetCondition waits for the Fleet to be in a specific condition or fails the test if the condition can't be met in 5 minutes.
func (*Framework) CreateAndApplyAllocation ¶ added in v0.12.0
func (f *Framework) CreateAndApplyAllocation(t *testing.T, flt *agonesv1.Fleet) *allocationv1.GameServerAllocation
CreateAndApplyAllocation creates and applies an Allocation to a Fleet
func (*Framework) CreateGameServerAndWaitUntilReady ¶
func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *agonesv1.GameServer) (*agonesv1.GameServer, error)
CreateGameServerAndWaitUntilReady Creates a GameServer and wait for its state to become ready.
func (*Framework) CreateNamespace ¶ added in v1.1.0
CreateNamespace creates a namespace and a service account in the test cluster
func (*Framework) DefaultGameServer ¶ added in v1.4.0
func (f *Framework) DefaultGameServer(namespace string) *agonesv1.GameServer
DefaultGameServer provides a default GameServer fixture, based on parameters passed to the Test Framework.
func (*Framework) DeleteNamespace ¶ added in v1.1.0
DeleteNamespace deletes a namespace from the test cluster
func (*Framework) ListGameServersFromFleet ¶ added in v0.5.0
ListGameServersFromFleet lists GameServers from a particular fleet
func (*Framework) NewStatsCollector ¶ added in v0.9.0
func (f *Framework) NewStatsCollector(name, version string) *StatsCollector
NewStatsCollector returns new instance of statistics collector, which can be used to emit performance statistics for load tests and stress tests.
func (*Framework) WaitForFleetAutoScalerCondition ¶ added in v0.10.0
func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, condition func(fas *autoscaling.FleetAutoscaler) bool)
WaitForFleetAutoScalerCondition waits for the FleetAutoscaler to be in a specific condition or fails the test if the condition can't be met in 2 minutes. nolint: dupl
func (*Framework) WaitForFleetCondition ¶ added in v0.5.0
func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(fleet *agonesv1.Fleet) bool) error
WaitForFleetCondition waits for the Fleet to be in a specific condition or returns an error if the condition can't be met in 5 minutes.
func (*Framework) WaitForFleetGameServerListCondition ¶ added in v0.9.0
func (f *Framework) WaitForFleetGameServerListCondition(flt *agonesv1.Fleet, cond func(servers []agonesv1.GameServer) bool) error
WaitForFleetGameServerListCondition waits for the list of GameServers to match a condition specified by a callback and the size of GameServers to match fleet's Spec.Replicas.
func (*Framework) WaitForFleetGameServersCondition ¶ added in v0.5.0
func (f *Framework) WaitForFleetGameServersCondition(flt *agonesv1.Fleet, cond func(server *agonesv1.GameServer) bool) error
WaitForFleetGameServersCondition waits for all GameServers for a given fleet to match a condition specified by a callback.
func (*Framework) WaitForGameServerState ¶
func (f *Framework) WaitForGameServerState(gs *agonesv1.GameServer, state agonesv1.GameServerState, timeout time.Duration) (*agonesv1.GameServer, error)
WaitForGameServerState Waits untils the gameserver reach a given state before the timeout expires (with a default logger)
func (*Framework) WaitForGameServerStateWithLogger ¶ added in v1.5.0
func (f *Framework) WaitForGameServerStateWithLogger(logger *logrus.Entry, gs *agonesv1.GameServer, state agonesv1.GameServerState, timeout time.Duration) (*agonesv1.GameServer, error)
WaitForGameServerStateWithLogger Waits untils the gameserver reach a given state before the timeout expires, and logs against a give logger (usually useful to log the name of the test with the checks)
type StatsCollector ¶ added in v0.9.0
type StatsCollector struct {
// contains filtered or unexported fields
}
StatsCollector collects latency and throughput counters. The ReportDuration() method is safe for concurrent use by multiple goroutines.
func (*StatsCollector) Report ¶ added in v0.9.0
func (p *StatsCollector) Report()
Report outputs performance report to log.
func (*StatsCollector) ReportDuration ¶ added in v0.9.0
func (p *StatsCollector) ReportDuration(d time.Duration, err error)
ReportDuration adds a single time measurement.