Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions packages/logger/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"commit": "commit",
"test": "npm run test:unit",
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"test:e2e": "jest --group=e2e",
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e/logger",
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e/logger",
"test:e2e": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
"watch": "jest --watch",
"build": "tsc",
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",
Expand Down Expand Up @@ -43,6 +45,7 @@
"types": "./lib/index.d.ts",
"typedocMain": "src/index.ts",
"devDependencies": {
"@aws-cdk/aws-lambda": "^1.137.0",
"@aws-cdk/aws-lambda-nodejs": "^1.137.0",
"@aws-cdk/core": "^1.137.0",
"@middy/core": "^2.5.6",
Expand All @@ -55,6 +58,7 @@
"@typescript-eslint/parser": "^5.4.0",
"aws-cdk": "^1.137.0",
"aws-sdk": "^2.1048.0",
"concurrently": "^7.0.0",
"eslint": "^8.3.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^2.5.0",
Expand Down
21 changes: 14 additions & 7 deletions packages/logger/tests/e2e/basicFeatures.middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@
import path from 'path';
import { randomUUID } from 'crypto';
import { App, Stack } from '@aws-cdk/core';
import { createStackWithLambdaFunction, deployStack, destroyStack, invokeFunction } from '../helpers/e2eUtils';
import { createStackWithLambdaFunction, deployStack, destroyStack, generateUniqueName, invokeFunction, isValidRuntimeKey } from '../helpers/e2eUtils';
import { InvocationLogs } from '../helpers/InvocationLogs';

const runtime: string = process.env.RUNTIME || 'nodejs14x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
}

const LEVEL = InvocationLogs.LEVEL;
const TEST_CASE_TIMEOUT = 20000; // 20 seconds
const SETUP_TIMEOUT = 200000; // 200 seconds
const SETUP_TIMEOUT = 300000; // 300 seconds
const TEARDOWN_TIMEOUT = 200000;
const STACK_OUTPUT_LOG_GROUP = 'LogGroupName';

const uuid = randomUUID();
const stackName = `LoggerE2EBasicFeatureMiddyStack-${uuid}`;
const functionName = `loggerE2EBasicFeaturesMiddy-${uuid}`;
const stackName = generateUniqueName(uuid, runtime, 'BasicFeatures-Middy');
const functionName = generateUniqueName(uuid, runtime, 'BasicFeatures-Middy');
const lambdaFunctionCodeFile = 'basicFeatures.middy.test.FunctionCode.ts';

