diff --git a/packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts b/packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts index fc0909c747..8dd29c0b29 100644 --- a/packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts +++ b/packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts @@ -80,9 +80,7 @@ class DefaultLambda implements LambdaInterface { ): Promise { logger.addContext(context); - await new Promise((resolve) => - setTimeout(resolve, context.getRemainingTimeInMillis()) - ); + await new Promise((resolve) => setTimeout(resolve, 1500)); logger.info('Processed event', { details: event.foo }); diff --git a/packages/idempotency/tests/e2e/idempotentDecorator.test.ts b/packages/idempotency/tests/e2e/idempotentDecorator.test.ts index cfee5257a1..ec740e0f03 100644 --- a/packages/idempotency/tests/e2e/idempotentDecorator.test.ts +++ b/packages/idempotency/tests/e2e/idempotentDecorator.test.ts @@ -74,8 +74,7 @@ describe('Idempotency e2e test decorator, default settings', () => { function: { entry: lambdaFunctionCodeFilePath, handler: 'handlerTimeout', - timeout: Duration.seconds(3), - memorySize: 512, + timeout: Duration.seconds(2), }, }, { @@ -285,11 +284,10 @@ describe('Idempotency e2e test decorator, default settings', () => { }); expect(idempotencyRecord.Items?.[0].status).toEqual('COMPLETED'); - // 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 - expect(functionLogs[0]).toHaveLength(0); - expect(logs[0].getReportLog()).toMatch(/Status: timeout$/); + // During the first invocation the handler should be called, so the logs should contain 1 log + expect(functionLogs[0]).toHaveLength(2); + expect(functionLogs[0][0]).toContain('Task timed out after'); - // During the second invocation the handler should be called and complete, so the logs should contain 1 log expect(functionLogs[1]).toHaveLength(1); expect(TestInvocationLogs.parseFunctionLog(functionLogs[1][0])).toEqual( expect.objectContaining({ diff --git a/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts b/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts index d5afb7a101..499eda7cca 100644 --- a/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts +++ b/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts @@ -65,11 +65,12 @@ export const handlerTimeout = middy( logger.addContext(context); if (event.invocation === 0) { - await new Promise((resolve) => { - setTimeout(resolve, context.getRemainingTimeInMillis()); - }); + await new Promise((resolve) => setTimeout(resolve, 4000)); } - logger.info('Processed event', { details: event.foo }); + + logger.info('Processed event', { + details: event.foo, + }); return { foo: event.foo, diff --git a/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.ts b/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.ts index 0f37d5c88d..1af54e589d 100644 --- a/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.ts +++ b/packages/idempotency/tests/e2e/makeHandlerIdempotent.test.ts @@ -74,8 +74,7 @@ describe(`Idempotency E2E tests, middy middleware usage`, () => { function: { entry: lambdaFunctionCodeFilePath, handler: 'handlerTimeout', - timeout: Duration.seconds(3), - memorySize: 512, + timeout: Duration.seconds(2), }, }, { @@ -264,9 +263,9 @@ describe(`Idempotency E2E tests, middy middleware usage`, () => { }); expect(idempotencyRecords.Items?.[0].status).toEqual('COMPLETED'); - // 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 - expect(functionLogs[0]).toHaveLength(0); - expect(logs[0].getReportLog()).toMatch(/Status: timeout$/); + // During the first invocation the function should timeout so the logs should contain 2 logs + expect(functionLogs[0]).toHaveLength(2); + expect(functionLogs[0][0]).toContain('Task timed out after'); // During the second invocation the handler should be called and complete, so the logs should // contain 1 log expect(functionLogs[1]).toHaveLength(1); diff --git a/packages/testing/src/TestInvocationLogs.ts b/packages/testing/src/TestInvocationLogs.ts index 10fcf957a0..fa396c98eb 100644 --- a/packages/testing/src/TestInvocationLogs.ts +++ b/packages/testing/src/TestInvocationLogs.ts @@ -105,22 +105,6 @@ class TestInvocationLogs { return filteredLogs; } - /** - * Return the log that contains the report of the function `REPORT RequestId` - */ - public getReportLog(): string { - const endLogIndex = TestInvocationLogs.getReportLogIndex(this.logs); - - return this.logs[endLogIndex]; - } - - /** - * The index of the log that contains the report of the function `REPORT RequestId` - */ - public static getReportLogIndex(logs: string[]): number { - return logs.findIndex((log) => log.startsWith('REPORT RequestId')); - } - public static getStartLogIndex(logs: string[]): number { return logs.findIndex((log) => log.startsWith('START RequestId')); }