Commit Graph
43 Commits
Author SHA1 Message Date
Christophe Simonis 1655202924 [MERGE] forward port branch 11.0 up to 59a8a1cd8e 2018-05-17 13:19:49 +02:00
Xavier Dollé 69714fbeee [FIX] mail: correctly filter needaction on unread notifications in message_format
Previously to this commit needaction used by JS was not taking into account
read notifications. It means notably Inbox counter could be higher than
expected as taking into account read messages while Inbox displays only
unread messages. This commit fixes that by checking notification state when
giving needaction_partner_ids to message_format result.

This fix has a small impact on performances as message_format is used in
notification process for chat or push. A better implementation of message
format and its postprocess could probably lessen this fix impact. As we
target stable version we avoid rewriting other part of the code. Optimization
will be done in development version.

Related to task ID 1841243.
2018-05-16 16:00:06 +02:00
Raphael ColletandThibault Delavallee 4412cb0bf4 [IMP] tests: do not warn about margins and improve logging
* margin have been recently added on some query count tests as currently query
   count is not completely deterministic. Setting a warning is not really
   interesting as it is the current behavior. Being in margin is now green
   and solely provide a different logging message;
 * logged messages are improved to ease grep;

This also reverts aae54ecc15 .

Co-authored-by: Thibault Delavallee <tde@odoo.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2018-05-15 13:29:30 +02:00
Christophe Simonis e70e5b6cf3 [MERGE] forward port branch 11.0 up to 2787de8c68 2018-05-14 16:46:11 +02:00
Christophe Simonis aae54ecc15 [FIX] test_mail: bump expected query count 2018-05-09 14:51:11 +02:00
Thibault Delavallée 81a0852077 [IMP] test_mail: set a margin on some mail-related performance tests
Query count for some mail tests is not always the same for a given test.
This leads notably to runbot being randomly red although there is no real
error. This commit lessen the issue of having red runbot or wrongly
incremented tests by using the recently-introduced margin parameter on
performance tests.

Some work is still ongoing to find why some tests are not completely
reproducible. In the meantime let us have some warnings instead of errors.
2018-04-09 16:52:12 +02:00
Thibault Delavallée 42659dc70c [IMP] test_mail: add performance tests to cover more separate features
In test_mail there are performance tests involving several followers and give
counters for some heavy real-life-like use cases. Purpose of this commit is to
have more basic performance tests for main mail features, like simple post,
simple subscription of one follower. It allows to have an idea of the basic
cost of various features.

Adding use cases for message_post includes
 * posting without followers (aka, no notification)
 * posting with a ping (by email or by inbox)
 * logging a note with optimized method _message_log or with message_post

Adding use cases for activities includes setting an activity as done. This
action posts a message and is therefore interesting to evaluate.

Adding use cases for subscription includes
 * adding and re-adding one follower, with default or specified subtypes
 * updating responsible field triggering a simple tracking and an assignation
   email or notification (not completely supported in saas 11.2 meaning this
   counter will increase when forward-ported)
 * note that some subscription tests have already been added at a01933c9b4

Finally some heavier tests are added for assignation and tracking based
on QWeb view.

This commit is related to task ID 1824965 . This one is an ongoing task
and several commits may be linked to that task.
2018-03-09 12:34:21 +01:00
Thibault Delavallée a01933c9b4 [IMP] test_mail: add unit and performance tests about adding followers
Purpose of this commit is to test existing behavior of followers subscription
as well as adding some query count tests about message_subscribe method. As
followers subscription technical implementation may change in a near future
in order to be optimized it is a good idea to have current behavior and query
count validated.

This commit adds

 * test for followers update using message_subscribe API. Tests are added
   with forced and unforced subtypes to ensure behavior will not change or
   will be changed while knowing it;
 * performance test about message_subscribe, about adding new followers,
   and subscribing already-existing followers in force mode or not;

Query count performance test shows that message_subscribe could probably
be improved. It does several things that require queries (check of access
rights, check for existing subscriptions, ensure customers have no access
to internal subtypes, ...). However we feel it could be improved in order
to speed-up the subscription of followers.

