Closed Bug 1674159 Opened 4 years ago Closed 4 years ago

Fix slow test in the Terminology app

Categories

(Webtools Graveyard :: Pontoon, defect, P2)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mathjazz, Assigned: mail)

Details

The tests in the Terminology app are executing very slowly. We should investigate why and fix their performance.

Here's what I have found out so far. Some tests create several terms, with each creation taking about 3 seconds. This is due to update_terminology_project_stats() being called whenever a new Term is created in the terminology. It's understandably slow because the stats for every related TranslatedResource, Locale and ProjectLocale have to be recalculated/aggregated.
There are several ways to solve this:

  • Change the tests to use fewer terms. I don't really like this, since we shouldn't need to adjust the tests for slow code.
  • Skip/mock the stat updates in the corresponding slow tests.
  • Introduce functions for bulk-creating new terms. This would only help the tests, and not really Pontoon itself.
  • Make the stat calculation/aggregation faster. This is the cleanest solution, but also the hardest.

#2 sounds like the way to go.

We already do something similar:
https://github.com/mozilla/pontoon/blob/master/pontoon/base/models.py#L3135

Assignee: nobody → pfischbeck
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.