benchmark

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package benchmark package provides tools to run progressive or independent benchmarks against teleport services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportLatencyProfile

func ExportLatencyProfile(path string, h *hdrhistogram.Histogram, ticks int32, valueScale float64) (string, error)

ExportLatencyProfile exports the latency profile and returns the path as a string if no errors

Types

type Config

type Config struct {
	// Rate is requests per second origination rate
	Rate int
	// MinimumWindow is the min duration
	MinimumWindow time.Duration
	// MinimumMeasurments is the min amount of requests
	MinimumMeasurements int
}

Config specifies benchmark requests to run

func (*Config) Benchmark

func (c *Config) Benchmark(ctx context.Context, tc *client.TeleportClient, suite Suite) (Result, error)

Benchmark connects to remote server and executes requests in parallel according to benchmark spec. It returns a benchmark result when completed. This is a blocking function that can be canceled via context argument.

type KubeExecBenchmark

type KubeExecBenchmark struct {
	// Namespace is the Kubernetes namespace to run the command against.
	Namespace string
	// PodName is the name of the pod to run the command against.
	PodName string
	// ContainerName is the name of the container to run the command against.
	ContainerName string
	// Command is the command to run.
	Command []string
	// Interactive turns on interactive sessions
	Interactive bool
}

KubeListBenchmark is a benchmark suite that runs successive kubectl exec against a Teleport Kubernetes proxy for a given duration and rate.

func (KubeExecBenchmark) BenchBuilder

BenchBuilder returns a WorkloadFunc for the given benchmark suite.

type KubeListBenchmark

type KubeListBenchmark struct {
	// Namespace is the Kubernetes namespace to run the command against.
	// If empty, it will include pods from all namespaces.
	Namespace string
}

KubeListBenchmark is a benchmark suite that runs successive kubectl get pods against a Teleport Kubernetes proxy for a given duration and rate.

func (KubeListBenchmark) BenchBuilder

BenchBuilder returns a WorkloadFunc for the given benchmark suite.

type Linear

type Linear struct {
	// LowerBound is the lower end of rps to execute
	LowerBound int
	// UpperBound is the upper end of rps to execute
	UpperBound int
	// Step is the amount of rps to increment by
	Step int
	// MinimumMeasurements is the minimum measurement a benchmark should execute
	MinimumMeasurements int
	// MinimumWindow is the minimum duration to run benchmark for
	MinimumWindow time.Duration
	// contains filtered or unexported fields
}

Linear generator

func (*Linear) GetBenchmark

func (lg *Linear) GetBenchmark() *Config

GetBenchmark returns the benchmark config for the current generation.

type Result

type Result struct {
	// RequestsOriginated is amount of requests originated
	RequestsOriginated int
	// RequestsFailed is amount of requests failed
	RequestsFailed int
	// Histogram holds the response duration values
	Histogram *hdrhistogram.Histogram
	// LastError contains last recorded error
	LastError error
	// Duration it takes for the whole benchmark to run
	Duration time.Duration
}

Result is a result of the benchmark

func Run

func Run(ctx context.Context, lg *Linear, host, login, proxy string, suite Suite) ([]Result, error)

Run is used to run the benchmarks, it is given a generator, command to run, a host, host login, and proxy. If host login or proxy is an empty string, it will use the default login

type SSHBenchmark

type SSHBenchmark struct {
	// Command to execute on the host.
	Command []string
	// Random whether to connect to a random host or not
	Random bool
}

SSHBenchmark is a benchmark suite that connects to the configured target hosts and executes the provided command.

func (SSHBenchmark) BenchBuilder

func (s SSHBenchmark) BenchBuilder(ctx context.Context, tc *client.TeleportClient) (WorkloadFunc, error)

BenchBuilder returns a WorkloadFunc for the given benchmark suite.

type Service

type Service string

Service is a the Teleport service to benchmark.

const (
	// SSHService is the SSH service
	SSHService Service = "ssh"
	// KubernetesService is the Kubernetes service
	KubernetesService Service = "kube"
)

type Suite

type Suite interface {
	// BenchBuilder returns a function that executes a single benchmark call.
	// The returned function is called in a loop until the context is canceled.
	BenchBuilder(context.Context, *client.TeleportClient) (WorkloadFunc, error)
}

Suite is an interface that defines a benchmark suite.

type WebSSHBenchmark

type WebSSHBenchmark struct {
	// Command to execute on the host.
	Command []string
	// Random whether to connect to a random host or not
	Random bool
	// Duration of the test used to determine if renewing web sessions
	// is necessary.
	Duration time.Duration
}

WebSSHBenchmark is a benchmark suite that connects to the configured target hosts via the web api and executes the provided command.

func (WebSSHBenchmark) BenchBuilder

BenchBuilder returns a WorkloadFunc for the given benchmark suite.

type WebSessionBenchmark

type WebSessionBenchmark struct {
	// Command to execute on the host.
	Command []string
	// Max number of sessions to have open at once.
	Max int
	// Duration of the test used to determine if renewing web sessions
	// is necessary.
	Duration time.Duration
	// contains filtered or unexported fields
}

WebSessionBenchmark is a benchmark suite that connects to the configured target hosts via the web api and executes the provided command.

func (*WebSessionBenchmark) BenchBuilder

BenchBuilder returns a WorkloadFunc for the given benchmark suite.

func (*WebSessionBenchmark) Config

type WorkloadFunc

type WorkloadFunc func(context.Context) error

WorkloadFunc is a function that executes a single benchmark call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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