This is linked to task 49265; it is only the first steps of it.
2018-03-01 16:00:36 +01:00
Christophe Simonis 0f02dcb639 [MERGE] forward port branch saas-11.1 up to c69d00157e 2018-02-12 18:08:27 +01:00
Thibault Delavallée 29955b2109 [DOC] test_mail: increment activity counter
Sometimes runbot adds one query. Not sure why, let us avoid having
red runbots.
2018-02-12 13:07:41 +01:00
Christophe Simonis 5f3301e5cb [MERGE] forward port branch 11.0 up to 20e4cd5bcd 2018-02-09 16:13:08 +01:00
Thibault Delavallée d19195de0d [DOC] test_mail: update performance counters after last commits
Commits improving performance counters related to mailing

 * introduction of message_log (https://github.com/odoo/odoo/commit/8ddca6f95a52d36c4a8731dcf93413e8206dce81) and its application in
   the mail_thread (https://github.com/odoo/odoo/commit/99be64dc174af9ad7eb739575215aa03260e833b and https://github.com/odoo/odoo/commit/74ec8a95a0f7b1aadd847a728b4d9bc24daca495). This
   commit has a big impact on the runbot installation query count (110K on 700K, about 15%);
 * moving templates from mail.templates to qweb (https://github.com/odoo/odoo/commit/2f7593761c1ea432e2e58045150150356816f868). This
   merge has an impact on the runbot installation query count (10K on 680K);
 * removing (un)follow buttons in notification emails (https://github.com/odoo/odoo/commit/11d2d30e91758baaa9c6241a86f97ae3dfe52ad2).
   This commit has an impact on the runbot installation query count
   (8K on 690K);
 * removing 'always' tracking option, meaning less tracking values are
   created when writing on a record (https://github.com/odoo/odoo/commit/c99de4551583e801ecc6669ac456c4f7e2eef1da). No impact is given
   as it is mixed with another commit that decreases performances.

Commits decreasing performance counters related to mailing

 * adding the discussion subtype consideration in data send to the bus
   (https://github.com/odoo/odoo/commit/c99de4551583e801ecc6669ac456c4f7e2eef1da). Future improvements will come that improve bus
   management in chatter and channels.

Apart from those commits there are several commits notably from @rco-odoo
that improves performances that are not listed here.
2018-01-31 11:44:22 +01:00
Thibault Delavallée 8ddca6f95a [IMP] mail: introduce _message_log as shortcut when logging notifications
This commit introduces _message_log to use when logging notification-based
notes on a document. Its main purpose is to provide a shortcut to the
complex mechanism of message_post. As it is a lighter code and as it
performs less checks and value computation it allows to clearly gain
queries when logging notes.

It does

 * skip the notification process completely. Side effect is that followers
   following note subtype are not notified of document created and pure
   note tracking. This is considered more as a fix than a feature change.
   Indeed following notes means that followers want to receive notes
   logged by other users. The fact that system notifications without a
   specific subtypes are also notes is a side-effect of the current
   implementation;
 * support only notification-based notes and should not be used currently
   when logging real notes as those could trigger the notification
   process;
 * skip access rights checks as it creates the message as superuser. It
   is therefore defined as a private method and should be called within
   a method where access rights are already granted;

On community runbot installing all 203 modules takes 580K queries instead
of 690 at the time of testing. It is a 15% performance increase based on
the 'all modules installation' metric.

In a distant future message_post and message_log could be merged after
some cleaning but it is easier currently to have this shortcut available.
Moreover as there are clouds on the mail module some developers prefer
to already have some optimization and code cleaning done to avoid
loosing all their hair.

This commit includes a small test. In a same distant future more tests
will probably be added depending on how mail API evolves.
2018-01-30 17:20:45 +01:00
Xavier-Do c99de45515 [IMP] chatter: improve chatter readability
Only messages as comments and email template should keep a white backround since they are not internal.

It is also enough to display fields that changed on subtypes (update message) since emails will be reworked soon and more information will be given there. The support of 'always' track can be removed. (is now considered as a simple tracked field)

The use of self.env.ref('mail.mt_comment').id add some query and the performance tests needs to be update since message_format is called by notify_by_chat. This code will be refactor later
2018-01-30 14:49:03 +01:00
Thibault Delavallée ba5133dc63 [IMP] mail: add two performance tests
This commits adds two tests in test_mail performance tests related to
the write operation. Indeed create a often tested but there are less
performance tests related to the write. Those two tests are

 * first one is a simple write on a chatter-enabled model without any
   tracking or specific feature; nothing should happen when performing
   a write in that kind of model;
 * second one is a write on a complex tracking-enabled model linked to
   templates and auto subscription. It allows to have some figures for
   real world use case.
2018-01-30 14:23:04 +01:00
Thibault Delavallée f408fffbc0 [DOC] test_mail: update performance counters after last commits
Due to last commits that aim at improving Odoo performance all complex
tests of test_mail now take less queries to execute. Counters are
updated to match the current runbot behavior.

There is quite a big improvement when posting using a template compared
to other tests. As there are not enough tests to ensure all results
are correct let us stay careful by saying "it seems there are
improvements".
2018-01-30 10:42:55 +01:00
Raphael Collet 2bfc23030d [FIX] base, test_mail: logger names in tests 2018-01-29 11:08:35 +01:00
Christophe Simonis a98b46b8f5 [MERGE] forward port branch saas-11.1 up to fa1f2132e7 2018-01-22 18:44:05 +01:00
Christophe Simonis fa1f2132e7 [MERGE] forward port branch 11.0 up to 950d9b2369 2018-01-22 17:47:32 +01:00
Xavier-Do 5d04c4c5ee [REV] Miss push
This reverts commit 935e4f6a25.
2018-01-19 11:37:51 +01:00
Xavier-Do 935e4f6a25 Task: [mail] clean chatter.
Remove "always" tracking support
Change greay background logic
2018-01-19 10:06:42 +01:00
Thibault Delavallée d139e92c62 [REF] mail: move message notify and author subscription in after_post hook method
Purpose
 * move notify in message_post instead of always doing it at message
   creation

Specifications
 * message create should only create a message
 * message post should be in charge of calling the notification process
2018-01-11 11:53:58 +01:00
Thibault Delavallée 5c3e0391ac [IMP] test_mail: correctly set aliases when performing tests
In order to really test a production environment we have to ensure
some mail related config parameters are set. This has an impact on
some tests.

Which is strange is that it lessens query number of a test that
already uses those parameters. Maybe XMas spirit.
2018-01-08 17:04:57 +01:00
Christophe Simonis d9436e34f8 [FIX] test_mail: adapt query count
A few more queries are made with enterprise addons.
2018-01-04 12:55:50 +01:00
Christophe Simonis 27c3c34c08 [FIX] test_mail: adapt query count 2018-01-03 17:29:49 +01:00
Christophe Simonis 55b810dc70 [MERGE] forward port branch saas-11.1 up to 726b91b9fb 2018-01-03 14:05:48 +01:00
Christophe Simonis 726b91b9fb [FIX] test_mail: bump query count (bis) 2018-01-03 13:20:28 +01:00
Christophe Simonis de2de75589 [FIX] test_mail: bump query count 2018-01-03 12:58:34 +01:00
Christophe Simonis 362f0489d0 [MERGE] forward port branch 11.0 up to fe22a0f9ca 2018-01-03 12:28:52 +01:00
Thibault Delavallée f3687f7eec [FIX] test_mail: update query counters for enterprise
As on enterprise module install order can be different from community
query count for some mail-related tests are different. This commit
updates some counters to avoid breaking enterprise runbot and give
time to find the source of added queries.
2017-12-19 17:25:36 +01:00
Thibault Delavallée 8655b32bb8 [FIX] mail: fix tracking test with employee, reusing previous record
Query count was wrong as the tracking was not performed.
2017-12-19 15:52:41 +01:00
Christophe Monniez f73098fcba [FIX] test_mail: increment the query counter for employee too
When searching the id mail.mail_activity_data_todo a request is done and
should be taken into account by the assertQueryCount.

This commit does just that... for the employee login.
Thanks to the murphy's law, the test branch was green.
2017-12-18 16:48:48 +01:00
Christophe Monniez 292f53885c [FIX] test_mail: increment query counter
When searching the id mail.mail_activity_data_todo a request is done and
should be taken into account by the assertQueryCount.

This commit does just that.
2017-12-18 16:36:23 +01:00
Thibault Delavallée 9b75577320 [IMP] test_mail: add some mail performance tests
New tests are added in test_mail to have tests for message_post and
complex mail thread features. Purpose is to have performance counters
for more complex stuff in mail and begin to work on performances
and try to lessen those counters.
2017-12-15 16:45:37 +01:00
Thibault Delavallée 0ae15750d4 [IMP] mail: bounce email going directly to catchall when they are no replies 2017-12-15 12:33:23 +01:00
Raphael Collet ba25420312 [REF] tests: decorators and method to count queries (#21499)
Add the context manager method `assertQueryCount` to count queries,
the decorator `@users(...)` to execute a test for several users, and
the decorator `@warmup` to execute a test twice (warm-up, then real).
2017-12-12 15:52:35 +01:00
Thibault Delavallée cde06d5f5c [IMP] test_mail: move some data into demo and update tests accordingly
Creating data directly in tests was done when tests were located in mail
module to avoid creating real data or demo. Now that mail tests have their
own module we can create demo data and use them in tests. It is simpler to
have demo data for things like subtype and email templates to ease
understanding and reuse.
2017-12-12 15:46:37 +01:00
Thibault Delavallée ebc4704b21 [FIX] test_mail: update counters
It seems query count oscillates between 45 and 46. I will have to check
but let us raise it a bit to avoid random red runbots.
2017-12-06 13:12:32 +01:00
Thibault Delavallée 010add2903 [FIX] test_(performance/mail): better use test_performance in test_mail and update counters
Containing

 * fix self._round not always existing;
 * fix counter for activity creation;
 * use self.str() in order to have some variation in test_mail;
 * separate base performance to mail feature specific performance tests;
2017-12-06 11:33:10 +01:00
Christophe Simonis 2f99470458 [MERGE] forward port branch 11.0 up to c201cf2b77 2017-12-01 12:55:02 +01:00
Thibault Delavallée 22cce3be9d [ADD] test_mail: add some performances tests 2017-11-29 10:11:15 +01:00
Thibault Delavallée d040bfde89 [MOV] (test_)mail: move tests into their dedicated module
Purpose: avoid having useless tables for test models in a
production environment.
2017-11-29 10:11:15 +01:00
Thibault Delavallée 1cc1ef5058 [SPLIT] test_performance: split between base and mail performance tests
Test performance will now hold the base class for performance tests as
well as tests related to the ORM, depending only on base. A new module
test_mail is introduced at this commit that contains performance tests
related to mail module. This commit contains only code move and should
not impact anything.

Future commits will move mail tests into test_mail so that all mail
related tests are located in the same optional module. This allows
notably to avoid creating a lot of unnecessary tables when installing
mail module on production databases.
2017-11-29 10:05:01 +01:00