domsolutions / xk6-fasthttp

A k6 extension using fasthttp library for improved speed of HTTP/1.1 requests
Apache License 2.0
2 stars 0 forks source link

`checkstatus` function doesn't work correctly #22

Closed mprokopjc closed 1 day ago

mprokopjc commented 2 months ago

Hey! 👋 I was following example usage of checkstatus from https://github.com/domsolutions/xk6-fasthttp/blob/master/examples/json.js#L11 but it doesn't work for me correctly.

When I run following k6 script:

import { Request, Client, checkstatus } from "k6/x/fasthttp";

export const options = {
    vus: 1,
    iterations: 3
};

const client = new Client({
    max_conns_per_host: 1,
    tls_config: {
        insecure_skip_verify: true
    }
})

export default function () {
    let req = new Request('https://test-api.k6.io/public/crocodiles/', {
        headers: {
            "content-type": "application/json"
        }
    });

    let res = client.get(req);
    console.log(res.status);
    checkstatus(200, res);
}

Below is the output when I run it. While the output for console.log(res.status); indicates that all requests returned 200 OK, the check using checkstatus(200, res) failed. See screenshot from of its output:

image

k6 version that I am using:

./k6 version                                                                                                                                                  ✘ 255
k6 v0.51.0 (go1.21.6, darwin/amd64)
Extensions:
  github.com/domsolutions/xk6-fasthttp v0.0.0-20240608093340-3f8eb414c343, k6/x/fasthttp [js]
domsolutions commented 1 day ago

Hi @mprokopjc

Sorry for the late reply, this has now been fixed in the latest release https://github.com/domsolutions/xk6-fasthttp/releases/tag/0.1.1

mprokopjc commented 10 hours ago

Perfect. Thank you!