Skip to content

Commit

Permalink
feat(NODE-5614): add support for explicit resource management (#4177)
Browse files Browse the repository at this point in the history
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
  • Loading branch information
baileympearson and nbbeeken authored Aug 7, 2024
1 parent 54efb7d commit b3f3987
Show file tree
Hide file tree
Showing 30 changed files with 757 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
lib
test/disabled
!etc/docs

test/explicit-resource-management
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@
{
// Settings for generated definition files
"files": [
"mongodb.d.ts"
"**/*.d.ts",
"lib/*.d.ts"
],
"parser": "@typescript-eslint/parser",
"rules": {
Expand Down
27 changes: 27 additions & 0 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,36 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"

"check resource management":
- command: subprocess.exec
type: test
params:
working_dir: "src"
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh"

"check resource management feature integration":
- command: subprocess.exec
type: test
params:
working_dir: "src"
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
MONGODB_URI: ${MONGODB_URI}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-resource-management-feature-integration.sh"

"compile driver":
- command: subprocess.exec
type: test
Expand All @@ -362,6 +388,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
Expand Down
114 changes: 108 additions & 6 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,33 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
check resource management:
- command: subprocess.exec
type: test
params:
working_dir: src
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh
check resource management feature integration:
- command: subprocess.exec
type: test
params:
working_dir: src
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
MONGODB_URI: ${MONGODB_URI}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-resource-management-feature-integration.sh
compile driver:
- command: subprocess.exec
type: test
Expand All @@ -325,6 +349,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
Expand Down Expand Up @@ -3459,7 +3484,45 @@ tasks:
- {key: NPM_VERSION, value: '9'}
- func: install dependencies
- func: run lint checks
- name: check-types-typescript-next
- name: run-resource-management-no-async-dispose
tags:
- resource-management
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: v16.20.2}
- {key: NPM_VERSION, value: '9'}
- func: install dependencies
- func: check resource management
- name: run-resource-management-async-dispose
tags:
- resource-management
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: latest}
- {key: NPM_VERSION, value: '9'}
- func: install dependencies
- func: check resource management
- name: test-explicit-resource-management-feature-integration
tags:
- resource-management
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: VERSION, value: latest}
- {key: TOPOLOGY, value: replica_set}
- {key: NODE_LTS_VERSION, value: latest}
- func: install dependencies
- func: bootstrap mongo-orchestration
- func: check resource management feature integration
- name: check-types-typescript-next-node-types-20.14.10
tags:
- check-types-typescript-next
- typescript-compilation
Expand All @@ -3471,11 +3534,12 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: next}
- {key: TYPES_VERSION, value: 20.14.10}
- func: install dependencies
- func: check types
- name: compile-driver-typescript-current
- name: check-types-typescript-current-node-types-20.14.10
tags:
- compile-driver-typescript-current
- check-types-typescript-current
- typescript-compilation
commands:
- command: expansions.update
Expand All @@ -3485,9 +3549,25 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 20.14.10}
- func: install dependencies
- func: compile driver
- name: check-types-typescript-current
- func: check types
- name: check-types-typescript-next-node-types-16.x
tags:
- check-types-typescript-next
- typescript-compilation
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: next}
- {key: TYPES_VERSION, value: 16.x}
- func: install dependencies
- func: check types
- name: check-types-typescript-current-node-types-16.x
tags:
- check-types-typescript-current
- typescript-compilation
Expand All @@ -3499,9 +3579,10 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 16.x}
- func: install dependencies
- func: check types
- name: check-types-typescript-4.4
- name: check-types-typescript-4.4-node-types-18.11.9
tags:
- check-types-typescript-4.4
- typescript-compilation
Expand All @@ -3513,8 +3594,24 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: '4.4'}
- {key: TYPES_VERSION, value: 18.11.9}
- func: install dependencies
- func: check types
- name: compile-driver-typescript-current-node-types-20.14.10
tags:
- compile-driver-typescript-current
- typescript-compilation
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 20.14.10}
- func: install dependencies
- func: compile driver
- name: download-and-merge-coverage
tags: []
commands:
Expand Down Expand Up @@ -5171,3 +5268,8 @@ buildvariants:
run_on: rhel80-large
tasks:
- test_atlas_task_group_search_indexes
- name: resource management tests
display_name: resource management tests
run_on: rhel80-large
tasks:
- .resource-management
113 changes: 79 additions & 34 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,56 +492,93 @@ SINGLETON_TASKS.push(
{ func: 'run lint checks' }
]
},
{
name: 'run-resource-management-no-async-dispose',
tags: ['resource-management'],
commands: [
updateExpansions({
NODE_LTS_VERSION: "v16.20.2",
NPM_VERSION: 9
}),
{ func: 'install dependencies' },
{ func: 'check resource management' }
]
},
{
name: 'run-resource-management-async-dispose',
tags: ['resource-management'],
commands: [
updateExpansions({
NODE_LTS_VERSION: 'latest',
NPM_VERSION: 9
}),
{ func: 'install dependencies' },
{ func: 'check resource management' }
]
},
{
name: 'test-explicit-resource-management-feature-integration',
tags: ['resource-management'],
commands: [
updateExpansions({
VERSION: 'latest',
TOPOLOGY: 'replica_set',
NODE_LTS_VERSION: 'latest'
}),
{ func: 'install dependencies' },
{ func: 'bootstrap mongo-orchestration' },
{ func: 'check resource management feature integration' }
]
},
...Array.from(makeTypescriptTasks())
]
);

