Files
frankenphp/testdata/performance/hanging-requests.js
Kévin Dunglas 52a0be5728 feat(ext): expose GoValue() and PHPValue() functions (#1877)
* feat(ext): expose a GoValue function

* GoValue()
2025-09-15 16:25:11 +02:00

31 lines
743 B
JavaScript

import http from "k6/http";
/**
* It is not uncommon for external services to hang for a long time.
* Make sure the server is resilient in such cases and doesn't hang as well.
*/
export const options = {
stages: [
{ duration: "20s", target: 100 },
{ duration: "20s", target: 500 },
{ duration: "20s", target: 0 },
],
thresholds: {
http_req_failed: ["rate<0.01"],
},
};
/* global __ENV */
export default function () {
// 2% chance for a request that hangs for 15s
if (Math.random() < 0.02) {
http.get(
`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=15000&work=10000&output=100`,
);
return;
}
// a regular request
http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=5&work=10000&output=100`);
}