No results for

Powered byAlgolia

Single request

suggest edits
single-request.js
1import http from 'k6/http';
2import { sleep, check } from 'k6';
3import { Counter } from 'k6/metrics';
4
5// A simple counter for http requests
6
7export const requests = new Counter('http_reqs');
8
9// you can specify stages of your test (ramp up/down patterns) through the options object
10// target is the number of VUs you are aiming for
11
12export const options = {
13 stages: [
14 { target: 20, duration: '1m' },
15 { target: 15, duration: '1m' },
16 { target: 0, duration: '1m' },
17 ],
18 thresholds: {
19 requests: ['count < 100'],
20 },
21};
22
23export default function () {
24 // our HTTP request, note that we are saving the response to res, which can be accessed later
25
26 const res = http.get('http://test.k6.io');
27
28 sleep(1);
29
30 const checkRes = check(res, {
31 'status is 200': (r) => r.status === 200,
32 'response body': (r) => r.body.indexOf('Feel free to browse') !== -1,
33 });
34}