Skip to content

Commit 55047e2

Browse files
committed
Try runInBand to prevent 502/503
1 parent dcaa976 commit 55047e2

3 files changed

Lines changed: 91 additions & 74 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,13 @@ jobs:
3232
- name: Run Linter
3333
run: npm run lint
3434

35-
tests:
35+
unit-tests:
3636
runs-on: ubuntu-latest
3737
strategy:
3838
fail-fast: false
3939
matrix:
4040
node-version: [20, 22, 24]
41-
test: [unit, integration:v5:batch]
42-
batch-index: [0, 1, 2, 3, 4]
43-
exclude:
44-
- test: unit
45-
batch-index: 1
46-
- test: unit
47-
batch-index: 2
48-
- test: unit
49-
batch-index: 3
50-
- test: unit
51-
batch-index: 4
52-
- test: integration:v4
53-
batch-index: 1
54-
- test: integration:v4
55-
batch-index: 2
56-
- test: integration:v4
57-
batch-index: 3
58-
- test: integration:v4
59-
batch-index: 4
60-
name: Node.js v${{ matrix.node-version }} - ${{ matrix.test == 'integration:v5:batch' && format('{0}{1}', matrix.test, matrix.batch-index) || matrix.test }} tests
41+
name: Node.js v${{ matrix.node-version }} - unit tests
6142
steps:
6243
- name: Checkout
6344
uses: actions/checkout@v4
@@ -77,42 +58,71 @@ jobs:
7758
- name: Install Dependencies
7859
if: steps.cache.outputs.cache-hit != 'true'
7960
run: npm ci
80-
- name: Stagger integration start (reduce auth/server thundering)
81-
if: ${{ matrix.test == 'integration:v5:batch' }}
82-
run: |
83-
# Spread 15 integration jobs over ~30s so token endpoint isn't hammered
84-
case "${{ matrix.node-version }}" in 20) n=0;; 22) n=1;; 24) n=2;; *) n=0;; esac
85-
delay=$(( ${{ matrix.batch-index }} * 6 + n * 2 ))
86-
echo "Staggering ${delay}s before running tests (batch ${{ matrix.batch-index }}, node ${{ matrix.node-version }})"
87-
sleep "$delay"
88-
- name: Run ${{ matrix.test }} Tests and Add Annotations
89-
id: tests
90-
run: |
91-
if [ "${{ matrix.test }}" = "integration:v5:batch" ]; then
92-
npm run test:integration:v5:batch -- ${{ matrix.batch-index }} -- --ci --coverage --reporters=default --reporters=github-actions --reporters=jest-junit
93-
else
94-
npm run test:${{ matrix.test }} -- --ci --coverage --reporters=default --reporters=github-actions --reporters=jest-junit
95-
fi
61+
- name: Run unit tests
62+
run: npm run test:unit -- --ci --coverage --reporters=default --reporters=github-actions --reporters=jest-junit
9663
env:
97-
ORKES_BACKEND_VERSION: ${{ matrix.test == 'integration:v4' && '4' || (contains(matrix.test, 'integration:v5') && '5' || '') }}
98-
CONDUCTOR_SERVER_URL: ${{ matrix.test == 'integration:v4' && vars.SERVER_URL_V4 || (contains(matrix.test, 'integration') && vars.SERVER_URL || '') }}
99-
CONDUCTOR_AUTH_KEY: ${{ matrix.test == 'integration:v4' && secrets.AUTH_KEY_V4 || (contains(matrix.test, 'integration') && secrets.AUTH_KEY || '') }}
100-
CONDUCTOR_AUTH_SECRET: ${{ matrix.test == 'integration:v4' && secrets.AUTH_SECRET_V4 || (contains(matrix.test, 'integration') && secrets.AUTH_SECRET || '') }}
101-
CONDUCTOR_SDK_INITIAL_TOKEN_STAGGER_MS: ${{ (matrix.test == 'integration:v4' || contains(matrix.test, 'integration')) && '2000' || '' }}
102-
JEST_JUNIT_OUTPUT_NAME: ${{ matrix.test == 'integration:v5:batch' && format('{0}{1}-node-{2}-test-results.xml', matrix.test, matrix.batch-index, matrix.node-version) || format('{0}-node-{1}-test-results.xml', matrix.test, matrix.node-version) }}
64+
JEST_JUNIT_OUTPUT_NAME: unit-tests-node-${{ matrix.node-version }}-test-results.xml
10365
- name: Publish Test Results
10466
uses: dorny/test-reporter@v2
10567
if: ${{ !cancelled() }}
10668
with:
107-
name: ${{ matrix.test == 'integration:v5:batch' && format('{0}{1} (Node {2})', matrix.test, matrix.batch-index, matrix.node-version) || format('{0} (Node {1})', matrix.test, matrix.node-version) }}
108-
path: reports/${{ matrix.test == 'integration:v5:batch' && format('{0}{1}-node-{2}-test-results.xml', matrix.test, matrix.batch-index, matrix.node-version) || format('{0}-node-{1}-test-results.xml', matrix.test, matrix.node-version) }}
69+
name: unit tests (Node ${{ matrix.node-version }})
70+
path: reports/unit-tests-node-${{ matrix.node-version }}-test-results.xml
10971
reporter: jest-junit
11072
- name: Upload coverage to Codecov
11173
if: always()
11274
uses: codecov/codecov-action@v4
11375
with:
11476
token: ${{ secrets.CODECOV_TOKEN }}
11577
files: ./coverage/lcov.info
116-
flags: ${{ matrix.test }}
117-
name: codecov-${{ matrix.test }}-node-${{ matrix.node-version }}
78+
flags: unit
79+
name: codecov-unit-node-${{ matrix.node-version }}
80+
fail_ci_if_error: false
81+
82+
integration-tests:
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 25
85+
name: Node.js 22 - integration tests (v5)
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v4
89+
- name: Set up Node
90+
uses: actions/setup-node@v4
91+
with:
92+
node-version: "22"
93+
cache: "npm"
94+
- name: Cache node_modules
95+
id: cache
96+
uses: actions/cache@v4
97+
with:
98+
path: node_modules
99+
key: npm-22-${{ hashFiles('package-lock.json') }}
100+
restore-keys: |
101+
npm-22-
102+
- name: Install Dependencies
103+
if: steps.cache.outputs.cache-hit != 'true'
104+
run: npm ci
105+
- name: Run integration tests (v5)
106+
run: npm run test:integration:v5 -- --ci --coverage --runInBand --testTimeout=120000 --reporters=default --reporters=github-actions --reporters=jest-junit
107+
env:
108+
ORKES_BACKEND_VERSION: "5"
109+
CONDUCTOR_SERVER_URL: ${{ vars.SERVER_URL }}
110+
CONDUCTOR_AUTH_KEY: ${{ secrets.AUTH_KEY }}
111+
CONDUCTOR_AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
112+
JEST_JUNIT_OUTPUT_NAME: integration-v5-node-22-test-results.xml
113+
- name: Publish Test Results
114+
uses: dorny/test-reporter@v2
115+
if: ${{ !cancelled() }}
116+
with:
117+
name: integration tests v5 (Node 22)
118+
path: reports/integration-v5-node-22-test-results.xml
119+
reporter: jest-junit
120+
- name: Upload coverage to Codecov
121+
if: always()
122+
uses: codecov/codecov-action@v4
123+
with:
124+
token: ${{ secrets.CODECOV_TOKEN }}
125+
files: ./coverage/lcov.info
126+
flags: integration-v5
127+
name: codecov-integration-v5-node-22
118128
fail_ci_if_error: false

