Documentation
¶
Overview ¶
Package helpers provides performance assertion utilities for load testing.
Package helpers provides mock server implementations for load testing.
Package helpers provides Prometheus metrics collection for load testing.
Package helpers provides utility functions for load testing.
Index ¶
- func CheckSLO(slo PerformanceSLO, value float64) (bool, string)
- func ExtractRepoName(fullName string) string
- func GenerateNamespaceName(prefix string) string
- func GetCRDPath() string
- func NewNamespace(name string) *corev1.Namespace
- func Percentile(durations []time.Duration, percentile int) time.Duration
- func SanitizeName(name string) string
- func WriteHTMLReport(filename string, report PerformanceReport) error
- type ArgoCDAppStatus
- type ArgoCDHealthStatus
- type ArgoCDMockServer
- func (am *ArgoCDMockServer) AddApplication(cluster string, app *MockArgoCDApp)
- func (am *ArgoCDMockServer) CreateCluster(name string)
- func (am *ArgoCDMockServer) GetApplication(cluster, appName string) *MockArgoCDApp
- func (am *ArgoCDMockServer) GetRateLimitStats(cluster string) clusterStats
- func (am *ArgoCDMockServer) GetURL() string
- func (am *ArgoCDMockServer) Reset()
- func (am *ArgoCDMockServer) SetLatency(cluster string, latency time.Duration)
- func (am *ArgoCDMockServer) SetRateLimit(cluster string, tokensPerInterval int, interval time.Duration)
- func (am *ArgoCDMockServer) Start() error
- func (am *ArgoCDMockServer) Stop()
- func (am *ArgoCDMockServer) UpdateApplication(cluster string, app *MockArgoCDApp)
- type ArgoCDSyncStatus
- type GitHubMockServer
- type LatencyHistogram
- type MetricAnalysis
- type MetricsCollector
- func (mc *MetricsCollector) AddEndpoint(url string)
- func (mc *MetricsCollector) AnalyzeMetric(metricName string) MetricAnalysis
- func (mc *MetricsCollector) ExtractOperatorMetrics(snapshot *MetricsSnapshot) OperatorMetrics
- func (mc *MetricsCollector) GetLatestSnapshot() *MetricsSnapshot
- func (mc *MetricsCollector) GetMetricHistory(metricName string) []float64
- func (mc *MetricsCollector) ScrapeAll() error
- type MetricsSnapshot
- type MockArgoCDApp
- type MockPR
- type OperatorMetrics
- type PerformanceAssertion
- func AssertErrorRate(name string, errors, total int) *PerformanceAssertion
- func AssertGoroutines(name string, count int) *PerformanceAssertion
- func AssertLatency(name string, latency time.Duration) *PerformanceAssertion
- func AssertMemory(name string, bytes uint64) *PerformanceAssertion
- func AssertThroughput(name string, itemsProcessed int, duration time.Duration) *PerformanceAssertion
- func (pa *PerformanceAssertion) Failed() bool
- func (pa *PerformanceAssertion) Reason() string
- func (pa *PerformanceAssertion) ShouldBeAtLeast(min float64) *PerformanceAssertion
- func (pa *PerformanceAssertion) ShouldBeAtMost(max float64) *PerformanceAssertion
- func (pa *PerformanceAssertion) ShouldBeBetween(min, max float64) *PerformanceAssertion
- type PerformanceReport
- type PerformanceSLO
- type ResourceMonitor
- type ResourceSnapshot
- type SLOReport
- type SLOResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSLO ¶
func CheckSLO(slo PerformanceSLO, value float64) (bool, string)
CheckSLO checks if a value meets the SLO requirement.
func ExtractRepoName ¶
ExtractRepoName extracts the repository name from owner/repo format.
func GenerateNamespaceName ¶
GenerateNamespaceName creates a unique namespace name for testing. Format: <prefix>-<timestamp>-<random>
func GetCRDPath ¶
func GetCRDPath() string
GetCRDPath returns the path to the CRD directory for testing. Walks up the directory tree to find the project root.
func NewNamespace ¶
NewNamespace creates a Namespace object for testing.
func Percentile ¶
Percentile calculates the nth percentile of a duration slice. Returns zero duration if slice is empty.
func SanitizeName ¶
SanitizeName converts a string to a valid Kubernetes name. Replaces invalid characters with hyphens and lowercases.
func WriteHTMLReport ¶
func WriteHTMLReport(filename string, report PerformanceReport) error
WriteHTMLReport writes a performance report to an HTML file.
Types ¶
type ArgoCDAppStatus ¶
type ArgoCDAppStatus struct {
Sync ArgoCDSyncStatus
Health ArgoCDHealthStatus
}
ArgoCDAppStatus represents ArgoCD application status.
type ArgoCDHealthStatus ¶
type ArgoCDHealthStatus struct {
Status string
}
ArgoCDHealthStatus represents health status.
type ArgoCDMockServer ¶
type ArgoCDMockServer struct {
// contains filtered or unexported fields
}
ArgoCDMockServer is a high-performance mock ArgoCD API server for load testing.
func NewArgoCDMockServer ¶
func NewArgoCDMockServer() *ArgoCDMockServer
NewArgoCDMockServer creates a new mock ArgoCD API server.
func (*ArgoCDMockServer) AddApplication ¶
func (am *ArgoCDMockServer) AddApplication(cluster string, app *MockArgoCDApp)
AddApplication adds an application to a cluster.
func (*ArgoCDMockServer) CreateCluster ¶
func (am *ArgoCDMockServer) CreateCluster(name string)
CreateCluster creates a mock cluster.
func (*ArgoCDMockServer) GetApplication ¶
func (am *ArgoCDMockServer) GetApplication(cluster, appName string) *MockArgoCDApp
GetApplication retrieves an application from a cluster.
func (*ArgoCDMockServer) GetRateLimitStats ¶
func (am *ArgoCDMockServer) GetRateLimitStats(cluster string) clusterStats
GetRateLimitStats returns rate limiting statistics for a cluster.
func (*ArgoCDMockServer) GetURL ¶
func (am *ArgoCDMockServer) GetURL() string
GetURL returns the mock server URL.
func (*ArgoCDMockServer) Reset ¶
func (am *ArgoCDMockServer) Reset()
Reset clears all data in the mock server.
func (*ArgoCDMockServer) SetLatency ¶
func (am *ArgoCDMockServer) SetLatency(cluster string, latency time.Duration)
SetLatency configures simulated latency for a cluster.
func (*ArgoCDMockServer) SetRateLimit ¶
func (am *ArgoCDMockServer) SetRateLimit(cluster string, tokensPerInterval int, interval time.Duration)
SetRateLimit configures rate limiting for a cluster.
func (*ArgoCDMockServer) Start ¶
func (am *ArgoCDMockServer) Start() error
Start starts the mock ArgoCD API server.
func (*ArgoCDMockServer) Stop ¶
func (am *ArgoCDMockServer) Stop()
Stop stops the mock ArgoCD API server.
func (*ArgoCDMockServer) UpdateApplication ¶
func (am *ArgoCDMockServer) UpdateApplication(cluster string, app *MockArgoCDApp)
UpdateApplication updates an application in a cluster.
type ArgoCDSyncStatus ¶
ArgoCDSyncStatus represents sync status.
type GitHubMockServer ¶
type GitHubMockServer struct {
// contains filtered or unexported fields
}
GitHubMockServer is a high-performance mock GitHub API server for load testing.
func NewGitHubMockServer ¶
func NewGitHubMockServer() *GitHubMockServer
NewGitHubMockServer creates a new mock GitHub API server.
func (*GitHubMockServer) AddPR ¶
func (gm *GitHubMockServer) AddPR(repo string, pr *MockPR)
AddPR adds a PR to a repository.
func (*GitHubMockServer) CreateRepository ¶
func (gm *GitHubMockServer) CreateRepository(name string)
CreateRepository creates a mock repository.
func (*GitHubMockServer) GetURL ¶
func (gm *GitHubMockServer) GetURL() string
GetURL returns the mock server URL.
func (*GitHubMockServer) Reset ¶
func (gm *GitHubMockServer) Reset()
Reset clears all data in the mock server.
func (*GitHubMockServer) Start ¶
func (gm *GitHubMockServer) Start() error
Start starts the mock GitHub API server.
func (*GitHubMockServer) Stop ¶
func (gm *GitHubMockServer) Stop()
Stop stops the mock GitHub API server.
type LatencyHistogram ¶
LatencyHistogram represents a Prometheus histogram with calculated percentiles.
func ParseHTTPLatencyHistogram ¶
func ParseHTTPLatencyHistogram(snapshot *MetricsSnapshot, metricPrefix string) LatencyHistogram
ParseHTTPLatencyHistogram parses a Prometheus histogram and returns percentiles.
func (LatencyHistogram) Average ¶
func (lh LatencyHistogram) Average() time.Duration
Average returns the average latency from the histogram.
func (LatencyHistogram) Percentile ¶
func (lh LatencyHistogram) Percentile(percentile float64) time.Duration
Percentile calculates the specified percentile from the histogram.
type MetricAnalysis ¶
MetricAnalysis contains statistical analysis of a metric over time.
func (MetricAnalysis) String ¶
func (ma MetricAnalysis) String() string
String returns a string representation of the analysis.
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector scrapes and analyzes Prometheus metrics during load tests.
func NewMetricsCollector ¶
func NewMetricsCollector(registry *prometheus.Registry) *MetricsCollector
NewMetricsCollector creates a new metrics collector.
func (*MetricsCollector) AddEndpoint ¶
func (mc *MetricsCollector) AddEndpoint(url string)
AddEndpoint adds a Prometheus metrics endpoint to scrape.
func (*MetricsCollector) AnalyzeMetric ¶
func (mc *MetricsCollector) AnalyzeMetric(metricName string) MetricAnalysis
AnalyzeMetric analyzes a metric over time and returns statistics.
func (*MetricsCollector) ExtractOperatorMetrics ¶
func (mc *MetricsCollector) ExtractOperatorMetrics(snapshot *MetricsSnapshot) OperatorMetrics
ExtractOperatorMetrics extracts cd-operator specific metrics from a snapshot.
func (*MetricsCollector) GetLatestSnapshot ¶
func (mc *MetricsCollector) GetLatestSnapshot() *MetricsSnapshot
GetLatestSnapshot returns the most recent metrics snapshot.
func (*MetricsCollector) GetMetricHistory ¶
func (mc *MetricsCollector) GetMetricHistory(metricName string) []float64
GetMetricHistory returns the history of a specific metric.
func (*MetricsCollector) ScrapeAll ¶
func (mc *MetricsCollector) ScrapeAll() error
ScrapeAll scrapes all configured endpoints and stores a snapshot.
type MetricsSnapshot ¶
MetricsSnapshot captures Prometheus metrics at a point in time.
type MockArgoCDApp ¶
type MockArgoCDApp struct {
Name string
Status ArgoCDAppStatus
}
MockArgoCDApp represents a mock ArgoCD application for load testing.
func GenerateMockArgoCDApp ¶
func GenerateMockArgoCDApp(cluster, name, syncStatus, healthStatus string) *MockArgoCDApp
GenerateMockArgoCDApp creates a mock ArgoCD application.
type OperatorMetrics ¶
type OperatorMetrics struct {
PRDiscoveryTotal float64
PRQualificationTotal float64
PRMergeTotal float64
DriftDetectionTotal float64
GitHubAPICallsTotal float64
ArgoCDAPICallsTotal float64
WorkerPoolQueueDepth float64
ReconcileLoopDuration float64
}
OperatorMetrics contains key cd-operator metrics.
type PerformanceAssertion ¶
type PerformanceAssertion struct {
// contains filtered or unexported fields
}
PerformanceAssertion provides fluent API for asserting performance metrics.
func AssertErrorRate ¶
func AssertErrorRate(name string, errors, total int) *PerformanceAssertion
AssertErrorRate creates an error rate assertion.
func AssertGoroutines ¶
func AssertGoroutines(name string, count int) *PerformanceAssertion
AssertGoroutines creates a goroutine count assertion.
func AssertLatency ¶
func AssertLatency(name string, latency time.Duration) *PerformanceAssertion
AssertLatency creates a latency assertion.
func AssertMemory ¶
func AssertMemory(name string, bytes uint64) *PerformanceAssertion
AssertMemory creates a memory usage assertion.
func AssertThroughput ¶
func AssertThroughput(name string, itemsProcessed int, duration time.Duration) *PerformanceAssertion
AssertThroughput creates a throughput assertion.
func (*PerformanceAssertion) Failed ¶
func (pa *PerformanceAssertion) Failed() bool
Failed returns true if the assertion failed.
func (*PerformanceAssertion) Reason ¶
func (pa *PerformanceAssertion) Reason() string
Reason returns the failure reason.
func (*PerformanceAssertion) ShouldBeAtLeast ¶
func (pa *PerformanceAssertion) ShouldBeAtLeast(min float64) *PerformanceAssertion
ShouldBeAtLeast asserts the value is at least the minimum.
func (*PerformanceAssertion) ShouldBeAtMost ¶
func (pa *PerformanceAssertion) ShouldBeAtMost(max float64) *PerformanceAssertion
ShouldBeAtMost asserts the value is at most the maximum.
func (*PerformanceAssertion) ShouldBeBetween ¶
func (pa *PerformanceAssertion) ShouldBeBetween(min, max float64) *PerformanceAssertion
ShouldBeBetween asserts the value is between min and max.
type PerformanceReport ¶
type PerformanceReport struct {
TestName string
TotalItems int
Duration time.Duration
StartSnapshot ResourceSnapshot
EndSnapshot ResourceSnapshot
SuccessCount int
ErrorCount int
LatencyP50 time.Duration
LatencyP95 time.Duration
LatencyP99 time.Duration
}
PerformanceReport captures performance metrics for a load test.
type PerformanceSLO ¶
type PerformanceSLO struct {
Name string
Description string
Threshold float64
Unit string
Comparator string // "<=", ">=", "<", ">"
}
PerformanceSLO defines a Service Level Objective for load tests.
func DriftPipelineSLOs ¶
func DriftPipelineSLOs() []PerformanceSLO
DriftPipelineSLOs returns the default SLOs for drift pipeline load tests.
func PRPipelineSLOs ¶
func PRPipelineSLOs() []PerformanceSLO
PRPipelineSLOs returns the default SLOs for PR pipeline load tests.
type ResourceMonitor ¶
type ResourceMonitor struct {
// contains filtered or unexported fields
}
ResourceMonitor tracks resource usage over time during load tests.
func NewResourceMonitor ¶
func NewResourceMonitor(ctx context.Context) *ResourceMonitor
NewResourceMonitor creates a new resource monitor.
func (*ResourceMonitor) GenerateReport ¶
func (rm *ResourceMonitor) GenerateReport() PerformanceReport
GenerateReport generates a performance report from collected data.
func (*ResourceMonitor) Snapshot ¶
func (rm *ResourceMonitor) Snapshot() ResourceSnapshot
Snapshot returns the current resource usage snapshot.
func (*ResourceMonitor) Start ¶
func (rm *ResourceMonitor) Start() error
Start begins collecting resource metrics at regular intervals.
type ResourceSnapshot ¶
type ResourceSnapshot struct {
Timestamp time.Time
CPUUsagePercent float64
MemoryUsageBytes uint64
GoroutineCount int
}
ResourceSnapshot captures system resource usage at a point in time.
type SLOReport ¶
SLOReport summarizes SLO compliance for a load test.
func CheckAllSLOs ¶
func CheckAllSLOs(slos []PerformanceSLO, measurements map[string]float64) SLOReport
CheckAllSLOs checks all SLOs against measured values.