loadgen

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultIterations = 10
View Source
const DefaultMaxConcurrent = 10

Variables

This section is empty.

Functions

func GetScenarios

func GetScenarios() map[string]*Scenario

GetScenarios gets a copy of registered scenarios

func MustRegisterScenario

func MustRegisterScenario(scenario Scenario)

MustRegisterScenario registers a scenario in the global static registry. Panics if registration fails. The file name of the caller is be used as the scenario name.

func TaskQueueForRun

func TaskQueueForRun(scenarioName, runID string) string

TaskQueueForRun returns a default task queue name for the given scenario name and run ID.

func VisibilityCountIsEventually

func VisibilityCountIsEventually(
	ctx context.Context,
	client client.Client,
	request *workflowservice.CountWorkflowExecutionsRequest,
	expectedCount int,
	waitAtMost time.Duration,
) error

VisibilityCountIsEventually ensures that some visibility query count matches the provided expected number within the provided time limit.

Types

type Executor

type Executor interface {
	// Run the scenario
	Run(context.Context, ScenarioInfo) error
}

Executor for a scenario.

type ExecutorFunc

type ExecutorFunc func(context.Context, ScenarioInfo) error

ExecutorFunc is an Executor implementation for a function

func (ExecutorFunc) Run

func (e ExecutorFunc) Run(ctx context.Context, info ScenarioInfo) error

Run implements [Executor.Run].

type FileOrArgs

type FileOrArgs struct {
	// If set, the file to load the input from
	FilePath string
	// If set, args to pass to the Rust input generator. Do not specify output args, as it is
	// expected that the proto output is written to stdout (the default).
	Args []string
}

type FuzzExecutor

type FuzzExecutor struct {
	// Must be specified, called once on startup, and determines how TestInputs will be used for
	// iterations of the scenario. If a file is specified, it will be loaded and used as the input
	// for every iteration. If generator args are specified, it will be invoked once per iteration
	// and those inputs will be saved and then fed out to each iteration.
	InitInputs func(context.Context, ScenarioInfo) FileOrArgs

	DefaultConfiguration RunConfiguration
}

func (FuzzExecutor) GetDefaultConfiguration

func (k FuzzExecutor) GetDefaultConfiguration() RunConfiguration

func (FuzzExecutor) Run

func (k FuzzExecutor) Run(ctx context.Context, info ScenarioInfo) error

type GenericExecutor

type GenericExecutor struct {
	// Function to execute a single iteration of this scenario
	Execute func(context.Context, *Run) error
	// Default configuration if any.
	DefaultConfiguration RunConfiguration
}

func (*GenericExecutor) GetDefaultConfiguration

func (g *GenericExecutor) GetDefaultConfiguration() RunConfiguration

func (*GenericExecutor) Run

func (g *GenericExecutor) Run(ctx context.Context, info ScenarioInfo) error

type HasDefaultConfiguration

type HasDefaultConfiguration interface {
	GetDefaultConfiguration() RunConfiguration
}

HasDefaultConfiguration is an interface executors can implement to show their default configuration.

type KitchenSinkExecutor

type KitchenSinkExecutor struct {
	TestInput *kitchensink.TestInput

	// Called once on start
	PrepareTestInput func(context.Context, ScenarioInfo, *kitchensink.TestInput) error

	// Called for each iteration. TestInput is copied entirely into KitchenSinkWorkflowOptions on
	// each iteration.
	UpdateWorkflowOptions func(context.Context, *Run, *KitchenSinkWorkflowOptions) error

	DefaultConfiguration RunConfiguration
}

func (KitchenSinkExecutor) GetDefaultConfiguration

func (k KitchenSinkExecutor) GetDefaultConfiguration() RunConfiguration

func (KitchenSinkExecutor) Run

type KitchenSinkWorkflowOptions

type KitchenSinkWorkflowOptions struct {
	Params       *kitchensink.TestInput
	StartOptions client.StartWorkflowOptions
}

type Run

type Run struct {
	// Do not mutate this, this is shared across the entire scenario
	*ScenarioInfo
	// Each run should have a unique iteration.
	Iteration int
	Logger    *zap.SugaredLogger
}

Run represents an individual scenario run (many may be in a single instance (of possibly many) of a scenario).

func (*Run) DefaultKitchenSinkWorkflowOptions

func (r *Run) DefaultKitchenSinkWorkflowOptions() KitchenSinkWorkflowOptions

DefaultKitchenSinkWorkflowOptions gets the default kitchen sink workflow info.

func (*Run) DefaultStartWorkflowOptions

func (r *Run) DefaultStartWorkflowOptions() client.StartWorkflowOptions

DefaultStartWorkflowOptions gets default start workflow info.

func (*Run) ExecuteAnyWorkflow

func (r *Run) ExecuteAnyWorkflow(ctx context.Context, options client.StartWorkflowOptions, workflow interface{}, valuePtr interface{}, args ...interface{}) error

ExecuteAnyWorkflow wraps calls to the client executing workflows to include some logging, returning an error if the execution fails.

func (*Run) ExecuteKitchenSinkWorkflow

func (r *Run) ExecuteKitchenSinkWorkflow(ctx context.Context, options *KitchenSinkWorkflowOptions) error

ExecuteKitchenSinkWorkflow starts the generic "kitchen sink" workflow and waits for its completion ignoring its result. Concurrently it will perform any client actions specified in kitchensink.TestInput.ClientSequence

func (*Run) TaskQueue

func (r *Run) TaskQueue() string

type RunConfiguration

type RunConfiguration struct {
	// Number of iterations to run of this scenario (mutually exclusive with Duration).
	Iterations int
	// Duration limit of this scenario (mutually exclusive with Iterations). If
	// neither iterations nor duration is set, default is DefaultIterations.
	Duration time.Duration
	// Maximum number of instances of the Execute method to run concurrently.
	// Default is DefaultMaxConcurrent.
	MaxConcurrent int
}

func (*RunConfiguration) ApplyDefaults

func (r *RunConfiguration) ApplyDefaults()

type Scenario

type Scenario struct {
	Description string
	Executor    Executor
}

func GetScenario

func GetScenario(name string) *Scenario

GetScenario gets a scenario by name from the global static registry.

type ScenarioInfo

type ScenarioInfo struct {
	// Name of the scenario (inferred from the file name)
	ScenarioName string
	// Run ID of the current scenario run, used to generate a unique task queue
	// and workflow ID prefix. This is a single value for the whole scenario, and
	// not a Workflow RunId.
	RunID string
	// Metrics component for registering new metrics.
	MetricsHandler client.MetricsHandler
	// A zap logger.
	Logger *zap.SugaredLogger
	// A Temporal client.
	Client client.Client
	// Configuration info passed by user if any.
	Configuration RunConfiguration
	// ScenarioOptions are info passed from the command line. Do not mutate these.
	ScenarioOptions map[string]string
	// The namespace that was used when connecting the client.
	Namespace string
	// Path to the root of the omes dir
	RootPath string
}

ScenarioInfo contains information about the scenario under execution.

func (*ScenarioInfo) NewRun

func (s *ScenarioInfo) NewRun(iteration int) *Run

NewRun creates a new run.

func (*ScenarioInfo) ScenarioOptionInt

func (s *ScenarioInfo) ScenarioOptionInt(name string, defaultValue int) int

Jump to

Keyboard shortcuts

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