MCPcopy Create free account
hub / github.com/BlockRunAI/ClawRouter / testMemoryPressure

Function testMemoryPressure

test/resilience-errors.ts:285–313  ·  view source on GitHub ↗
(ctx: TestContext)

Source from the content-addressed store, hash-verified

283// ═══════════════════════════════════════════════════════════════════════════
284
285async function testMemoryPressure(ctx: TestContext): Promise<void> {
286 console.log("\n═══ Test 5: Memory Pressure (Concurrent Large Requests) ═══\n");
287
288 try {
289 // Send 20 concurrent requests with 100KB payloads
290 const promises = Array.from({ length: 20 }).map(() =>
291 fetch(`${ctx.proxy.baseUrl}/v1/chat/completions`, {
292 method: "POST",
293 headers: { "Content-Type": "application/json" },
294 body: JSON.stringify({
295 model: "deepseek/deepseek-chat",
296 messages: [{ role: "user", content: "x".repeat(100_000) }], // 100KB
297 }),
298 signal: AbortSignal.timeout(5000),
299 }).catch(() => null),
300 );
301
302 await Promise.all(promises);
303 await sleep(100);
304
305 const health = await fetch(`${ctx.proxy.baseUrl}/health`);
306 assert(health.ok, "Proxy survived memory pressure (20x 100KB concurrent requests)");
307 } catch (err) {
308 assert(
309 false,
310 `Memory pressure test failed: ${err instanceof Error ? err.message : String(err)}`,
311 );
312 }
313}
314
315// ═══════════════════════════════════════════════════════════════════════════
316// Main Test Runner

Callers 1

mainFunction · 0.85

Calls 2

sleepFunction · 0.70
assertFunction · 0.70

Tested by

no test coverage detected