framework

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package framework is a package helping setting up end-to-end testing across a Kubernetes cluster.

Index

Constants

View Source
const (
	AutoCleanupLabelKey   = "agones.dev/e2e-test-auto-cleanup"
	AutoCleanupLabelValue = "true"
)

special labels that can be put on pods to trigger automatic cleanup.

Variables

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

func FleetReadyCount(amount int32) func(*logrus.Entry, *agonesv1.Fleet) bool

FleetReadyCount returns the ready count in a fleet

func GetAllocation added in v0.12.0

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

func SendGameServerTCPToPort(gs *agonesv1.GameServer, portName string, msg string) (string, error)

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 SendTCP added in v1.9.0

func SendTCP(address, msg string) (string, error)

SendTCP sends a message to an address, and returns its reply if it returns one in 30 seconds

func TestLogger added in v1.19.0

func TestLogger(t *testing.T) *logrus.Entry

TestLogger returns the standard logger for helper functions.

Types

type Framework

type Framework struct {
	KubeClient      kubernetes.Interface
	AgonesClient    versioned.Interface
	GameServerImage string
	PullSecret      string
	StressTestLevel int
	PerfOutputDir   string
	Version         string
	Namespace       string
	CloudProduct    string
	WaitForState    time.Duration // default time to wait for state changes, may change based on cloud product.
}

Framework is a testing framework

func NewFromFlags added in v1.4.0

func NewFromFlags() (*Framework, error)

NewFromFlags sets up the testing framework with the standard command line flags.

func (*Framework) AssertFleetCondition added in v1.1.0

func (f *Framework) AssertFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(*logrus.Entry, *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) CleanUp

func (f *Framework) CleanUp(ns string) error

CleanUp Delete all Agones resources in a given namespace.

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(t *testing.T, 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

func (f *Framework) CreateNamespace(namespace string) error

CreateNamespace creates a namespace and a service account in the test cluster

func (*Framework) CycleAllocations added in v1.22.0

func (f *Framework) CycleAllocations(ctx context.Context, t *testing.T, flt *agonesv1.Fleet, period time.Duration, allocDuration time.Duration)

CycleAllocations repeatedly Allocates a GameServer in the Fleet (if one is available), once every specified period. Each Allocated GameServer gets deleted allocDuration after it was Allocated. GameServers will continue to be Allocated until a message is passed to the done channel.

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

func (f *Framework) DeleteNamespace(namespace string) error

DeleteNamespace deletes a namespace from the test cluster

func (*Framework) ListGameServersFromFleet added in v0.5.0

func (f *Framework) ListGameServersFromFleet(flt *agonesv1.Fleet) ([]agonesv1.GameServer, error)

ListGameServersFromFleet lists GameServers from a particular fleet

func (*Framework) LogEvents added in v1.19.0

func (f *Framework) LogEvents(t *testing.T, log *logrus.Entry, namespace string, objOrRef k8sruntime.Object)

LogEvents logs all the events for a given Kubernetes objects. Useful for debugging why something went wrong.

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) ScaleFleet added in v1.32.0

func (f *Framework) ScaleFleet(t *testing.T, log *logrus.Entry, flt *agonesv1.Fleet, replicas int32)

ScaleFleet will scale a Fleet with retries to a specified replica size.

func (*Framework) SendGameServerUDP added in v1.19.0

func (f *Framework) SendGameServerUDP(t *testing.T, 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 (*Framework) SendGameServerUDPToPort added in v1.19.0

func (f *Framework) SendGameServerUDPToPort(t *testing.T, gs *agonesv1.GameServer, portName string, msg string) (string, error)

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

func (*Framework) SendUDP added in v1.19.0

func (f *Framework) SendUDP(t *testing.T, address, msg string) (string, error)

SendUDP sends a message to an address, and returns its reply if it returns one in 10 seconds. Will retry 5 times, in case UDP packets drop.

func (*Framework) SkipOnCloudProduct added in v1.29.0

func (f *Framework) SkipOnCloudProduct(t *testing.T, product, reason string)

SkipOnCloudProduct skips the test if the e2e was invoked with --cloud-product=<product>.

func (*Framework) WaitForFleetAutoScalerCondition added in v0.10.0

func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, condition func(log *logrus.Entry, 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(*logrus.Entry, *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(t *testing.T, 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)

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.

Jump to

Keyboard shortcuts

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