Versions in this module Expand all Collapse all v0 v0.1.1 Nov 26, 2024 v0.0.1 Nov 26, 2024 Changes in this version + const CallGroupLabel + const DefaultCallResultBufLen + const DefaultCallTimeout + const DefaultGenName + const DefaultLimitsCPU + const DefaultLimitsMemory + const DefaultRateLimitUnitDuration + const DefaultRequestsCPU + const DefaultRequestsMemory + const DefaultSetupTimeout + const DefaultStatsPollInterval + const DefaultStepChangePrecision + const DefaultTeardownTimeout + const K8sStatePollInterval + const LogLevelEnvVar + var CPUIdleThresholdPercentage = 20 + var DefaultBuildScript []byte + var DefaultDockerIgnorefile []byte + var DefaultDockerfile []byte + var ErrCallTimeout = errors.New("generator request call timeout") + var ErrInvalidLabels = errors.New("invalid Loki labels, labels should be [a-z][A-Z][0-9] and _") + var ErrInvalidScheduleType = errors.New("schedule type must be either of wasp.RPS, wasp.VU, use package constants") + var ErrInvalidSegmentDuration = errors.New("SegmentDuration must be defined") + var ErrNoCfg = errors.New("config is nil") + var ErrNoGun = errors.New("rps load scheduleSegments selected but gun implementation is nil") + var ErrNoImpl = errors.New("either \"gun\" or \"vu\" implementation must provided") + var ErrNoJobs = errors.New(...) + var ErrNoNamespace = errors.New("namespace is empty") + var ErrNoSchedule = errors.New("no schedule segments were provided") + var ErrNoVU = errors.New("vu load scheduleSegments selected but vu implementation is nil") + var ErrSetup = errors.New("generator request setup error") + var ErrSetupTimeout = errors.New("generator request setup timeout") + var ErrStartFrom = errors.New("from must be > 0") + var ErrTeardown = errors.New("generator request teardown error") + var ErrTeardownTimeout = errors.New("generator request teardown timeout") + var MEMFreeThresholdPercentage = 0 + var ResourcesThresholdCheckInterval = 5 * time.Second + func CPUCheckLoop() + func CheckDashboardAlerts(grafanaClient *grafana.Client, from, to time.Time, dashboardUID string) ([]grafana.Annotation, error) + func ExecCmd(command string) error + func ExecCmdWithStreamFunc(command string, outputFunction func(string)) error + func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error) + func GetLogger(t *testing.T, componentName string) zerolog.Logger + func LabelsMapToModel(m map[string]string) model.LabelSet + type AlertChecker struct + RequirementLabelKey string + T *testing.T + func NewAlertChecker(t *testing.T) *AlertChecker + func (m *AlertChecker) AnyAlerts(dashboardUUID, requirementLabelValue string) ([]grafana.AlertGroupsResponse, error) + type ClusterConfig struct + BuildCtxPath string + BuildScriptPath string + ChartPath string + DockerCmdExecPath string + DockerIgnoreFilePath string + DockerfilePath string + HelmDeployTimeoutSec string + HelmValues map[string]string + ImageTag string + KeepJobs bool + Namespace string + RegistryName string + RepoName string + UpdateImage bool + func (m *ClusterConfig) Defaults() error + func (m *ClusterConfig) Validate() (err error) + type ClusterProfile struct + Cancel context.CancelFunc + Ctx context.Context + func NewClusterProfile(cfg *ClusterConfig) (*ClusterProfile, error) + func (m *ClusterProfile) Run() error + type Config struct + CallResultBufLen int + CallTimeout time.Duration + FailOnErr bool + GenName string + Gun Gun + Labels map[string]string + LoadType ScheduleType + Logger zerolog.Logger + LokiConfig *LokiConfig + RateLimitUnitDuration time.Duration + SamplerConfig *SamplerConfig + Schedule []*Segment + SetupTimeout time.Duration + SharedData interface{} + StatsPollInterval time.Duration + T *testing.T + TeardownTimeout time.Duration + VU VirtualUser + func (lgc *Config) Validate() error + type Generator struct + Cfg *Config + Log zerolog.Logger + Responses *Responses + ResponsesChan chan *Response + ResponsesCtx context.Context + ResponsesWaitGroup *sync.WaitGroup + func NewGenerator(cfg *Config) (*Generator, error) + func (g *Generator) Errors() []string + func (g *Generator) GetData() *ResponseData + func (g *Generator) InputSharedData() interface{} + func (g *Generator) Pause() + func (g *Generator) Resume() + func (g *Generator) Run(wait bool) (interface{}, bool) + func (g *Generator) Stats() *Stats + func (g *Generator) StatsJSON() map[string]interface{} + func (g *Generator) Stop() (interface{}, bool) + func (g *Generator) Wait() (interface{}, bool) + type GrafanaOpts struct + AnnotateDashboardUID string + CheckDashboardAlertsAfterRun string + GrafanaToken string + GrafanaURL string + WaitBeforeAlertCheck time.Duration + type Gun interface + Call func(l *Generator) *Response + type HTTPMockServer struct + Sleep time.Duration + func NewHTTPMockServer(cfg *HTTPMockServerConfig) *HTTPMockServer + func (s *HTTPMockServer) Run() + func (s *HTTPMockServer) URL() string + type HTTPMockServerConfig struct + FirstAPIHTTPCode int + FirstAPILatency time.Duration + SecondAPIHTTPCode int + SecondAPILatency time.Duration + type K8sClient struct + ClientSet *kubernetes.Clientset + RESTConfig *rest.Config + func NewK8sClient() *K8sClient + func (m *K8sClient) TrackJobs(ctx context.Context, nsName, syncLabel string, jobNum int, keepJobs bool) error + type LokiClient struct + func NewLokiClient(extCfg *LokiConfig) (*LokiClient, error) + func (m *LokiClient) Handle(ls model.LabelSet, t time.Time, s string) error + func (m *LokiClient) HandleStruct(ls model.LabelSet, t time.Time, st interface{}) error + func (m *LokiClient) StopNow() + type LokiConfig struct + BackoffConfig backoff.Config + BasicAuth string + BatchSize int + BatchWait time.Duration + DropRateLimitedBatches bool + ExposePrometheusMetrics bool + Headers map[string]string + MaxErrors int + MaxLineSize int + MaxLineSizeTruncate bool + MaxStreams int + TenantID string + Timeout time.Duration + Token string + URL string + func DefaultLokiConfig() *LokiConfig + func NewEnvLokiConfig() *LokiConfig + func NewLokiConfig(endpoint *string, tenant *string, basicAuth *string, token *string) *LokiConfig + type LokiLogWrapper struct + MaxErrors int + func NewLokiLogWrapper(maxErrors int) *LokiLogWrapper + func (m *LokiLogWrapper) Log(kvars ...interface{}) error + func (m *LokiLogWrapper) SetClient(c *LokiClient) + type MockGun struct + Data []string + func NewMockGun(cfg *MockGunConfig) *MockGun + func (m *MockGun) Call(l *Generator) *Response + type MockGunConfig struct + CallSleep time.Duration + FailRatio int + InternalStop bool + TimeoutRatio int + type MockHTTPGun struct + Data []string + func NewHTTPMockGun(cfg *MockHTTPGunConfig) *MockHTTPGun + func (m *MockHTTPGun) Call(l *Generator) *Response + type MockHTTPGunConfig struct + TargetURL string + type MockVirtualUser struct + Data []string + func NewMockVU(cfg *MockVirtualUserConfig) *MockVirtualUser + func (m *MockVirtualUser) Call(l *Generator) + func (m *MockVirtualUser) Clone(_ *Generator) VirtualUser + func (m *MockVirtualUser) Setup(_ *Generator) error + func (m *MockVirtualUser) Teardown(_ *Generator) error + type MockVirtualUserConfig struct + CallSleep time.Duration + FailRatio int + SetupFailure bool + SetupSleep time.Duration + TeardownFailure bool + TeardownSleep time.Duration + TimeoutRatio int + type MockWSServer struct + Logf func(f string, v ...interface{}) + Sleep time.Duration + func (s MockWSServer) ServeHTTP(w http.ResponseWriter, r *http.Request) + type Profile struct + Generators []*Generator + ProfileID string + func NewProfile() *Profile + func (m *Profile) Add(g *Generator, err error) *Profile + func (m *Profile) Pause() + func (m *Profile) Resume() + func (m *Profile) Run(wait bool) (*Profile, error) + func (m *Profile) Wait() + func (m *Profile) WithGrafana(opts *GrafanaOpts) *Profile + type Response struct + Data interface{} + Duration time.Duration + Error string + Failed bool + FinishedAt *time.Time + Group string + Path string + StartedAt *time.Time + StatusCode string + Timeout bool + type ResponseData struct + FailResponses *SliceBuffer[*Response] + OKData *SliceBuffer[any] + OKResponses *SliceBuffer[*Response] + type Responses struct + func NewResponses(ch chan *Response) *Responses + func (m *Responses) Err(r *resty.Response, group string, err error) + func (m *Responses) OK(r *resty.Response, group string) + type Sampler struct + func NewSampler(cfg *SamplerConfig) *Sampler + func (m *Sampler) ShouldRecord(cr *Response, s *Stats) bool + type SamplerConfig struct + SuccessfulCallResultRecordRatio int + type ScheduleType string + const RPS + const VU + type Segment struct + Duration time.Duration + From int64 + func Combine(segs ...[]*Segment) []*Segment + func CombineAndRepeat(times int, segs ...[]*Segment) []*Segment + func Plain(from int64, duration time.Duration) []*Segment + func Steps(from, increase int64, steps int, duration time.Duration) []*Segment + func (ls *Segment) Validate() error + type SliceBuffer struct + Capacity int + Data []T + Idx int + func NewSliceBuffer[T any](cap int) *SliceBuffer[T] + func (m *SliceBuffer[T]) Append(s T) + type Stats struct + CallTimeout atomic.Int64 + CurrentRPS atomic.Int64 + CurrentSegment atomic.Int64 + CurrentTimeUnit int64 + CurrentVUs atomic.Int64 + Duration int64 + Failed atomic.Int64 + LastSegment atomic.Int64 + RunFailed atomic.Bool + RunPaused atomic.Bool + RunStopped atomic.Bool + SamplesRecorded atomic.Int64 + SamplesSkipped atomic.Int64 + Success atomic.Int64 + type VUControl struct + func NewVUControl() *VUControl + func (m *VUControl) Stop(_ *Generator) + func (m *VUControl) StopChan() chan struct{} + type VirtualUser interface + Call func(l *Generator) + Clone func(l *Generator) VirtualUser + Setup func(l *Generator) error + Stop func(l *Generator) + StopChan func() chan struct{} + Teardown func(l *Generator) error + type WSMockVU struct + Data []string + func NewWSMockVU(cfg *WSMockVUConfig) *WSMockVU + func (m *WSMockVU) Call(l *Generator) + func (m *WSMockVU) Clone(_ *Generator) VirtualUser + func (m *WSMockVU) Setup(l *Generator) error + func (m *WSMockVU) Teardown(_ *Generator) error + type WSMockVUConfig struct + TargetURl string