- Updated README.md to reflect changes in load testing commands and added usage examples for Bash scripts. - Converted PowerShell load testing scripts to Bash equivalents for better cross-platform compatibility. - Added new Bash scripts: run-loadtests.sh, summarize-artillery.sh, and summarize-k6.sh to mirror existing PowerShell functionality. - Updated admin-api.js and ws-chat.yml for consistency and improved performance metrics reporting. - Enhanced error handling and output formatting in summary scripts for better readability.
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
import http from "k6/http";
|
|
import { check, sleep } from "k6";
|
|
|
|
const baseUrl = __ENV.ADMIN_BASE_URL || "https://linearvoid.tv";
|
|
const adminCookie = __ENV.ADMIN_SESSION_COOKIE || "";
|
|
const requestParams = adminCookie ? { headers: { Cookie: adminCookie } } : {};
|
|
|
|
const endpoints = [
|
|
{ name: "overview", path: "/api/admin/overview" },
|
|
{ name: "analytics", path: "/api/admin/analytics" },
|
|
{ name: "chat_log", path: "/api/admin/chat-log" },
|
|
{ name: "users", path: "/api/admin/users" },
|
|
];
|
|
|
|
export const options = {
|
|
stages: [
|
|
{ duration: "30s", target: 10 },
|
|
{ duration: "60s", target: 50 },
|
|
{ duration: "60s", target: 100 },
|
|
{ duration: "30s", target: 0 },
|
|
],
|
|
thresholds: {
|
|
http_req_duration: ["p(95)<1000"],
|
|
http_req_failed: ["rate<0.01"],
|
|
"http_req_duration{endpoint:overview}": ["p(95)<1000"],
|
|
"http_req_duration{endpoint:analytics}": ["p(95)<1000"],
|
|
"http_req_duration{endpoint:chat_log}": ["p(95)<1000"],
|
|
"http_req_duration{endpoint:users}": ["p(95)<1000"],
|
|
"http_req_failed{endpoint:overview}": ["rate<0.01"],
|
|
"http_req_failed{endpoint:analytics}": ["rate<0.01"],
|
|
"http_req_failed{endpoint:chat_log}": ["rate<0.01"],
|
|
"http_req_failed{endpoint:users}": ["rate<0.01"],
|
|
},
|
|
};
|
|
|
|
export default function () {
|
|
const requests = endpoints.map((endpoint) => [
|
|
"GET",
|
|
`${baseUrl}${endpoint.path}`,
|
|
null,
|
|
{
|
|
...requestParams,
|
|
tags: {
|
|
endpoint: endpoint.name,
|
|
},
|
|
},
|
|
]);
|
|
const responses = http.batch(requests);
|
|
|
|
responses.forEach((response, index) => {
|
|
const endpointPath = endpoints[index].path;
|
|
check(response, {
|
|
[`status is 200 for ${endpointPath}`]: (r) => r.status === 200,
|
|
});
|
|
});
|
|
|
|
sleep(1);
|
|
}
|