performance

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

Iterative Performance Test

Setup

Run prometheus_in_docker.sh create, this will create a docker network so that the container can reach the metrics server, then starts a container of Prometheus reachable at localhost:9090.

Running

You can see all arguments with their default values by running go test -v ./... -help=true in this directory.

The PERF environment variable must be set to 1 in order for the test to start.

Examples

PERF=1 go test -v ./... -repos 1 -iterations 10,20,30 - run 3 iterations, creating 10, then 20, then 30 control PackageRevisions in 1 Repository

PERF=1 go test -v ./... -repos 3 -iterations 10,20,10,30 - run 4 iterations, creating 30 (10x3), then 60 (20x3), then 30 (10x3), then 90 (30*3) PackageRevisions across 3 Repositories

Teardown

Run prometheus_in_docker.sh clean, this will delete the container and the network.

Example queries for Prometheus

propose (k8s client update) latency averaged over 1s + actual PR count
rate(porch_operation_duration_ms_sum{operation="propose"}[1s])/rate(porch_operation_duration_ms_count{operation="propose"}[1s])
or
porch_package_revisions_count
all k8s client operation latency averaged over 1s for control packages + actual PR count
rate(porch_operation_duration_ms_sum{name=~"iterative-.*"}[1s])/rate(porch_operation_duration_ms_count{name=~"iterative-.*"}[1s])
or
porch_package_revisions_count

Documentation

Index

Constants

View Source
const (
	LabelKind      = "kind"
	LabelOperation = "operation"
	LabelName      = "name"
)

Variables

View Source
var (
	KindPackageRevision          = "PackageRevision"
	KindPackageRevisionResources = "PackageRevisionResources"
	KindRepository               = "Repository"
)

Functions

func KindOf

func KindOf(o any) string

func MeasureAndRecord

func MeasureAndRecord(op Operation, obj any, fn func())

func NameOf

func NameOf(o any) string

func RecordMetric

func RecordMetric(kind string, operation Operation, name string, duration float64)

RecordMetric records both duration and count for an operation

Types

type FullMetricsData

type FullMetricsData struct {
	ControlRevisionCount int
	IterationIndex       int

	CreateControlRevisionsTotal,
	CreateControlRevisionsAvg,
	DeleteControlRevisionsTotal,
	DeleteControlRevisionsAvg MyDuration

	IterationMetricsData `json:",inline"`
}

type IterationMetricsData

type IterationMetricsData struct {
	List,
	Create,
	UpdateResources,
	GetAfterResourceUpdate,
	Propose,
	GetAfterPropose,
	Approve,
	GetAfterPublish,
	DeleteProposed,
	GetAfterProposeDelete,
	Delete MyDuration
}

type MyDuration

type MyDuration time.Duration

MyDuration is a wrapper around time.Duration for specifically handling time in (float) milliseconds

func AvgDuration

func AvgDuration(total MyDuration, n int) MyDuration

func Measure

func Measure(f func()) MyDuration

func (MyDuration) MarshalJSON

func (d MyDuration) MarshalJSON() ([]byte, error)

func (MyDuration) Milliseconds

func (d MyDuration) Milliseconds() float64

type Operation

type Operation string
const (
	OperationGet            Operation = "get"
	OperationCreate         Operation = "create"
	OperationUpdate         Operation = "update"
	OperationUpdateApproval Operation = "update-approval"
	OperationPatch          Operation = "patch"
	OperationPropose        Operation = "propose"
	OperationPublish        Operation = "publish"
	OperationProposeDelete  Operation = "propose-delete"
	OperationDelete         Operation = "delete"
	OperationList           Operation = "list"
)

type PerformanceSuite

type PerformanceSuite struct {
	TestSuiteWithGit
	// contains filtered or unexported fields
}

func (*PerformanceSuite) CreateE

func (t *PerformanceSuite) CreateE(obj client.Object, opts ...client.CreateOption)

func (*PerformanceSuite) CreateF

func (t *PerformanceSuite) CreateF(obj client.Object, opts ...client.CreateOption)

func (*PerformanceSuite) CreatePackageDraftF

func (t *PerformanceSuite) CreatePackageDraftF(repository, packageName, workspace string) *porchapi.PackageRevision

copied, so the operation is recorded

func (*PerformanceSuite) DeleteE

func (t *PerformanceSuite) DeleteE(obj client.Object, opts ...client.DeleteOption)

func (*PerformanceSuite) DeleteF

func (t *PerformanceSuite) DeleteF(obj client.Object, opts ...client.DeleteOption)

func (*PerformanceSuite) DeleteL

func (t *PerformanceSuite) DeleteL(obj client.Object, opts ...client.DeleteOption)

func (*PerformanceSuite) GetE

func (t *PerformanceSuite) GetE(key client.ObjectKey, obj client.Object)

func (*PerformanceSuite) GetF

func (t *PerformanceSuite) GetF(key client.ObjectKey, obj client.Object)

func (*PerformanceSuite) ListE

func (t *PerformanceSuite) ListE(list client.ObjectList, opts ...client.ListOption)

func (*PerformanceSuite) ListF

func (t *PerformanceSuite) ListF(list client.ObjectList, opts ...client.ListOption)

func (*PerformanceSuite) PatchE

func (t *PerformanceSuite) PatchE(obj client.Object, patch client.Patch, opts ...client.PatchOption)

func (*PerformanceSuite) PatchF

func (t *PerformanceSuite) PatchF(obj client.Object, patch client.Patch, opts ...client.PatchOption)

func (*PerformanceSuite) ServeMetrics

func (t *PerformanceSuite) ServeMetrics()

func (*PerformanceSuite) SetupSuite

func (t *PerformanceSuite) SetupSuite()

func (*PerformanceSuite) ShutdownMetrics

func (t *PerformanceSuite) ShutdownMetrics()

ShutdownMetrics tries to gracefully shut down the metrics server

func (*PerformanceSuite) TearDownSuite

func (t *PerformanceSuite) TearDownSuite()

func (*PerformanceSuite) UpdateApprovalF

func (*PerformanceSuite) UpdateApprovalL

func (*PerformanceSuite) UpdateE

func (t *PerformanceSuite) UpdateE(obj client.Object, opts ...client.UpdateOption)

func (*PerformanceSuite) UpdateF

func (t *PerformanceSuite) UpdateF(obj client.Object, opts ...client.UpdateOption)

Jump to

Keyboard shortcuts

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