K6: Check for 200 status pass - but site is actually timing out

Created on 18 Sep 2017  Â·  7Comments  Â·  Source: loadimpact/k6

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).

Most helpful comment

We should log a warning if no iterations completed by the test's end. I'll get on it.

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

na-- picture na--  Â·  4Comments

caalle picture caalle  Â·  4Comments

ppcano picture ppcano  Â·  3Comments

Julianhm9612 picture Julianhm9612  Â·  4Comments

athoune picture athoune  Â·  3Comments