lib

package
v1.2.11-prerelease4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvKeyRoot the environment variable key for runtime root dir
	EnvKeyRoot = "CADENCE_BENCH_ROOT"
	// EnvKeyConfigDir the environment variable key for config dir
	EnvKeyConfigDir = "CADENCE_BENCH_CONFIG_DIR"
	// EnvKeyEnvironment is the environment variable key for environment
	EnvKeyEnvironment = "CADENCE_BENCH_ENVIRONMENT"
	// EnvKeyAvailabilityZone is the environment variable key for AZ
	EnvKeyAvailabilityZone = "CADENCE_BENCH_AVAILABILITY_ZONE"
)
View Source
const (
	// CtxKeyRuntimeContext is the name of the context key whose value is the RuntimeContext
	CtxKeyRuntimeContext = ContextKey("ctxKeyRuntimeCtx")

	// CtxKeyCadenceClient is the name of the context key for the cadence client this cadence worker listens to
	CtxKeyCadenceClient = ContextKey("ctxKeyCadenceClient")
)
View Source
const (
	FailedCount = "failed"
)

counters go here

Variables

This section is empty.

Functions

func NewCadenceClients

func NewCadenceClients(runtime *RuntimeContext) (map[string]CadenceClient, error)

NewCadenceClients builds a CadenceClient for each domain from the runtimeContext

func RecordActivityEnd

func RecordActivityEnd(
	scope tally.Scope,
	sw tally.Stopwatch,
	err error,
)

RecordActivityEnd emits metrics at the end of an activity function

func RecordActivityStart

func RecordActivityStart(
	scope tally.Scope,
	name string,
	scheduledTimeNanos int64,
) (tally.Scope, tally.Stopwatch)

RecordActivityStart emits metrics at the beginning of an activity function

Types

type AggregatedTestConfig

type AggregatedTestConfig struct {
	Name             string                    `yaml:"name"`
	Description      string                    `yaml:"description"`
	TimeoutInSeconds int32                     `yaml:"timeoutInSeconds"`
	Basic            *BasicTestConfig          `yaml:"basic"`
	Signal           *SignalTestConfig         `yaml:"signal"`
	Timer            *TimerTestConfig          `yaml:"timer"`
	ConcurrentExec   *ConcurrentExecTestConfig `yaml:"concurrentExec"`
	Cancellation     *CancellationTestConfig   `yaml:"cancellation"`
}

AggregatedTestConfig contains the configration for a single test

type BasicTestConfig

type BasicTestConfig struct {
	// Launch workflow config
	UseBasicVisibilityValidation  bool    `yaml:"useBasicVisibilityValidation"`  // use basic(db based) visibility to verify the stress workflows, default false which requires advanced visibility on the server
	TotalLaunchCount              int     `yaml:"totalLaunchCount"`              // total number of stressWorkflows that started by the launchWorkflow
	RoutineCount                  int     `yaml:"routineCount"`                  // number of in-parallel launch activities that started by launchWorkflow, to start the stressWorkflows
	FailureThreshold              float64 `yaml:"failureThreshold"`              // the threshold of failed stressWorkflow for deciding whether or not the whole testSuite failed.
	MaxLauncherActivityRetryCount int     `yaml:"maxLauncherActivityRetryCount"` // the max retry on launcher activity to start stress workflows, default: 5
	ContextTimeoutInSeconds       int     `yaml:"contextTimeoutInSeconds"`       // RPC timeout inside activities(e.g. starting a stressWorkflow) default 3s
	WaitTimeBufferInSeconds       int     `yaml:"waitTimeBufferInSeconds"`       // buffer time in addition of ExecutionStartToCloseTimeoutInSeconds to wait for stressWorkflows before verification, default 300(5 minutes)
	// Stress workflow config
	ExecutionStartToCloseTimeoutInSeconds int  `yaml:"executionStartToCloseTimeoutInSeconds"` // StartToCloseTimeout of stressWorkflow, default 5m
	ChainSequence                         int  `yaml:"chainSequence"`                         // number of steps in the stressWorkflow
	ConcurrentCount                       int  `yaml:"concurrentCount"`                       // number of in-parallel activity(dummy activity only echo data) in a step of the stressWorkflow
	PayloadSizeBytes                      int  `yaml:"payloadSizeBytes"`                      // payloadSize of echo data in the dummy activity
	MinCadenceSleepInSeconds              int  `yaml:"minCadenceSleepInSeconds"`              // control sleep time between two steps in the stressWorkflow, actual sleep time = random(min,max), default: 0
	MaxCadenceSleepInSeconds              int  `yaml:"maxCadenceSleepInSeconds"`              // control sleep time between two steps in the stressWorkflow, actual sleep time = random(min,max), default: 0
	PanicStressWorkflow                   bool `yaml:"panicStressWorkflow"`                   // if true, stressWorkflow will always panic, default false
}

