k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Documentation

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Params (k6/http)

Params

Params is an object used by the http.* methods that generate HTTP requests. Params contains request-specific options like e.g. HTTP headers that should be inserted into the request.

"cookies", "jar" and "redirects" only available on master branch or through DockerHub loadimpact/k6:latest

As of this writing, Oct 30th 2017, the cookies, jar and redirects option is not included in an official release yet. If you want to use it you'll either have to build k6 from source (master branch) or use the latest Docker image available through DockerHub as loadimpact/k6:latest.

Name
Type
Description

Params.cookies

object

Object with key-value pairs representing request scoped cookies (they won't be added to VU cookie jar)
{cookies: { key: "val", key2: "val2" }}

You also have the option to say that a request scoped cookie should override a cookie in the VU cookie jar:
{cookies: { key: { value: "val", replace: true }}}

Params.headers

object

Object with key-value pairs representing custom HTTP headers the user would like to add to the request.

Params.jar

object

http.CookieJar object to override default VU cookie jar with. Cookies added to request will be sourced from this jar and cookies set by server will be added to this jar.

Params.redirects

number

The number of redirects to follow for this request. Overrides the global test option maxRedirects.

Params.tags

object

Key-value pairs where the keys are names of tags and the values are tag values. Response time metrics generated as a result of the request will have these tags added to them, allowing the user to filter out those results specifically, when looking at results data.

import http from "k6/http";

export default function() {
	let params = {
    cookies: { "my_cookie": "value" },
		headers: { "X-MyHeader": "k6test" },
    redirects: 5,
		tags: { "k6test": "yes" }
	};
  let res = http.get("https://loadimpact.com", params);
};

A k6 script that will make an HTTP request with a custom HTTP header and tag results data with a specific tag

Here is another example using http.batch() with a Params argument:

import http from "k6/http";

let url1 = "https://api.loadimpact.com/v3/account/me";
let url2 = "http://httpbin.org/get"
let apiToken = "f232831bda15dd233c53b9c548732c0197619a3d3c451134d9abded7eb5bb195";
let requestHeaders = {
	"User-Agent": "k6",
	"Authorization": "Token " + apiToken
};

export default function() {
	let res = http.batch([
		{ method: "GET", url: url1, params: { headers: requestHeaders } },
		{ method: "GET", url: url2 }
	]);
};

Params (k6/http)