The checks cannot be 100%, and my "status was 200" is 0%

Hi, K6 Community, i am new to K6 and still learning.

I got this error when i running a test, the checks cannot be 100%, and my “status was 200” is 0% can anyone help me please?

Hi @zndzzh

Welcome to the community forum :wave:

Based on the screenshot, it looks like the requests are not returning a status 200 ok and some duration is below the defined threshold of 2 seconds. Those are not errors in the test, but information regarding the checks you defined. That is, your system under test is not returing the http response code you expect, and some requests are slower than what you defined.

I recommend debugging your script to better understand where the failed checks come from. Start small, with maybe 1 iteration and 1 vu, and check the http response code and response time. Do you have the same failed checks with less load?

Maybe your service returns a 201 status or other status, instead of 200? Debugging will help you figure this out.

We can further help if you share the (sanitized) script and the complete test output (so we can see if there are indeed any error logs). Even if the label says “Status was 200”, what we need to see is the check in the script.

I hope this helps.

Cheers!

Hi @eyeveebe thanks for your respond,

this is my script

i’ve try with 201 status but still the same, and when i try with 1vu and 1 iterattion, still 0%

Hi @zndzzh

I would first start by finding out the status code of this type of request, outside k6. You can run a curl -v -X GET https://reqres.in/api/users/275. In my case, if the url is correct, I see a 404:

* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 404
< date: Thu, 27 Apr 2023 19:10:39 GMT

Meaning this URL is does not respond. The same you will probably see if you access it in a browser, using Developer tools. Again, you’ll see a status 404 (page not found).

You need to figure out first what URLs your test should invoke. If you try the same script with one of our test urls that actually return a 200 status:

import http from 'k6/http';
import { check, sleep } from 'k6';

export let options = {
    vus: 1,
    iterations: 1,
    duration: '2s',
};

export default function () {
    let res = http.get("https://httpbin.org/status/200");
    check(res, {
        "is status 200": (r) => r.status === 200,
        "Request duration is below 2s": (r) => r.timings.duration < 2000,
    });
}

You will see the check passes.

To summarize, this is due to your endpoint not returning what you expect (most probably the user with id 275 does not exist?). k6 is working as expected here and letting you know that the response is not a 200 (or 201). The fix is on the endpoint (or the urls your test requests), not k6.

I hope this helps.

Cheers!