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

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Jul 9, 2024

Pull Request

Issue

With over 3000+ tests and counting, over the years the repository has gone from 15+ minutes of CI time down to under 6 minutes with community efforts #7262. I had the idea years ago to find slow tests and duplicate tests with the same name and functionality using a custom Jasmine Spec Reporter.

This can also help find bottlenecks in performance or tests improvements for instance
This takes 3 seconds and I don't know why maybe it's internal or a Jasmine best practice thats missing.

it('polygon loop is not valid', done => {
    const coords = [
      [0, 0],
      [0, 1],
      [1, 0],
      [1, 1],
    ];
    const obj = new TestObject();
    obj.set('polygon', new Parse.Polygon(coords));
    obj.save().then(done.fail, () => done());
});

Optimizing tests as they are created is the goal.

Approach

  • Remove duplicate tests
  • Remove unnecessary setTimeout
  • Cleanup console warnings
  • Display tests taking longer that 2 seconds
  • Saves ~10 seconds
  • Rename test with same name but different functionality
  • I left it('supports bytes range if start and end undefined) just to make sure it displays in CI

Sub 5 minutes

Executed 3087 of 3173 specs INCOMPLETE (86 PENDING) in 4 mins 50 secs. 

Copy link

parse-github-assistant bot commented Jul 9, 2024

Thanks for opening this pull request!

  • ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as Closes: #123 in the PR description, so I can recognize it.

@dplewis dplewis requested review from mtrezza and a team July 9, 2024 00:38
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.14%. Comparing base (872b9eb) to head (756d110).
Report is 51 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9188      +/-   ##
==========================================
- Coverage   94.16%   94.14%   -0.02%     
==========================================
  Files         186      186              
  Lines       14751    14751              
==========================================
- Hits        13890    13888       -2     
- Misses        861      863       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtrezza
Copy link
Member

mtrezza commented Jul 9, 2024

It still logs duplicate tests:

Duplicate spec: Auth should load auth without a config
Duplicate spec: Auth should load auth with a config
Duplicate spec: AuthenticationProviders should throw error when Facebook request appId is wrong data type
Duplicate spec: apple signin auth adapter (using client id as string) should throw error with with invalid jwt issuer
Duplicate spec: facebook limited auth adapter (using client id as string) should throw error with with invalid jwt issuer
Duplicate spec: Auth Adapter features should throw if no triggers found
Duplicate spec: InstallationsRouter query installations with count = 1
Duplicate spec: MongoStorageAdapter should use index for caseInsensitive query
Duplicate spec: Parse.File testing Gridstore Range supports bytes range if start and end undefined
Duplicate spec: Parse.Query hint query find with hint object

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor log improvements

spec/support/CurrentSpecReporter.js Show resolved Hide resolved
spec/support/CurrentSpecReporter.js Outdated Show resolved Hide resolved
spec/support/CurrentSpecReporter.js Outdated Show resolved Hide resolved
spec/support/CurrentSpecReporter.js Outdated Show resolved Hide resolved
mtrezza added 4 commits July 9, 2024 13:13
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
mtrezza added 2 commits July 9, 2024 13:13
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
.nvmrc Outdated Show resolved Hide resolved
@mtrezza mtrezza changed the title test: Find duplicate specs and analyze slow tests ci: Find duplicate specs and analyze slow tests Jul 9, 2024
@mtrezza mtrezza changed the title ci: Find duplicate specs and analyze slow tests test: Find duplicate specs and analyze slow tests Jul 9, 2024
@mtrezza mtrezza changed the title test: Find duplicate specs and analyze slow tests test: Find duplicate tests and slow tests Jul 9, 2024
@mtrezza mtrezza changed the title test: Find duplicate tests and slow tests test: Find duplicate and slow tests Jul 9, 2024
@mtrezza mtrezza changed the title test: Find duplicate and slow tests ci: Find duplicate and slow tests Jul 9, 2024
@dplewis
Copy link
Member Author

dplewis commented Jul 9, 2024

@mtrezza I removed all the dups, looks like there around 75 tests that take longer than a 1000ms.

This is ready for review.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clean-up and optimization done with this PR is great. But the changes in the test names can be problematic going forward.

I understand that a test needs a unique ID to reference the test. But this also means the title suddenly is not just a test description but has a function that influences this logic. It requires manual data duplication, i.e. add the DB name and version to the text, even though this is defined in the test methods used.

Maintenance: If there are duplicate tests, the CI passes, if I'm not mistaken. That means neither contributors nor reviewers can consider the result of this check. In the end, we'll accumulate test duplicates until someone looks at the logs and cleans it up.

Review effort: This adds an additional review step to verify that the test title includes the methods that are used for the test, DB type and version.

Error prone: New tests are often created by copy/paste/modify. When changing the method, the text description now also has to adapt accordingly, including any specified DB and version. If a test description includes an incorrect MongoDB version, the failing test's title in the logs is misleading.

I'm thinking about how this could be addressed...

Worst case, we throw out the test duplication detection until we found a solution and keep the - I believe by itself already very valuable - execution time analysis.

We may be able to uniquely identify a test by its name, file and code line number without relying on a unique test description. We are also introducing test IDs for the external Oracle DB adapter. A solution could be to add IDs to all tests, with VSC and regex scripting maybe not much of an effort.

@dplewis
Copy link
Member Author

dplewis commented Jul 10, 2024

@mtrezza I reverted the DB specific duplicate tests. They can be handled in a separate PR.

@mtrezza mtrezza merged commit e355f36 into parse-community:alpha Jul 16, 2024
26 of 27 checks passed
@dplewis dplewis deleted the display-slow-tests branch July 16, 2024 11:32
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jul 17, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Oct 3, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants