Skip to content

Commit bb7b1fc

Browse files
mstoykovIvan Mirićna--rogchap
authored
Changes for k6 v0.29.0 (#144)
Co-authored-by: Ivan Mirić <[email protected]> Co-authored-by: na-- <[email protected]> Co-authored-by: Roger Chapman <[email protected]>
1 parent d36c6d4 commit bb7b1fc

20 files changed

+482
-11
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ docker-compose up -d --build
1616
```
1717

1818
Note that starting up the docker takes several minutes, during which the
19-
website will not be accessible. Use `docker-compose log -f web` to track
20-
progress.
19+
website will not be accessible. Use `docker-compose logs -f web` to track
20+
progress.
2121

2222
Then visit http://localhost:8100
2323

@@ -36,7 +36,7 @@ cd k6-docs
3636
npm install
3737
```
3838

39-
Running manually:
39+
Running manually:
4040

4141
```bash
4242
npm start
@@ -55,6 +55,6 @@ All tags created using the format `vN.N.N`, for instance `v0.0.1`, will result i
5555
## Contributing
5656

5757
Documentation articles are markdown files structured under the
58-
[`src/data/markdown/docs`](src/data/markdown/docs) folder.
58+
[`src/data/markdown/docs`](src/data/markdown/docs) folder.
5959

6060
The markdown files support a few custom extensions explained on the [File Format Guide](CONTRIBUTING_FILE_FORMAT.md).

src/data/markdown/docs/01 guides/01 Getting started/02 Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ brew install k6
4343

4444
## Windows (MSI installer)
4545

46-
Download the k6 installer from [here](https://dl.bintray.com/loadimpact/windows/k6-v0.28.0-amd64.msi)
46+
Download the k6 installer from [here](https://dl.bintray.com/loadimpact/windows/k6-v0.29.0-amd64.msi)
4747

4848
## Binaries
4949

src/data/markdown/docs/01 guides/02 Using k6/05 Options.md

Lines changed: 125 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ Options allow you to configure how k6 will behave during test execution.
1212
| [Batch](#batch) | Max number of simultaneous connections of a `http.batch()` call |
1313
| [Batch per host](#batch-per-host) | Max number of simultaneous connections of a `http.batch()` call for a host |
1414
| [Blacklist IPs](#blacklist-ips) | Blacklist IP ranges from being called |
15+
| [Block hostnames](#block-hostnames) | Block any requests to specific hostnames |
1516
| [Compatibility Mode](#compatibility-mode) | Support running scripts with different ECMAScript modes |
1617
| [Config](#config) | Specify the config file in JSON format to read the options values |
1718
| [Discard Response Bodies](#discard-response-bodies) | Specify if response bodies should be discarded |
19+
| [DNS](#dns) | Configure DNS resolution behavior |
1820
| [Duration](#duration) | A string specifying the total duration a test run should be run for |
1921
| [Execution Segment](#execution-segment) | Limit execution to a segment of the total test |
2022
| [Extension Options](#extension-options) | An object used to set configuration options for third-party collectors |
@@ -24,6 +26,7 @@ Options allow you to configure how k6 will behave during test execution.
2426
| [Insecure Skip TLS Verify](#insecure-skip-tls-verify) | A boolean specifying whether should ignore TLS verifications for VU connections |
2527
| [Iterations](#iterations) | A number specifying a fixed number of iterations to execute of the script |
2628
| [Linger](#linger) | A boolean specifying whether k6 should linger around after test run completion |
29+
| [Local IPs](#local-ips) | A list of local IPs, IP ranges, and CIDRs from which VUs will make requests |
2730
| [Log Output](#log-output) | Configuration about where logs from k6 should be send |
2831
| [LogFormat](#logformat) | Specify the format of the log output |
2932
| [Max Redirects](#max-redirects) | The maximum number of HTTP redirects that k6 will follow |
@@ -209,6 +212,40 @@ export let options = {
209212

210213
</CodeGroup>
211214

215+
216+
217+
### Block Hostnames
218+
219+
> _New in v0.29.0_
220+
221+
Blocks hostnames based on a list glob match strings. The pattern matching string can have a single
222+
`*` at the beginning such as `*.example.com` that will match anything before that such as
223+
`test.example.com` and `test.test.example.com`.
224+
Available in `k6 run` and `k6 cloud` commands.
225+
226+
| Env | CLI | Code / Config file | Default |
227+
| -------------------- | ------------------- | ------------------ | ------- |
228+
| `K6_BLOCK_HOSTNAMES` | `--block-hostnames` | `blockHostnames` | `null` |
229+
230+
<CodeGroup labels={[]} lineNumbers={[true]}>
231+
232+
```javascript
233+
export let options = {
234+
blockHostnames: ["test.k6.io" , "*.example.com"],
235+
};
236+
```
237+
238+
</CodeGroup>
239+
240+
241+
<CodeGroup labels={[]}>
242+
243+
```bash
244+
$ k6 run --block-hostnames="test.k6.io,*.example.com" script.js
245+
```
246+
247+
</CodeGroup>
248+
212249
### Compatibility Mode
213250

214251
Support running scripts with different ECMAScript compatibility modes.
@@ -263,6 +300,64 @@ export let options = {
263300

264301
</CodeGroup>
265302

303+
### DNS
304+
305+
> _New in v0.29.0_
306+
307+
This is a composite option that provides control of DNS resolution behavior with
308+
configuration for cache expiration (TTL), IP selection strategy and IP version
309+
preference. The TTL field in the DNS record is currently not read by k6, so the
310+
`ttl` option allows manual control over this behavior, albeit as a fixed value
311+
for the duration of the test run.
312+
313+
Note that DNS resolution is done only on new HTTP connections, and by default k6
314+
will try to reuse connections if HTTP keep-alive is supported. To force a certain
315+
DNS behavior consider enabling the [`noConnectionReuse`](#no-connection-reuse)
316+
option in your tests.
317+
318+
319+
| Env | CLI | Code / Config file | Default |
320+
| ---------| --------| -------------------| ---------------------------------------- |
321+
| `K6_DNS` | `--dns` | `dns` | `ttl=5m,select=random,policy=preferIPv4` |
322+
323+
Possible `ttl` values are:
324+
- `0`: no caching at all - each request will trigger a new DNS lookup.
325+
- `inf`: cache any resolved IPs for the duration of the test run.
326+
- any time duration like `60s`, `5m30s`, `10m`, `2h`, etc.; if no unit is specified (e.g. `ttl=3000`), k6 assumes milliseconds.
327+
328+
Possible `select` values are:
329+
- `first`: always pick the first resolved IP.
330+
- `random`: pick a random IP for every new connection.
331+
- `roundRobin`: iterate sequentially over the resolved IPs.
332+
333+
Possible `policy` values are:
334+
- `preferIPv4`: use IPv4 addresses if available, otherwise fall back to IPv6.
335+
- `preferIPv6`: use IPv6 addresses if available, otherwise fall back to IPv4.
336+
- `onlyIPv4`: only use IPv4 addresses, ignore any IPv6 ones.
337+
- `onlyIPv6`: only use IPv6 addresses, ignore any IPv4 ones.
338+
- `any`: no preference, use all addresses.
339+
340+
Here are some configuration examples:
341+
342+
```bash
343+
k6 run --dns "ttl=inf,select=first,policy=any" script.js # the old k6 behavior before v0.29.0
344+
K6_DNS="ttl=5m,select=random,policy=preferIPv4" k6 cloud script.js # new default behavior from v0.29.0
345+
```
346+
347+
<CodeGroup labels={[ "script.js" ]} lineNumbers={[true]}>
348+
349+
```javascript
350+
export let options = {
351+
dns: {
352+
ttl: '1m',
353+
select: 'roundRobin',
354+
policy: 'any'
355+
}
356+
}
357+
```
358+
359+
</CodeGroup>
360+
266361
### Duration
267362

268363
A string specifying the total duration a test run should be run for. During this time each
@@ -408,7 +503,7 @@ $ k6 run --include-system-env-vars ~/script.js
408503
### Insecure Skip TLS Verify
409504

410505
A boolean, true or false. When this option is enabled (set to true), all of the verifications that
411-
would otherwise be done to establish trust in a server provided TLS certificate will be ignored.
506+
would otherwise be done to establish trust in a server provided TLS certificate will be ignored.
412507
This only applies to connections created by VU code, such as http requests.
413508
Available in `k6 run` and `k6 cloud` commands
414509

@@ -481,6 +576,31 @@ export let options = {
481576

482577
</CodeGroup>
483578

579+
### Local IPs
580+
581+
A list of IPs, IP ranges and CIDRs from which VUs will make requests. The IPs will be sequentially
582+
given out to VUs. This option doesn't change anything on the OS level so the IPs need to be already
583+
configured on the OS level in order for k6 to be able to use them. Also IPv4 CIDRs with more than 2
584+
IPs don't include the first and last IP as they are reserved for referring to the network itself and
585+
the broadcast address respectively.
586+
587+
This option can be used for splitting the network traffic from k6 between multiple network cards, thus potentially increasing the available network throughput. For example, if you have 2 NICs, you can run k6 with `--local-ips="<IP-from-first-NIC>,<IP-from-second-NIC>"` to balance the traffic equally between them - half of the VUs will use the first IP and the other half will use the second. This can scale to any number of NICs, and you can repeat some local IPs to give them more traffic. For example, `--local-ips="<IP1>,<IP2>,<IP3>,<IP3>"` will split VUs between 3 different source IPs in a 25%:25%:50% ratio.
588+
589+
Available in the `k6 run` command.
590+
591+
| Env | CLI | Code / Config file | Default |
592+
| -------------- | ---------------- | ------------------ | ------- |
593+
| `K6_LOCAL_IPS` | `--local-ips` | N/A | N/A |
594+
595+
596+
<CodeGroup labels={[]}>
597+
598+
```bash
599+
$ k6 run --local-ips=192.168.20.12-192.168.20-15,192.168.10.0/27 script.js
600+
```
601+
602+
</CodeGroup>
603+
484604
### Log output
485605

486606
This option specifies where to send logs to and another configuration connected to it. Available in the `k6 run` command.
@@ -500,6 +620,7 @@ The possible keys with their meanings and default values:
500620
| key | meaning | default value |
501621
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
502622
| `nothing` | the endpoint to which to send logs | `http://127.0.0.1:3100/loki/api/v1/push` |
623+
| allowedLabels | if set k6 will send only the provided labels as such and all others will be appended to the message in the form `key=value`. The value of the option is in the form `[label1,label2]` | N/A |
503624
| label.`labelName` | adds an additional label with the provided key and value to each message | N/A |
504625
| limit | the limit of message per pushPeriod, an additional log is send when the limit is reached, logging how many logs were dropped | 100 |
505626
| level | the minimal level of a message so it's send to loki | all |
@@ -839,7 +960,7 @@ Available in the `k6 run` command.
839960
| ------------------- | ----------------------------- | ------------------ | ------- |
840961
| `K6_SUMMARY_EXPORT` | `--summary-export <filename>` | N/A | `null` |
841962

842-
<CodeGroup labels={["Code", "Shell"]} lineNumbers={[true]}>
963+
<CodeGroup labels={[ "Shell" ]} lineNumbers={[true]}>
843964

844965
```bash
845966
$ k6 run --summary-export export.json ~/script.js
@@ -1070,7 +1191,8 @@ export let options = {
10701191
### User Agent
10711192

10721193
A string specifying the user-agent string to use in `User-Agent` headers when sending HTTP
1073-
requests. Available in `k6 run` and `k6 cloud` commands
1194+
requests. Setting it to an empty string will not send a `User-Agent` header since v0.29.0.
1195+
Available in `k6 run` and `k6 cloud` commands
10741196

10751197
| Env | CLI | Code / Config file | Default |
10761198
| --------------- | -------------- | ------------------ | --------------------------------------------------------------------- |

src/data/markdown/docs/01 guides/02 Using k6/08 Tags and Groups.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Currently, k6 automatically creates the following tags by default:
6161
| `proto` | the used protocol name (e.g. `HTTP/1.1`) |
6262
| `subproto` | the subprotocol name (used by websockets) |
6363
| `status` | the HTTP status code (e.g. `200`, `404`, etc.) |
64-
| `method` | the HTTP method name (e.g. `GET`, `POST`, etc.) |
64+
| `method` | the HTTP method name (e.g. `GET`, `POST`, etc.) or the RPC method name for gRPC |
6565
| `url` | the HTTP request URL |
6666
| `name` | the HTTP [request name](/using-k6/http-requests#url-grouping) |
6767
| `group` | the full [group](#groups) path |
@@ -70,6 +70,8 @@ Currently, k6 automatically creates the following tags by default:
7070
| `error_code` | added in k6 v0.24.0, this is a number that is unique for different error types; a list of current error codes can be found at the [Error Codes](/javascript-api/error-codes) page |
7171
| `tls_version` | the [TLS](/using-k6/protocols/ssl-tls) version |
7272
| `scenario` | the name of the scenario where the metric was emitted |
73+
| `service` | the RPC service name for gRPC |
74+
| `rpc_type` | one of `unary`, `server_streaming`, `client_streaming` or `bidirectional_streaming` for gRPC. *Note:* only `unary` requests are currently supported. |
7375

7476
If you choose, you could disable some of the above tags by using the `systemTags`
7577
[option](/using-k6/options), just keep in mind that some data collectors (e.g. `cloud`)

src/data/markdown/docs/01 guides/02 Using k6/10 Protocols.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Out of the box k6 comes with support for the following protocols:
77
* HTTP/1.1
88
* [HTTP/2](/using-k6/protocols/http-2)
99
* [WebSockets](/using-k6/protocols/websockets)
10+
* [gRPC](/using-k6/protocols/grpc)
1011

1112
k6 will use HTTP/1.1 by default when it contacts a server. If, after connection, the server
1213
reports to k6 that it supports [HTTP/2](/using-k6/protocols/http-2), k6 will upgrade the
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: 'gRPC'
3+
excerpt: ''
4+
---
5+
6+
## Overview
7+
8+
[gRPC](https://grpc.io/) is a lightweight open-source RPC framework. It was originally developed by Google, with 1.0
9+
being released in August 2016. Since then, it's gained a lot of attention as well as a wide adoption.
10+
11+
In comparison to JSON, which is transmitted as human-readable text, gRPC is binary, making it both
12+
faster to transmit and more compact. In the benchmarks we've seen between gRPC and JSON-based REST,
13+
gRPC has proved to be a lot faster than it's more traditional counterpart. The messages and services
14+
used for gRPC are described in `.proto` files, containing [Protocol Buffers](https://en.wikipedia.org/wiki/Protocol_Buffers) (protobuf) definitions.
15+
16+
Starting with k6 v0.29.0, we support unary gRPC requests via the [k6/net/grpc](/javascript-api/k6-net-grpc) built-in module.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)