Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8058ef4

Browse files
authoredMar 17, 2025··
Merge branch 'main' into tests/logger_advanced_e2e
2 parents b8c1bec + 1dcf438 commit 8058ef4

File tree

5 files changed

+184
-151
lines changed

5 files changed

+184
-151
lines changed
 

‎docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# version 9.5.35
2-
FROM squidfunk/mkdocs-material@sha256:479a06a8f5a320a9b2b17e72cb7012388d66ea71a8568235cfa072eb152bc30c
2+
FROM squidfunk/mkdocs-material@sha256:f226a2d2d5983643cab401491fc40e8a5711a50e90c21433f80e91c014cff1f5
33

44
# Install Node.js
55
RUN apk add --no-cache nodejs=20.15.1-r0 npm

‎package-lock.json

Lines changed: 134 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@biomejs/biome": "^1.9.4",
5454
"@types/aws-lambda": "^8.10.147",
5555
"@types/node": "^22.13.10",
56-
"@vitest/coverage-v8": "^3.0.8",
56+
"@vitest/coverage-v8": "^3.0.9",
5757
"husky": "^9.1.7",
5858
"lerna": "8.1.2",
5959
"lint-staged": "^15.5.0",

‎packages/logger/tests/e2e/sampleRate.decorator.test.FunctionCode.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,12 @@ const LOG_MSG = process.env.LOG_MSG || 'Hello World';
99
const logger = new Logger({
1010
sampleRateValue: SAMPLE_RATE,
1111
});
12-
let firstInvocation = true;
1312

1413
class Lambda implements LambdaInterface {
15-
private readonly logMsg: string;
14+
private readonly logMsg = LOG_MSG;
1615

17-
public constructor() {
18-
this.logMsg = LOG_MSG;
19-
}
20-
21-
// Decorate your handler class method
2216
@logger.injectLambdaContext()
2317
public async handler(_event: TestEvent, context: Context): TestOutput {
24-
if (firstInvocation) {
25-
firstInvocation = false;
26-
} else {
27-
logger.refreshSampleRateCalculation();
28-
}
2918
this.printLogInAllLevels();
3019

3120
return {

‎packages/testing/src/TestStack.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,63 @@ class TestStack {
6666
Service: 'Powertools-for-AWS-e2e-tests',
6767
},
6868
});
69+
let lastCreateLog = 0;
70+
let lastDestroyLog = 0;
71+
const creationDeleteLogFrequency = 10000; // 10 seconds
72+
const that = this;
6973
this.#cli = new Toolkit({
7074
color: false,
7175
ioHost: {
76+
/**
77+
* Log messages to the console depending on the log level.
78+
*
79+
* If the `RUNNER_DEBUG` environment variable is set to `1`, all messages are logged.
80+
*
81+
* Otherwise, we log messages that are either warnings or errors as well as periodic
82+
* updates on the stack creation and destruction process.
83+
*
84+
* @param msg - Message to log sent by the CDK CLI
85+
*/
7286
async notify(msg) {
87+
if (process.env.RUNNER_DEBUG === '1') {
88+
testConsole.log(msg);
89+
return;
90+
}
91+
if (msg.message.includes('destroyed') && msg.message.includes('✅')) {
92+
testConsole.log(msg.message);
93+
return;
94+
}
95+
if (msg.message.includes('✅') && !msg.message.includes('deployed')) {
96+
testConsole.log(`${that.testName} deployed successfully`);
97+
return;
98+
}
99+
if (msg.message.includes('CREATE_IN_PROGRESS')) {
100+
if (Date.now() - lastCreateLog < creationDeleteLogFrequency) {
101+
return;
102+
}
103+
lastCreateLog = Date.now();
104+
testConsole.log(`${that.testName} stack is being created...`);
105+
return;
106+
}
107+
if (msg.message.includes('DELETE_IN_PROGRESS')) {
108+
if (Date.now() - lastDestroyLog < creationDeleteLogFrequency) {
109+
return;
110+
}
111+
lastDestroyLog = Date.now();
112+
testConsole.log(`${that.testName} stack is being destroyed...`);
113+
return;
114+
}
115+
if (['warning', 'error'].includes(msg.level)) {
116+
testConsole.log(msg);
117+
}
118+
},
119+
async requestResponse(msg) {
73120
if (
74121
process.env.RUNNER_DEBUG === '1' ||
75122
['warning', 'error'].includes(msg.level)
76123
) {
77124
testConsole.log(msg);
78125
}
79-
},
80-
async requestResponse(msg) {
81-
testConsole.log(msg);
82126
return msg.defaultResponse;
83127
},
84128
},

0 commit comments

Comments
 (0)
Please sign in to comment.