I have a simple script test.js
import { check, sleep } from "k6";
import http from "k6/http";
export default function() {
check(http.get("http://demo.k6.io"), {
"status is 200": (res) => res.status == 200
});
sleep(1);
}
I get the following result:
Running k6 with script 'test.js' ...
/\ |‾‾| /‾‾/ /‾/
/\ / \ | |_/ / / /
/ \/ \ | | / ‾‾\
/ \ | |‾\ \ | (_) |
/ __________ \ |__| \__\ \___/ Welcome to k6 v0.17.1!
execution: local
output: Load Impact (https://app.loadimpact.com/k6/runs/70)
script: /scripts/test.js (js)
duration: 30s, iterations: 0
vus: 10, max: 10
web ui: http://0.0.0.0:6565/
done [==========================================================] 30s / 30s
✓ status is 200
vus.......: 10
vus_max...: 10
... done.
Thing is though that http://demo.k6.io is (at least at the time of this writing) times out if trying to go to it with a browser/curl. So I'm confused as to why the k6 reports a pass for 200 status here. Also the report overall does not make it clear a timeout has happened (you just don't get any of the normal metrics).
This was tested with the latest dockerized k6 (v0.17.1).
I guess you didnt get any response, so no checks => no errors.
@artych But the check passes and thus reports a status of 200?
Yes, IMHO opinion, k6 should report a timeout (exception?) and not a 200 pass.
@aidylewis @Griatch
Run it with duration bigger than "30s" and you'll get timeout error and status will be red.
@artych This seems to be correct - running for 31 seconds times out the connection and prints a failed status on the check as expected. Nevertheless I would think it more logical to report that no data was received/no checks could run rather than pass checks by default if running a shorter test than the timeout - especially since the starting documentation specifically gives examples that run for 30 seconds.
Magic 31st second :)
We should log a warning if no iterations completed by the test's end. I'll get on it.
Most helpful comment
We should log a warning if no iterations completed by the test's end. I'll get on it.