Is there a way to execute X number of requests?
I've played around with iterations and virtual users but they seem to require a duration being set when I don't want to set a duration just execute X number of requests per user. I don't want to ramp up or try to maximize throughput, just fire the requests.
Thanks
I think you could use simple JavaScript loop.
Example scenario test.js
:
import http from 'k6/http';
const N = 10;
export default function () {
for (let i = 0; i < N; ++i) {
http.get('http://test.k6.io');
}
}
k6 run test.js
output, as you see - exact 10 requests:
[12:06]d.vinokurov@MBP-DVinokurov[lptl]$ k6 run test.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: test.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)
running (00m01.6s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m01.6s/10m0s 1/1 iters, 1 per VU
data_received..................: 113 kB 71 kB/s
data_sent......................: 760 B 476 B/s
http_req_blocked...............: avg=14.56ms min=2µs med=2.5µs max=145.61ms p(90)=14.56ms p(95)=80.09ms
http_req_connecting............: avg=14.38ms min=0s med=0s max=143.8ms p(90)=14.38ms p(95)=79.09ms
http_req_duration..............: avg=144.89ms min=143.37ms med=144.2ms max=151.88ms p(90)=145.74ms p(95)=148.81ms
{ expected_response:true }...: avg=144.89ms min=143.37ms med=144.2ms max=151.88ms p(90)=145.74ms p(95)=148.81ms
http_req_failed................: 0.00% ✓ 0 ✗ 10
http_req_receiving.............: avg=1.52ms min=286µs med=821µs max=7.62ms p(90)=2.65ms p(95)=5.13ms
http_req_sending...............: avg=30.69µs min=15µs med=18µs max=147µs p(90)=34.49µs p(95)=90.74µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=143.33ms min=142.69ms med=143.17ms max=144.24ms p(90)=144.02ms p(95)=144.13ms
http_reqs......................: 10 6.264016/s
iteration_duration.............: avg=1.59s min=1.59s med=1.59s max=1.59s p(90)=1.59s p(95)=1.59s
iterations.....................: 1 0.626402/s
vus............................: 1 min=1 max=1
vus_max........................: 1 min=1 max=1