Postgres: Properly initialize database on startup and debugger (#7255)
* PG: Properly initialize database * fix flaky tests * flaky test * correct test * no idea * clean up debugger
This commit is contained in:
@@ -230,10 +230,10 @@ describe('Auth', () => {
|
||||
const role2 = new Parse.Role('role2loadtest' + i, acl2);
|
||||
role.getUsers().add([user]);
|
||||
role2.getUsers().add([user2]);
|
||||
roles.push(role.save());
|
||||
roles.push(role2.save());
|
||||
roles.push(role);
|
||||
roles.push(role2);
|
||||
}
|
||||
const savedRoles = await Promise.all(roles);
|
||||
const savedRoles = await Parse.Object.saveAll(roles);
|
||||
expect(savedRoles.length).toBe(rolesNumber * 2);
|
||||
const cloudRoles = await userAuth.getRolesForUser();
|
||||
const cloudRoles2 = await user2Auth.getRolesForUser();
|
||||
|
||||
@@ -170,6 +170,7 @@ describe('miscellaneous', function () {
|
||||
const config = Config.get('test');
|
||||
// Remove existing data to clear out unique index
|
||||
TestUtils.destroyAllDataPermanently()
|
||||
.then(() => config.database.adapter.performInitialization({ VolatileClassesSchemas: [] }))
|
||||
.then(() => config.database.adapter.createClass('_User', userSchema))
|
||||
.then(() =>
|
||||
config.database.adapter
|
||||
@@ -210,6 +211,7 @@ describe('miscellaneous', function () {
|
||||
const config = Config.get('test');
|
||||
// Remove existing data to clear out unique index
|
||||
TestUtils.destroyAllDataPermanently()
|
||||
.then(() => config.database.adapter.performInitialization({ VolatileClassesSchemas: [] }))
|
||||
.then(() => config.database.adapter.createClass('_User', userSchema))
|
||||
.then(() =>
|
||||
config.database.adapter.createObject('_User', userSchema, {
|
||||
|
||||
@@ -54,8 +54,6 @@ describe('ParseGraphQLSchema', () => {
|
||||
const graphQLSchema = await parseGraphQLSchema.load();
|
||||
const updatedGraphQLSchema = await parseGraphQLSchema.load();
|
||||
expect(graphQLSchema).toBe(updatedGraphQLSchema);
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
expect(graphQLSchema).toBe(await parseGraphQLSchema.load());
|
||||
});
|
||||
|
||||
it('should load a brand new GraphQL Schema if Parse Schema changes', async () => {
|
||||
|
||||
@@ -275,32 +275,26 @@ describe('Parse.Query testing', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('query with limit equal to maxlimit', function (done) {
|
||||
it('query with limit equal to maxlimit', async () => {
|
||||
const baz = new TestObject({ foo: 'baz' });
|
||||
const qux = new TestObject({ foo: 'qux' });
|
||||
reconfigureServer({ maxLimit: 1 });
|
||||
Parse.Object.saveAll([baz, qux]).then(function () {
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.limit(1);
|
||||
query.find().then(function (results) {
|
||||
equal(results.length, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
await reconfigureServer({ maxLimit: 1 });
|
||||
await Parse.Object.saveAll([baz, qux]);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.limit(1);
|
||||
const results = await query.find();
|
||||
equal(results.length, 1);
|
||||
});
|
||||
|
||||
it('query with limit exceeding maxlimit', function (done) {
|
||||
it('query with limit exceeding maxlimit', async () => {
|
||||
const baz = new TestObject({ foo: 'baz' });
|
||||
const qux = new TestObject({ foo: 'qux' });
|
||||
reconfigureServer({ maxLimit: 1 });
|
||||
Parse.Object.saveAll([baz, qux]).then(function () {
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.limit(2);
|
||||
query.find().then(function (results) {
|
||||
equal(results.length, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
await reconfigureServer({ maxLimit: 1 });
|
||||
await Parse.Object.saveAll([baz, qux]);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.limit(2);
|
||||
const results = await query.find();
|
||||
equal(results.length, 1);
|
||||
});
|
||||
|
||||
it('containedIn object array queries', function (done) {
|
||||
|
||||
@@ -2,7 +2,6 @@ const ParseServerRESTController = require('../lib/ParseServerRESTController')
|
||||
.ParseServerRESTController;
|
||||
const ParseServer = require('../lib/ParseServer').default;
|
||||
const Parse = require('parse/node').Parse;
|
||||
const TestUtils = require('../lib/TestUtils');
|
||||
const semver = require('semver');
|
||||
|
||||
let RESTController;
|
||||
@@ -183,10 +182,6 @@ describe('ParseServerRESTController', () => {
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestUtils.destroyAllDataPermanently(true);
|
||||
});
|
||||
|
||||
it('should handle a batch request with transaction = true', done => {
|
||||
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
||||
myObject
|
||||
|
||||
@@ -19,10 +19,11 @@ const dropTable = (client, className) => {
|
||||
|
||||
describe_only_db('postgres')('PostgresStorageAdapter', () => {
|
||||
let adapter;
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
const config = Config.get('test');
|
||||
adapter = config.database.adapter;
|
||||
return adapter.deleteAllClasses();
|
||||
await adapter.deleteAllClasses();
|
||||
await adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||
});
|
||||
|
||||
it('schemaUpgrade, upgrade the database schema when schema changes', done => {
|
||||
|
||||
@@ -28,6 +28,7 @@ describe('SchemaController', () => {
|
||||
afterEach(async () => {
|
||||
await config.database.schemaCache.clear();
|
||||
await TestUtils.destroyAllDataPermanently(false);
|
||||
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||
});
|
||||
|
||||
it('can validate one object', done => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const batch = require('../lib/batch');
|
||||
const request = require('../lib/request');
|
||||
const TestUtils = require('../lib/TestUtils');
|
||||
const semver = require('semver');
|
||||
|
||||
const originalURL = '/parse/batch';
|
||||
@@ -187,10 +186,6 @@ describe('batch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestUtils.destroyAllDataPermanently(true);
|
||||
});
|
||||
|
||||
it('should handle a batch request with transaction = true', done => {
|
||||
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
||||
myObject
|
||||
|
||||
@@ -167,7 +167,7 @@ const reconfigureServer = changedConfiguration => {
|
||||
const Parse = require('parse/node');
|
||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||
|
||||
beforeEach(done => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
Parse.User.enableUnsafeCurrentUser();
|
||||
} catch (error) {
|
||||
@@ -175,23 +175,10 @@ beforeEach(done => {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
TestUtils.destroyAllDataPermanently(true)
|
||||
.catch(error => {
|
||||
// For tests that connect to their own mongo, there won't be any data to delete.
|
||||
if (error.message === 'ns not found' || error.message.startsWith('connect ECONNREFUSED')) {
|
||||
return;
|
||||
} else {
|
||||
fail(error);
|
||||
return;
|
||||
}
|
||||
})
|
||||
.then(reconfigureServer)
|
||||
.then(() => {
|
||||
Parse.initialize('test', 'test', 'test');
|
||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
await reconfigureServer();
|
||||
|
||||
Parse.initialize('test', 'test', 'test');
|
||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
|
||||
@@ -147,6 +147,7 @@ describe('schemas', () => {
|
||||
afterEach(async () => {
|
||||
await config.database.schemaCache.clear();
|
||||
await TestUtils.destroyAllDataPermanently(false);
|
||||
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||
});
|
||||
|
||||
it('requires the master key to get all schemas', done => {
|
||||
@@ -2816,7 +2817,11 @@ describe('schemas', () => {
|
||||
});
|
||||
|
||||
describe('index management', () => {
|
||||
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
|
||||
beforeEach(async () => {
|
||||
await TestUtils.destroyAllDataPermanently(false);
|
||||
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||
});
|
||||
|
||||
it('cannot create index if field does not exist', done => {
|
||||
request({
|
||||
url: 'http://localhost:8378/1/schemas/NewClass',
|
||||
|
||||
Reference in New Issue
Block a user