Skip to content

Commit b3f3987

Browse files
baileympearsonnbbeeken
andauthoredAug 7, 2024··
feat(NODE-5614): add support for explicit resource management (#4177)
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
1 parent 54efb7d commit b3f3987

30 files changed

+757
-79
lines changed
 

‎.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
lib
33
test/disabled
44
!etc/docs
5+
6+
test/explicit-resource-management

‎.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@
271271
{
272272
// Settings for generated definition files
273273
"files": [
274-
"mongodb.d.ts"
274+
"**/*.d.ts",
275+
"lib/*.d.ts"
275276
],
276277
"parser": "@typescript-eslint/parser",
277278
"rules": {

‎.evergreen/config.in.yml

+27
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,36 @@ functions:
348348
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
349349
TS_VERSION: ${TS_VERSION}
350350
TS_CHECK: CHECK_TYPES
351+
TYPES_VERSION: ${TYPES_VERSION}
351352
binary: bash
352353
args:
353354
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
354355

356+
"check resource management":
357+
- command: subprocess.exec
358+
type: test
359+
params:
360+
working_dir: "src"
361+
timeout_secs: 60
362+
env:
363+
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
364+
binary: bash
365+
args:
366+
- "${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh"
367+
368+
"check resource management feature integration":
369+
- command: subprocess.exec
370+
type: test
371+
params:
372+
working_dir: "src"
373+
timeout_secs: 60
374+
env:
375+
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
376+
MONGODB_URI: ${MONGODB_URI}
377+
binary: bash
378+
args:
379+
- "${PROJECT_DIRECTORY}/.evergreen/run-resource-management-feature-integration.sh"
380+
355381
"compile driver":
356382
- command: subprocess.exec
357383
type: test
@@ -362,6 +388,7 @@ functions:
362388
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
363389
TS_VERSION: ${TS_VERSION}
364390
TS_CHECK: COMPILE_DRIVER
391+
TYPES_VERSION: ${TYPES_VERSION}
365392
binary: bash
366393
args:
367394
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"

‎.evergreen/config.yml

+108-6
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,33 @@ functions:
312312
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
313313
TS_VERSION: ${TS_VERSION}
314314
TS_CHECK: CHECK_TYPES
315+
TYPES_VERSION: ${TYPES_VERSION}
315316
binary: bash
316317
args:
317318
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
319+
check resource management:
320+
- command: subprocess.exec
321+
type: test
322+
params:
323+
working_dir: src
324+
timeout_secs: 60
325+
env:
326+
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
327+
binary: bash
328+
args:
329+
- ${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh
330+
check resource management feature integration:
331+
- command: subprocess.exec
332+
type: test
333+
params:
334+
working_dir: src
335+
timeout_secs: 60
336+
env:
337+
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
338+
MONGODB_URI: ${MONGODB_URI}
339+
binary: bash
340+
args:
341+
- ${PROJECT_DIRECTORY}/.evergreen/run-resource-management-feature-integration.sh
318342
compile driver:
319343
- command: subprocess.exec
320344
type: test
@@ -325,6 +349,7 @@ functions:
325349
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
326350
TS_VERSION: ${TS_VERSION}
327351
TS_CHECK: COMPILE_DRIVER
352+
TYPES_VERSION: ${TYPES_VERSION}
328353
binary: bash
329354
args:
330355
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
@@ -3459,7 +3484,45 @@ tasks:
34593484
- {key: NPM_VERSION, value: '9'}
34603485
- func: install dependencies
34613486
- func: run lint checks
3462-
- name: check-types-typescript-next
3487+
- name: run-resource-management-no-async-dispose
3488+
tags:
3489+
- resource-management
3490+
commands:
3491+
- command: expansions.update
3492+
type: setup
3493+
params:
3494+
updates:
3495+
- {key: NODE_LTS_VERSION, value: v16.20.2}
3496+
- {key: NPM_VERSION, value: '9'}
3497+
- func: install dependencies
3498+
- func: check resource management
3499+
- name: run-resource-management-async-dispose
3500+
tags:
3501+
- resource-management
3502+
commands:
3503+
- command: expansions.update
3504+
type: setup
3505+
params:
3506+
updates:
3507+
- {key: NODE_LTS_VERSION, value: latest}
3508+
- {key: NPM_VERSION, value: '9'}
3509+
- func: install dependencies
3510+
- func: check resource management
3511+
- name: test-explicit-resource-management-feature-integration
3512+
tags:
3513+
- resource-management
3514+
commands:
3515+
- command: expansions.update
3516+
type: setup
3517+
params:
3518+
updates:
3519+
- {key: VERSION, value: latest}
3520+
- {key: TOPOLOGY, value: replica_set}
3521+
- {key: NODE_LTS_VERSION, value: latest}
3522+
- func: install dependencies
3523+
- func: bootstrap mongo-orchestration
3524+
- func: check resource management feature integration
3525+
- name: check-types-typescript-next-node-types-20.14.10
34633526
tags:
34643527
- check-types-typescript-next
34653528
- typescript-compilation
@@ -3471,11 +3534,12 @@ tasks:
34713534
- {key: NODE_LTS_VERSION, value: '16'}
34723535
- {key: NPM_VERSION, value: '9'}
34733536
- {key: TS_VERSION, value: next}
3537+
- {key: TYPES_VERSION, value: 20.14.10}
34743538
- func: install dependencies
34753539
- func: check types
3476-
- name: compile-driver-typescript-current
3540+
- name: check-types-typescript-current-node-types-20.14.10
34773541
tags:
3478-
- compile-driver-typescript-current
3542+
- check-types-typescript-current
34793543
- typescript-compilation
34803544
commands:
34813545
- command: expansions.update
@@ -3485,9 +3549,25 @@ tasks:
34853549
- {key: NODE_LTS_VERSION, value: '16'}
34863550
- {key: NPM_VERSION, value: '9'}
34873551
- {key: TS_VERSION, value: current}
3552+
- {key: TYPES_VERSION, value: 20.14.10}
34883553
- func: install dependencies
3489-
- func: compile driver
3490-
- name: check-types-typescript-current
3554+
- func: check types
3555+
- name: check-types-typescript-next-node-types-16.x
3556+
tags:
3557+
- check-types-typescript-next
3558+
- typescript-compilation
3559+
commands:
3560+
- command: expansions.update
3561+
type: setup
3562+
params:
3563+
updates:
3564+
- {key: NODE_LTS_VERSION, value: '16'}
3565+
- {key: NPM_VERSION, value: '9'}
3566+
- {key: TS_VERSION, value: next}
3567+
- {key: TYPES_VERSION, value: 16.x}
3568+
- func: install dependencies
3569+
- func: check types
3570+
- name: check-types-typescript-current-node-types-16.x
34913571
tags:
34923572
- check-types-typescript-current
34933573
- typescript-compilation
@@ -3499,9 +3579,10 @@ tasks:
34993579
- {key: NODE_LTS_VERSION, value: '16'}
35003580
- {key: NPM_VERSION, value: '9'}
35013581
- {key: TS_VERSION, value: current}
3582+
- {key: TYPES_VERSION, value: 16.x}
35023583
- func: install dependencies
35033584
- func: check types
3504-
- name: check-types-typescript-4.4
3585+
- name: check-types-typescript-4.4-node-types-18.11.9
35053586
tags:
35063587
- check-types-typescript-4.4
35073588
- typescript-compilation
@@ -3513,8 +3594,24 @@ tasks:
35133594
- {key: NODE_LTS_VERSION, value: '16'}
35143595
- {key: NPM_VERSION, value: '9'}
35153596
- {key: TS_VERSION, value: '4.4'}
3597+
- {key: TYPES_VERSION, value: 18.11.9}
35163598
- func: install dependencies
35173599
- func: check types
3600+
- name: compile-driver-typescript-current-node-types-20.14.10
3601+
tags:
3602+
- compile-driver-typescript-current
3603+
- typescript-compilation
3604+
commands:
3605+
- command: expansions.update
3606+
type: setup
3607+
params:
3608+
updates:
3609+
- {key: NODE_LTS_VERSION, value: '16'}
3610+
- {key: NPM_VERSION, value: '9'}
3611+
- {key: TS_VERSION, value: current}
3612+
- {key: TYPES_VERSION, value: 20.14.10}
3613+
- func: install dependencies
3614+
- func: compile driver
35183615
- name: download-and-merge-coverage
35193616
tags: []
35203617
commands:
@@ -5171,3 +5268,8 @@ buildvariants:
51715268
run_on: rhel80-large
51725269
tasks:
51735270
- test_atlas_task_group_search_indexes
5271+
- name: resource management tests
5272+
display_name: resource management tests
5273+
run_on: rhel80-large
5274+
tasks:
5275+
- .resource-management

‎.evergreen/generate_evergreen_tasks.js

+79-34
Original file line numberDiff line numberDiff line change
@@ -492,56 +492,93 @@ SINGLETON_TASKS.push(
492492
{ func: 'run lint checks' }
493493
]
494494
},
495+
{
496+
name: 'run-resource-management-no-async-dispose',
497+
tags: ['resource-management'],
498+
commands: [
499+
updateExpansions({
500+
NODE_LTS_VERSION: "v16.20.2",
501+
NPM_VERSION: 9
502+
}),
503+
{ func: 'install dependencies' },
504+
{ func: 'check resource management' }
505+
]
506+
},
507+
{
508+
name: 'run-resource-management-async-dispose',
509+
tags: ['resource-management'],
510+
commands: [
511+
updateExpansions({
512+
NODE_LTS_VERSION: 'latest',
513+
NPM_VERSION: 9
514+
}),
515+
{ func: 'install dependencies' },
516+
{ func: 'check resource management' }
517+
]
518+
},
519+
{
520+
name: 'test-explicit-resource-management-feature-integration',
521+
tags: ['resource-management'],
522+
commands: [
523+
updateExpansions({
524+
VERSION: 'latest',
525+
TOPOLOGY: 'replica_set',
526+
NODE_LTS_VERSION: 'latest'
527+
}),
528+
{ func: 'install dependencies' },
529+
{ func: 'bootstrap mongo-orchestration' },
530+
{ func: 'check resource management feature integration' }
531+
]
532+
},
495533
...Array.from(makeTypescriptTasks())
496534
]
497535
);
498536

499537
function* makeTypescriptTasks() {
500-
for (const TS_VERSION of ['next', 'current', '4.4']) {
501-
// We don't compile on next, because compilation errors are likely. We do expect
502-
// that the drivers types continue to work with next though.
503-
if (TS_VERSION !== '4.4' && TS_VERSION !== 'next') {
504-
yield {
505-
name: `compile-driver-typescript-${TS_VERSION}`,
506-
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
507-
commands: [
508-
updateExpansions({
509-
NODE_LTS_VERSION: LOWEST_LTS,
510-
NPM_VERSION: 9,
511-
TS_VERSION
512-
}),
513-
{ func: 'install dependencies' },
514-
{ func: 'compile driver' }
515-
]
516-
};
538+
function makeCompileTask(TS_VERSION, TYPES_VERSION) {
539+
return {
540+
name: `compile-driver-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
541+
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
542+
commands: [
543+
updateExpansions({
544+
NODE_LTS_VERSION: LOWEST_LTS,
545+
NPM_VERSION: 9,
546+
TS_VERSION,
547+
TYPES_VERSION
548+
}),
549+
{ func: 'install dependencies' },
550+
{ func: 'compile driver' }
551+
]
517552
}
518-
519-
yield {
520-
name: `check-types-typescript-${TS_VERSION}`,
553+
}
554+
function makeCheckTypesTask(TS_VERSION, TYPES_VERSION) {
555+
return {
556+
name: `check-types-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
521557
tags: [`check-types-typescript-${TS_VERSION}`, 'typescript-compilation'],
522558
commands: [
523559
updateExpansions({
524560
NODE_LTS_VERSION: LOWEST_LTS,
525561
NPM_VERSION: 9,
526-
TS_VERSION
562+
TS_VERSION,
563+
TYPES_VERSION
527564
}),
528565
{ func: 'install dependencies' },
529566
{ func: 'check types' }
530567
]
531-
};
568+
}
532569
}
533-
return {
534-
name: 'run-typescript-next',
535-
tags: ['run-typescript-next', 'typescript-compilation'],
536-
commands: [
537-
updateExpansions({
538-
NODE_LTS_VERSION: LOWEST_LTS,
539-
NPM_VERSION: 9
540-
}),
541-
{ func: 'install dependencies' },
542-
{ func: 'run typescript next' }
543-
]
544-
};
570+
571+
const typesVersion = require('../package.json').devDependencies['@types/node'].slice(1)
572+
yield makeCheckTypesTask('next', typesVersion);
573+
yield makeCheckTypesTask('current', typesVersion);
574+
575+
yield makeCheckTypesTask('next', '16.x');
576+
yield makeCheckTypesTask('current', '16.x');
577+
578+
// typescript 4.4 only compiles our types with this particular version
579+
yield makeCheckTypesTask('4.4', '18.11.9');
580+
581+
yield makeCompileTask('current', typesVersion);
545582
}
546583

547584
BUILD_VARIANTS.push({
@@ -731,6 +768,13 @@ BUILD_VARIANTS.push({
731768
tasks: ['test_atlas_task_group_search_indexes']
732769
});
733770

771+
BUILD_VARIANTS.push({
772+
name: 'resource management tests',
773+
display_name: 'resource management tests',
774+
run_on: DEFAULT_OS,
775+
tasks: ['.resource-management']
776+
});
777+
734778
// TODO(NODE-4575): unskip zstd and snappy on node 16
735779
for (const variant of BUILD_VARIANTS.filter(
736780
variant => variant.expansions && [16, 18, 20].includes(variant.expansions.NODE_LTS_VERSION)
@@ -755,6 +799,7 @@ fileData.tasks = (fileData.tasks || [])
755799
.concat(AUTH_DISABLED_TASKS)
756800
.concat(AWS_LAMBDA_HANDLER_TASKS)
757801
.concat(MONGOCRYPTD_CSFLE_TASKS);
802+
758803
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);
759804

760805
fs.writeFileSync(

‎.evergreen/install-dependencies.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4+
# allowed values:
5+
## a nodejs major version (i.e., 16)
6+
## 'latest'
7+
## a full nodejs version, in the format v<major>.<minor>.patch
48
NODE_LTS_VERSION=${NODE_LTS_VERSION:-16}
59
# npm version can be defined in the environment for cases where we need to install
610
# a version lower than latest to support EOL Node versions.

0 commit comments

Comments
 (0)
Please sign in to comment.