Skip to content

Commit da0dbfe

Browse files
Update mongodb to the latest version 🚀 (#6348)
* fix(package): update mongodb to version 3.5.0 * chore(package): update lockfile package-lock.json * Fix shutdown issues Properly retrieves the number of connections https://docs.mongodb.com/manual/reference/command/serverStatus/#connections Bump to 3.5.1 * remove fit Co-authored-by: Diamond Lewis <[email protected]>
1 parent 06791d8 commit da0dbfe

File tree

6 files changed

+59
-33
lines changed

6 files changed

+59
-33
lines changed

‎package-lock.json

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"lodash": "4.17.15",
4444
"lru-cache": "5.1.1",
4545
"mime": "2.4.4",
46-
"mongodb": "3.4.1",
46+
"mongodb": "3.5.1",
4747
"node-rsa": "1.0.7",
4848
"parse": "2.11.0",
4949
"pg-promise": "10.4.0",

‎spec/GridFSBucketStorageAdapter.spec.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ describe('GridFSBucket and GridStore interop', () => {
6161
await expectMissingFile(gfsAdapter, 'myFileName');
6262
});
6363

64-
it('handleShutdown, close connection', done => {
64+
it('handleShutdown, close connection', async () => {
6565
const databaseURI = 'mongodb://localhost:27017/parse';
6666
const gfsAdapter = new GridFSBucketAdapter(databaseURI);
6767

68-
gfsAdapter._connect().then(db => {
69-
expect(db.serverConfig.connections().length > 0).toEqual(true);
70-
gfsAdapter.handleShutdown().then(() => {
71-
expect(db.serverConfig.connections().length > 0).toEqual(false);
72-
done();
73-
});
74-
});
68+
const db = await gfsAdapter._connect();
69+
const status = await db.admin().serverStatus();
70+
expect(status.connections.current > 0).toEqual(true);
71+
72+
await gfsAdapter.handleShutdown();
73+
try {
74+
await db.admin().serverStatus();
75+
expect(false).toBe(true);
76+
} catch (e) {
77+
expect(e.message).toEqual('topology was destroyed');
78+
}
7579
});
7680
});

‎spec/GridStoreAdapter.spec.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,20 @@ describe_only_db('mongo')('GridStoreAdapter', () => {
9797
.catch(fail);
9898
});
9999

100-
it('handleShutdown, close connection', done => {
100+
it('handleShutdown, close connection', async () => {
101101
const databaseURI = 'mongodb://localhost:27017/parse';
102102
const gridStoreAdapter = new GridStoreAdapter(databaseURI);
103103

104-
gridStoreAdapter._connect().then(db => {
105-
expect(db.serverConfig.connections().length > 0).toEqual(true);
106-
gridStoreAdapter.handleShutdown().then(() => {
107-
expect(db.serverConfig.connections().length > 0).toEqual(false);
108-
done();
109-
});
110-
});
104+
const db = await gridStoreAdapter._connect();
105+
const status = await db.admin().serverStatus();
106+
expect(status.connections.current > 0).toEqual(true);
107+
108+
await gridStoreAdapter.handleShutdown();
109+
try {
110+
await db.admin().serverStatus();
111+
expect(false).toBe(true);
112+
} catch (e) {
113+
expect(e.message).toEqual('topology was destroyed');
114+
}
111115
});
112116
});

‎spec/MongoStorageAdapter.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
271271
});
272272
});
273273

274-
it('handleShutdown, close connection', done => {
274+
it('handleShutdown, close connection', async () => {
275275
const adapter = new MongoStorageAdapter({ uri: databaseURI });
276276

277277
const schema = {
@@ -282,17 +282,17 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
282282
},
283283
};
284284

285-
adapter.createObject('MyClass', schema, {}).then(() => {
286-
expect(adapter.database.serverConfig.connections().length > 0).toEqual(
287-
true
288-
);
289-
adapter.handleShutdown().then(() => {
290-
expect(adapter.database.serverConfig.connections().length > 0).toEqual(
291-
false
292-
);
293-
done();
294-
});
295-
});
285+
await adapter.createObject('MyClass', schema, {});
286+
const status = await adapter.database.admin().serverStatus();
287+
expect(status.connections.current > 0).toEqual(true);
288+
289+
await adapter.handleShutdown();
290+
try {
291+
await adapter.database.admin().serverStatus();
292+
expect(false).toBe(true);
293+
} catch (e) {
294+
expect(e.message).toEqual('topology was destroyed');
295+
}
296296
});
297297

298298
it('getClass if exists', async () => {

‎spec/ParseServer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('Server Url Checks', () => {
106106
parseServerProcess.on('close', code => {
107107
expect(code).toEqual(1);
108108
expect(stdout).toBeUndefined();
109-
expect(stderr).toContain('MongoNetworkError');
109+
expect(stderr).toContain('MongoServerSelectionError');
110110
done();
111111
});
112112
});

0 commit comments

Comments
 (0)