Skip to content

Commit 0dce52f

Browse files
retry with 1000 requests
1 parent 8eb519b commit 0dce52f

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { describe, test, expect, jest } from "@jest/globals";
2+
import { orkesConductorClient } from "../../src/orkes";
3+
import { WorkflowExecutor } from "../../src/core";
4+
import { TaskType, WorkflowDef } from "../../src/common";
5+
6+
// --- Configuration for the Load Test ---
7+
// The number of requests to send in parallel.
8+
// Adjust this number to find the breaking point of your load balancer.
9+
const CONCURRENT_REQUESTS = 3000;
10+
const TEST_TIMEOUT = 60000 * 10; // 60 seconds
11+
12+
describe("Load balancer test for POST requests", () => {
13+
jest.setTimeout(TEST_TIMEOUT);
14+
15+
test(`should handle ${CONCURRENT_REQUESTS} POST requests`, async () => {
16+
const client = await orkesConductorClient();
17+
const executor = new WorkflowExecutor(client);
18+
console.log(`Starting POST load test for workflow registration`);
19+
console.log(`Sending ${CONCURRENT_REQUESTS} concurrent requests...`);
20+
const requestPromises: Promise<any>[] = [];
21+
for (let i = 0; i < CONCURRENT_REQUESTS; i++) {
22+
const workflowName = "JS_SDK_load_test_post_workflow"
23+
const workflowDef: WorkflowDef = {
24+
name: workflowName,
25+
version: 1,
26+
inputParameters: [],
27+
tasks: [
28+
{
29+
name: "JS_SDK_simple_task_post",
30+
taskReferenceName: "JS_SDK_simple_task_post_ref",
31+
type: TaskType.SIMPLE,
32+
},
33+
],
34+
timeoutSeconds: 0,
35+
};
36+
requestPromises.push(executor.registerWorkflow(true, workflowDef));
37+
}
38+
const results = await Promise.allSettled(requestPromises);
39+
let successCount = 0;
40+
const econnresetErrors: any[] = [];
41+
const http429Errors: any[] = [];
42+
const otherErrors: any[] = [];
43+
results.forEach((result, index) => {
44+
if (result.status === "fulfilled") {
45+
successCount++;
46+
} else {
47+
const reason = result.reason;
48+
if (reason?.code === "ECONNRESET") {
49+
econnresetErrors.push({ requestIndex: index, reason });
50+
} else if (reason?.body?.status === 429) {
51+
http429Errors.push({ requestIndex: index, reason });
52+
} else {
53+
otherErrors.push({ requestIndex: index, reason });
54+
}
55+
}
56+
});
57+
console.log("--- Load Test Results ---");
58+
console.log(
59+
`Successful Requests: ${successCount} / ${CONCURRENT_REQUESTS}`
60+
);
61+
console.log(`ECONNRESET Failures: ${econnresetErrors.length}`);
62+
console.log(`HTTP 429 Failures: ${http429Errors.length}`);
63+
console.log(`Other Failures: ${otherErrors.length}`);
64+
console.log("-------------------------");
65+
if (econnresetErrors.length > 0) {
66+
console.error("ECONNRESET errors detected:", econnresetErrors);
67+
}
68+
if (http429Errors.length > 0) {
69+
console.error(
70+
"HTTP 429 (Too Many Requests) errors detected:",
71+
http429Errors
72+
);
73+
}
74+
if (otherErrors.length > 0) {
75+
console.error(`\n--- Other Errors (${otherErrors.length}) ---`);
76+
for (const error of otherErrors) {
77+
console.error(
78+
`Request Index ${error.requestIndex} failed. Reason:`,
79+
error.reason
80+
);
81+
}
82+
console.error("--------------------------\n");
83+
}
84+
expect(econnresetErrors.length).toBe(0);
85+
expect(http429Errors.length).toBe(0);
86+
expect(otherErrors.length).toBe(0);
87+
});
88+
});

0 commit comments

Comments
 (0)