Skip to content

Commit 69f9952

Browse files
committed
fix setupDatabase
1 parent b466ecd commit 69f9952

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

.evergreen/run-mongodb-aws-ecs-test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ source ./.evergreen/prepare-shell.sh # should not run git clone
1313

1414
# load node.js
1515
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
16-
17-
# run the tests
18-
npm install aws4

.evergreen/setup-mongodb-aws-auth-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ cd $DRIVERS_TOOLS/.evergreen/auth_aws
2323

2424
cd $BEFORE
2525

26-
npm install --no-save aws4
27-
2826
if [ $MONGODB_AWS_SDK = 'false' ]; then rm -rf ./node_modules/@aws-sdk/credential-providers; fi
2927

3028
# revert to show test output

test/integration/node-specific/examples/change_streams.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict';
33

44
const { setTimeout } = require('timers');
5+
const setupDatabase = require('../../shared').setupDatabase;
56
const expect = require('chai').expect;
67

78
// TODO: NODE-3819: Unskip flaky MacOS/Windows tests.
@@ -10,9 +11,13 @@ maybeDescribe('examples(change-stream):', function () {
1011
let client;
1112
let db;
1213

14+
before(async function () {
15+
await setupDatabase(this.configuration);
16+
});
17+
1318
beforeEach(async function () {
1419
client = await this.configuration.newClient().connect();
15-
db = client.db('change_stream_examples');
20+
db = client.db(this.configuration.db);
1621

1722
// ensure database exists, we need this for 3.6
1823
await db.collection('inventory').insertOne({});

test/integration/shared.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,21 @@ function ignoreNsNotFound(err) {
9090
if (!err.message.match(/ns not found/)) throw err;
9191
}
9292

93-
function setupDatabase(configuration, dbsToClean) {
93+
async function setupDatabase(configuration, dbsToClean) {
9494
dbsToClean = Array.isArray(dbsToClean) ? dbsToClean : [];
95-
var configDbName = configuration.db;
96-
var client = configuration.newClient(configuration.writeConcernMax(), {
97-
maxPoolSize: 1
98-
});
95+
const configDbName = configuration.db;
9996

10097
dbsToClean.push(configDbName);
10198

102-
return client
103-
.connect()
104-
.then(() =>
105-
dbsToClean.reduce(
106-
(result, dbName) =>
107-
result
108-
.then(() =>
109-
client.db(dbName).command({ dropAllUsersFromDatabase: 1, writeConcern: { w: 1 } })
110-
)
111-
.then(() => client.db(dbName).dropDatabase({ writeConcern: { w: 1 } })),
112-
Promise.resolve()
113-
)
114-
)
115-
.then(
116-
() => client.close(),
117-
err => client.close(() => Promise.reject(err))
118-
);
99+
const client = configuration.newClient(configuration.writeConcernMax());
100+
try {
101+
for (const dbName of dbsToClean) {
102+
await client.db(dbName).command({ dropAllUsersFromDatabase: 1, writeConcern: { w: 1 } });
103+
await client.db(dbName).dropDatabase({ writeConcern: { w: 1 } });
104+
}
105+
} finally {
106+
await client.close();
107+
}
119108
}
120109

121110
/**

0 commit comments

Comments
 (0)