* Stress tests with very high load
(server)
| 395 | * Stress tests with very high load |
| 396 | */ |
| 397 | async function stressTests (server) { |
| 398 | const baseUrl = `http://localhost:${server.server.address().port}`; |
| 399 | |
| 400 | console.log("\n🔥 Stress Tests"); |
| 401 | console.log("=".repeat(50)); |
| 402 | |
| 403 | const tests = [ |
| 404 | { |
| 405 | title: "Stress Test - High Connections", |
| 406 | url: `${baseUrl}/ping`, |
| 407 | connections: 200, |
| 408 | duration: 15 |
| 409 | }, |
| 410 | { |
| 411 | title: "Stress Test - Very High Connections", |
| 412 | url: `${baseUrl}/ping`, |
| 413 | connections: 500, |
| 414 | duration: 10 |
| 415 | }, |
| 416 | { |
| 417 | title: "Stress Test - JSON with High Load", |
| 418 | url: `${baseUrl}/users`, |
| 419 | connections: 100, |
| 420 | duration: 15 |
| 421 | }, |
| 422 | { |
| 423 | title: "Stress Test - Large Response High Load", |
| 424 | url: `${baseUrl}/large`, |
| 425 | connections: 50, |
| 426 | duration: 10 |
| 427 | } |
| 428 | ]; |
| 429 | |
| 430 | const results = []; |
| 431 | for (const test of tests) { |
| 432 | console.log("\n⚠️ Warning: Running high-load stress test..."); |
| 433 | const result = await runLoadTest(test); |
| 434 | results.push({ ...test, result }); |
| 435 | |
| 436 | // Longer pause between stress tests |
| 437 | await new Promise(resolve => setTimeout(resolve, 3000)); |
| 438 | } |
| 439 | |
| 440 | return results; |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Parameterized endpoint tests |
no test coverage detected