@richmarshall Thank you for the detailed debug steps. I’ll try those.
here is the full script, please let me know if something is wrong. I run this on k8s pod so I call directly using service name.
import http from "k6/http";
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.2/index.js";
import { check } from "k6";
const target = __ENV.TARGET || 10000;
export let options = {
insecureSkipTLSVerify: true,
summaryTrendStats: [
"min",
"max",
"avg",
"med",
"p(99)",
"p(99.5)",
"p(99.9)",
],
discardResponseBodies: true,
scenarios: {
ramping: {
executor: "ramping-arrival-rate",
// Pre-allocate necessary VUs.
preAllocatedVUs: 50,
maxVUs: 2000,
stages: [
{ duration: "1m", target: target },
{ duration: "10m", target: target },
{ duration: "1m", target: 0 },
],
},
};
const url =
"http://service-name:8080/path";
const body = {
id: "id",
};
export default () => {
const params = {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${__ENV.TOKEN}`,
},
timeout: "1s",
};
const res = http.post(url, JSON.stringify(body), params);
check(res, {
"status was 200": (r) => r.status == 200,
"status was 403": (r) => r.status == 403,
"status was 404": (r) => r.status == 404,
"status was 422": (r) => r.status == 422,
"status was 423": (r) => r.status == 422,
"status was 500": (r) => r.status == 500,
"status was 501": (r) => r.status == 501,
"status was 502": (r) => r.status == 502,
"no response": (r) => !r.status,
});
};
export function handleSummary(data) {
const output_text = `${__ENV.OUTPUT}.txt`;
const output_json = `${__ENV.OUTPUT}.json`;
console.log(output_text);
console.log(output_json);
return {
stdout: textSummary(data, {}),
[output_text]: textSummary(data, {}),
[output_json]: JSON.stringify(
{ http_req_failed: data.metrics.http_req_failed.values },
null,
2,
),
};
}