Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | INFRASTRUCTURE & AUTOMATION4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : MacLustr Social Engine & Remote Navigator8 * File : tests/load.mjs9 * Module : tests10 * Repository : https://git.spboucher.ai/maclustr-social11 * Project Website : https://social.spboucher.ai12 * Created : 2026-12-0113 * Last Modified : 2026-12-0114 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: admin@spboucher.ai23 * Technical Contact: dev@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Small load probe against the PREPRODUCTION public path. usage: node tests/load.mjs <cookie> [total] [concurrency]43const [cookie, total = '1500', conc = '25'] = process.argv.slice(2); const S = 'https://social-staging.51-161-112-61.sslip.io';44const paths = ['/v1/overview', '/v1/brands', '/v1/jobs', '/v1/content', '/health/ready']; const lat = []; let err = 0, i = 0; const codes = {};45const t0 = performance.now();46await Promise.all(Array.from({ length: Number(conc) }, async () => { while (i < Number(total)) { const n = i++; const a = performance.now(); try { const r = await fetch(S + paths[n % paths.length], { headers: { cookie: `__Host-mls=${cookie}` } }); await r.arrayBuffer(); codes[r.status] = (codes[r.status] ?? 0) + 1; if (r.status >= 500) err++; } catch { err++; } lat.push(performance.now() - a); } }));47lat.sort((a, b) => a - b); const q = (p) => +lat[Math.floor(lat.length * p)].toFixed(1);48console.log(JSON.stringify({ total: lat.length, concurrency: Number(conc), seconds: +((performance.now() - t0) / 1000).toFixed(1), rps: +(lat.length / ((performance.now() - t0) / 1000)).toFixed(0), ms: { p50: q(0.5), p95: q(0.95), p99: q(0.99) }, codes, errors: err }));49