// Text to be used by Logger in the Lambda function
Expand All @@ -34,12 +40,12 @@ const ERROR_MSG = `error-${uuid}`;
const integTestApp = new App();
let logGroupName: string; // We do not know it until deployment
let stack: Stack;
describe('logger E2E tests basic functionalities (middy)', () => {

describe(`logger E2E tests basic functionalities (middy) for runtime: ${runtime}`, () => {

let invocationLogs: InvocationLogs[];

beforeAll(async () => {

// Create and deploy a stack with AWS CDK
stack = createStackWithLambdaFunction({
app: integTestApp,
Expand All @@ -58,7 +64,8 @@ describe('logger E2E tests basic functionalities (middy)', () => {
SINGLE_LOG_ITEM_VALUE,
ERROR_MSG,
},
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP,
runtime: runtime,
});
const stackArtifact = integTestApp.synth().getStackByName(stack.stackName);
const outputs = await deployStack(stackArtifact);
Expand Down
19 changes: 13 additions & 6 deletions packages/logger/tests/e2e/childLogger.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@
import path from 'path';
import { randomUUID } from 'crypto';
import { App, Stack } from '@aws-cdk/core';
import { createStackWithLambdaFunction, deployStack, destroyStack, invokeFunction } from '../helpers/e2eUtils';
import { createStackWithLambdaFunction, deployStack, destroyStack, generateUniqueName, invokeFunction, isValidRuntimeKey } from '../helpers/e2eUtils';
import { InvocationLogs } from '../helpers/InvocationLogs';

const runtime: string = process.env.RUNTIME || 'nodejs14x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
}

const LEVEL = InvocationLogs.LEVEL;
const TEST_CASE_TIMEOUT = 20000; // 20 seconds
const SETUP_TIMEOUT = 200000; // 200 seconds
const SETUP_TIMEOUT = 300000; // 300 seconds
const TEARDOWN_TIMEOUT = 200000;
const STACK_OUTPUT_LOG_GROUP = 'LogGroupName';

const uuid = randomUUID();
const stackName = `LoggerE2EChildLoggerManualStack-${uuid}`;
const functionName = `LoggerE2EChildLoggerManual-${uuid}`;
const stackName = generateUniqueName(uuid, runtime, 'ChildLogger-Manual');
const functionName = generateUniqueName(uuid, runtime, 'ChildLogger-Manual');
const lambdaFunctionCodeFile = 'childLogger.manual.test.FunctionCode.ts';

// Parameters to be used by Logger in the Lambda function
Expand All @@ -34,7 +40,7 @@ const CHILD_LOG_LEVEL = LEVEL.ERROR.toString();
const integTestApp = new App();
let logGroupName: string; // We do not know it until deployment
let stack: Stack;
describe('logger E2E tests child logger functionalities (manual)', () => {
describe(`logger E2E tests child logger functionalities (manual) for runtime: ${runtime}`, () => {

let invocationLogs: InvocationLogs[];

Expand All @@ -58,7 +64,8 @@ describe('logger E2E tests child logger functionalities (manual)', () => {
CHILD_LOG_MSG,
CHILD_LOG_LEVEL,
},
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP,
runtime: runtime,
});
const stackArtifact = integTestApp.synth().getStackByName(stack.stackName);
const outputs = await deployStack(stackArtifact);
Expand Down
20 changes: 13 additions & 7 deletions packages/logger/tests/e2e/sampleRate.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@
import path from 'path';
import { randomUUID } from 'crypto';
import { App, Stack } from '@aws-cdk/core';
import { createStackWithLambdaFunction, deployStack, destroyStack, invokeFunction } from '../helpers/e2eUtils';
import { createStackWithLambdaFunction, deployStack, destroyStack, generateUniqueName, invokeFunction, isValidRuntimeKey } from '../helpers/e2eUtils';
import { InvocationLogs } from '../helpers/InvocationLogs';

const LEVEL = InvocationLogs.LEVEL;
const runtime: string = process.env.RUNTIME || 'nodejs14x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
}

const LEVEL = InvocationLogs.LEVEL;
const TEST_CASE_TIMEOUT = 30000; // 30 seconds
const SETUP_TIMEOUT = 200000; // 200 seconds
const SETUP_TIMEOUT = 300000; // 300 seconds
const TEARDOWN_TIMEOUT = 200000;
const STACK_OUTPUT_LOG_GROUP = 'LogGroupName';

const uuid = randomUUID();
const stackName = `LoggerE2ESampleRateDecoratorStack-${uuid}`;
const functionName = `LoggerE2EampleRateDecorator-${uuid}`;
const stackName = generateUniqueName(uuid, runtime, 'SampleRate-Decorator');
const functionName = generateUniqueName(uuid, runtime, 'SampleRate-Decorator');
const lambdaFunctionCodeFile = 'sampleRate.decorator.test.FunctionCode.ts';

// Parameters to be used by Logger in the Lambda function
Expand All @@ -32,7 +37,7 @@ const LOG_LEVEL = LEVEL.ERROR.toString();
const integTestApp = new App();
let logGroupName: string; // We do not know it until deployment
let stack: Stack;
describe('logger E2E tests sample rate and injectLambdaContext()', () => {
describe(`logger E2E tests sample rate and injectLambdaContext() for runtime: ${runtime}`, () => {

let invocationLogs: InvocationLogs[];

Expand All @@ -53,7 +58,8 @@ describe('logger E2E tests sample rate and injectLambdaContext()', () => {
LOG_MSG,
SAMPLE_RATE,
},
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP
logGroupOutputKey: STACK_OUTPUT_LOG_GROUP,
runtime: runtime,
});
const stackArtifact = integTestApp.synth().getStackByName(stack.stackName);
const outputs = await deployStack(stackArtifact);
Expand Down
Loading