Update mongodb to the latest version 🚀 (#4855)

* fix(package): update mongodb to version 3.1.0

* chore(package): update lockfile

https://npm.im/greenkeeper-lockfile

* starting mongo 3.1.0, read preferences are passed again

* Adds test confirming #4831 is properly functional now
This commit is contained in:
greenkeeper[bot]
2018-06-27 14:12:51 -04:00
committed by Florent Vilmart
parent 43be9fed9d
commit 320eba1081
3 changed files with 3118 additions and 3531 deletions

9764
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@
"lodash": "4.17.5",
"lru-cache": "4.1.2",
"mime": "2.3.1",
"mongodb": "3.0.7",
"mongodb": "3.1.0",
"multer": "1.3.0",
"parse": "1.11.1",
"pg-promise": "8.4.0",

View File

@@ -28,7 +28,7 @@ describe_only_db('mongo')('Read preference option', () => {
databaseAdapter.database.serverConfig.cursor.calls.all().forEach((call) => {
if (call.args[0].indexOf('MyObject') >= 0) {
myObjectReadPreference = true;
expect(call.args[2].readPreference).toBeUndefined();
expect(call.args[2].readPreference.preference).toBe(ReadPreference.PRIMARY);
}
});
@@ -39,6 +39,45 @@ describe_only_db('mongo')('Read preference option', () => {
});
});
it('should preserve the read preference set (#4831)', async () => {
const { MongoStorageAdapter } = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter');
const adapterOptions = {
uri: 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase',
mongoOptions: {
readPreference: ReadPreference.NEAREST,
}
};
await reconfigureServer({ databaseAdapter: new MongoStorageAdapter(adapterOptions) });
const databaseAdapter = (Config.get(Parse.applicationId)).database.adapter;
const obj0 = new Parse.Object('MyObject');
obj0.set('boolKey', false);
const obj1 = new Parse.Object('MyObject');
obj1.set('boolKey', true);
await Parse.Object.saveAll([obj0, obj1])
spyOn(databaseAdapter.database.serverConfig, 'cursor').and.callThrough();
const query = new Parse.Query('MyObject');
query.equalTo('boolKey', false);
const results = await query.find();
expect(results.length).toBe(1);
expect(results[0].get('boolKey')).toBe(false);
let myObjectReadPreference = null;
databaseAdapter.database.serverConfig.cursor.calls.all().forEach((call) => {
if (call.args[0].indexOf('MyObject') >= 0) {
myObjectReadPreference = true;
expect(call.args[2].readPreference.preference).toBe(ReadPreference.NEAREST);
}
});
expect(myObjectReadPreference).toBe(true);
console.log('OK!');
});
it('should change read preference in the beforeFind trigger', (done) => {
const databaseAdapter = (Config.get(Parse.applicationId)).database.adapter;
@@ -444,11 +483,11 @@ describe_only_db('mongo')('Read preference option', () => {
databaseAdapter.database.serverConfig.cursor.calls.all().forEach((call) => {
if (call.args[0].indexOf('MyObject0') >= 0) {
myObjectReadPreference0 = true;
expect(call.args[2].readPreference).toBeUndefined();
expect(call.args[2].readPreference.preference).toBe(ReadPreference.PRIMARY);
}
if (call.args[0].indexOf('MyObject1') >= 0) {
myObjectReadPreference1 = true;
expect(call.args[2].readPreference).toBeUndefined();
expect(call.args[2].readPreference.preference).toBe(ReadPreference.PRIMARY);
}
if (call.args[0].indexOf('MyObject2') >= 0) {
myObjectReadPreference2 = call.args[2].readPreference.preference;
@@ -559,11 +598,11 @@ describe_only_db('mongo')('Read preference option', () => {
databaseAdapter.database.serverConfig.cursor.calls.all().forEach((call) => {
if (call.args[0].indexOf('MyObject0') >= 0) {
myObjectReadPreference0 = true;
expect(call.args[2].readPreference).toBeUndefined();
expect(call.args[2].readPreference.preference).toBe(ReadPreference.PRIMARY);
}
if (call.args[0].indexOf('MyObject1') >= 0) {
myObjectReadPreference1 = true;
expect(call.args[2].readPreference).toBeUndefined();
expect(call.args[2].readPreference.preference).toBe(ReadPreference.PRIMARY);
}
if (call.args[0].indexOf('MyObject2') >= 0) {
myObjectReadPreference2 = call.args[2].readPreference.preference;