BasicTestConfig contains the configuration for running the Basic test scenario

type Bench

type Bench struct {
	Name         string   `yaml:"name"`
	Domains      []string `yaml:"domains"`
	NumTaskLists int      `yaml:"numTaskLists"`
}

Bench contains the configuration for bench tests

type Cadence

type Cadence struct {
	ServiceName     string `yaml:"service"`
	HostNameAndPort string `yaml:"host"`
}

Cadence contains the configuration for cadence service

type CadenceClient

type CadenceClient struct {
	client.Client
	// domainClient only exposes domain API
	client.DomainClient
	// this is the service needed to start the workers
	Service workflowserviceclient.Interface
}

CadenceClient is an abstraction on top of the cadence library client that serves as a union of all the client interfaces that the library exposes

func NewCadenceClientForDomain

func NewCadenceClientForDomain(
	runtime *RuntimeContext,
	domain string,
) (CadenceClient, error)

NewCadenceClientForDomain builds a CadenceClient for a specified domain based on runtimeContext

func (CadenceClient) CreateDomain

func (client CadenceClient) CreateDomain(name string, desc string, owner string) error

CreateDomain creates a cadence domain with the given name and description if the domain already exist, this method silently returns success

type CancellationTestConfig

type CancellationTestConfig struct {
	// TotalLaunchCount is the total number of workflow to start
	// note: make sure TotalLaunchCount mod Concurrency = 0 otherwise the validation for the test will fail
	TotalLaunchCount int `yaml:"totalLaunchCount"`

	// Concurrency specifies the concurrency for start and cancel workflow execution
	// approx. RPS = 10 * concurrency, approx. duration = totalLaunchCount / RPS
	Concurrency int `yaml:"concurrency"`

	// ContextTimeoutInSeconds specifies the context timeout for start and cancel workflow execution call
	// default: 3s
	ContextTimeoutInSeconds int `yaml:"contextTimeoutInSeconds"`
}

CancellationTestConfig contains the config for running workflow cancellation test

type ConcurrentExecTestConfig

type ConcurrentExecTestConfig struct {
	// TotalBatches is the total number of batches
	TotalBatches int `yaml:"totalBatches"`

	// Concurrency specifies the number of batches that will be run concurrently
	Concurrency int `yaml:"concurrency"`

	// BatchType specifies the type of batch, can be either "activity" or "childWorkflow", case insensitive
	BatchType string `yaml:"batchType"`

	// BatchSize specifies the number of activities or childWorkflows scheduled in a single decision batch
	BatchSize int `yaml:"batchSize"`

	// BatchPeriodInSeconds specifies the time interval between two set of batches (each set has #concurrency batches)
	BatchPeriodInSeconds int `yaml:"batchPeriodInSeconds"`

	// BatchMaxLatencyInSeconds specifies the max latency for scheduling/starting the activity or childWorkflow.
	// if latency is higher than this number, the corresponding activity or childWorkflow will be
	// considered as failed. This bench test is considered as success if:
	// avg(succeed activity or childWorkflow / batchSize) >= 0.99
	// If any of the activity or childWorkflow returns an error (for example, execution takes longer than BatchTimeoutInSeconds),
	// the bench test will fail immediately
	BatchMaxLatencyInSeconds int `yaml:"batchMaxLatencyInSeconds"`

	// BatchTimeoutInSeconds specifies the timeout for each batch execution
	BatchTimeoutInSeconds int `yaml:"batchTimeoutInSeconds"`
}

ConcurrentExecTestConfig contains the config for running concurrent execution test

type Config

type Config struct {
	Bench   Bench          `yaml:"bench"`
	Cadence Cadence        `yaml:"cadence"`
	Log     config.Logger  `yaml:"log"`
	Metrics config.Metrics `yaml:"metrics"`
}

Config contains the configuration for cadence bench

func (*Config) Validate

func (c *Config) Validate() error

type ContextKey

type ContextKey string

ContextKey is an alias for string, used as context key

type CronTestConfig

type CronTestConfig struct {
	TestSuites []TestSuiteConfig `yaml:"testSuites"`
}

CronTestConfig contains the configuration for running a set of testsuites in parallel based on a cron schedule

type ProcessSignalWorkflowConfig

type ProcessSignalWorkflowConfig struct {
	// CampaignCount is the number of local activities to be executed
	CampaignCount int `yaml:"campaignCount"`
	// ActionRate is probability that local activities result in actual action
	ActionRate float64 `yaml:"actionRate"`
	// Local activity failure rate
	FailureRate float64 `yaml:"failureRate"`
	// SignalCount before continue as new
	SignalBeforeContinueAsNew int   `yaml:"signalBeforeContinueAsNew"`
	EnableRollingWindow       bool  `yaml:"enableRollingWindow"`
	ScheduleTimeNano          int64 `yaml:"scheduleTimeNano"`
	MaxSignalDelayInSeconds   int   `yaml:"maxSignalDelayInSeconds"`
	MaxSignalDelayCount       int   `yaml:"maxSignalDelayCount"`
}

