Skip to content

Releases: grafana/k6

v0.23.1

18 Dec 10:54
v0.23.1
Compare
Choose a tag to compare

A minor release that fixes some of the issues in the v0.23.0 release.

Bugs fixed!

  • Cloud: Fixed the interaction between the environment variable and JSON-based configuration, and the Load Impact specific env.loadimpact JS options. Now only the projectID, name and token fields will be populated (without overriding other fields) when executing scripts with k6 cloud, and taken into account when sending metrics to Load Impact Insights with k6 run -o cloud. (#848, #871, #872)
  • JS: Fixed a Babel transformation issue that caused closing brackets to sometimes be commented out. (#853)
  • JS: Fixed environment variable propagation when executing script bundles. (#853)
  • HAR converter: Fixed a panic due to a missing nil check. (#861)
  • Cloud: Limit the amount of samples that k6 sends in a single package to the ingest by splitting them up. (#860)
  • Metrics: Fix the incorrect tracing of some corner case HTTP requests that resulted in negative or hugely positive metric values. (#862)

v0.23.0

22 Nov 14:04
v0.23.0
b8e1c60
Compare
Choose a tag to compare

v0.23.0 is here! 🎉

Hopefully this is the last intermediary release before v1.0.0. It is a bit light on new features, but it includes a lot of bug fixes and minor improvements! Also, the latest Docker tag will point to this release until we release the next stable one. Users wanting to use the bleeding edge k6 features can do that via the new master docker tag, which is pushed by every CI build of the git master branch.

Thanks to @sherrman, @ofauchon, @AndriiChuzhynov, @entone, @mariolopjr, and @tkbky for contributing to this release!

To see what's left for the v1.0.0 release, check out this milestone!

Also, have a look at our roadmap for what's up ahead, beyond the v1.0 release.

New Features!

New option: No Cookies Reset (#729)

A new option has been added that disables the default behavior of resetting the cookie jar after each VU iteration. If it's enabled, saved cookies will be persisted across VU iterations. For the moment there's no CLI flag for this option, instead it can only be set via the noCookiesReset key from the exported script options or via the K6_NO_COOKIES_RESET environment variable.

k6/http: New options to discard the response body or to specify its type (#742 and #749)

You can now specify what the type of an HTTP response's body should be with the new responseType request option. The possible values for it are text (the default), binary and none. The default text response type is backward-compatible, it doesn't change the current k6 behavior of returning the body attribute of the http/Response object as a string. It's well suited for working with web pages, text-based APIs and similar HTTP responses, but it can be unsuitable when dealing with binary files.

That's mostly because JavaScript strings are encoded with UTF-16 and converting binary data to it will frequently mangle some of the data. The new binary response type allows us to avoid that, it causes k6 to return the HTTP response's body as a byte array. This allows us to deal with the binary data without mangling it:

import http from 'k6/http';
import { sha256 } from 'k6/crypto';

export default function () {
    const expectedLogoHash = "fce7a09dde7c25b9822eca8438b7a5c397c2709e280e8e50f04d98bc8a66f4d9";

    let resp = http.get("http://test.loadimpact.com/images/logo.png", { responseType: "binary" });
    let logoHash = sha256(resp.body, "hex");
    if (logoHash !== expectedLogoHash) {
        throw new Error(`Expected logo hash to be ${expectedLogoHash} but it was ${logoHash}`);
    }
    http.post("https://httpbin.org/post", resp.body);
};

Saving HTTP response bodies is generally useful, especially when we need to use them (or parts of them) in subsequent requests. But in many cases it makes little to no sense to spend memory on saving the response body. For example, when requesting static website assets (JS, CSS, images etc.) or web pages without needed information, the actual file contents rarely matter when running load tests.

For cases like that, the value none for the responseType option allows k6 to discard incoming data on arrival, in order to save CPU cycles and prevent unnecessary copying of data. When enabled, the actual HTTP response body would be fully downloaded (so that the load test and all HTTP metrics for that request are still accurate), it just won't be saved in memory and passed on to the JavaScript runtime at all - the response.body attribute would be null:

import http from 'k6/http';
import { check } from "k6";

export default function () {
    const url = "http://test.loadimpact.com";
    let resp = http.get(url);
    let cssFile = resp.html().find("link[rel='stylesheet']").attr("href");

    check(http.get(`${url}/${cssFile}`, { responseType: "none" }), {
        "body was empty": (res) => res.body === null,
        "response code was 200": (res) => res.status == 200,
        "timings are present": (res) => res.timings.duration > 0,
    });
};

For convenience, there's also a new global config option that causes k6 to discard response bodies by default by switching the default responseType value to none. It can be enabled via the --discard-response-bodies CLI flag, the K6_DISCARD_RESPONSE_BODIES environment variable, or the discardResponseBodies script option:

import http from 'k6/http';
export let options = {
  discardResponseBodies: true,
};
export default function () {
  let response = http.get("http://test.loadimpact.com", { responseType: "text" });
  // ... do something with the response, but ignore the contents of static files:
  http.batch([
    "http://test.loadimpact.com/images/logo.png",
    "http://test.loadimpact.com/style.css"
  ]);
};

Thanks to @sherrman for reporting the binary handling issues that prompted the addition of the responseType option! And thanks to @ofauchon for implementing both of the discard response body options, of which the local per-request one was later transformed into the responseType=none value!

k6/http: The Response.json() method now supports selectors

The selectors are implemented with the gjson library and allow optimized lookups and basic filtering of JSON elements in HTTP responses, which could be especially useful in combination with k6 checks:

import http from "k6/http";
import { check } from "k6";

export default function () {
	let resp = http.get("https://api.spacexdata.com/v2/launches/");

	let currentYear = (new Date()).getFullYear();
	check(resp, {
		"falcon heavy": (r) => r.json("#[flight_number==55].rocket.second_stage.payloads.0.payload_id") === "Tesla Roadster",
		"no failure this year": (r) => r.json("#[launch_success==false]#.launch_year").every((y) => y < currentYear),
		"success ratio": (r) => r.json("#[launch_success==true]#").length > 10 * r.json("#[launch_success==false]#").length,
	});
}

Thanks to @AndriiChuzhynov for implementing this! (#766)

New option: disable the summary at the end of a test (#729)

A new option that disables the end-of-test summary has been added. That summary is often superfluous when k6 tests are run in a distributed execution mode, or when the generated metrics are piped to an external output like InfluxDB or Load Impact Insights. The option can be enabled with the --no-summary CLI flag or the K6_NO_SUMMARY environment variable. When both it and the and the --no-thresholds option are enabled, k6 won't store any generated metrics in-memory, making the test execution a bit more efficient.

New option: set a minimum iteration duration (#821)

You can now specify the minimum amount of time a single iteration should take via the new minIterationDuration option. It's also configurable via the --min-iteration-duration CLI flag and K6_MIN_ITERATION_DURATION environment variable. This setting only applies for full iterations, so any interrupted iterations due to ramping down of VUs from a stage or at the end of the tests can still be shorter.

UX

  • Added a warning when the maximum number of VUs is more than the total number of iterations (#802)

Internals

  • Cloud output: improved outlier metric detection for small batches. (#744)
  • Use 20 as the the default values of the batch and batchPerHost options. They determine the maximum number of parallel requests (in total and per-host respectively) an http.batch() call will make per VU. The previous value for batch was 10 and for batchPerHost it was 0 (unlimited). We now also use their values to determine the maximum number of open idle connections in a VU. (#685)
  • Due to refactoring needed for the redirect fixes, the NTLM authentication library k6 uses is changed from this to this. (#753)
  • Switched the default CircleCI tests and linting to use Go 1.11.2, but we still maintain 1.10 compatibility by running all of the tests with Go 1.10.3 too. Official k6 standalone builds will also be done with Go 1.11+ from now on. (#813)
  • Automated docker builds of the git master branch will now tag the resulting docker image as master as well. The latest docker tag will point to the latest stable official release, so it will be equivalent to v0.23.0 until we release the next k6 version. (#846)

Bugs fixed!

  • UI: The interactive k6 login influxdb command failed to write the supplied options to the config file. (#734)
  • UI: Password input is now masked in k6 login influxdb and k6 login cloud. (#734)
  • Config: Environment variables can now be used to modify k6's behavior in the k6 login subcommands. (#734)
  • HTTP: Binary response bodies were mangled because there was no way to avoid converting them to UTF-16 JavaScript strings. (#749)
  • Config: Stages were appended instead of overwritten from upper config "tiers", and were doubled when supplied via the CLI flag. (#759)
  • HAR converter: Fixed a panic due to a missing array length check. (#760)
  • HTTP: http.batch() calls could panic because of a data race when the batchPerHost global option was used. (#770)
  • Docker: Fixed the grafana image in the docker-compose setup. Thanks @entone and @mariolopjr! (#783)
  • Config: Stages configured via the script options or environment variables couldn't be disabled via the CLI flags. (#786)
  • UI: Don't report infinities and extreme speeds when tests take 0 time. Thanks @tkbky! (#790)
  • HTTP: Correct metric tracking when HTTP requests are redirected. (#753)
  • HAR converter: Added escaping for page IDs and names in the generated scripts. (#801)
  • Setup data: Distinguish between undefined (when there is no setup() function...
Read more

v0.22.1

23 Jul 13:52
v0.22.1
b76e4c1
Compare
Choose a tag to compare

A minor release that adds some UX improvements and fixes some of the issues in the v0.22.0 release.

UX

  • The consolidated user-supplied options (the final combination of config file options, exported script options, environment variables and command-line flags) are now exported back into the options script variable and can be accessed from the script. Thanks to @MohanPrasathS for working on this! (#681 and #713)
  • Improved error messages when outputting results to or executing tests in the Load Impact cloud (#716)

Bugs fixed!

  • Logging: using the --no-color flag caused k6 to print output intended for sdtout to stderr instead. (#712)
  • Logging: some error messages originating from Go's standard library did not obey the --logformat option. (#712)
  • JSON output: when the standard output was used, the JSON collector closed it before k6 was finished printing the end-of-test summary to it (#715)
  • Metrics: some zero-filled metrics were emitted when scaling down the number of VUs (#710)

v0.22.0

06 Jul 16:21
5e03050
Compare
Choose a tag to compare

v0.22.0 is here! 🎉

We're making an intermediary release before v1.0.0, as we wanted to get some changes out quicker. Thanks to @MohanPrasathS for contributing to this release!

To see what's left for the v1.0.0 release, check out this milestone!

Also, have a look at our roadmap for what's up ahead, beyond the v1.0 release.

New Features!

  • New JS API to set seed for PRNG. Now, you are able to set a seed to get reproducible (pseudo-)random numbers. (#677)
import {randomSeed} from "k6";

randomSeed(123456789);
let rnd = Math.random();
console.log(rnd)
  • A new option --no-vu-connection-reuse lets users close HTTP keep-alive connections between iterations of a VU. (#676)
  • You can now set the minimum and maximum sleep time at the end of an iteration with the new --min-sleep and --max-sleep HAR coverter CLI flags. (#694)
  • Another new feature in the HAR converter enabled users to specify a JSON file with script options that would be added to the options of the generated scripts with the new --options flag. (#694)

UX

Automated deb, rpm, msi and nuget package builds (#675)

Previously we only had Homebrew releases for Mac and simple archives with plain binary releases for all other platforms. From now on, we'll also automatically build installation packages for Windows and rpm or deb based Linux distributions and upload them to bintray on every new release: https://bintray.com/loadimpact

For Debian-based Linux distributions, you have to do something like this to install k6:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install k6

And for rpm-based ones like Fedora and CentOS:

wget https://bintray.com/loadimpact/rpm/rpm -O bintray-loadimpact-rpm.repo
sudo mv bintray-loadimpact-rpm.repo /etc/yum.repos.d/
sudo yum install k6

For Windows you can download and install the latest .msi package or, if you use the chocolatey package manager, follow these instructions to set up the k6 repository.

Other UX improvements

  • There's a new option to reset the saved cloud token: k6 login cloud --reset (#672)
  • The check and group names in the summary at the end of a test now appear in the order they were defined. Thanks to @MohanPrasathS for fixing this! (#674)

Internals

Real-time metrics (#678)

Previously most metrics were emitted only when a script iteration ended. With these changes, metrics would be continuously pushed in real-time, even in the middle of a script iteration. This should slightly decrease memory usage and help a lot with the aggregation efficiency of the cloud collector.

Portable builds (#658)

Before this, k6 builds that were done with just the standard Go language tools (i.e. go get, go build, etc.) were not portable because static resources like JS libraries had to be embedded in the binary after the build. Building fully portable binaries was done with the build-release.sh script (which used go.rice to bundle the static resources in the binary), but now that embedding is done beforehand and is commited in the git repo, so commands like go get/build/install produce fully-portable binary files without extra steps.

Bugs fixed!

  • Metrics emitted by setup() and teardown() are not discarded anymore. They are emitted and have the implicit root group tag values of setup and teardown respectively (#678)
  • Fixed a potential nil pointer error when the k6 cloud command is interrupted. (#682)

Breaking Changes

  • The --no-connection-reuse option has been re-purposed and now disables keep-alive connections globally. The newly added --no-vu-connection-reuse option does what was previously done by --no-connection-reuse - it closes any open connections between iterations of a VU, but allows for reusing them inside of a single iteration. (#676)

v0.21.1

04 Jun 09:45
f7d082c
Compare
Choose a tag to compare

A bug fix release to fix some issues in the v0.21.0 release.

Bugs fixed!

  • Multiple bugs in the HTTP request and batch handling (#642)
  • Fix negative http_req_sending values in the summary (#651)
  • Respect the setup() and teardown() timeouts even when triggered by the API (#661)

v0.21.0

23 May 07:15
a973a6a
Compare
Choose a tag to compare

v0.21.0 is here! 🎉

We're happy to see continued contributions from members of the community in this release, from 4 people outside of Load Impact this time around. A big thanks to the following people for contributing to this release: @antekresic, @cyberw, @danron and @jmccann. Also, thanks to everyone that contributed in other ways on Github, in Slack and for spreading the word about k6!

To see the current plan for the next release, check out this milestone, which we aim to make the v1.0 release!

Have a look at our roadmap for what's up ahead, beyond the v1.0 release.

New Features!

CLI/Options: Add --tag flag and tags option to set test-wide tags (#553)

You can now specify any number of tags on the command line using the --tag NAME=VALUE flag. You can also use the tags option to the set tags in the code.

The specified tags will be applied across all metrics. However if you have set a tag with the same name on a request, check or custom metric in the code that tag value will have precedence.

Thanks to @antekresic for their work on this!

Docs: Test wide tags and Options

CLI/Options: Add --summary-time-unit flag (#638)

You can now specify the time unit used to show the summary trend stats. It can be: 's' for seconds, 'ms' for milliseconds or 'us' microseconds.

$ k6 run --summary-time-unit ms ~/script.js

Docs: Options

k6/http: Support for HTTP NTLM Authentication (#556)

import http from "k6/http";
import { check } from "k6";

export default function() {
    // Passing username and password as part of URL plus the auth option will authenticate using HTTP Digest authentication
    let res = http.get("http://user:passwd@example.com/path", {auth: "ntlm"});

    // Verify response
    check(res, {
        "status is 200": (r) => r.status === 200
    });
}

Docs: HTTP Params

HAR converter: Add support for correlating JSON values (#516)

There is now support for correlating JSON values in recordings, replacing recorded request values with references to the previous response.

Thanks to @cyberw for their work on this!

InfluxDB output: Add support for sending certain sample tags as fields (#585)

Since InfluxDB indexes tags, highly variable information like vu, iter or even url may lead to high memory usage. The InfluxDB documentation recommends to use fields in that case, which is what k6 does now. There is a new INFLUXDB_TAGS_AS_FIELDS option (collectors.influxdb.tagsAsFields in the global k6 JSON config) that specifies which of the tags k6 emits will be sent as fields to InfluxDB. By default that's only url (but not name), vu and iter (if enabled).

Thanks to @danron for their work on this!

Configurable setup and teardown timeouts (#602)

Previously the setup() and teardown() functions timed out after 10 seconds. Now that period is configurable via the setupTimeout and teardownTimeout script options or the K6_SETUP_TIMEOUT and K6_TEARDOWN_TIMEOUT environment variables. The default timeouts are still 10 seconds and at this time there are no CLI options for changing them to avoid clutter.

In-client aggregation for metrics streamed to the cloud (#600)

Metrics streamed to the Load Impact cloud can be partially aggregated to reduce bandwidth usage and processing times. Outlier metrics are automatically detected and excluded from that aggregation.

Docs: Load Impact Insights Aggregation

HAR converter: Set more realistic sleep time (#608)

The default sleep time added at the end of the generated test has been changed from 2-4s to 20-40s to be more realistic (although still probably on the low end for some types of sites [1][2]).

[1] - https://moz.com/blog/ecommerce-benchmark-kpi-study-2017
[2] - https://www.brafton.com/blog/strategy/brafton-2017-content-marketing-benchmark-report/

Remote IP address as an optional system metric tag (#616)

It's now possible to add the remote server's IP address to the tags for HTTP and WebSocket metrics. The ip system tag is not included by default, but it could easily be enabled by modifying the systemTags option.

Raw log format (#634)

There is a new log format called raw. When used, it will print only the log message without adding any debug information like, date or the log level. It should be useful for debuging scripts when printing a HTML response for example.

$ k6 run --log-format raw ~/script.js

Option to output metrics to Apache Kafka (#617)

There is now support for outputing metrics to Apache Kafka! You can configure a Kafka broker (or multiple ones), topic and message format directly from the command line like this:

k6 --out kafka=brokers={broker1,broker2},topic=k6,format=json

The default format is json, but you can also use the InfluxDB line protocol for direct ingestion by InfluxDB:

k6 --out kafka=brokers=my_broker_host,topic=k6metrics,format=influxdb

You can even specify format options such as the tagsAsFields option for InfluxDB:

k6 --out kafka=brokers=someBroker,topic=someTopic,format=influxdb,influxdb.tagsAsFields={url,name,myCustomTag}

Docs: Apache Kafka output

Thanks to @jmccann for their work on this!

Multiple outputs (#624)

It's now possible to simultaneously send the emitted metrics to several outputs by using the CLI --out flag multiple times, for example:
k6 run --out json=test.json --out influxdb=http://localhost:8086/k6

Thanks to @jmccann for their work on this!

Cloud execution: CLI flag to exit k6 when test reaches running state (#632)

There's now a new CLI flag --exit-on-running when running cloud tests (k6 cloud ...) to have k6 exit when the test reaches the running state.

UX

  • Clearer error message when using open function outside init context (#563)
  • Better error message when a script or module can't be found (#565). Thanks to @antekresic for their work on this!

Internals

  • Removed all httpbin.org usage in tests, now a local transient HTTP server is used instead (#555). Thanks to @mccutchen for the great go-httpbin library!
  • Fixed various data races and enabled automated testing with -race (#564)

Bugs

  • Archive: archives generated on Windows can now run on *nix and vice versa. (#566)
  • Submetrics are being tagged properly now. (#609)
  • HTML: fixed the Selection.each(fn) function, which was returning only the first element. (#610)
  • Invalid Stages option won't keep k6 running indefinitely. (#615)
  • the --no-color option is now being repected for the logs. (#634)

Breaking changes

  • The Load Impact cloud configuration options no_compress and project_id and the payload_size InfluxDB option have been renamed to noCompress, projectID and payloadSize respectively, to match the other JS option names.

v0.20.0

22 Mar 16:09
Compare
Choose a tag to compare

Lots of goodies in this release! 🎉

We are working towards a 1.0 release of k6, and as part of this release we've also published our roadmap for 2018 in the Github wiki, here it is. We welcome comments and discussion relating to the roadmap, both in the corresponding issues as well as in Slack.

Once again we saw contributions from several members of the community in this release, from 9 people outside of Load Impact, woop woop! A big thanks to the following people for contributing to this release: @antekresic, @cstyan, @cyberw, @danron, @dstpierre, @luizbafilho, @marklagendijk, @na-- and @pkruhlei.

Two of the above contributors have also become full time employees of Load Impact since the last release, to accelerate the development of k6. We welcome @luizbafilho and @na-- to the distributed k6 core team!

To see the current plan for the next release, check out this milestone.

New Features!

k6/http: Support for binary files and multipart requests (#370, #420 and #524)

The init context open() function now supports binary files:

import http from "k6/http";
import {md5} from "k6/crypto";

let binFile = open("./image.png", "b");

export default function() {
    console.log(md5(binFile, "hex"));
}

and the HTTP module has handily gained support for multipart requests:

import http from "k6/http";

let binFile = open("./image.png", "b");

export default function() {
    var data = {
        field: "this is a standard form field",
        file: http.file(binFile, "my image file.png")
    };
    var res = http.post("https://example.com/upload", data);
}

Thanks @dstpierre for their work on this!

Docs: Multipart requests

k6/http: Request information through response object (#447)

Request information is now exposed through the Response object:

import http from "k6/http";

export default function() {
    let res = http.get("https://example.com/")
    console.log(`Method: ${res.request.method}`);
    new Map(Object.entries(res.request.headers)).forEach((v, k) => console.log(`Header: ${k}=${v}`));
    console.log(`Body: ${res.request.method}`);
}

Thanks to @cstyan for their work on this!

Docs: Request information

Lifecycle: setup/teardown functions (#457)

Finally k6 has the same basic test lifecycle hooks as many "normal" testing tools, setup and teardown, and you have the full JS API of k6 available within these functions which means you can make HTTP calls etc. that you can’t do in the global/init scope.

To use the lifecycle hooks you simply define an exported setup() and/or teardown() function in your script:

export function setup() {
	return { “data”: “passed to main and teardown function” };
}

export function teardown(data)  {
	console.log(JSON.stringify(data));
}

export default function(data) {
if (data.v != 1) {
		throw new Error("incorrect data: " + JSON.stringify(data));
	}
}

Docs: Test life cycle

CLI: HTTP debug flag (#447)

If you specify --http-debug when running a test k6 will now continuously print request and response information.

Thanks to @marklagendijk for their work on this!

Docs: HTTP debugging

Options: DNS override (#494)

Overriding DNS resolution of hostnames can come in handy when testing a system that is run in multiple environments (dev, staging, prod etc.) with different IP addresses but responds to the same Host header.

import http from "k6/http";

export let options = {
    hosts: {
        "loadimpact.com": "1.2.3.4",
        "test.loadimpact.com": "5.6.7.8"
    }
};

export default function() {
    http.get("http://loadimpact.com/");
    http.get("http://test.loadimpact.com/");
}

Tip: you can use environment variables to switch the IP based on environment.

Thanks @luizbafilho for their work on this!

Docs: DNS Override option

CLI: Add -e flag environment variable flag (#495)

You can now specify any number of environment variables on the command line using the -e NAME=VALUE flag.

As a matter of security, when running k6 cloud ... or k6 archive ... the system's environment variables will not be included in the resulting archive, you'll now have to use the new --include-system-env-vars flag to get that behavior. When executing k6 run ... the system's environment will continue to be exposed to your script.

We encourage the use of -e NAME=VALUE to make environment variable use explicit and compatible across local and cloud execution.

Thanks @na-- for their work on this!

Docs: Environment variables

HAR converter: Add --no-batch flag (#497)

A --no-batch CLI flag has been added to k6 convert command to disable the creation of batch request statements in favor of individual http.get/del/options/patch/post/put statements.

Thanks @danron and @cyberw for their work on this!

HAR converter: Add --return-on-failed-check flag (#499)

A --return-on-failed-check CLI flag has been added to k6 convert command to optionally return/exit the current VU iteration if a response status code check fails (requires the existing --enable-status-code-checks to be specified as well).

Thanks @cyberw for their work on this!

HAR converter: Add --correlate flag (#500)

A first step towards doing correlations when converting HAR to JS has implemented. In this first iteration, if --correlate is specified the converter will try to detect issues with redirects.

Thanks @cyberw for their work on this!

Stats: Use linear interpolation when calculating percentiles (#498)

The percentile calculation has been changed to use linear interpolation of two bounding values if percentile doesn't precisely fall on a value/sample index.

Thresholds: Support for aborting test early as soon as threshold is hit (#508)

Up until now thresholds were evaluated continuously throughout the test but could never abort a running test.
This PR adds functionality to specify that a test run should abort the test as soon as a threshold evaluates to false, optionally with a delay in threshold evaluation to avoid aborting to early when the number of samples collected is low.

export let options = {
    thresholds: {
        "http_req_duration": ["avg<100", { threshold: "p(95)<200", abortOnFail: true, delayAbortEval: "30s" }]
    }
};

Thanks @antekresic for their work on this!

Docs: Thresholds with abort

Docker: Use full Alpine as base image for k6 (#514)

Thanks @pkruhlei for their contribution!

CLI: Option to whitelist what tags should be added to metric samples (#525)

Adds a CLI option --system-tags "url,method,status" to specify a whitelist of system tags that will be included in the metrics output.

The following tags can be specified:

  • url (http, websocket)
  • method (http)
  • status (http, websocket)
  • proto (http)
  • subproto (websocket)
  • error (http)
  • name (http)
  • group (http)
  • check (http)
  • tls_version (http)
  • ocsp_status (http)
  • iter (vu)
  • vu (vu)

All but the last 3 (ocsp_status, iter, vu) are included by default. Some collectors (e.g. cloud) could require that certain tags are included.

Docs: System tags

k6/http: Support for HTTP Digest Authentication (#533)

import http from "k6/http";
import { check } from "k6";

export default function() {
    // Passing username and password as part of URL plus the auth option will authenticate using HTTP Digest authentication
    let res = http.get("http://user:passwd@httpbin.org/digest-auth/auth/user/passwd", {auth: "digest"});

    // Verify response
    check(res, {
        "status is 200": (r) => r.status === 200,
        "is authenticated": (r) => r.json().authenticated === true,
        "is correct user": (r) => r.json().user === "user"
    });
}

Docs: HTTP Params

Bugs fixed!

  • HAR converter: Fixed issue with construction of body parameter when PostData.Params values are present. (#489)

  • Stats: Fixed output of rate metrics to truncate rather than round when converting to string representation from float for summary output.

  • Stats: Fixes issue where calls to TrendSink.P() and TrendSink.Format() could return wrong results if TrendSink.Calc() hadn't been previously called. (#498)

  • Cloud/Insights: Fixed issue causing default test name to be empty when parsing script from STDIN (#510)

  • Cloud/Insights: Fixed handling of unexpected responses from server. (#522)

  • Stats: Fixed issue with calculation of data_received and data_sent metrics. (#523)

  • WebSockets: Fixed issue that different TLS settings like InsecureSkipTLSVerify were ignored for websockets (#531)

Breaking changes

  • The SummaryTrendStats configuration option has been renamed to summaryTrendStats, to match all of the other JS option names.

v0.19.0

23 Jan 13:41
Compare
Choose a tag to compare

The first release of 2018! 🎉

We have contributions from 10 people outside of Load Impact in this release, yay! To celebrate that and make onboarding of new users and contributors easier we’ve improved the README to give a better overview of the project and the Contributing guide with better instructions how to get a k6 dev environment set up.

A big thanks to the following people for contributing to this release: @antekresic, @borjacampina, @cstyan, @dstpierre, @ivoreis, @jonathon-L, @marklagendijk, @Ripolin, @tbroadley, and @tmcgannon

New Features!

HAR to JS converter (#291, #453)

k6 now has a builtin command k6 convert recording.har > recording.js to convert HAR files to JS. This is great for being able to quickly go from a browser/proxy recording to a k6 script, a common flow for getting started with a new test case.

Thanks to @borjacampina for their work on this!

Docs: HAR converter

CLI/options: RPS limiter

A global request per second limiter has been added to k6. It will trigger if the RPS level goes above the set value, blocking further requests for a short period to maintain the desired level.

export let options = {
    rps: 100
};

Or --rps on the CLI.

CLI: Logging in JSON format (#434)

You can now output logs in JSON format! It looks something like this:
{"level":"debug","msg":"Engine terminated cleanly","time":"2017-12-20T12:30:35Z"}

Thanks to @ivoreis for this PR!

k6/http: Automatic decompression of deflate encoded response bodies (#419)

Adds handling of deflate (as specified in RFC 1950) encoded response bodies by automatically decompressing them.

k6/http: Automatic decompression of gzip encoded response bodies (#438)

Same as the one above but for gzip. k6 previously automatically handled gzip compressed bodies as long as no Accept-Encoding header was explicitly specified when making a request, but this adds transparent decompression as long as the Content-Encoding header in a response is set to gzip.

Thanks to @Ripolin for discovering the discrepancy in the handling of gzipped responses and for fixing it!

k6/http: TLS handshaking metric (#454)

k6 will now measure TLS handshaking time. The metric is called http_req_tls_handshaking and is accessible in scripts as res.timings.tls_handshaking.

Thanks to @antekresic for this PR!

k6/html: Form serialization methods (#435)

This feature adds some missing jQuery APIs for serializing form elements to a URL-encoded string, array or object.

import http from "k6/http";

export default function() {
    let res = http.get(“https://example.com/form”);
    let form = res.html().find('form');
    const serialized = form.serializeObject();
}

Thanks to @marklagendijk for their work on this!

Docs: serialize(), serializeArray() and serializeObject()

k6/http: Form submission method (#437, #445)

A sister feature to the one above, adding a submitForm(...) method to the response object for making it easier to work with HTML form submissions.

import http from "k6/http";

export default function() {
    let res = http.get(“https://example.com/form”);
    res = res.submitForm({ fields: { message: "hello world" });
}

Again, thanks to @marklagendijk for their work on this!

Docs: Response.submitForm() and Working with HTML forms

k6/http: Add back OPTIONS method (#451)

Up until v0.13.0 k6 supported CONNECT, OPTIONS and TRACE methods, besides the more common HTTP methods. In v0.13.0 these methods were then lost in a big refactor where we switched JS engine from Otto to goja.

Thanks to @cstyan for this PR!

k6/http: Link click method (#459)

A wrapper around the Selection API to locate an link/anchor tag in the response HTML and generate a click request. It adds a clickLink(...) method to the response object.

import http from "k6/http";

export default function() {
    let res = http.get("https://httpbin.org/links/10/0");
    res = res.clickLink({ selector: 'a:nth-child(4)' })
}

Yet again, thanks to @marklagendijk for their work on this!

Docs: Response.clickLink()

Metrics: iteration_duration metric, vu and iter tags (#460)

A new metric, iteration_duration, has been added to k6. It measures the time it takes to run one full iteration of the default/main function. Most builtin metrics (http, group, checks etc.) are now also automatically tagged with vu and iter tags, representing the VU and iteration number where the metric data point was collected.

CLI: Specify what stats to report for trend metrics (#462)

A new CLI option --summary-trend-stats avg,med,max,p(95),p(99),p(99.9) for specifying what stats to show for trend metrics (response times) in the summary output after a test run has finished.

Thanks @antekresic for this contribution!

k6/http: Set default user-agent (#466)

By default k6 will now send a user-agent string in the following format: k6/0.19.0 (https://k6.io/);.

Bugs fixed!

  • k6/http: The val() Selection method now properly returns an empty string for input fields when the value attribute is missing. (#435, thanks @marklagendijk)

  • k6/http: Fixed three bugs related to cookie handling when doing redirects. (#479, thanks @marklagendijk)

  • Archive: Fixed JSON encoding of <, > and & characters. (#421, thanks @dstpierre)

  • Engine: Improved stability of some tests to decrease flakiness of CI builds.

  • Stats: Fixed median calculation when sample count is even (#432, thanks @tmcgannon)

  • Docs: Fixed typo in README (#433, thanks @tbroadley)

  • Docs: Fixed broken link in README (#482, thanks @jonathon-L)

v0.18.2

07 Dec 16:24
Compare
Choose a tag to compare

Features:

  • k6/http: Limit concurrent requests in http.batch() calls. (#296)

    export let options = {
      batch: 20, // Default: 10
    }
  • Flag to blacklist certain IP ranges from being called from scripts. (#389)

  • Flag to disable running of thresholds. (#42)

  • Archives now contain original sources, not transpiled gibberish. (#387)

  • k6/http: Enabled TLS Renegotiation

Fixed:

  • Broken colouring on Windows (#398)
  • Incorrect progress bars when using stages (#347)
  • Unhelpful errors from -o cloud
  • Tests with -o cloud failing when sources were read from stdin (#375)

v0.18.0

21 Nov 20:24
Compare
Choose a tag to compare

This release was quite some time in the making, and for good reason - we changed a ton of stuff under the hood, merged a bunch of big features, and we had to make sure it was all stable before releasing it out into the wild.

Note! This version removes the web UI, which has been unmaintained and deprecated for several releases. If you're interested in maintaining a web UI, please contact us and we can work something out. (#300)

Note! Due to some significant changes in how we store disk configuration, if you previously used k6 login to store credentials for influxdb, you will need to do so again after updating to v0.18.0.

New Features!

k6/html: full jQuery API compatibility!! (#197)

This is a huge feature and incredibly exciting to us - res.html() now returns an object that supports the full jQuery API!

check(http.get("http://example.com/"), {
    "status is 200": (r) => r.status === 200,
    "caption is correct": (r) => r.html("h1").text() == "Example Domain",
})

Well, we say the full, but there are actually two exceptions: stuff like height() and width() that only makes sense if you're actually rendering the page in a browser, and anything that modifies the document (data("key", "value")), which doesn't make any sense in the context of a load testing tool.

If you'd like to see these two added, show us a use case and we'll see what we can do!

It's worth noting that this isn't just a huge feature, it's the single biggest pull request I have ever seen, adding over 5000 lines of code (many of which are code generated!). For scale, the entire k6 codebase (before this PR) was around 20,000 lines.

Huge thanks to @mitnuh for their tireless work on this!

Complete rework of the CLI! (#110)

This is a huge change and the biggest culprit for this delay - because the CLI is so important, and because of the sheer size of this change, we couldn't just ship it off until we were absolutely sure it worked.

Not only is the new CLI code substantially easier to work with for us - we don't have to get all antsy about adding any CLI-facing features out of fear we may break something:

  • Help pages (k6 --help) are now more helpful, complete with usage examples.
  • There's no more weirdness with certain flags having to be in certain positions (eg. k6 run -v now works, not just k6 -v run).
  • And we threw in coloured output for control commands while we were at it.

All options can now be set from the environment

Yup. Instead of -u 100/--vus 100, or specifying the vus: 100 option, you can now set K6_VUS in the environment instead.

The order of predecence for this is: defaults > disk config > script options > environment variables > commandline flags.

k6/http: You can pass objects to http.batch() (#295)

http.batch([
    { "method": "GET", "url": "http://example.com/" },
])

Thanks to @borjacampina for this contribution!

k6/http: TLS information in HTTP responses (#322)

HTTP responses now have several new fields, all of which are also exported as tags, and a couple of new constants for their values:

  • tls_version (eg. http.TLS_1_2)
  • tls_cipher_suite (eg. "TLS_RSA_WITH_RC4_128_SHA")
  • ocsp
    • produced_at (timestamp, ms)
    • this_update (timestamp, ms)
    • next_update (timestamp, ms)
    • revoked_at (timestamp, ms)
    • revocation_reason (eg. http.OCSP_REASON_KEY_COMPROMISE)
    • status (eg. http.OCSP_STATUS_GOOD)

k6/http: New API for cookie management (#323)

This is a pretty big feature youthat has been asked about for a long time - we now have a comprehensive API for anything you could possibly want to do regarding cookies.

There's much more, but the biggest thing that's been asked for is how to manually set a cookie for a request, and read it back out - without messing about with manually constructing HTTP headers:

check(http.get("http://example.com/", { cookies: { name: "value" } }), {
    "status is 200": (r) => r.status === 200,
    "some cookie is set": (r) => r.cookies.my_cookie === "hi",
});

Much smaller Docker images (#337)

With the web UI gone, we could drop our Node dependency, and we're also now using Alpine Linux base images.

Thanks to @StephenRadachy for this contribution!

Much faster loading of external ES5 libraries! (#212)

The code responsible for loading JS files now skips invoking Babel for files that are already valid ES5. Yes, it was actually that simple, and it cuts minutes(!) off loading big, already minimised libraries like Faker.js.

k6/encoding: base64 encoding and decoding (#327)

What it says on the tin. Supports normal or URL-safe encodings.

import enc from "k6/encoding";

export default function() {
	console.log(enc.b64encode("hello!!")); // aGVsbG8hIQ==
	console.log(enc.b64encode("hello!!", "rawurl")); // aGVsbG8hIQ
}

Bugs fixed!

  • The iterations metric wasn't exported properly. (#313)

  • Sporadic errors at the end of tests. (#358)

  • Incorrect scaling/failed requests at the start of a test when using stages. (#326)

  • k6/ws: The close event sometimes wouldn't be emitted. (#329)

  • k6/ws: Respond to pings with pongs as decreed by the ws spec. (#330)

  • k6/ws: Missing metrics at the end of a test. (#333)

  • cloud: Anonymous tests with -o cloud now show correct URLs. (#348)

  • cloud: More useful error messages from tests with -o cloud.