function* makeTypescriptTasks() {
for (const TS_VERSION of ['next', 'current', '4.4']) {
// We don't compile on next, because compilation errors are likely. We do expect
// that the drivers types continue to work with next though.
if (TS_VERSION !== '4.4' && TS_VERSION !== 'next') {
yield {
name: `compile-driver-typescript-${TS_VERSION}`,
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION
}),
{ func: 'install dependencies' },
{ func: 'compile driver' }
]
};
function makeCompileTask(TS_VERSION, TYPES_VERSION) {
return {
name: `compile-driver-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION,
TYPES_VERSION
}),
{ func: 'install dependencies' },
{ func: 'compile driver' }
]
}

yield {
name: `check-types-typescript-${TS_VERSION}`,
}
function makeCheckTypesTask(TS_VERSION, TYPES_VERSION) {
return {
name: `check-types-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
tags: [`check-types-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION
TS_VERSION,
TYPES_VERSION
}),
{ func: 'install dependencies' },
{ func: 'check types' }
]
};
}
}
return {
name: 'run-typescript-next',
tags: ['run-typescript-next', 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9
}),
{ func: 'install dependencies' },
{ func: 'run typescript next' }
]
};

const typesVersion = require('../package.json').devDependencies['@types/node'].slice(1)
yield makeCheckTypesTask('next', typesVersion);
yield makeCheckTypesTask('current', typesVersion);

yield makeCheckTypesTask('next', '16.x');
yield makeCheckTypesTask('current', '16.x');

// typescript 4.4 only compiles our types with this particular version
yield makeCheckTypesTask('4.4', '18.11.9');

yield makeCompileTask('current', typesVersion);
}

BUILD_VARIANTS.push({
Expand Down Expand Up @@ -731,6 +768,13 @@ BUILD_VARIANTS.push({
tasks: ['test_atlas_task_group_search_indexes']
});

BUILD_VARIANTS.push({
name: 'resource management tests',
display_name: 'resource management tests',
run_on: DEFAULT_OS,
tasks: ['.resource-management']
});

// TODO(NODE-4575): unskip zstd and snappy on node 16
for (const variant of BUILD_VARIANTS.filter(
variant => variant.expansions && [16, 18, 20].includes(variant.expansions.NODE_LTS_VERSION)
Expand All @@ -755,6 +799,7 @@ fileData.tasks = (fileData.tasks || [])
.concat(AUTH_DISABLED_TASKS)
.concat(AWS_LAMBDA_HANDLER_TASKS)
.concat(MONGOCRYPTD_CSFLE_TASKS);

fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);

fs.writeFileSync(
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -o errexit # Exit the script with error if any of the commands fail

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

0 comments on commit b3f3987

Please sign in to comment.