minirunner

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package minirunner provides a mock implementation of the lib.Runner We use it in tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveVU

type ActiveVU struct {
	*VU
	*lib.VUActivationParams
	// contains filtered or unexported fields
}

ActiveVU holds a VU and its activation parameters

func (*ActiveVU) RunOnce

func (vu *ActiveVU) RunOnce() error

RunOnce runs the mock default function once, incrementing its iteration.

type MiniRunner

type MiniRunner struct {
	Fn              func(ctx context.Context, state *lib.State, out chan<- metrics.SampleContainer) error
	SetupFn         func(ctx context.Context, out chan<- metrics.SampleContainer) ([]byte, error)
	TeardownFn      func(ctx context.Context, out chan<- metrics.SampleContainer) error
	HandleSummaryFn func(context.Context, *lib.Summary) (map[string]io.Reader, error)

	SetupData []byte

	Options      lib.Options
	PreInitState *lib.TestPreInitState
	// contains filtered or unexported fields
}

MiniRunner partially implements the lib.Runner interface, but instead of using a real JS runtime, it allows us to directly specify the options and functions with Go code.

func (MiniRunner) GetOptions

func (r MiniRunner) GetOptions() lib.Options

GetOptions returns the supplied options struct.

func (MiniRunner) GetSetupData

func (r MiniRunner) GetSetupData() []byte

GetSetupData returns json representation of the setup data if setup() is specified and was ran, nil otherwise.

func (*MiniRunner) HandleSummary added in v0.32.0

func (r *MiniRunner) HandleSummary(ctx context.Context, s *lib.Summary) (map[string]io.Reader, error)

HandleSummary calls the specified summary callback, if supplied.

func (MiniRunner) IsExecutable

func (r MiniRunner) IsExecutable(_ string) bool

IsExecutable satisfies lib.Runner, but is mocked for MiniRunner since it doesn't deal with JS.

func (MiniRunner) MakeArchive

func (r MiniRunner) MakeArchive() *lib.Archive

MakeArchive isn't implemented, it always returns nil and is just here to satisfy the lib.Runner interface.

func (*MiniRunner) NewVU

func (r *MiniRunner) NewVU(
	_ context.Context, idLocal, idGlobal uint64, out chan<- metrics.SampleContainer,
) (lib.InitializedVU, error)

NewVU returns a new VU with an incremental ID.

func (*MiniRunner) SetOptions

func (r *MiniRunner) SetOptions(opts lib.Options) error

SetOptions allows you to override the runner options.

func (*MiniRunner) SetSetupData

func (r *MiniRunner) SetSetupData(data []byte)

SetSetupData saves the externally supplied setup data as JSON in the runner.

func (*MiniRunner) Setup

func (r *MiniRunner) Setup(ctx context.Context, out chan<- metrics.SampleContainer) (err error)

Setup calls the supplied mock setup() function, if present.

func (MiniRunner) Teardown

func (r MiniRunner) Teardown(ctx context.Context, out chan<- metrics.SampleContainer) error

Teardown calls the supplied mock teardown() function, if present.

type VU

type VU struct {
	R            *MiniRunner
	Out          chan<- metrics.SampleContainer
	ID, IDGlobal uint64
	Iteration    int64
	// contains filtered or unexported fields
}

VU is a mock VU, spawned by a MiniRunner.

func (*VU) Activate

func (vu *VU) Activate(params *lib.VUActivationParams) lib.ActiveVU

Activate the VU so it will be able to run code.

func (*VU) GetID

func (vu *VU) GetID() uint64

GetID returns the unique VU ID.

func (*VU) State added in v0.37.0

func (vu *VU) State() *lib.State

State returns the VU's State.

Jump to

Keyboard shortcuts

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