Documentation
¶
Index ¶
Constants ¶
const ( // ErrorCodeNone indicates no error: The script executed successfully. ErrorCodeNone = "" // ErrorCodeFailed indicates the k6 test failed and exited with a controlled, non-zero status. // This typically happens due to calling fail(), breached thresholds, etc. ErrorCodeFailed = "failed" // ErrorCodeTimeout occurs when the execution context is cancelled. ErrorCodeTimeout = "timeout" // ErrorCodeKilled signals that k6 exited with an error code >=128, which means that the process was killed. // If it is killed due to the timeout logic, ErrorCodeTimeout is returned instead. ErrorCodeKilled = "killed" // ErrorCodeAborted signals k6 exiting with an status code we map to uncontrolled failures, such as config errors, // javascript exceptions, etc. ErrorCodeAborted = "aborted" // ErrorCodeUnknown reperesents a non-nil error we cannot map to any known cause. ErrorCodeUnknown = "unknown" )
Variables ¶
var ( ErrStacktrace = errors.New("fatal error occurred while running the script") ErrThrown = errors.New("uncaught error occurred while running the script") )
var ( ErrBuggyRunner = errors.New("runner returned buggy response") ErrFromRunner = errors.New("runner reported an error") )
var ErrNoTimeout = errors.New("check has no timeout")
ErrNoTimeout is returned by Runner implementations if the supplied script has a timeout of zero.
var ErrUnexpectedStatus = errors.New("unexpected status code")
Functions ¶
This section is empty.
Types ¶
type CheckInfo ¶ added in v0.29.0
type CheckInfo struct {
// Type is the string representation of the check type this script belongs to (browser, scripted, multihttp, etc.)
Type string `json:"type"`
// Metadata is a collection of key/value pairs containing information about this check, such as check and tenant ID.
// It is loosely typed on purpose: Metadata should only be used for informational properties that will make its way
// into telemetry, and not for making decision on it.
Metadata map[string]any `json:"metadata"`
}
CheckInfo holds information about the SM check that triggered this script.
func CheckInfoFromSM ¶ added in v0.29.0
CheckInfoFromSM returns a CheckInfo from the information of the given SM check.
func (*CheckInfo) MarshalZerologObject ¶ added in v0.32.0
MarshalZerologObject implements zerolog.LogObjectMarshaler so it can be logged in a friendly way.
type HTTPMetrics ¶ added in v0.36.0
type HTTPMetrics struct {
Requests *prometheus.CounterVec
RequestsPerRun *prometheus.HistogramVec
}
func NewHTTPMetrics ¶ added in v0.36.0
func NewHTTPMetrics(registerer prometheus.Registerer) *HTTPMetrics
type HTTPRunRequest ¶ added in v0.28.1
type HTTPRunRequest struct {
Script `json:",inline"`
SecretStore SecretStore `json:",inline"`
NotAfter time.Time `json:"notAfter"`
}
HTTPRunRequest
type HttpRunner ¶
type HttpRunner struct {
// contains filtered or unexported fields
}
func (HttpRunner) Run ¶
func (r HttpRunner) Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)
func (HttpRunner) WithLogger ¶
func (r HttpRunner) WithLogger(logger *zerolog.Logger) Runner
type Local ¶ added in v0.28.2
type Local struct {
// contains filtered or unexported fields
}
func (Local) Run ¶ added in v0.28.2
func (r Local) Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)
type Processor ¶ added in v0.24.3
type Processor struct {
// contains filtered or unexported fields
}
Processor runs a script with a runner and parses the k6 output.
func NewProcessor ¶ added in v0.24.3
type RunResponse ¶
type Runner ¶
type Runner interface {
WithLogger(logger *zerolog.Logger) Runner
Run(ctx context.Context, script Script, secretStore SecretStore) (*RunResponse, error)
}
func New ¶
func New(opts RunnerOpts) Runner
type RunnerOpts ¶ added in v0.22.0
type RunnerOpts struct {
Uri string
BlacklistedIP string
Registerer prometheus.Registerer
}
type Script ¶
type Script struct {
// Script is the blob of bytes that is to be run.
Script []byte `json:"script"`
// Settings is a common representation of the fields common to all implementation-specific check settings that the
// runners are interested about.
Settings Settings `json:"settings"`
// CheckInfo holds information about the SM check that triggered this script.
CheckInfo CheckInfo `json:"check"`
}
Script is a k6 script that a runner is able to run, with some added instructions for that runner to act on.
type SecretStore ¶ added in v0.35.0
func (SecretStore) IsConfigured ¶ added in v0.35.0
func (s SecretStore) IsConfigured() bool
IsConfigured returns true if the SecretStore has both URL and token configured.
type Settings ¶ added in v0.19.0
type Settings struct {
// Timeout for k6 run, in milliseconds. This value is a configuration value for remote runners, which will instruct
// them to return an error if the operation takes longer than this time to complete. Clients should expect that
// requests to remote runners may take longer than this value due to network and other latencies, and thus clients
// should wait additional time before aborting outgoing requests.
Timeout int64 `json:"timeout"`
}
Settings is a common representation of the fields common to all implementation-specific check settings that the runners are interested about.