Skip to content

Commit e7199e8

Browse files
authored
test: Investigate flaky tests by turning off tests randomizer (#9181)
1 parent 2ecc5a5 commit e7199e8

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

Diff for: spec/CloudCode.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ describe('Cloud Code', () => {
13621362
});
13631363

13641364
it('should not encode Parse Objects', async () => {
1365+
await reconfigureServer({ encodeParseObjectInCloudFunction: false });
13651366
const user = new Parse.User();
13661367
user.setUsername('username');
13671368
user.setPassword('password');

Diff for: spec/ParseAPI.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ describe('miscellaneous', function () {
12681268
});
12691269

12701270
it('test cloud function query parameters with array of pointers', async () => {
1271+
await reconfigureServer({ encodeParseObjectInCloudFunction: false });
12711272
Parse.Cloud.define('echoParams', req => {
12721273
return req.params;
12731274
});

Diff for: spec/helper.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ const defaultConfiguration = {
113113
directAccess: true,
114114
silent,
115115
logLevel,
116+
liveQuery: {
117+
classNames: ['TestObject'],
118+
},
119+
startLiveQueryServer: true,
116120
fileUpload: {
117121
enableForPublic: true,
118122
enableForAnonymousUser: true,
@@ -134,6 +138,7 @@ const defaultConfiguration = {
134138
shortLivedAuth: mockShortLivedAuth(),
135139
},
136140
allowClientClassCreation: true,
141+
encodeParseObjectInCloudFunction: true,
137142
};
138143

139144
if (silent) {
@@ -162,15 +167,15 @@ const destroyAliveConnections = function () {
162167
}
163168
};
164169
// Set up a default API server for testing with default configuration.
165-
let server;
166-
170+
let parseServer;
167171
let didChangeConfiguration = false;
168172

169173
// Allows testing specific configurations of Parse Server
170174
const reconfigureServer = async (changedConfiguration = {}) => {
171-
if (server) {
172-
await new Promise(resolve => server.close(resolve));
173-
server = undefined;
175+
if (parseServer) {
176+
destroyAliveConnections();
177+
await new Promise(resolve => parseServer.server.close(resolve));
178+
parseServer = undefined;
174179
return reconfigureServer(changedConfiguration);
175180
}
176181
didChangeConfiguration = Object.keys(changedConfiguration).length !== 0;
@@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => {
179184
port,
180185
});
181186
cache.clear();
182-
const parseServer = await ParseServer.startApp(newConfiguration);
183-
server = parseServer.server;
187+
parseServer = await ParseServer.startApp(newConfiguration);
184188
Parse.CoreManager.setRESTController(RESTController);
185189
parseServer.expressApp.use('/1', err => {
186190
console.error(err);
187191
fail('should not call next');
188192
});
189-
server.on('connection', connection => {
193+
parseServer.liveQueryServer?.server?.on('connection', connection => {
194+
const key = `${connection.remoteAddress}:${connection.remotePort}`;
195+
openConnections[key] = connection;
196+
connection.on('close', () => {
197+
delete openConnections[key];
198+
});
199+
});
200+
parseServer.server.on('connection', connection => {
190201
const key = `${connection.remoteAddress}:${connection.remotePort}`;
191202
openConnections[key] = connection;
192203
connection.on('close', () => {
@@ -214,16 +225,12 @@ beforeAll(async () => {
214225
Parse.serverURL = 'http://localhost:' + port + '/1';
215226
});
216227

217-
beforeEach(() => {
218-
jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000;
219-
});
220-
221228
afterEach(function (done) {
222229
const afterLogOut = async () => {
223-
if (Object.keys(openConnections).length > 0) {
224-
console.warn('There were open connections to the server left after the test finished');
230+
// Jasmine process uses one connection
231+
if (Object.keys(openConnections).length > 1) {
232+
console.warn(`There were ${Object.keys(openConnections).length} open connections to the server left after the test finished`);
225233
}
226-
destroyAliveConnections();
227234
await TestUtils.destroyAllDataPermanently(true);
228235
SchemaCache.clear();
229236
if (didChangeConfiguration) {

Diff for: spec/support/jasmine.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"spec_dir": "spec",
33
"spec_files": ["*spec.js"],
44
"helpers": ["helper.js"],
5-
"random": true
5+
"random": false
66
}

0 commit comments

Comments
 (0)