Skip to content

Commit 85bda5c

Browse files
committed
wip
1 parent af30db9 commit 85bda5c

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

.evergreen/config.in.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ tasks:
946946
type: setup
947947
params:
948948
updates:
949-
- { key: NPM_VERSION, value: "9" }
949+
- { key: NODE_VERSION, value: "22" }
950950
- func: "install dependencies"
951951
- command: ec2.assume_role
952952
params:

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ tasks:
865865
type: setup
866866
params:
867867
updates:
868-
- {key: NPM_VERSION, value: '9'}
868+
- {key: NODE_VERSION, value: '22'}
869869
- func: install dependencies
870870
- command: ec2.assume_role
871871
params:

.evergreen/prepare-shell.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export PATH="$MONGODB_BINARIES:$PATH"
3232

3333
if [ ! -d "$DRIVERS_TOOLS" ]; then
3434
# Only clone driver tools if it does not exist
35-
git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}"
35+
git clone "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}"
36+
git -C "${DRIVERS_TOOLS}" fetch -a
37+
git -C "${DRIVERS_TOOLS}" switch NODE-6839-lambda-timeout
3638
fi
3739

3840
echo "installed DRIVERS_TOOLS from commit $(git -C "${DRIVERS_TOOLS}" rev-parse HEAD)"

test/lambda/mongodb/app.mjs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
import * as assert from 'node:assert/strict';
1+
/* eslint-disable no-console */
2+
import util from 'node:util';
23

34
import { MongoClient } from 'mongodb';
45

56
// Creates the client that is cached for all requests, subscribes to
67
// relevant events, and forces the connection pool to get populated.
78
const mongoClient = new MongoClient(process.env.MONGODB_URI, {
8-
monitorCommands: true
9+
monitorCommands: true,
10+
mongodbLogComponentSeverities: {
11+
command: 'trace',
12+
topology: 'trace',
13+
connection: 'trace',
14+
default: 'trace'
15+
},
16+
mongodbLogMaxDocumentLength: 10_000,
17+
mongodbLogPath: {
18+
write(log) {
19+
console.log(
20+
util.inspect(log, { colors: false, breakLength: Infinity, compact: true, depth: Infinity })
21+
);
22+
}
23+
}
924
});
1025

1126
let openConnections = 0;
@@ -14,49 +29,38 @@ let totalHeartbeatDuration = 0;
1429
let totalCommands = 0;
1530
let totalCommandDuration = 0;
1631

17-
mongoClient.on('commandStarted', (event) => {
18-
console.log('commandStarted', event);
19-
});
20-
21-
mongoClient.on('commandSucceeded', (event) => {
32+
mongoClient.on('commandSucceeded', event => {
2233
totalCommands++;
2334
totalCommandDuration += event.duration;
24-
console.log('commandSucceeded', event);
2535
});
2636

27-
mongoClient.on('commandFailed', (event) => {
37+
mongoClient.on('commandFailed', event => {
2838
totalCommands++;
2939
totalCommandDuration += event.duration;
30-
console.log('commandFailed', event);
3140
});
3241

33-
mongoClient.on('serverHeartbeatStarted', (event) => {
34-
console.log('serverHeartbeatStarted', event);
35-
assert.strictEqual(event.awaited, false);
42+
mongoClient.on('serverHeartbeatStarted', event => {
43+
if (event.awaited !== false) console.log('server hb started', { awaited: event.awaited });
3644
});
3745

38-
mongoClient.on('serverHeartbeatSucceeded', (event) => {
46+
mongoClient.on('serverHeartbeatSucceeded', event => {
3947
heartbeatCount++;
4048
totalHeartbeatDuration += event.duration;
41-
console.log('serverHeartbeatSucceeded', event);
42-
assert.strictEqual(event.awaited, false);
49+
if (event.awaited !== false) console.log('server hb succeeded', { awaited: event.awaited });
4350
});
4451

45-
mongoClient.on('serverHeartbeatFailed', (event) => {
52+
mongoClient.on('serverHeartbeatFailed', event => {
4653
heartbeatCount++;
4754
totalHeartbeatDuration += event.duration;
48-
console.log('serverHeartbeatFailed', event);
49-
assert.strictEqual(event.awaited, false);
55+
if (event.awaited !== false) console.log('server hb failed', { awaited: event.awaited });
5056
});
5157

52-
mongoClient.on('connectionCreated', (event) => {
58+
mongoClient.on('connectionCreated', () => {
5359
openConnections++;
54-
console.log('connectionCreated', event);
5560
});
5661

57-
mongoClient.on('connectionClosed', (event) => {
62+
mongoClient.on('connectionClosed', () => {
5863
openConnections--;
59-
console.log('connectionClosed', event);
6064
});
6165

6266
// Populate the connection pool.
@@ -65,8 +69,8 @@ await mongoClient.connect();
6569
// Create the response to send back.
6670
function createResponse() {
6771
return {
68-
averageCommandDuration: totalCommandDuration / totalCommands,
69-
averageHeartbeatDuration: totalHeartbeatDuration / heartbeatCount,
72+
averageCommandDuration: totalCommands === 0 ? 0 : totalCommandDuration / totalCommands,
73+
averageHeartbeatDuration: heartbeatCount === 0 ? 0 : totalHeartbeatDuration / heartbeatCount,
7074
openConnections: openConnections,
7175
heartbeatCount: heartbeatCount
7276
};
@@ -85,10 +89,10 @@ function reset() {
8589
* The handler function itself performs an insert/delete and returns the
8690
* id of the document in play.
8791
*
88-
* @param {Object} event - API Gateway Lambda Proxy Input Format
89-
* @returns {Object} object - API Gateway Lambda Proxy Output Format
92+
* @param event - API Gateway Lambda Proxy Input Format
93+
* @returns API Gateway Lambda Proxy Output Format
9094
*/
91-
export const lambdaHandler = async (event) => {
95+
export const lambdaHandler = async () => {
9296
const db = mongoClient.db('lambdaTest');
9397
const collection = db.collection('test');
9498
const { insertedId } = await collection.insertOne({ n: 1 });

0 commit comments

Comments
 (0)