diff --git a/package-lock.json b/package-lock.json index 210e0010..57dbb9ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -728,6 +728,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -793,6 +794,7 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, "funding": [ { "type": "github", @@ -1566,6 +1568,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, "funding": [ { "type": "github", @@ -2664,7 +2667,7 @@ "packages/bson-bench": { "version": "0.0.1", "license": "Apache-2.0", - "dependencies": { + "devDependencies": { "bson": "4.7" }, "engines": { @@ -2676,6 +2679,8 @@ "version": "4.7.2", "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz", "integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==", + "dev": true, + "license": "Apache-2.0", "dependencies": { "buffer": "^5.6.0" }, diff --git a/packages/bson-bench/README.md b/packages/bson-bench/README.md index 25442b93..35edbced 100644 --- a/packages/bson-bench/README.md +++ b/packages/bson-bench/README.md @@ -1,6 +1,6 @@ # bson-bench -This library provides functionality to install and run benchmarks against bson and bson-ext. +This library provides functionality to install and run benchmarks against bson. > [!IMPORTANT] > This library is **NOT** an official MongoDB product and is meant for internal use only diff --git a/packages/bson-bench/package.json b/packages/bson-bench/package.json index c6f9df2f..3dea9128 100644 --- a/packages/bson-bench/package.json +++ b/packages/bson-bench/package.json @@ -16,11 +16,11 @@ "keywords": [], "author": "The MongoDB NodeJS Team ", "license": "Apache-2.0", - "dependencies": { - "bson": "4.7" - }, "directories": { "lib": "lib", "test": "test" + }, + "devDependencies": { + "bson": "4.7" } } diff --git a/packages/bson-bench/src/base.ts b/packages/bson-bench/src/base.ts index 3b758b51..62b89a20 100644 --- a/packages/bson-bench/src/base.ts +++ b/packages/bson-bench/src/base.ts @@ -1,4 +1,3 @@ -import * as BSON from 'bson'; import { readFileSync } from 'fs'; import { join } from 'path'; import { performance } from 'perf_hooks'; @@ -56,10 +55,7 @@ function run(bson: BSONLib | ConstructibleBSON, config: BenchmarkSpecification) try { if (bson.EJSON) doc = bson.EJSON.parse(readFileSync(config.documentPath, 'utf8')); - // NOTE: The BSON version used here is bson@4. This is for compatibility with bson-ext as it is - // the only version of the js-bson library explicitly compatible with bson-ext and which does - // not result in bson-ext throwing an error when running deserialization tests. - else doc = BSON.EJSON.parse(readFileSync(config.documentPath, 'utf8')); + else throw new Error('No EJSON parser found'); } catch (cause) { reportErrorAndQuit(new Error('Failed to read test document', { cause })); return; diff --git a/packages/bson-bench/src/common.ts b/packages/bson-bench/src/common.ts index b263ab04..f14463b5 100644 --- a/packages/bson-bench/src/common.ts +++ b/packages/bson-bench/src/common.ts @@ -5,20 +5,20 @@ import { join } from 'path'; import { exists } from './utils'; // handle normal npm package regex -export const NPM_PACKAGE_REGEX = /(bson-ext|bson)@((\d+(\.\d+)?(\.\d+)?)|latest)/; +export const NPM_PACKAGE_REGEX = /(bson)@((\d+(\.\d+)?(\.\d+)?)|latest)/; // handle git tags/commits -export const GIT_PACKAGE_REGEX = /(bson-ext|bson)#(.+)/; +export const GIT_PACKAGE_REGEX = /(bson)#(.+)/; // handle local package -export const LOCAL_PACKAGE_REGEX = /(bson-ext|bson):(.+)/; +export const LOCAL_PACKAGE_REGEX = /(bson):(.+)/; /** - * The Package class represents the bson or bson-ext package to be tested + * The Package class represents the bson package to be tested * This package can be an npm package, a git repository or a local package **/ export class Package { type: 'npm' | 'git' | 'local'; // bson library to install - library: 'bson' | 'bson-ext'; + library: 'bson'; computedModuleName: string; // semver version specification npmVersion?: string; @@ -33,17 +33,17 @@ export class Package { let match: RegExpExecArray | null; if ((match = NPM_PACKAGE_REGEX.exec(libSpec))) { this.type = 'npm'; - this.library = match[1] as 'bson' | 'bson-ext'; + this.library = match[1] as 'bson'; this.npmVersion = match[2]; this.computedModuleName = `${this.library}-${this.npmVersion}`; } else if ((match = GIT_PACKAGE_REGEX.exec(libSpec))) { this.type = 'git'; - this.library = match[1] as 'bson' | 'bson-ext'; + this.library = match[1] as 'bson'; this.gitCommitish = match[2]; this.computedModuleName = `${this.library}-git-${this.gitCommitish}`; } else if ((match = LOCAL_PACKAGE_REGEX.exec(libSpec))) { this.type = 'local'; - this.library = match[1] as 'bson' | 'bson-ext'; + this.library = match[1] as 'bson'; this.localPath = match[2]; const cleanedLocalPath = this.localPath.replaceAll('/', '_').replaceAll('\\', '_'); @@ -81,9 +81,6 @@ export class Package { case 'bson': source = `git://github.com/mongodb/js-bson#${this.gitCommitish}`; break; - case 'bson-ext': - source = `git://github.com/mongodb-js/bson-ext#${this.gitCommitish}`; - break; } break; case 'local': @@ -130,7 +127,7 @@ export type BenchmarkSpecification = { iterations: number; /** Number of iterations that will be run to warm up the V8 engine */ warmup: number; - /** Specifier of the bson or bson-ext library to be used. Can be an npm package, git repository or + /** Specifier of the bson library to be used. Can be an npm package, git repository or * local package */ library: string; installLocation?: string; diff --git a/packages/bson-bench/src/task.ts b/packages/bson-bench/src/task.ts index d27ce56a..d0f5ee67 100644 --- a/packages/bson-bench/src/task.ts +++ b/packages/bson-bench/src/task.ts @@ -98,13 +98,8 @@ export class Task { break; // special cases case 'validation': - // utf8 validation is always on for bson-ext - output['utf8Validation'] = /^bson-ext/.test(this.benchmark.library) - ? 1 - : // if value of boolean for js-bson, convert to number, otherwise assume true - typeof o[key]['utf8'] === 'boolean' - ? Number(o[key]['utf8']) - : 1; + output.utf8Validation = + typeof o[key]['utf8'] === 'boolean' ? Number(o[key]['utf8']) : 1; break; default: output[key] = diff --git a/packages/bson-bench/test/unit/common.test.ts b/packages/bson-bench/test/unit/common.test.ts index 270b5abb..efbad711 100644 --- a/packages/bson-bench/test/unit/common.test.ts +++ b/packages/bson-bench/test/unit/common.test.ts @@ -44,7 +44,7 @@ describe('common functionality', function () { }); }); - context('when trying to install an npm package apart from bson or bson-ext', function () { + context('when trying to install an npm package apart from bson', function () { it('throws an error', function () { expect(() => new Package('notBson@1.0.0', installDir)).to.throw( Error, @@ -53,7 +53,7 @@ describe('common functionality', function () { }); }); - context('when trying to install a git package apart from bson or bson-ext', function () { + context('when trying to install a git package apart from bson', function () { it('throws an error', function () { expect(() => new Package('notBson#abcdabcdabcd', installDir)).to.throw( Error, @@ -96,7 +96,7 @@ describe('common functionality', function () { context('#install()', function () { context('when given a correctly formatted npm package that exists', function () { - for (const lib of ['bson@6.0.0', 'bson-ext@4.0.0', 'bson@latest', 'bson-ext@latest']) { + for (const lib of ['bson@6.0.0', 'bson@latest']) { it(`installs ${lib} successfully to the specified install directory`, async function () { const pack = new Package(lib, installDir); await pack.install(); diff --git a/packages/bson-bench/test/unit/task.test.ts b/packages/bson-bench/test/unit/task.test.ts index d16e09ed..64e2ad6f 100644 --- a/packages/bson-bench/test/unit/task.test.ts +++ b/packages/bson-bench/test/unit/task.test.ts @@ -20,16 +20,7 @@ describe('Task', function () { const BSON_PATH = process.env.BSON_PATH; const BSON_EXT_PATH = process.env.BSON_EXT_PATH; - const versions = [ - 'bson@6.2.0', - 'bson@4.0.0', - 'bson@1.1.6', - 'bson@5.0.0', - 'bson#v6.1.0', - `bson:${LOCAL_BSON}`, - 'bson-ext@4.0.0', - 'bson-ext#c1284d1' - ]; + const versions = ['bson@6.2.0', 'bson@4.0.0', 'bson@5.0.0', 'bson#v6.1.0', `bson:${LOCAL_BSON}`]; const operations: ('serialize' | 'deserialize')[] = ['serialize', 'deserialize']; if (BSON_PATH) versions.push(`bson:${BSON_PATH}`); if (BSON_EXT_PATH) versions.push(`bson:${BSON_EXT_PATH}`); @@ -59,14 +50,6 @@ describe('Task', function () { }); it('completes successfully', async function () { - if ( - Number(process.versions.node.split('.')[0]) >= 20 && - /bson-ext#.*/.test(test.library) - ) { - console.log('Skipping installing bson-ext via git tag on Node 20'); - this.skip(); - } - await task.run(); for (const child of task.children) { expect(child.exitCode).to.not.be.null; @@ -76,7 +59,7 @@ describe('Task', function () { it('strips the tag or commit from the test name', function () { expect(task.testName).to.not.include(test.library); - expect(task.testName).to.match(/bson|bson-ext/); + expect(task.testName).to.match(/bson/); }); }); } @@ -323,7 +306,7 @@ describe('Task', function () { before(async () => { task = new Task({ documentPath: 'test/documents/long_largeArray.json', - library: 'bson-ext@4.0.0', + library: 'bson@4', operation: 'deserialize', warmup: 100, iterations: 100, diff --git a/packages/bson-bench/test/utils.ts b/packages/bson-bench/test/utils.ts index 78cda50a..4d0c447d 100644 --- a/packages/bson-bench/test/utils.ts +++ b/packages/bson-bench/test/utils.ts @@ -6,13 +6,13 @@ import { exists } from '../src/utils'; export { exists } from '../src/utils'; /** - * Remove all installed bson and bson-ext versions that have been installed by tests + * Remove all installed bson versions that have been installed by tests */ export async function clearTestedDeps(installDir: string) { const targetDir = path.join(installDir, 'node_modules'); if (await exists(targetDir)) for await (const dirent of await fs.opendir(targetDir)) { - if (/^(bson-ext|bson)-(git|local)?.*$/.test(dirent.name)) { + if (/^(bson)-(git|local)?.*$/.test(dirent.name)) { await fs.rm(path.join(targetDir, dirent.name), { recursive: true, force: true