test: Fix flaky tests for comment in MongoDB query (#9015)
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Config = require('../lib/Config');
|
const Config = require('../lib/Config');
|
||||||
const TestUtils = require('../lib/TestUtils');
|
|
||||||
const { MongoClient } = require('mongodb');
|
const { MongoClient } = require('mongodb');
|
||||||
const databaseURI = 'mongodb://localhost:27017/';
|
const databaseURI = 'mongodb://localhost:27017/';
|
||||||
const request = require('../lib/request');
|
const request = require('../lib/request');
|
||||||
@@ -20,22 +19,33 @@ const masterKeyOptions = {
|
|||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const profileLevel = 2;
|
||||||
describe_only_db('mongo')('Parse.Query with comment testing', () => {
|
describe_only_db('mongo')('Parse.Query with comment testing', () => {
|
||||||
beforeEach(async () => {
|
beforeAll(async () => {
|
||||||
config = Config.get('test');
|
config = Config.get('test');
|
||||||
client = await MongoClient.connect(databaseURI, {
|
client = await MongoClient.connect(databaseURI, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
});
|
});
|
||||||
database = client.db('parseServerMongoAdapterTestDatabase');
|
database = client.db('parseServerMongoAdapterTestDatabase');
|
||||||
const level = 2;
|
let profiler = await database.command({ profile: 0 });
|
||||||
const profiling = await database.command({ profile: level });
|
expect(profiler.was).toEqual(0);
|
||||||
console.log(`profiling ${JSON.stringify(profiling)}`);
|
console.log(`Disabling profiler : ${profiler.was}`);
|
||||||
|
profiler = await database.command({ profile: profileLevel });
|
||||||
|
profiler = await database.command({ profile: -1 });
|
||||||
|
console.log(`Enabling profiler : ${profiler.was}`);
|
||||||
|
profiler = await database.command({ profile: -1 });
|
||||||
|
expect(profiler.was).toEqual(profileLevel);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const profiler = await database.command({ profile: -1 });
|
||||||
|
expect(profiler.was).toEqual(profileLevel);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await database.command({ profile: 0 });
|
||||||
await client.close();
|
await client.close();
|
||||||
await TestUtils.destroyAllDataPermanently(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('send comment with query through REST', async () => {
|
it('send comment with query through REST', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user