src/integration-tests/EventClient.test.ts

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
1-
import { afterEach, describe, expect, jest, test } from "@jest/globals";
1+
import {
2+
afterEach,
3+
beforeAll,
4+
describe,
5+
expect,
6+
jest,
7+
test,
8+
} from "@jest/globals";
29
import type {
310
Action,
411
ConnectivityTestInput,
512
EventHandler,
613
Tag,
714
} from "../open-api";
8-
import { EventClient, orkesConductorClient } from "../sdk";
15+
import { EventClient } from "../sdk";
16+
import { createClientWithRetry } from "./utils/createClientWithRetry";
917
import { describeForOrkesV5 } from "./utils/customJestDescribe";
1018

1119
const TEST_HANDLER_NAME_PREFIX = "jsSdkTest:";
1220

1321
describe("EventClient", () => {
14-
jest.setTimeout(60000);
22+
jest.setTimeout(30000);
23+
24+
let eventClient: EventClient;
25+
26+
beforeAll(async () => {
27+
const client = await createClientWithRetry();
28+
eventClient = new EventClient(client);
29+
});
1530

1631
// Clean up any event handlers created by tests (runs even when a test fails)
1732
afterEach(async () => {
1833
try {
19-
const eventClient = new EventClient(await orkesConductorClient());
34+
if (!eventClient) return;
2035
const handlers = await eventClient.getAllEventHandlers();
2136
const toRemove = handlers.filter(
2237
(h) => h.name?.startsWith(TEST_HANDLER_NAME_PREFIX)
@@ -65,7 +80,6 @@ describe("EventClient", () => {
6580

6681
describe("Event Handler Management", () => {
6782
test("Should add a single event handler", async () => {
68-
const eventClient = new EventClient(await orkesConductorClient());
6983
const handlerName = createUniqueName("event-handler");
7084
const eventName = createUniqueName("event");
7185

@@ -138,7 +152,6 @@ describe("EventClient", () => {
138152
});
139153

140154
test("Should add multiple event handlers", async () => {
141-
const eventClient = new EventClient(await orkesConductorClient());
142155
const handlerName1 = createUniqueName("event-handler-1");
143156
const handlerName2 = createUniqueName("event-handler-2");
144157
const eventName1 = createUniqueName("event-1");
@@ -166,7 +179,6 @@ describe("EventClient", () => {
166179
});
167180

168181
test("Should update an event handler", async () => {
169-
const eventClient = new EventClient(await orkesConductorClient());
170182
const handlerName = createUniqueName("event-handler");
171183
const eventName = createUniqueName("event");
172184

@@ -199,14 +211,12 @@ describe("EventClient", () => {
199211
});
200212

201213
test("Should get all event handlers", async () => {
202-
const eventClient = new EventClient(await orkesConductorClient());
203214
const handlers = await eventClient.getAllEventHandlers();
204215

205216
expect(Array.isArray(handlers)).toBe(true);
206217
});
207218

208219
test("Should get event handler by name", async () => {
209-
const eventClient = new EventClient(await orkesConductorClient());
210220
const handlerName = createUniqueName("event-handler");
211221
const eventName = createUniqueName("event");
212222

@@ -226,7 +236,6 @@ describe("EventClient", () => {
226236
});
227237

228238
test("Should get event handlers for a specific event", async () => {
229-
const eventClient = new EventClient(await orkesConductorClient());
230239
const handlerName = createUniqueName("event-handler");
231240
const eventName = createUniqueName("event");
232241

@@ -252,7 +261,6 @@ describe("EventClient", () => {
252261
});
253262

254263
test("Should remove an event handler", async () => {
255-
const eventClient = new EventClient(await orkesConductorClient());
256264
const handlerName = createUniqueName("event-handler");
257265
const eventName = createUniqueName("event");
258266

@@ -281,7 +289,6 @@ describe("EventClient", () => {
281289

282290
describe("Tag Management", () => {
283291
test("Should get tags for an event handler", async () => {
284-
const eventClient = new EventClient(await orkesConductorClient());
285292
const handlerName = createUniqueName("event-handler");
286293
const eventName = createUniqueName("event");
287294

@@ -322,7 +329,6 @@ describe("EventClient", () => {
322329
});
323330

324331
test("Should put tags for an event handler", async () => {
325-
const eventClient = new EventClient(await orkesConductorClient());
326332
const handlerName = createUniqueName("event-handler");
327333
const eventName = createUniqueName("event");
328334

@@ -363,7 +369,6 @@ describe("EventClient", () => {
363369
});
364370

365371
test("Should delete tags for an event handler", async () => {
366-
const eventClient = new EventClient(await orkesConductorClient());
367372
const handlerName = createUniqueName("event-handler");
368373
const eventName = createUniqueName("event");
369374

@@ -423,7 +428,6 @@ describe("EventClient", () => {
423428

424429
describe("Test Endpoint", () => {
425430
test("Should call test endpoint", async () => {
426-
const eventClient = new EventClient(await orkesConductorClient());
427431

428432
const result = await eventClient.test();
429433
expect(result).toBeDefined();
@@ -432,7 +436,6 @@ describe("EventClient", () => {
432436

433437
describe("Error Handling", () => {
434438
test("Should return null or throw when getting non-existent event handler", async () => {
435-
const eventClient = new EventClient(await orkesConductorClient());
436439
const nonExistentName = createUniqueName("non-existent-handler");
437440

438441
try {
@@ -446,7 +449,6 @@ describe("EventClient", () => {
446449
});
447450

448451
test("Should throw error when removing non-existent handler", async () => {
449-
const eventClient = new EventClient(await orkesConductorClient());
450452
const nonExistentName = createUniqueName("non-existent-handler");
451453

452454
await expect(
@@ -455,7 +457,6 @@ describe("EventClient", () => {
455457
});
456458

457459
test("Should throw error when updating non-existent event handler", async () => {
458-
const eventClient = new EventClient(await orkesConductorClient());
459460
const nonExistentName = createUniqueName("non-existent-handler");
460461
const eventName = createUniqueName("event");
461462

@@ -473,7 +474,6 @@ describe("EventClient", () => {
473474
});
474475

475476
test("Should throw error when getting queue config for non-existent queue", async () => {
476-
const eventClient = new EventClient(await orkesConductorClient());
477477
const nonExistentQueueType = createUniqueName("non-existent-type");
478478
const nonExistentQueueName = createUniqueName("non-existent-queue");
479479

@@ -483,7 +483,6 @@ describe("EventClient", () => {
483483
});
484484

485485
test("Should throw error when adding event handler with invalid data", async () => {
486-
const eventClient = new EventClient(await orkesConductorClient());
487486

488487
const invalidHandler = {
489488
name: "",
@@ -498,7 +497,6 @@ describe("EventClient", () => {
498497
});
499498

500499
test("Should handle error when testing connectivity with invalid input", async () => {
501-
const eventClient = new EventClient(await orkesConductorClient());
502500

503501
const invalidInput: ConnectivityTestInput = {
504502
sink: "",
@@ -511,7 +509,6 @@ describe("EventClient", () => {
511509
});
512510

513511
test("Should handle error when handling incoming event with invalid data", async () => {
514-
const eventClient = new EventClient(await orkesConductorClient());
515512

516513
const invalidEventData: Record<string, string> = {};
517514

@@ -523,7 +520,6 @@ describe("EventClient", () => {
523520

524521
describeForOrkesV5("Event Processing", () => {
525522
test("Should handle incoming event", async () => {
526-
const eventClient = new EventClient(await orkesConductorClient());
527523
const handlerName = createUniqueName("event-handler");
528524
const eventName = createUniqueName("event");
529525

@@ -611,7 +607,6 @@ describe("EventClient", () => {
611607

612608
describeForOrkesV5("Event Executions and Statistics", () => {
613609
test("Should get all active event handlers (execution view)", async () => {
614-
const eventClient = new EventClient(await orkesConductorClient());
615610

616611
const handlerName = createUniqueName("event-handler");
617612
const eventName = createUniqueName("event");
@@ -666,7 +661,6 @@ describe("EventClient", () => {
666661
});
667662

668663
test("Should get event executions for a handler", async () => {
669-
const eventClient = new EventClient(await orkesConductorClient());
670664
const handlerName = createUniqueName("event-handler");
671665
const eventName = createUniqueName("event");
672666
const workflowName = createUniqueName("test-workflow");
@@ -730,7 +724,6 @@ describe("EventClient", () => {
730724
});
731725

732726
test("Should get event handlers with statistics", async () => {
733-
const eventClient = new EventClient(await orkesConductorClient());
734727
const handlerName = createUniqueName("event-handler");
735728
const eventName = createUniqueName("event");
736729
const workflowName = createUniqueName("test-workflow");
@@ -795,7 +788,6 @@ describe("EventClient", () => {
795788
});
796789

797790
test("Should get event messages for an event", async () => {
798-
const eventClient = new EventClient(await orkesConductorClient());
799791
const handlerName = createUniqueName("event-handler");
800792
const eventName = createUniqueName("event");
801793
const workflowName = createUniqueName("test-workflow");

0 commit comments

Comments
 (0)