Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Find duplicate and slow tests #9188

Merged
merged 23 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dd37911
test: Find duplicate specs and analyze slow tests
dplewis Jul 8, 2024
311b20c
Merge branch 'alpha' into display-slow-tests
dplewis Jul 9, 2024
a77d341
remove timeout
dplewis Jul 9, 2024
f471e95
output duplicates
dplewis Jul 9, 2024
e6e6841
more duplicate tests
dplewis Jul 9, 2024
72312ca
Merge branch 'alpha' into display-slow-tests
dplewis Jul 9, 2024
80b3529
Merge branch 'alpha' into display-slow-tests
mtrezza Jul 9, 2024
4a1f227
Update spec/support/CurrentSpecReporter.js
mtrezza Jul 9, 2024
220b6a5
Update spec/support/CurrentSpecReporter.js
mtrezza Jul 9, 2024
af66be7
Update spec/support/CurrentSpecReporter.js
mtrezza Jul 9, 2024
702608f
Update spec/support/CurrentSpecReporter.js
mtrezza Jul 9, 2024
be72594
Update spec/support/CurrentSpecReporter.js
mtrezza Jul 9, 2024
a93cb3e
Update CurrentSpecReporter.js
mtrezza Jul 9, 2024
d7f1a29
Merge branch 'alpha' into display-slow-tests
mtrezza Jul 9, 2024
291c8cb
Update CurrentSpecReporter.js
mtrezza Jul 9, 2024
6cc001e
Merge branch 'alpha' into display-slow-tests
mtrezza Jul 9, 2024
c13517e
Merge branch 'alpha' into display-slow-tests
mtrezza Jul 9, 2024
6504b26
remove duplicate tests
dplewis Jul 9, 2024
4cbf09f
remove more duplicate tests
dplewis Jul 9, 2024
2a3ddbe
reduce execution time to 1 second
dplewis Jul 9, 2024
6ab4d85
change back 2 seconds limit was curious about 1 second
dplewis Jul 9, 2024
04c95e5
revert DB specific tests
dplewis Jul 9, 2024
756d110
Merge branch 'alpha' into display-slow-tests
mtrezza Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .nvmrc
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
10.14.2

20.15.0
23 changes: 1 addition & 22 deletions spec/CloudCode.Validator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,6 @@ describe('cloud validator', () => {
});
});

it('set params on cloud functions', done => {
Parse.Cloud.define(
'hello',
() => {
return 'Hello world!';
},
{
fields: ['a'],
}
);
Parse.Cloud.run('hello', {})
.then(() => {
fail('function should have failed.');
})
.catch(error => {
expect(error.code).toEqual(Parse.Error.VALIDATION_ERROR);
expect(error.message).toEqual('Validation failed. Please specify data for a.');
done();
});
});

