Skip to content

Commit

Permalink
chore: fix lint && ns not found issues
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Sep 7, 2022
1 parent b572e99 commit 90931c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 18 additions & 2 deletions test/benchmarks/driverBench/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

const fs = require('fs');
const path = require('path');
const { Readable } = require('stream');
const { pipeline } = require('stream/promises');
const { MongoClient } = require('../../..');
const { GridFSBucket } = require('../../..');

// eslint-disable-next-line no-restricted-modules
const { MONGODB_ERROR_CODES } = require('../../../lib/error');

const DB_NAME = 'perftest';
const COLLECTION_NAME = 'corpus';

Expand Down Expand Up @@ -48,7 +53,11 @@ function initCollection() {
}

function dropCollection() {
return this.collection.drop();
return this.collection.drop().catch(e => {
if (e.code !== MONGODB_ERROR_CODES.NamespaceNotFound) {
throw e;
}
});
}

function initBucket() {
Expand Down Expand Up @@ -86,6 +95,12 @@ function makeLoadInsertDocs(numberOfOperations) {
};
}

async function writeSingleByteFileToBucket() {
const stream = this.bucket.openUploadStream('setup-file.txt');
const oneByteFile = Readable.from('a');
return pipeline(oneByteFile, stream);
}

module.exports = {
makeClient,
connectClient,
Expand All @@ -101,5 +116,6 @@ module.exports = {
initBucket,
dropBucket,
makeLoadTweets,
makeLoadInsertDocs
makeLoadInsertDocs,
writeSingleByteFileToBucket
};
6 changes: 0 additions & 6 deletions test/benchmarks/mongoBench/suites/parallelBench.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ async function clearTemporaryDirectory() {
await Promise.all(files.map(file => rm(file)));
}

async function removeTemporaryDirectory() {
await rm(this.temporaryDirectory, { recursive: true, force: true }).catch(() => {
// ignore errors, specifically directory not found
});
}

async function ldjsonMultiUpload() {
const directory = resolve(benchmarkFileDirectory, 'ldjson_multi');
const files = await readdir(directory);
Expand Down

0 comments on commit 90931c5

Please sign in to comment.