Documentation
¶
Overview ¶
Package js is the JavaScript implementation of the lib.Runner and relative concepts for executing concurrent-safe JavaScript code.
Index ¶
- func NewModuleResolver(pwd *url.URL, preInitState *lib.TestPreInitState, ...) *modules.ModuleResolver
- type ActiveVU
- type Bundle
- type BundleInstance
- type Runner
- func (r *Runner) GetOptions() lib.Options
- func (r *Runner) GetSetupData() []byte
- func (r *Runner) HandleSummary(ctx context.Context, legacy *lib.LegacySummary, s *summary.Summary, ...) (map[string]io.Reader, error)
- func (r *Runner) IsExecutable(name string) bool
- func (r *Runner) MakeArchive() *lib.Archive
- func (r *Runner) NewVU(ctx context.Context, idLocal, idGlobal uint64, ...) (lib.InitializedVU, error)
- func (r *Runner) SetOptions(opts lib.Options) error
- func (r *Runner) SetSetupData(data []byte)
- func (r *Runner) Setup(ctx context.Context, out chan<- metrics.SampleContainer) error
- func (r *Runner) Teardown(ctx context.Context, out chan<- metrics.SampleContainer) error
- type VU
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewModuleResolver ¶
func NewModuleResolver(pwd *url.URL, preInitState *lib.TestPreInitState, filesystems map[string]fsext.Fs, ) *modules.ModuleResolver
NewModuleResolver is used to create a Runner appropriate module resolver
Types ¶
type ActiveVU ¶
type ActiveVU struct {
*VU
*lib.VUActivationParams
// contains filtered or unexported fields
}
ActiveVU holds a VU and its activation parameters
type Bundle ¶
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 ¶
func NewBundle( piState *lib.TestPreInitState, src *loader.SourceData, filesystems map[string]fsext.Fs, mr *modules.ModuleResolver, ) (*Bundle, error)
NewBundle creates a new bundle from a source file and a filesystem.
func NewBundleFromArchive ¶
func NewBundleFromArchive( piState *lib.TestPreInitState, arc *lib.Archive, mr *modules.ModuleResolver, ) (*Bundle, error)
NewBundleFromArchive creates a new bundle from an lib.Archive.
func (*Bundle) Instantiate ¶
Instantiate creates a new runtime from this bundle.
type BundleInstance ¶
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, mr *modules.ModuleResolver, ) (*Runner, error)
New returns a new Runner for the provided source
func NewFromArchive ¶
func NewFromArchive(piState *lib.TestPreInitState, arc *lib.Archive, mr *modules.ModuleResolver) (*Runner, error)
NewFromArchive returns a new Runner from the source in the provided archive
func NewFromBundle ¶
func NewFromBundle(piState *lib.TestPreInitState, b *Bundle) (*Runner, error)
NewFromBundle returns a new Runner from the provided Bundle
func (*Runner) GetOptions ¶
GetOptions returns the currently calculated lib.Options for the given Runner.
func (*Runner) GetSetupData ¶
GetSetupData returns the setup data as json if Setup() was specified and executed, nil otherwise
func (*Runner) HandleSummary ¶
func (r *Runner) HandleSummary( ctx context.Context, legacy *lib.LegacySummary, s *summary.Summary, meta summary.Meta, ) (map[string]io.Reader, error)
HandleSummary calls the specified summary callback, if supplied.
func (*Runner) IsExecutable ¶
IsExecutable returns whether the given name is an exported and executable function in the script.
func (*Runner) MakeArchive ¶
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 ¶
SetOptions sets the test Options to the provided data and makes necessary changes to the Runner.
func (*Runner) SetSetupData ¶
SetSetupData saves the externally supplied setup data as json in the runner, so it can be used in VUs
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
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compiler implements additional functionality for k6 to compile js code.
|
Package compiler implements additional functionality for k6 to compile js code. |
|
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 |
|
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/browser/browser
Package browser is the browser module's entry point, and initializer of various global types, and a translation layer between sobek and the internal business logic.
|
Package browser is the browser module's entry point, and initializer of various global types, and a translation layer between sobek and the internal business logic. |
|
k6/browser/chromium
Package chromium is responsible for launching a Chrome browser process and managing its lifetime.
|
Package chromium is responsible for launching a Chrome browser process and managing its lifetime. |
|
k6/browser/common
Package common provides the main logic of the browser module.
|
Package common provides the main logic of the browser module. |
|
k6/browser/common/js
Package js provides JavaScript code that the browser module evaluates on the browser.
|
Package js provides JavaScript code that the browser module evaluates on the browser. |
|
k6/browser/env
Package env provides types to interact with environment setup.
|
Package env provides types to interact with environment setup. |
|
k6/browser/k6error
Package k6error contains ErrFatal.
|
Package k6error contains ErrFatal. |
|
k6/browser/k6ext
Package k6ext acts as an encapsulation layer between the k6 core and xk6-browser.
|
Package k6ext acts as an encapsulation layer between the k6 core and xk6-browser. |
|
k6/browser/k6ext/k6test
Package k6test provides mock implementations of k6 elements for testing purposes.
|
Package k6test provides mock implementations of k6 elements for testing purposes. |
|
k6/browser/keyboardlayout
Package keyboardlayout provides keyboard key interpretation and layout validation.
|
Package keyboardlayout provides keyboard key interpretation and layout validation. |
|
k6/browser/log
Package log provides logging for the browser module.
|
Package log provides logging for the browser module. |
|
k6/browser/storage
Package storage provides data storage for the extension and user specific data.
|
Package storage provides data storage for the extension and user specific data. |
|
k6/browser/tests
Package tests provides integration tests.
|
Package tests provides integration tests. |
|
k6/browser/tests/ws
Package ws provides a test WebSocket server.
|
Package ws provides a test WebSocket server. |
|
k6/browser/trace
Package trace provides tracing instrumentation tailored for k6 browser needs.
|
Package trace provides tracing instrumentation tailored for k6 browser needs. |
|
k6/crypto
Package crypto provides common hashing function for the k6
|
Package crypto provides common hashing function for the k6 |
|
k6/crypto/x509
Package x509 provides X.509 certificate parsing for the k6
|
Package x509 provides X.509 certificate parsing for the k6 |
|
k6/data
Package data implements `k6/data` js module for k6.
|
Package data implements `k6/data` js module for k6. |
|
k6/encoding
Package encoding provides encoding/decoding functionality for the k6
|
Package encoding provides encoding/decoding functionality for the k6 |
|
k6/execution
Package execution implements k6/execution which lets script find out more about it is execution.
|
Package execution implements k6/execution which lets script find out more about it is execution. |
|
k6/experimental
Package experimental includes experimental module features
|
Package experimental includes experimental module features |
|
k6/experimental/csv
Package csv provides a CSV parser for k6.
|
Package csv provides a CSV parser for k6. |
|
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/streams
Package streams provides support for the Web Streams API.
|
Package streams provides support for the Web Streams API. |
|
k6/grpc
Package grpc is the root module of the k6-grpc extension.
|
Package grpc is the root module of the k6-grpc extension. |
|
k6/metrics
Package metrics implements k6/metrics and let script work with custom metrics.
|
Package metrics implements k6/metrics and let script work with custom metrics. |
|
k6/secrets
Package secrets implements `k6/secrets` giving access to secrets from secret sources to js code.
|
Package secrets implements `k6/secrets` giving access to secrets from secret sources to js code. |
|
k6/timers
Package timers exposes setInterval setTimeout and co.
|
Package timers exposes setInterval setTimeout and co. |
|
k6/webcrypto
Package webcrypto exports the webcrypto API.
|
Package webcrypto exports the webcrypto API. |
|
k6/websockets
Package websockets implements to some extend WebSockets API https://websockets.spec.whatwg.org
|
Package websockets implements to some extend WebSockets API https://websockets.spec.whatwg.org |
|
k6/websockets/events
Package events represent the events that can be sent to the client https://dom.spec.whatwg.org/#event
|
Package events represent the events that can be sent to the client https://dom.spec.whatwg.org/#event |
|
k6/ws
Package ws implements a k6/ws for k6.
|
Package ws implements a k6/ws for k6. |
|
tc55
|
|
|
timers
Package timers is implementing setInterval setTimeout and co.
|
Package timers is implementing setInterval setTimeout and co. |