ProcessSignalWorkflowConfig is the parameters to process signal workflow

type Runnable

type Runnable interface {
	Run() error
}

Runnable is an interface for anything that exposes a Run method

type RuntimeContext

type RuntimeContext struct {
	Bench   Bench
	Cadence Cadence
	Logger  *zap.Logger
	Metrics tally.Scope
}

RuntimeContext contains all of the context information needed at cadence bench runtime

func NewRuntimeContext

func NewRuntimeContext(cfg *Config) (*RuntimeContext, error)

NewRuntimeContext builds a runtime context from the config

type SignalTestConfig

type SignalTestConfig struct {
	// LoaderCount defines how many loader activities
	LoaderCount int `yaml:"loaderCount"`
	// LoadTestWorkflowCount defines how many load test workflow in total
	LoadTestWorkflowCount int `yaml:"loadTestWorkflowCount"`
	// SignalCount is the number of signals per workflow
	SignalCount int `yaml:"signalCount"`
	// SignalDataSize is the size of signal data
	SignalDataSize int `yaml:"signalDataSize"`
	// RateLimit is per loader rate limit to hit cadence server
	RateLimit                         int     `yaml:"rateLimit"`
	WorkflowExecutionTimeoutInSeconds int     `yaml:"workflowExecutionTimeoutInSeconds"`
	DecisionTaskTimeoutInSeconds      int     `yaml:"decisionTaskTimeoutInSeconds"`
	FailureThreshold                  float64 `yaml:"failureThreshold"`
	ProcessSignalWorkflowConfig
}

SignalTestConfig is the parameters for signalLoadTestWorkflow

type TestSuiteConfig

type TestSuiteConfig struct {
	Name    string                 `yaml:"name"`
	Domain  string                 `yaml:"domain"`
	Configs []AggregatedTestConfig `yaml:"configs"`
}

TestSuiteConfig contains the configration for running a set of tests sequentially

type TimerTestConfig

type TimerTestConfig struct {
	// TotalTimerCount is the total number of timers to fire
	TotalTimerCount int `yaml:"totalTimerCount"`

	// TimerPerWorkflow is the number of timers in each workflow
	// workflow will continue execution and complete when the first timer fires
	// Set this number larger than one to test no-op timer case
	// TotalTimerCount / TimerPerWorkflow = total number of workflows
	TimerPerWorkflow int `yaml:"timerPerWorkflow"`

	// ShortestTimerDurationInSeconds after test start, the first timer will fire
	ShortestTimerDurationInSeconds int `yaml:"shortestTimerDurationInSeconds"`

	// LongestTimerDurationInSeconds after test start, the last timer will fire
	LongestTimerDurationInSeconds int `yaml:"longestTimerDurationInSeconds"`

	// MaxTimerLatencyInSeconds specifies the maximum latency for the first timer in the workflow
	// if a timer's latency is larger than this value, that timer will be considered as failed
	// if > 1% timer fire beyond this threshold, the test will fail
	MaxTimerLatencyInSeconds int `yaml:"maxTimerLatencyInSeconds"`

	// TimerTimeoutInSeconds specifies the duration beyond which a timer is considered as lost and fail the test
	TimerTimeoutInSeconds int `yaml:"timerTimeoutInSeconds"`

	// RoutineCount is the number of goroutines used for starting workflows
	// approx. RPS = 10 * RoutineCount
	// # of workflows = TotalTimerCount / TimerPerWorkflow
	// please make sure ShortestTimerDurationInSeconds > # of workflows / RPS, so that timer starts firing
	// after all workflows has been started.
	// please also make sure test timeout > LongestTimerDurationInSeconds + TimerTimeoutInSeconds
	RoutineCount int `yaml:"routineCount"`
}

TimerTestConfig contains the config for running timer bench test

type WorkflowMetricsProfile

type WorkflowMetricsProfile struct {
	Scope tally.Scope
	// contains filtered or unexported fields
}

WorkflowMetricsProfile is the state that's needed to record success/failed and latency metrics at the end of a workflow

func BeginWorkflow

func BeginWorkflow(ctx workflow.Context, wfType string, scheduledTimeNanos int64) (*WorkflowMetricsProfile, error)

BeginWorkflow executes the common steps involved in all the workflow functions It checks for workflow task version compatibility and also records the execution in m3. This function must be the first call in every workflow function Returns metrics scope on success, error on failure

func (*WorkflowMetricsProfile) End

func (profile *WorkflowMetricsProfile) End(err error) error

End records the elapsed time and reports the latency, success, failed counts to m3

Jump to

Keyboard shortcuts

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