it('allow params on cloud functions', done => {
Parse.Cloud.define(
'hello',
Expand Down Expand Up @@ -1629,7 +1608,7 @@ describe('cloud validator', () => {
}
});

it('Logs on invalid config', () => {
it('Logs on multiple invalid configs', () => {
const fields = [
{
field: 'otherKey',
Expand Down
1 change: 1 addition & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Cloud Code', () => {
});

it('cloud code must be valid type', async () => {
spyOn(console, 'error').and.callFake(() => {});
await expectAsync(reconfigureServer({ cloud: true })).toBeRejectedWith(
"argument 'cloud' must either be a string or a function"
);
Expand Down
24 changes: 0 additions & 24 deletions spec/ParseFile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,30 +842,6 @@ describe('Parse.File testing', () => {
expect(file.headers['content-range']).toBe('bytes 0-1212/1212');
});

it('supports bytes range if end is greater than size', async () => {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest',
};
const response = await request({
method: 'POST',
headers: headers,
url: 'http://localhost:8378/1//files/file.txt ',
body: repeat('argle bargle', 100),
});
const b = response.data;
const file = await request({
url: b.url,
headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
Range: 'bytes=0-2000',
},
}).catch(e => e);
expect(file.headers['content-range']).toBe('bytes 0-1212/1212');
});

it('supports bytes range with 0 length', async () => {
const headers = {
'Content-Type': 'application/octet-stream',
Expand Down
1 change: 0 additions & 1 deletion spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ describe('ParseLiveQuery', function () {
await obj2.save();
obj2.set('foo', 'bart');
await obj2.save();
await sleep(2000);
expect(createSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
});
Expand Down
29 changes: 0 additions & 29 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,35 +1633,6 @@ describe('ParseLiveQueryServer', function () {
});
});

it('matches CLP when find is restricted to userIds', done => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
const acl = new Parse.ACL();
acl.setReadAccess(testUserId, true);
// Mock sessionTokenCache will return false when sessionToken is undefined
const client = {
sessionToken: 'sessionToken',
getSubscriptionInfo: jasmine.createSpy('getSubscriptionInfo').and.returnValue({
sessionToken: 'userId',
}),
};
const requestId = 0;

parseLiveQueryServer
._matchesCLP(
{
find: { userId: true },
},
{ className: 'Yolo' },
client,
requestId,
'find'
)
.then(isMatched => {
expect(isMatched).toBe(true);
done();
});
});

it('matches CLP when find is restricted to userIds', done => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
const acl = new Parse.ACL();
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseQuery.Aggregate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe('Parse.Query Aggregate testing', () => {
});

it_exclude_dbs(['postgres'])(
'can group by any date field (it does not work if you have dirty data)', // rows in your collection with non date data in the field that is supposed to be a date
'can group by any date field (it does not work if you have dirty data) (Mongo)', // rows in your collection with non date data in the field that is supposed to be a date
done => {
const obj1 = new TestObject({ dateField2019: new Date(1990, 11, 1) });
const obj2 = new TestObject({ dateField2019: new Date(1990, 5, 1) });
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('Parse.Query Aggregate testing', () => {
);

it_only_db('postgres')(
'can group by any date field (it does not work if you have dirty data)', // rows in your collection with non date data in the field that is supposed to be a date
'can group by any date field (it does not work if you have dirty data) (Postgres)', // rows in your collection with non date data in the field that is supposed to be a date
done => {
const obj1 = new TestObject({ dateField2019: new Date(1990, 11, 1) });
const obj2 = new TestObject({ dateField2019: new Date(1990, 5, 1) });
Expand Down
32 changes: 16 additions & 16 deletions spec/ParseQuery.hint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
await TestUtils.destroyAllDataPermanently(false);
});

it_only_mongodb_version('<5.1>=6')('query find with hint string', async () => {
it_only_mongodb_version('<5.1>=6')('query find with hint string (Mongo <5.1>=6)', async () => {
const object = new TestObject();
await object.save();

Expand All @@ -39,7 +39,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.1<6')('query find with hint string', async () => {
it_only_mongodb_version('>=5.1<6')('query find with hint string (Mongo >=5.1<6)', async () => {
const object = new TestObject();
await object.save();

Expand Down Expand Up @@ -78,7 +78,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('<4.4')('query aggregate with hint string', async () => {
it_only_mongodb_version('<4.4')('query aggregate with hint string (Mongo <4.4)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -100,7 +100,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint string', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint string (Mongo >=4.4<5.1)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -124,7 +124,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint string', async () => {
it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint string (Mongo >=5.1<5.2)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -148,7 +148,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.2')('query aggregate with hint string', async () => {
it_only_mongodb_version('>=5.2')('query aggregate with hint string (Mongo >=5.2)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -172,7 +172,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('<4.4')('query aggregate with hint object', async () => {
it_only_mongodb_version('<4.4')('query aggregate with hint object (Mongo <4.4)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -192,7 +192,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint object', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint object (Mongo >=4.4<5.1)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -217,7 +217,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint object', async () => {
it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint object (Mongo >=5.1<5.2)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -242,7 +242,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=5.2')('query aggregate with hint object', async () => {
it_only_mongodb_version('>=5.2')('query aggregate with hint object (Mongo >=5.2)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -267,7 +267,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('<5.1>=6')('query find with hint (rest)', async () => {
it_only_mongodb_version('<5.1>=6')('query find with hint (rest) (Mongo <5.1>=6)', async () => {
const object = new TestObject();
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand All @@ -292,7 +292,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.1<6')('query find with hint (rest)', async () => {
it_only_mongodb_version('>=5.1<6')('query find with hint (rest) (Mongo >=5.1<6)', async () => {
const object = new TestObject();
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand All @@ -317,7 +317,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('<4.4')('query aggregate with hint (rest)', async () => {
it_only_mongodb_version('<4.4')('query aggregate with hint (rest) (Mongo <4.4)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand All @@ -344,7 +344,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint (rest)', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint (rest) (Mongo >=4.4<5.1)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand Down Expand Up @@ -377,7 +377,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint (rest)', async () => {
it_only_mongodb_version('>=5.1<5.2')('query aggregate with hint (rest) (Mongo >=5.1<5.2)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand Down Expand Up @@ -410,7 +410,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=5.2')('query aggregate with hint (rest)', async () => {
it_only_mongodb_version('>=5.2')('query aggregate with hint (rest) (Mongo >=5.2)', async () => {
dplewis marked this conversation as resolved.
Show resolved Hide resolved
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand Down
2 changes: 1 addition & 1 deletion spec/PostgresStorageAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ describe_only_db('postgres')('PostgresStorageAdapter', () => {
await dropTable(client, tableName);
});

it('should use index for caseInsensitive query', async () => {
it('should use index for caseInsensitive query with user', async () => {
await adapter.deleteAllClasses();
const config = Config.get('test');
config.schemaCache.clear();
Expand Down
2 changes: 1 addition & 1 deletion spec/PushWorker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('PushWorker', () => {
});
});

it('transforms body appropriately', () => {
it('transforms body appropriately with title locale', () => {
const cleanBody = PushUtils.transformPushBodyForLocale(
{
data: {
Expand Down
4 changes: 4 additions & 0 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ afterEach(function (done) {
.then(afterLogOut);
});

afterAll(() => {
global.displaySlowTests();
});

const TestObject = Parse.Object.extend({
className: 'TestObject',
});
Expand Down
33 changes: 31 additions & 2 deletions spec/support/CurrentSpecReporter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
// Sets a global variable to the current test spec
// ex: global.currentSpec.description

const { performance } = require('perf_hooks');
global.currentSpec = null;

const timerMap = {};
const duplicates = [];

mtrezza marked this conversation as resolved.
Show resolved Hide resolved
class CurrentSpecReporter {
specStarted(spec) {
if (timerMap[spec.fullName]) {
console.log('Duplicate spec: ' + spec.fullName);
duplicates.push(spec.fullName);
}
timerMap[spec.fullName] = performance.now();
global.currentSpec = spec;
}
specDone() {
specDone(result) {
if (result.status === 'excluded') {
delete timerMap[result.fullName];
return;
}
timerMap[result.fullName] = (performance.now() - timerMap[result.fullName]) / 1000;
global.currentSpec = null;
}
}
global.displaySlowTests = function() {
const times = Object.values(timerMap).sort((a,b) => b - a);
if (times.length > 0) {
console.log('Showing slowest tests:');
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
}
times.forEach((time) => {
// Show test taking longer than 2 second
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
if (time > 2) {
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
console.warn(Object.keys(timerMap).find(key => timerMap[key] === time), `${time.toFixed(3)}s`);
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
}
});
console.log('\n');
duplicates.forEach((spec) => {
console.warn('Duplicate spec: ' + spec);
});
};

module.exports = CurrentSpecReporter;
Loading