Skip to content

Commit 36e3e62

Browse files
authored
Revert "chore(tests): change timeout reporting in idempotency e2e tests (#2074)" (#2080)
This reverts commit e5630d4.
1 parent e5630d4 commit 36e3e62

File tree

5 files changed

+14
-34
lines changed

5 files changed

+14
-34
lines changed

packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class DefaultLambda implements LambdaInterface {
8080
): Promise<string> {
8181
logger.addContext(context);
8282

83-
await new Promise((resolve) =>
84-
setTimeout(resolve, context.getRemainingTimeInMillis())
85-
);
83+
await new Promise((resolve) => setTimeout(resolve, 1500));
8684

8785
logger.info('Processed event', { details: event.foo });
8886

packages/idempotency/tests/e2e/idempotentDecorator.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ describe('Idempotency e2e test decorator, default settings', () => {
7474
function: {
7575
entry: lambdaFunctionCodeFilePath,
7676
handler: 'handlerTimeout',
77-
timeout: Duration.seconds(3),
78-
memorySize: 512,
77+
timeout: Duration.seconds(2),
7978
},
8079
},
8180
{
@@ -285,11 +284,10 @@ describe('Idempotency e2e test decorator, default settings', () => {
285284
});
286285
expect(idempotencyRecord.Items?.[0].status).toEqual('COMPLETED');
287286

288-
// During the first invocation the function should timeout so the logs should not contain any log and the report log should contain a timeout message
289-
expect(functionLogs[0]).toHaveLength(0);
290-
expect(logs[0].getReportLog()).toMatch(/Status: timeout$/);
287+
// During the first invocation the handler should be called, so the logs should contain 1 log
288+
expect(functionLogs[0]).toHaveLength(2);
289+
expect(functionLogs[0][0]).toContain('Task timed out after');
291290

292-
// During the second invocation the handler should be called and complete, so the logs should contain 1 log
293291
expect(functionLogs[1]).toHaveLength(1);
294292
expect(TestInvocationLogs.parseFunctionLog(functionLogs[1][0])).toEqual(
295293
expect.objectContaining({

packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ export const handlerTimeout = middy(
6565
logger.addContext(context);
6666

6767
if (event.invocation === 0) {
68-
await new Promise((resolve) => {
69-
setTimeout(resolve, context.getRemainingTimeInMillis());
70-
});
68+
await new Promise((resolve) => setTimeout(resolve, 4000));
7169
}
72-
logger.info('Processed event', { details: event.foo });
70+
71+
logger.info('Processed event', {
72+
details: event.foo,
73+
});
7374

7475
return {
7576
foo: event.foo,

packages/idempotency/tests/e2e/makeHandlerIdempotent.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ describe(`Idempotency E2E tests, middy middleware usage`, () => {
7474
function: {
7575
entry: lambdaFunctionCodeFilePath,
7676
handler: 'handlerTimeout',
77-
timeout: Duration.seconds(3),
78-
memorySize: 512,
77+
timeout: Duration.seconds(2),
7978
},
8079
},
8180
{
@@ -264,9 +263,9 @@ describe(`Idempotency E2E tests, middy middleware usage`, () => {
264263
});
265264
expect(idempotencyRecords.Items?.[0].status).toEqual('COMPLETED');
266265

267-
// During the first invocation the function should timeout so the logs should not contain any log and the report log should contain a timeout message
268-
expect(functionLogs[0]).toHaveLength(0);
269-
expect(logs[0].getReportLog()).toMatch(/Status: timeout$/);
266+
// During the first invocation the function should timeout so the logs should contain 2 logs
267+
expect(functionLogs[0]).toHaveLength(2);
268+
expect(functionLogs[0][0]).toContain('Task timed out after');
270269
// During the second invocation the handler should be called and complete, so the logs should
271270
// contain 1 log
272271
expect(functionLogs[1]).toHaveLength(1);

packages/testing/src/TestInvocationLogs.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,6 @@ class TestInvocationLogs {
105105
return filteredLogs;
106106
}
107107

108-
/**
109-
* Return the log that contains the report of the function `REPORT RequestId`
110-
*/
111-
public getReportLog(): string {
112-
const endLogIndex = TestInvocationLogs.getReportLogIndex(this.logs);
113-
114-
return this.logs[endLogIndex];
115-
}
116-
117-
/**
118-
* The index of the log that contains the report of the function `REPORT RequestId`
119-
*/
120-
public static getReportLogIndex(logs: string[]): number {
121-
return logs.findIndex((log) => log.startsWith('REPORT RequestId'));
122-
}
123-
124108
public static getStartLogIndex(logs: string[]): number {
125109
return logs.findIndex((log) => log.startsWith('START RequestId'));
126110
}

0 commit comments

Comments
 (0)