js

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: AGPL-3.0 Imports: 59 Imported by: 2

Documentation

Overview

Package js is the JavaScript implementation of the lib.Runner and relative concepts for executing concurrent-safe JavaScript code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveVU added in v0.27.0

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

ActiveVU holds a VU and its activation parameters

func (*ActiveVU) RunOnce added in v0.27.0

func (u *ActiveVU) RunOnce() error

RunOnce runs the configured Exec function once.

type Bundle added in v0.13.0

type Bundle struct {
	Options lib.Options

	CompatibilityMode lib.CompatibilityMode // parsed value

	ModuleResolver *modules.ModuleResolver
	// contains filtered or unexported fields
}

A Bundle is a self-contained bundle of scripts and resources. You can use this to produce identical BundleInstance objects.

func NewBundle added in v0.13.0

func NewBundle(
	piState *lib.TestPreInitState, src *loader.SourceData, filesystems map[string]fsext.Fs,
) (*Bundle, error)

NewBundle creates a new bundle from a source file and a filesystem.

func NewBundleFromArchive added in v0.15.0

func NewBundleFromArchive(piState *lib.TestPreInitState, arc *lib.Archive) (*Bundle, error)

NewBundleFromArchive creates a new bundle from an lib.Archive.

func (*Bundle) Instantiate added in v0.13.0

func (b *Bundle) Instantiate(ctx context.Context, vuID uint64) (*BundleInstance, error)

Instantiate creates a new runtime from this bundle.

type BundleInstance added in v0.13.0

type BundleInstance struct {
	Runtime *goja.Runtime
	// contains filtered or unexported fields
}

A BundleInstance is a self-contained instance of a Bundle.

type Runner

type Runner struct {
	Bundle *Bundle

	BaseDialer net.Dialer
	Resolver   netext.Resolver
	// TODO: Remove ActualResolver, it's a hack to simplify mocking in tests.
	ActualResolver netext.MultiResolver
	RPSLimit       *rate.Limiter
	RunTags        *metrics.TagSet

	BufferPool *lib.BufferPool
	// contains filtered or unexported fields
}

Runner implements lib.Runner and is used to run js tests

func New

func New(piState *lib.TestPreInitState, src *loader.SourceData, filesystems map[string]fsext.Fs) (*Runner, error)

New returns a new Runner for the provided source

func NewFromArchive added in v0.15.0

func NewFromArchive(piState *lib.TestPreInitState, arc *lib.Archive) (*Runner, error)

NewFromArchive returns a new Runner from the source in the provided archive

func NewFromBundle added in v0.15.0

func NewFromBundle(piState *lib.TestPreInitState, b *Bundle) (*Runner, error)

NewFromBundle returns a new Runner from the provided Bundle

func (*Runner) GetDefaultGroup added in v0.5.0

func (r *Runner) GetDefaultGroup() *lib.Group

GetDefaultGroup returns the default (root) Group.

func (*Runner) GetOptions

func (r *Runner) GetOptions() lib.Options

GetOptions returns the currently calculated lib.Options for the given Runner.

func (*Runner) GetSetupData added in v0.21.0

func (r *Runner) GetSetupData() []byte

GetSetupData returns the setup data as json if Setup() was specified and executed, nil otherwise

func (*Runner) HandleSummary added in v0.32.0

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

HandleSummary calls the specified summary callback, if supplied.

func (*Runner) IsExecutable added in v0.27.0

func (r *Runner) IsExecutable(name string) bool

IsExecutable returns whether the given name is an exported and executable function in the script.

func (*Runner) MakeArchive added in v0.15.0

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

MakeArchive creates an Archive of the runner. There should be a corresponding NewFromArchive() function that will restore the runner from the archive.

func (*Runner) NewVU

func (r *Runner) NewVU(
	ctx context.Context, idLocal, idGlobal uint64, samplesOut chan<- metrics.SampleContainer,
) (lib.InitializedVU, error)

NewVU returns a new initialized VU.

func (*Runner) SetOptions added in v0.18.1

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

SetOptions sets the test Options to the provided data and makes necessary changes to the Runner.

func (*Runner) SetSetupData added in v0.21.0

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

SetSetupData saves the externally supplied setup data as json in the runner, so it can be used in VUs

func (*Runner) Setup added in v0.20.0

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

Setup runs the setup function if there is one and sets the setupData to the returned value

func (*Runner) Teardown added in v0.20.0

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

Teardown runs the teardown function if there is one.

type VU

type VU struct {
	BundleInstance

	Runner    *Runner
	Transport *http.Transport
	Dialer    *netext.Dialer
	CookieJar *cookiejar.Jar
	TLSConfig *tls.Config
	ID        uint64 // local to the current instance
	IDGlobal  uint64 // global across all instances

	Console    *console
	BufferPool *lib.BufferPool

	Samples chan<- metrics.SampleContainer
	// contains filtered or unexported fields
}

VU implements the lib.VU interface for the js Runner.

func (*VU) Activate added in v0.27.0

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

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

func (*VU) GetID added in v0.27.0

func (u *VU) GetID() uint64

GetID returns the unique VU ID.

Directories

Path Synopsis
Package common contains helpers for interacting with the JavaScript runtime.
Package common contains helpers for interacting with the JavaScript runtime.
Package eventloop implements an event loop to be used thought js and it's subpackages
Package eventloop implements an event loop to be used thought js and it's subpackages
Package modules defines interfaces used for developing k6's JavaScript modules.
Package modules defines interfaces used for developing k6's JavaScript modules.
k6
Package k6 implements the module imported as 'k6' from inside k6.
Package k6 implements the module imported as 'k6' from inside k6.
k6/data
Package data implements `k6/data` js module for k6.
Package data implements `k6/data` js module for k6.
k6/experimental
Package experimental includes experimental module features
Package experimental includes experimental module features
k6/experimental/fs
Package fs provides a k6 module that allows users to interact with files from the local filesystem as per the [File API design document].
Package fs provides a k6 module that allows users to interact with files from the local filesystem as per the [File API design document].
k6/experimental/tracing
Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
k6/html
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT
k6/http
Package http implements the k6/http js module for k6.
Package http implements the k6/http js module for k6.
k6/ws
Package ws implements a k6/ws for k6.
Package ws implements a k6/ws for k6.
Package modulestest contains helpers to test js modules
Package modulestest contains helpers to test js modules
Package promises provides helpers for working with promises in k6.
Package promises provides helpers for working with promises in k6.

Jump to

Keyboard shortcuts

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