Skip to content

Commit

Permalink
Replace some test-api examples (73 remain)
Browse files Browse the repository at this point in the history
  • Loading branch information
federicotdn committed Jan 20, 2025
1 parent 4d5adff commit d38562c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions docs/sources/k6/next/javascript-api/k6-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ The `name` property can be used for executing the logic based on which script is
{{< code >}}

<!-- md-k6:skip -->

```javascript
import exec from 'k6/execution';

Expand Down Expand Up @@ -157,6 +159,8 @@ Aborting is possible during initialization:

{{< code >}}

<!-- md-k6:skip -->

```javascript
import exec from 'k6/execution';
exec.test.abort();
Expand All @@ -168,6 +172,8 @@ As well as inside the `default` function:

{{< code >}}

<!-- md-k6:skip -->

```javascript
import exec from 'k6/execution';

Expand All @@ -189,6 +195,8 @@ Get the consolidated and derived options' values

{{< code >}}

<!-- md-k6:skip -->

```javascript
import exec from 'k6/execution';

Expand Down Expand Up @@ -222,7 +230,7 @@ export default function () {
exec.vu.metrics.tags['mytag2'] = 2;

// the metrics these HTTP requests emit will get tagged with `mytag` and `mytag2`:
http.batch(['https://test.k6.io', 'https://test-api.k6.io']);
http.batch(['https://test.k6.io', 'https://quickpizza.grafana.com']);
}
```

Expand All @@ -244,11 +252,11 @@ export default function () {
exec.vu.metrics.metadata['trace_id'] = 'somecoolide';

// the metrics these HTTP requests emit will get the metadata `trace_id`:
http.batch(['https://test.k6.io', 'https://test-api.k6.io']);
http.batch(['https://test.k6.io', 'https://quickpizza.grafana.com']);

delete exec.vu.metrics.metadata['trace_id']; // this will unset it
// which will make the metrics these requests to not have the metadata `trace_id` set on them.
http.batch(['https://test.k6.io', 'https://test-api.k6.io']);
http.batch(['https://test.k6.io', 'https://quickpizza.grafana.com']);
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This method takes an object argument where the following properties can be set:
import http from 'k6/http';

export default function () {
const res = http.get('https://test-api.k6.io/public/crocodiles/');
const res = http.get('https://quickpizza.grafana.com/api/json?foo=bar');

console.log(res.json());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const CounterErrors = new Counter('Errors');
export const options = { thresholds: { Errors: ['count<100'] } };

export default function () {
const res = http.get('https://test-api.k6.io/public/crocodiles/1/');
const res = http.get('https://quickpizza.grafana.com/api/json?name=Bert');
const contentOK = res.json('name') === 'Bert';
CounterErrors.add(!contentOK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const options = {
};

export default function () {
const res = http.get('https://test-api.k6.io/public/crocodiles/1/');
const res = http.get('https://quickpizza.grafana.com');
GaugeContentSize.add(res.body.length);
sleep(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const options = {
};

export default function () {
const resp = http.get('https://test-api.k6.io/public/crocodiles/1/');
const resp = http.get('https://quickpizza.grafana.com');

errorRate.add(resp.status >= 400);

Expand Down

0 comments on commit d38562c

Please sign in to comment.