-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(NODE-7335): Create dedicated mocha runner with isolated vm context #4876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tadjik1
merged 50 commits into
mongodb:main
from
PavelSafronov:NODE-7335-bundle-and-barrel-approach-poc
Mar 25, 2026
Merged
Changes from 32 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
4dbd896
initial POC
baileympearson b790827
lint
baileympearson 1d1c89e
add adapter unit test
baileympearson 58d8976
unit tests and integration tests
baileympearson 9e0e0ff
cleanup implementation, fix tests
baileympearson 0738ef8
comments
baileympearson dcdbd79
Merge branch 'main' into NODE-7385
baileympearson 358ede2
working POC bundle + context
baileympearson c8e5888
working POC bundle + context
baileympearson f82c084
Merge branch 'main' into NODE-7345-2-poc-single-context
tadjik1 7f2bd34
got some things working, now figuring out the general types in tests
PavelSafronov 875174b
improve tooling and migrate timeout.test.ts to new format
PavelSafronov 7d9cf78
added better message to restricted require error, including the sourc…
PavelSafronov b17b665
keep wrapper on the same line as the bundle code, so we have accurate…
PavelSafronov d23ee71
added readme info about the current approach
PavelSafronov f45d754
minor changes to get unit and integ tests working
PavelSafronov bb11d48
added a nodeless build variant
PavelSafronov 06273e7
updated imports of all integ tests and added a bunch of new exports t…
PavelSafronov 5756424
readme updates
PavelSafronov 5c3fcfa
more exports and fixes for integ tests
PavelSafronov 1d0bb60
remove logging from vm context, remove runNodelessTests
PavelSafronov 06ee01a
log more info about require error
PavelSafronov d6a56b8
add console log when require is blocked
PavelSafronov 7cb3e5d
remove .only
PavelSafronov 641cb28
Merge branch 'main' into NODE-7335-bundle-and-barrel-approach-poc
PavelSafronov 3556355
change how we block require calls, log more info
PavelSafronov 8e0da0a
Merge branch 'NODE-7335-bundle-and-barrel-approach-poc' of https://gi…
PavelSafronov 3ebd9dd
simplified path logic for the require check
PavelSafronov 551c70d
update a few more test imports, skip a v8 test in nodeless testing, a…
PavelSafronov d2fbe57
add a few more exports
PavelSafronov 7a2fda5
add missing export
PavelSafronov f454070
fix prose test, add unit test for nodeless
PavelSafronov 7bd8b9a
swapped files to remove all import changes, got most non-integ tests …
PavelSafronov 837f71a
remove incorrect import
PavelSafronov e187769
remove debug calls
PavelSafronov 670f69e
minor fixes
PavelSafronov 4d537b2
pr feedback: remove duplicates
PavelSafronov e3703f0
script and eslint updated
PavelSafronov 9183a64
pr feedback:
PavelSafronov a2804c7
Merge branch 'main' into NODE-7335-bundle-and-barrel-approach-poc
PavelSafronov 7907619
Merge branch 'NODE-7335-bundle-and-barrel-approach-poc' of https://gi…
PavelSafronov 76634cb
pr feedback:
PavelSafronov 7c3c25a
pr feedback: remove sandbox.global
PavelSafronov 711d724
pr feedback: use a different approach of allowing requires
PavelSafronov be87f76
pr feedback: pare down the list of nodeless tasks
PavelSafronov 971cc26
Merge branch 'NODE-7335-bundle-and-barrel-approach-poc' of https://gi…
PavelSafronov b248512
ci refactor
PavelSafronov 81e9151
fix lint errors
tadjik1 847c68e
Merge branch 'main' into NODE-7335-bundle-and-barrel-approach-poc
tadjik1 f32fbec
build fix: export MAX_RETRIES
PavelSafronov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,3 +108,5 @@ uri.txt | |
| crypt_shared.sh | ||
|
|
||
| *keytab | ||
| driver.bundle.js | ||
| test/tools/runner/bundle/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import fs from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| // eslint-disable-next-line no-restricted-globals | ||
| const useBundled = process.env.MONGODB_BUNDLED === 'true'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const rootDir = path.join(__dirname, '..'); | ||
|
nbbeeken marked this conversation as resolved.
Outdated
|
||
| const outputBarrelFile = path.join(rootDir, 'test/mongodb_runtime-testing.ts'); | ||
| const source = useBundled ? './mongodb_bundled' : './mongodb'; | ||
|
|
||
| const contents = | ||
| `// This file is auto-generated. Do not edit.\n` + | ||
| `// Run 'npm run build:runtime-barrel' to regenerate.\n` + | ||
| `export const runNodelessTests = ${useBundled};\n` + | ||
| `export * from '${source}';\n`; | ||
| await fs.writeFile(outputBarrelFile, contents); | ||
|
|
||
| // eslint-disable-next-line no-console | ||
| console.log(`✓ ${outputBarrelFile} now re-exports from ${source}`); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/env node | ||
| import fs from 'node:fs/promises'; | ||
| import { isBuiltin } from 'node:module'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| import * as esbuild from 'esbuild'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const rootDir = path.join(__dirname, '..'); | ||
|
|
||
| const outdir = path.join(rootDir, 'test/tools/runner/bundle/'); | ||
| await fs.rm(outdir, { recursive: true, force: true }); | ||
|
|
||
| const outputBundleFile = path.join(outdir, 'driver-bundle.js'); | ||
| await esbuild.build({ | ||
| entryPoints: [path.join(rootDir, 'test/mongodb.ts')], | ||
| bundle: true, | ||
| outfile: outputBundleFile, | ||
| platform: 'node', | ||
| format: 'cjs', | ||
| target: 'node20', | ||
| external: [ | ||
| 'bson', | ||
|
nbbeeken marked this conversation as resolved.
Outdated
|
||
| 'mongodb-connection-string-url', | ||
| '@mongodb-js/saslprep', | ||
| '@mongodb-js/zstd', | ||
| 'mongodb-client-encryption', | ||
| 'snappy', | ||
| '@napi-rs/snappy*', | ||
| 'kerberos', | ||
| 'gcp-metadata', | ||
| '@aws-sdk/credential-providers' | ||
| ], | ||
| plugins: [ | ||
| { | ||
| name: 'externalize-node-builtins', | ||
| setup(build) { | ||
| build.onResolve({ filter: /.*/ }, args => { | ||
| if (isBuiltin(args.path)) { | ||
| return { path: args.path, external: true }; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| ], | ||
| sourcemap: 'inline', | ||
| logLevel: 'info' | ||
| }); | ||
|
|
||
| // eslint-disable-next-line no-console | ||
| console.log(`✓ Driver bundle created at ${outputBundleFile}`); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.