test: Investigate flaky tests by turning off tests randomizer (#9181)
This commit is contained in:
@@ -113,6 +113,10 @@ const defaultConfiguration = {
|
||||
directAccess: true,
|
||||
silent,
|
||||
logLevel,
|
||||
liveQuery: {
|
||||
classNames: ['TestObject'],
|
||||
},
|
||||
startLiveQueryServer: true,
|
||||
fileUpload: {
|
||||
enableForPublic: true,
|
||||
enableForAnonymousUser: true,
|
||||
@@ -134,6 +138,7 @@ const defaultConfiguration = {
|
||||
shortLivedAuth: mockShortLivedAuth(),
|
||||
},
|
||||
allowClientClassCreation: true,
|
||||
encodeParseObjectInCloudFunction: true,
|
||||
};
|
||||
|
||||
if (silent) {
|
||||
@@ -162,15 +167,15 @@ const destroyAliveConnections = function () {
|
||||
}
|
||||
};
|
||||
// Set up a default API server for testing with default configuration.
|
||||
let server;
|
||||
|
||||
let parseServer;
|
||||
let didChangeConfiguration = false;
|
||||
|
||||
// Allows testing specific configurations of Parse Server
|
||||
const reconfigureServer = async (changedConfiguration = {}) => {
|
||||
if (server) {
|
||||
await new Promise(resolve => server.close(resolve));
|
||||
server = undefined;
|
||||
if (parseServer) {
|
||||
destroyAliveConnections();
|
||||
await new Promise(resolve => parseServer.server.close(resolve));
|
||||
parseServer = undefined;
|
||||
return reconfigureServer(changedConfiguration);
|
||||
}
|
||||
didChangeConfiguration = Object.keys(changedConfiguration).length !== 0;
|
||||
@@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => {
|
||||
port,
|
||||
});
|
||||
cache.clear();
|
||||
const parseServer = await ParseServer.startApp(newConfiguration);
|
||||
server = parseServer.server;
|
||||
parseServer = await ParseServer.startApp(newConfiguration);
|
||||
Parse.CoreManager.setRESTController(RESTController);
|
||||
parseServer.expressApp.use('/1', err => {
|
||||
console.error(err);
|
||||
fail('should not call next');
|
||||
});
|
||||
server.on('connection', connection => {
|
||||
parseServer.liveQueryServer?.server?.on('connection', connection => {
|
||||
const key = `${connection.remoteAddress}:${connection.remotePort}`;
|
||||
openConnections[key] = connection;
|
||||
connection.on('close', () => {
|
||||
delete openConnections[key];
|
||||
});
|
||||
});
|
||||
parseServer.server.on('connection', connection => {
|
||||
const key = `${connection.remoteAddress}:${connection.remotePort}`;
|
||||
openConnections[key] = connection;
|
||||
connection.on('close', () => {
|
||||
@@ -214,16 +225,12 @@ beforeAll(async () => {
|
||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000;
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
const afterLogOut = async () => {
|
||||
if (Object.keys(openConnections).length > 0) {
|
||||
console.warn('There were open connections to the server left after the test finished');
|
||||
// Jasmine process uses one connection
|
||||
if (Object.keys(openConnections).length > 1) {
|
||||
console.warn(`There were ${Object.keys(openConnections).length} open connections to the server left after the test finished`);
|
||||
}
|
||||
destroyAliveConnections();
|
||||
await TestUtils.destroyAllDataPermanently(true);
|
||||
SchemaCache.clear();
|
||||
if (didChangeConfiguration) {
|
||||
|
||||
Reference in New Issue
Block a user