From d978b9e1c0f8e4a66de1b4ececbb97f77a1718d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 May 2021 13:36:52 +0000 Subject: [PATCH] [IMP] various: update query counters according to latest runbot run Base: seems related fields take only 1 extra query instead of 3 Crm: assignment seems to have been slightly improved. Some randomness still happens. Hr Holidays: seems it was further improved beyond space frontier Hr Work Entry Holidays: seems it was further improved Test mail: those tests were a bit random, seems random is gone (hopefully) Test mail full: updated local counters Test mass mailing: seems we gained one query, updated local counters closes odoo/odoo#70504 X-original-commit: 8c215b3d60929166b3e60e2a4dfb2a6c70439046 Related: odoo/enterprise#18194 Signed-off-by: Thibault Delavallee (tde) --- addons/crm/tests/test_crm_lead_convert_mass.py | 8 ++++---- addons/crm/tests/test_performances.py | 4 ++-- .../hr_work_entry_holidays/tests/test_performance.py | 10 +++++----- addons/test_mail/tests/test_performance.py | 1 - addons/test_mail_full/tests/test_sms_performance.py | 6 +++--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/addons/crm/tests/test_crm_lead_convert_mass.py b/addons/crm/tests/test_crm_lead_convert_mass.py index 9e379ac3d8c..89821f8f37c 100644 --- a/addons/crm/tests/test_crm_lead_convert_mass.py +++ b/addons/crm/tests/test_crm_lead_convert_mass.py @@ -5,7 +5,7 @@ from odoo.addons.crm.tests import common as crm_common from odoo.tests.common import tagged, users -@tagged('lead_manage') +@tagged('lead_manage', 'crm_performance') class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon): @classmethod @@ -24,7 +24,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon): with self.assertQueryCount(user_sales_manager=0): test_leads = self.env['crm.lead'].browse(test_leads.ids) - with self.assertQueryCount(user_sales_manager=255): # crm only: 252 + with self.assertQueryCount(user_sales_manager=252): test_leads._handle_salesmen_assignment(user_ids=user_ids, team_id=False) self.assertEqual(test_leads.team_id, self.sales_team_convert | self.sales_team_1) @@ -42,7 +42,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon): with self.assertQueryCount(user_sales_manager=0): test_leads = self.env['crm.lead'].browse(test_leads.ids) - with self.assertQueryCount(user_sales_manager=223): # crm only: 218 + with self.assertQueryCount(user_sales_manager=220): # still some randomness (220 spotted) - crm only: 218 test_leads._handle_salesmen_assignment(user_ids=user_ids, team_id=team_id) self.assertEqual(test_leads.team_id, self.sales_team_convert) @@ -166,7 +166,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon): test_leads = self._create_leads_batch(count=50, user_ids=[False]) user_ids = self.assign_users.ids - with self.assertQueryCount(user_sales_manager=1367): # crm only: 1357 + with self.assertQueryCount(user_sales_manager=1367): # still some randomness (1366 spotted) - crm only: 1357 mass_convert = self.env['crm.lead2opportunity.partner.mass'].with_context({ 'active_model': 'crm.lead', 'active_ids': test_leads.ids, diff --git a/addons/crm/tests/test_performances.py b/addons/crm/tests/test_performances.py index aa102588823..25a82e31f30 100644 --- a/addons/crm/tests/test_performances.py +++ b/addons/crm/tests/test_performances.py @@ -8,7 +8,7 @@ from odoo.tests.common import tagged from odoo.tools import mute_logger -@tagged('lead_assign', '-standard') +@tagged('lead_assign', 'crm_performance', '-standard') class TestLeadAssignPerf(TestLeadAssignCommon): """ Test performances of lead assignment feature added in saas-14.2 @@ -174,7 +174,7 @@ class TestLeadAssignPerf(TestLeadAssignCommon): lead.probability = (idx + 1) * 10 * ((int(lead.priority) + 1) / 2) with self.with_user('user_sales_manager'): - with self.assertQueryCount(user_sales_manager=6250): # crm only: 6237 + with self.assertQueryCount(user_sales_manager=6290): # crm only: 6287 self.env['crm.team'].browse(sales_teams.ids)._action_assign_leads(work_days=30) self.members.invalidate_cache(fnames=['lead_month_count']) diff --git a/addons/hr_work_entry_holidays/tests/test_performance.py b/addons/hr_work_entry_holidays/tests/test_performance.py index e9dc9d2a23c..b633da312d9 100644 --- a/addons/hr_work_entry_holidays/tests/test_performance.py +++ b/addons/hr_work_entry_holidays/tests/test_performance.py @@ -31,7 +31,7 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase): self.richard_emp.generate_work_entries(date(2018, 1, 1), date(2018, 1, 2)) leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0)) - with self.assertQueryCount(__system__=94, admin=99): + with self.assertQueryCount(__system__=94, admin=95): leave.action_validate() leave.action_refuse() @@ -40,14 +40,14 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase): def test_performance_leave_write(self): leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0)) - with self.assertQueryCount(__system__=24, admin=24): + with self.assertQueryCount(__system__=20, admin=20): leave.date_to = datetime(2018, 1, 1, 19, 0) leave.action_refuse() @users('__system__', 'admin') @warmup def test_performance_leave_create(self): - with self.assertQueryCount(__system__=28, admin=59): + with self.assertQueryCount(__system__=22, admin=23): leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0)) leave.action_refuse() @@ -56,7 +56,7 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase): def test_performance_leave_confirm(self): leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0)) leave.action_draft() - with self.assertQueryCount(__system__=22, admin=55): + with self.assertQueryCount(__system__=20, admin=21): leave.action_confirm() leave.state = 'cancel' @@ -108,7 +108,7 @@ class TestWorkEntryHolidaysPerformancesBigData(TestWorkEntryHolidaysBase): def test_work_entries_generation_perf(self): # Test Case 7: Try to generate work entries for # a hundred employees over a month - with self.assertQueryCount(__system__=11522, admin=11522): + with self.assertQueryCount(__system__=11319, admin=11522): work_entries = self.contracts._generate_work_entries(date(2020, 7, 1), date(2020, 8, 31)) # Original work entries to generate when we don't adapt date_generated_from and diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index 3d63925f5db..884eda1845f 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -302,7 +302,6 @@ class TestMailAPIPerformance(BaseMailPerformance): self._create_test_records() test_record = self.env['mail.test.ticket'].browse(self.test_record_full.id) test_template = self.env['mail.template'].browse(self.test_template_full.id) - # TODO FIXME non deterministic, last check 25 Mar 2020. Runbot at most +7 compared to local. with self.assertQueryCount(__system__=11, emp=12): composer = self.env['mail.compose.message'].with_context({ 'default_composition_mode': 'comment', diff --git a/addons/test_mail_full/tests/test_sms_performance.py b/addons/test_mail_full/tests/test_sms_performance.py index 58a1d245e09..cfa30321987 100644 --- a/addons/test_mail_full/tests/test_sms_performance.py +++ b/addons/test_mail_full/tests/test_sms_performance.py @@ -51,7 +51,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase): def test_message_sms_record_1_partner(self): record = self.test_record.with_user(self.env.user) pids = self.customer.ids - with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=23): # test_mail_enterprise: 25 + with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=23): # test_mail_enterprise: 18 messages = record._message_sms( body='Performance Test', partner_ids=pids, @@ -66,7 +66,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase): def test_message_sms_record_10_partners(self): record = self.test_record.with_user(self.env.user) pids = self.partners.ids - with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=41): # test_mail_enterprise: 43 + with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=41): messages = record._message_sms( body='Performance Test', partner_ids=pids, @@ -80,7 +80,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase): @warmup def test_message_sms_record_default(self): record = self.test_record.with_user(self.env.user) - with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=26): # test_mail_enterprise: 28 + with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=26): messages = record._message_sms( body='Performance Test', )