Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const options = {
};

// The default exported function is gonna be picked up by k6 as the entry point for the test script. It will be executed repeatedly in "iterations" for the whole duration of the test.
export default function() {
export default function () {
// Make a GET request to the target URL
http.get('https://quickpizza.grafana.com');

Expand Down
6 changes: 3 additions & 3 deletions docs/sources/k6/next/javascript-api/k6-ws/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ weight: 10

Initiate a WebSocket connection to a remote host.

Calling connect will block the VU finalization until the WebSocket connection is closed. Instead of continuously looping the main function (`export default function() { ... }`) over an over, each VU will be halted listening to async events and executing their event handlers until the connection is closed.
Calling connect will block the VU finalization until the WebSocket connection is closed. Instead of continuously looping the main function (`export default function () { ... }`) over an over, each VU will be halted listening to async events and executing their event handlers until the connection is closed.

The following events can close the connection:

Expand All @@ -21,7 +21,7 @@ The following events can close the connection:

| Parameter | Type | Description |
| --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url | string | Request URL (e.g. "ws://echo.websocket.org"). |
| url | string | Request URL (e.g. "wss://echo.websocket.org"). |
| params | object | [Params](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/params) object containing additional request parameters. |
| callback | function | The callback function that will be called when the WebSocket connection is initiated. A [Socket](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/socket) object will be passed to the function, and this object can be used to set up callbacks etc when things happen on the WebSocket connection |

Expand All @@ -39,7 +39,7 @@ The following events can close the connection:
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const resp = ws.connect(url, null, function (socket) {
socket.on('open', function () {
console.log('WebSocket connection established!');
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/next/javascript-api/k6-ws/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _A k6 script that will make a WebSocket request with a custom header and tag res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = {
headers: { 'X-MyHeader': 'k6test' },
tags: { k6test: 'yes' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Close the WebSocket connection.
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Send a ping. Ping messages can be used to verify that the remote endpoint is res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.on('pong', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can use `JSON.stringify` to convert a JSON or JavaScript values to a JSON st
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.send('my-message');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { sleep } from 'k6';

export default function () {
console.log('T0: Script started');
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
console.log('T0: Entered WebSockets run loop');
socket.setTimeout(function () {
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/next/using-k6/http-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Given the following script:
```javascript
import http from "k6/http";

export default function() {
export default function () {
http.get("https://google.com/");
}
```
Expand Down
12 changes: 6 additions & 6 deletions docs/sources/k6/next/using-k6/protocols/websockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Currently, it's available as an experimental module [`k6/experimental/websockets
{{< /admonition >}}

Comparing HTTP-based tests to WebSocket ones, you'll find differences in both structure and inner workings.
The primary difference is that instead of continuously looping the main function (`export default function() { ... }`) over and over, each VU is now runs an asynchronous event loop.
The primary difference is that instead of continuously looping the main function (`export default function () { ... }`) over and over, each VU is now runs an asynchronous event loop.

The basic structure of a WebSocket test looks like this:

Expand All @@ -33,7 +33,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -65,7 +65,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -97,7 +97,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -132,7 +132,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -164,7 +164,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
4 changes: 2 additions & 2 deletions docs/sources/k6/v1.1.x/javascript-api/k6-ws/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The following events can close the connection:

| Parameter | Type | Description |
| --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url | string | Request URL (e.g. "ws://echo.websocket.org"). |
| url | string | Request URL (e.g. "wss://echo.websocket.org"). |
| params | object | [Params](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/params) object containing additional request parameters. |
| callback | function | The callback function that will be called when the WebSocket connection is initiated. A [Socket](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/socket) object will be passed to the function, and this object can be used to set up callbacks etc when things happen on the WebSocket connection |

Expand All @@ -39,7 +39,7 @@ The following events can close the connection:
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const resp = ws.connect(url, null, function (socket) {
socket.on('open', function () {
console.log('WebSocket connection established!');
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/v1.1.x/javascript-api/k6-ws/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _A k6 script that will make a WebSocket request with a custom header and tag res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = {
headers: { 'X-MyHeader': 'k6test' },
tags: { k6test: 'yes' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Close the WebSocket connection.
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Send a ping. Ping messages can be used to verify that the remote endpoint is res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.on('pong', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can use `JSON.stringify` to convert a JSON or JavaScript values to a JSON st
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.send('my-message');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { sleep } from 'k6';

export default function () {
console.log('T0: Script started');
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
console.log('T0: Entered WebSockets run loop');
socket.setTimeout(function () {
Expand Down
10 changes: 5 additions & 5 deletions docs/sources/k6/v1.1.x/using-k6/protocols/websockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -65,7 +65,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -97,7 +97,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -132,7 +132,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down Expand Up @@ -164,7 +164,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
4 changes: 2 additions & 2 deletions docs/sources/k6/v1.2.x/javascript-api/k6-ws/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The following events can close the connection:

| Parameter | Type | Description |
| --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url | string | Request URL (e.g. "ws://echo.websocket.org"). |
| url | string | Request URL (e.g. "wss://echo.websocket.org"). |
| params | object | [Params](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/params) object containing additional request parameters. |
| callback | function | The callback function that will be called when the WebSocket connection is initiated. A [Socket](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-ws/socket) object will be passed to the function, and this object can be used to set up callbacks etc when things happen on the WebSocket connection |

Expand All @@ -39,7 +39,7 @@ The following events can close the connection:
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const resp = ws.connect(url, null, function (socket) {
socket.on('open', function () {
console.log('WebSocket connection established!');
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/v1.2.x/javascript-api/k6-ws/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _A k6 script that will make a WebSocket request with a custom header and tag res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = {
headers: { 'X-MyHeader': 'k6test' },
tags: { k6test: 'yes' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Close the WebSocket connection.
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const response = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Send a ping. Ping messages can be used to verify that the remote endpoint is res
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.on('pong', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can use `JSON.stringify` to convert a JSON or JavaScript values to a JSON st
import ws from 'k6/ws';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.send('my-message');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ws from 'k6/ws';
import { check } from 'k6';

export default function () {
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const params = { tags: { my_tag: 'hello' } };

const res = ws.connect(url, params, function (socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { sleep } from 'k6';

export default function () {
console.log('T0: Script started');
const url = 'ws://echo.websocket.org';
const url = 'wss://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
console.log('T0: Entered WebSockets run loop');
socket.setTimeout(function () {
Expand Down
Loading
Loading