This file will be removed.
-
require(mod)
Require a module.
var http = require('http');
-
sleep(t)
Sleep for
t
seconds. Decimals are allowed;sleep(0.5)
sleeps for half a second.This may be moved somewhere else later on.
Provides information about the currently executing VU.
-
vu.id()
Returns the VU's numeric ID.
-
http.do(method, url[, data[, params]])
Sends an HTTP Request.
For GET requests, data is an object that's turned into query parameters. For any other kind, strings are sent verbatim,
null
andundefined
omit the request body, and objects and arrays are JSON encoded.Params:
quiet
-bool
Do not report statistical information about this request.headers
-object
Headers to set on the request. Values will be turned into strings if they're not already.
Returns:
HTTPResponse
object.status
-integer
HTTP status code.body
-string
Response body. Always a string, empty if there's no body.headers
-object
Response headers. May be empty if there are none, but it's always an object.json()
Decodes the response body into JSON.
-
http.get(...)
- Alias forhttp.do('GET', ...)
-
http.post(...)
- Alias forhttp.do('POST', ...)
-
http.put(...)
- Alias forhttp.do('PUT', ...)
-
http.delete(...)
- Alias forhttp.do('DELETE', ...)
-
http.patch(...)
- Alias forhttp.do('PATCH', ...)
-
http.options(...)
- Alias forhttp.do('OPTIONS', ...)
-
log.type(type, msg[, extra])
Writes out a log message.
Type is one of
debug
,info
,warn
anderror
; messages to unknown channels will be ignored. Note thatdebug
messages are only displayed when running k6 with-v
(--verbose
).Extra is an object of extra data to be provided along with the message. It's considered good practice to have the message a fixed string, and use extra data to provide context information, rather than concatenating it with the message.
var log = require('log'); // Don't do this log.error("Something happened: " + error); // Do this instead log.error("Something happened", { error: error });