feat: Add comprehensive testing plan for IPSExtractor, including unit, integration, E2E, stress, and resilience tests. Introduce LaTeX documentation structure with sections for architecture, test strategy, and execution guidelines. Enhance README with setup instructions and k6 stress testing scripts.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import http from 'k6/http';
|
||||
import { check, sleep } from 'k6';
|
||||
|
||||
/**
|
||||
* ST-BOT-01 — Heartbeats concurrentes de workers.
|
||||
*
|
||||
* k6 run -e BASE_URL=http://127.0.0.1:8189 -e BOT_API_TOKEN=dev-token-change-me \
|
||||
* -e PROFILE=shared8g k6_bot_heartbeats.js
|
||||
*/
|
||||
const PROFILE = __ENV.PROFILE || 'shared8g';
|
||||
const TOKEN = __ENV.BOT_API_TOKEN || 'dev-token-change-me';
|
||||
const PREFIX = __ENV.WORKER_PREFIX || 'load-w';
|
||||
const BASE_URL = __ENV.BASE_URL || 'http://127.0.0.1:8189';
|
||||
|
||||
const profiles = {
|
||||
shared8g: { vus: 5, duration: '2m' },
|
||||
lab: { vus: 25, duration: '3m' },
|
||||
};
|
||||
|
||||
const cfg = profiles[PROFILE] || profiles.shared8g;
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
heartbeats: {
|
||||
executor: 'constant-vus',
|
||||
vus: cfg.vus,
|
||||
duration: cfg.duration,
|
||||
},
|
||||
},
|
||||
thresholds: {
|
||||
http_req_duration: ['p(95)<800'],
|
||||
checks: ['rate>0.95'],
|
||||
},
|
||||
tags: { profile: PROFILE },
|
||||
};
|
||||
|
||||
function headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${TOKEN}`,
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
}
|
||||
|
||||
export function setup() {
|
||||
for (let i = 0; i < cfg.vus; i++) {
|
||||
const wid = `${PREFIX}-${i}`;
|
||||
http.post(
|
||||
`${BASE_URL}/bot-descarga/workers/register`,
|
||||
JSON.stringify({ worker_id: wid, hostname: `k6-${i}`, max_concurrent: 1 }),
|
||||
{ headers: headers() },
|
||||
);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
export default function () {
|
||||
const wid = `${PREFIX}-${__VU - 1}`;
|
||||
const res = http.post(
|
||||
`${BASE_URL}/bot-descarga/workers/heartbeat`,
|
||||
JSON.stringify({ worker_id: wid }),
|
||||
{ headers: headers() },
|
||||
);
|
||||
check(res, {
|
||||
'heartbeat 200': (r) => r.status === 200,
|
||||
});
|
||||
sleep(8);
|
||||
}
|
||||
Reference in New Issue
Block a user