Skip to content

Commit ea77e21

Browse files
authored
perf(test): remove ingress capacity waits (#124630)
1 parent fb32d5d commit ea77e21

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

‎extensions/line/src/webhook-spool.test.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ describe("LINE webhook spool", () => {
185185
activeDeliveries -= 1;
186186
}
187187
});
188+
const listPending = vi.spyOn(queue, "listPending");
188189
const spool = createLineWebhookSpool({
189190
accountId: "default",
190191
runtime: runtime(),
@@ -203,15 +204,24 @@ describe("LINE webhook spool", () => {
203204
try {
204205
await spool.accept({ destination: "destination-1", events: firstBatch });
205206
await vi.waitFor(() => expect(deliver).toHaveBeenCalledTimes(8));
206-
207-
await spool.accept(callback(ninth));
208-
// Hold the eight adopted-but-unfinished deliveries across two timer pumps.
209207
await new Promise<void>((resolve) => {
210-
setTimeout(resolve, 1_100);
208+
setImmediate(resolve);
211209
});
212210

211+
const drainScansBeforeNinth = listPending.mock.calls.length;
212+
await spool.accept(callback(ninth));
213+
await vi.waitFor(() =>
214+
expect(listPending.mock.calls.length).toBeGreaterThan(drainScansBeforeNinth),
215+
);
216+
213217
expect(deliver).toHaveBeenCalledTimes(8);
214218
expect(maxActiveDeliveries).toBe(8);
219+
expect(await queue.listPending()).toEqual([
220+
expect.objectContaining({
221+
id: "message:message-event-concurrency-8",
222+
laneKey: "user:user-8",
223+
}),
224+
]);
215225

216226
releaseDeliveries();
217227
await vi.waitFor(() => expect(activeDeliveries).toBe(0));

‎extensions/msteams/src/msteams-ingress.test.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,31 @@ describe("Microsoft Teams durable ingress", () => {
348348
active -= 1;
349349
}
350350
});
351+
const listPending = vi.spyOn(queue, "listPending");
351352
const ingress = makeIngress(queue, dispatch);
352353
ingress.start();
353354
try {
354-
for (let index = 0; index < 9; index += 1) {
355+
for (let index = 0; index < 8; index += 1) {
355356
await ingress.accept(
356357
activity({ id: `activity-concurrency-${index}`, conversationId: `lane-${index}` }),
357358
);
358359
}
359360
await vi.waitFor(() => expect(dispatch).toHaveBeenCalledTimes(8));
360361
await new Promise<void>((resolve) => {
361-
setTimeout(resolve, 600);
362+
setImmediate(resolve);
362363
});
364+
365+
const drainScansBeforeNinth = listPending.mock.calls.length;
366+
await ingress.accept(activity({ id: "activity-concurrency-8", conversationId: "lane-8" }));
367+
await vi.waitFor(() =>
368+
expect(listPending.mock.calls.length).toBeGreaterThan(drainScansBeforeNinth),
369+
);
370+
363371
expect(dispatch).toHaveBeenCalledTimes(8);
364372
expect(maxActive).toBe(8);
373+
expect(await queue.listPending()).toEqual([
374+
expect.objectContaining({ id: "activity-concurrency-8", laneKey: "lane-8" }),
375+
]);
365376

366377
releaseDeliveries?.();
367378
await vi.waitFor(() => expect(dispatch).toHaveBeenCalledTimes(9));

0 commit comments

Comments
 (0)