[UPD] various: update query counters according to runbot state

Seems various flows are positively impacted by recent changes.

closes odoo/odoo#87899

Related: odoo/enterprise#25873
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Thibault Delavallée
2022-04-04 17:48:46 +02:00
parent 848e8d7ee4
commit bc6c87f19d
8 changed files with 39 additions and 39 deletions
@@ -323,7 +323,7 @@ class TestCompanyLeave(TransactionCase):
})
company_leave._compute_date_from_to()
with self.assertQueryCount(__system__=250, admin=865): # 247 community
with self.assertQueryCount(__system__=250, admin=865): # 249 community
# Original query count: 1987
# Without tracking/activity context keys: 5154
company_leave.action_validate()
+4 -4
View File
@@ -38,7 +38,7 @@ class TestPERF(common.TransactionCase):
@users('admin')
@warmup
def test_empty_sale_order_creation_perf(self):
with self.assertQueryCount(admin=34):
with self.assertQueryCount(admin=33):
self.env['sale.order'].create({
'partner_id': self.partners[0].id,
'user_id': self.salesmans[0].id,
@@ -48,7 +48,7 @@ class TestPERF(common.TransactionCase):
@warmup
def test_empty_sales_orders_batch_creation_perf(self):
# 1 SO insert, 2 SOL insert, 1 SO sequence fetch, 1 warehouse fetch, 3 followers queries ?
with self.assertQueryCount(admin=38):
with self.assertQueryCount(admin=37):
self.env['sale.order'].create([{
'partner_id': self.partners[0].id,
'user_id': self.salesmans[0].id,
@@ -59,7 +59,7 @@ class TestPERF(common.TransactionCase):
def test_dummy_sales_orders_batch_creation_perf(self):
""" Dummy SOlines (notes/sections) should not add any custom queries other than their insert"""
# + 4 SOL insert
with self.assertQueryCount(admin=40):
with self.assertQueryCount(admin=39):
self.env['sale.order'].create([{
'partner_id': self.partners[0].id,
'user_id': self.salesmans[0].id,
@@ -73,7 +73,7 @@ class TestPERF(common.TransactionCase):
@warmup
def test_light_sales_orders_batch_creation_perf_without_taxes(self):
self.products[0].taxes_id = [Command.set([])]
with self.assertQueryCount(admin=51):
with self.assertQueryCount(admin=48):
self.env['sale.order'].create([{
'partner_id': self.partners[0].id,
'user_id': self.salesmans[0].id,
@@ -42,7 +42,7 @@ class TestCrmPerformance(CrmPerformanceCase):
country_be = self.env.ref('base.be')
lang_be_id = self.env['res.lang']._lang_get_id('fr_BE')
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=244): # 236, sometimes +6
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=243): # 235, sometimes +6
self.env.cr._now = self.reference_now # force create_date to check schedulers
crm_values = [
{'country_id': country_be.id,
@@ -70,7 +70,7 @@ class TestCrmPerformance(CrmPerformanceCase):
country_be = self.env.ref('base.be')
lang_be = self.env['res.lang']._lang_get('fr_BE')
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=190): # tcf only: 175 - com runbot: 176/177
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=188): # tcf only: 175 - com runbot: 175
self.env.cr._now = self.reference_now # force create_date to check schedulers
with Form(self.env['crm.lead']) as lead_form:
lead_form.country_id = country_be
@@ -89,7 +89,7 @@ class TestCrmPerformance(CrmPerformanceCase):
@warmup
def test_lead_create_form_partner(self):
""" Test a single lead creation using Form with a partner """
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=195): # tcf only: 180 - com runbot: 181/182
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=193): # tcf only: 180 - com runbot: 180
self.env.cr._now = self.reference_now # force create_date to check schedulers
with Form(self.env['crm.lead']) as lead_form:
lead_form.partner_id = self.partners[0]
@@ -104,7 +104,7 @@ class TestCrmPerformance(CrmPerformanceCase):
country_be = self.env.ref('base.be')
lang_be_id = self.env['res.lang']._lang_get_id('fr_BE')
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=42): # tcf only: 41 - com runbot: 42
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=41):
self.env.cr._now = self.reference_now # force create_date to check schedulers
crm_values = [
{'country_id': country_be.id,
@@ -124,7 +124,7 @@ class TestCrmPerformance(CrmPerformanceCase):
@warmup
def test_lead_create_single_partner(self):
""" Test multiple lead creation (import) """
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=48): # tcf only: 47 - com runbot: 48
with freeze_time(self.reference_now), self.assertQueryCount(user_sales_leads=47):
self.env.cr._now = self.reference_now # force create_date to check schedulers
crm_values = [
{'partner_id': self.partners[0].id,
@@ -99,7 +99,7 @@ class TestDiscussFullPerformance(TransactionCase):
self.maxDiff = None
self.users[0].flush()
self.users[0].invalidate_cache()
with self.assertQueryCount(emp=86):
with self.assertQueryCount(emp=85): # 84 ent
init_messaging = self.users[0].with_user(self.users[0])._init_messaging()
self.assertEqual(init_messaging, {
@@ -428,7 +428,7 @@ class TestOnlineEventPerformance(EventPerformanceCase, UtilPerf):
# website customer data
with freeze_time(self.reference_now):
self.authenticate('user_eventmanager', 'user_eventmanager')
with self.assertQueryCount(default=69): # tef only: 68 (+1 ent)
with self.assertQueryCount(default=52): # tef only: 51 (+1 ent)
self._test_url_open('/event/%i' % self.test_event.id)
@warmup
@@ -436,7 +436,7 @@ class TestOnlineEventPerformance(EventPerformanceCase, UtilPerf):
# website customer data
with freeze_time(self.reference_now):
self.authenticate(None, None)
with self.assertQueryCount(default=47): # tef only: 47
with self.assertQueryCount(default=31):
self._test_url_open('/event/%i' % self.test_event.id)
@warmup
@@ -444,7 +444,7 @@ class TestOnlineEventPerformance(EventPerformanceCase, UtilPerf):
# website customer data
with freeze_time(self.reference_now):
self.authenticate('user_eventmanager', 'user_eventmanager')
with self.assertQueryCount(default=53): # tef only: 52 (+1 ent)
with self.assertQueryCount(default=50): # tef only: 49
self._test_url_open('/event')
@warmup
@@ -452,7 +452,7 @@ class TestOnlineEventPerformance(EventPerformanceCase, UtilPerf):
# website customer data
with freeze_time(self.reference_now):
self.authenticate(None, None)
with self.assertQueryCount(default=34): # tef only: 34
with self.assertQueryCount(default=30):
self._test_url_open('/event')
# @warmup
+21 -21
View File
@@ -286,7 +286,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
record.write({'name': 'Dupe write'})
with self.assertQueryCount(__system__=20, employee=24):
with self.assertQueryCount(__system__=19, employee=23):
record.action_close('Dupe feedback', attachment_ids=attachments.ids)
# notifications
@@ -313,7 +313,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(__system__=33, employee=39):
with self.assertQueryCount(__system__=32, employee=38):
composer._action_send_mail()
@users('__system__', 'employee')
@@ -335,7 +335,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer.id)],
})
with self.assertQueryCount(__system__=36, employee=44):
with self.assertQueryCount(__system__=35, employee=43):
composer._action_send_mail()
@users('__system__', 'employee')
@@ -346,7 +346,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_record = self.env['mail.test.ticket'].browse(self.test_record_full.id)
customer = self.env['res.partner'].browse(self.customer.ids)
attachments = self.env['ir.attachment'].with_user(self.env.user).create(self.test_attachments_vals)
with self.assertQueryCount(__system__=15, employee=15):
with self.assertQueryCount(__system__=14, employee=14):
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -360,7 +360,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
composer_form.attachment_ids.add(attachment)
composer = composer_form.save()
with self.assertQueryCount(__system__=44, employee=52):
with self.assertQueryCount(__system__=43, employee=51):
composer._action_send_mail()
# notifications
@@ -386,7 +386,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(__system__=26, employee=32):
with self.assertQueryCount(__system__=25, employee=31):
composer._action_send_mail()
@users('__system__', 'employee')
@@ -408,7 +408,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
}).create({})
composer._onchange_template_id_wrapper()
with self.assertQueryCount(__system__=33, employee=39):
with self.assertQueryCount(__system__=32, employee=38):
composer._action_send_mail()
# notifications
@@ -435,7 +435,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
}).create({})
composer._onchange_template_id_wrapper()
with self.assertQueryCount(__system__=41, employee=52):
with self.assertQueryCount(__system__=40, employee=51):
composer._action_send_mail()
# notifications
@@ -458,7 +458,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
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)
customer = self.env['res.partner'].browse(self.customer.ids)
with self.assertQueryCount(__system__=33, employee=33):
with self.assertQueryCount(__system__=32, employee=32):
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -469,7 +469,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(__system__=41, employee=47):
with self.assertQueryCount(__system__=40, employee=46):
composer._action_send_mail()
# notifications
@@ -490,7 +490,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
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)
customer = self.env['res.partner'].browse(self.customer.ids)
with self.assertQueryCount(__system__=34, employee=34):
with self.assertQueryCount(__system__=33, employee=33):
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -501,7 +501,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(__system__=53, employee=70):
with self.assertQueryCount(__system__=52, employee=69):
composer._action_send_mail()
# notifications
@@ -522,7 +522,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_assignation_email(self):
self.user_test.write({'notification_type': 'email'})
record = self.env['mail.test.track'].create({'name': 'Test'})
with self.assertQueryCount(__system__=39, employee=40):
with self.assertQueryCount(__system__=38, employee=39):
record.write({
'user_id': self.user_test.id,
})
@@ -729,7 +729,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.container.message_subscribe(self.user_portal.partner_id.ids)
record = self.container.with_user(self.env.user)
with self.assertQueryCount(__system__=54, employee=55): # about 20 (19?) queries per additional customer group
with self.assertQueryCount(__system__=53, employee=54): # about 20 (19?) queries per additional customer group
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
@@ -746,7 +746,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
record = self.container.with_user(self.env.user)
template_id = self.env.ref('test_mail.mail_test_container_tpl').id
with self.assertQueryCount(__system__=62, employee=63): # about 20 (19 ?) queries per additional customer group
with self.assertQueryCount(__system__=61, employee=62): # about 20 (19 ?) queries per additional customer group
record.message_post_with_template(template_id, message_type='comment', composition_mode='comment')
self.assertEqual(record.message_ids[0].body, '<p>Adding stuff on %s</p>' % record.name)
@@ -809,7 +809,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
})
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id)
with self.assertQueryCount(__system__=39, employee=40):
with self.assertQueryCount(__system__=38, employee=39):
rec.write({'user_id': self.user_portal.id})
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
# write tracking message
@@ -829,7 +829,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
customer_id = self.customer.id
user_id = self.user_portal.id
with self.assertQueryCount(__system__=91, employee=92):
with self.assertQueryCount(__system__=89, employee=90):
rec = self.env['mail.test.ticket'].create({
'name': 'Test',
'container_id': container_id,
@@ -858,7 +858,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
self.assertEqual(len(rec1.message_ids), 1)
with self.assertQueryCount(__system__=59, employee=59):
with self.assertQueryCount(__system__=58, employee=58):
rec.write({
'name': 'Test2',
'container_id': self.container.id,
@@ -895,7 +895,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
with self.assertQueryCount(__system__=66, employee=66):
with self.assertQueryCount(__system__=65, employee=65):
rec.write({
'name': 'Test2',
'container_id': container_id,
@@ -1081,7 +1081,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
messages.flush()
messages.invalidate_cache()
with self.assertQueryCount(employee=13): # tm only: 12
with self.assertQueryCount(employee=12):
res = messages.message_format()
self.assertEqual(len(res), 6)
@@ -1156,7 +1156,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
('attach tuple 3', "attachement tupple content 3", {'cid': 'cid2'}),
]
attachments = self.env['ir.attachment'].with_user(self.env.user).create(self.test_attachments_vals)
with self.assertQueryCount(employee=68):
with self.assertQueryCount(employee=67):
self.cr.sql_log = self.warm and self.cr.sql_log_count
record_container.with_context({}).message_post(
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
@@ -81,7 +81,7 @@ class TestMailPerformance(BaseMailPerformance):
record_ticket = self.env['mail.test.ticket.mc'].browse(self.record_ticket.ids)
attachments = self.env['ir.attachment'].create(self.test_attachments_vals)
with self.assertQueryCount(employee=102): # tmf: 93 / com: 100
with self.assertQueryCount(employee=100): # tmf: 93 / com: 98
new_message = record_ticket.message_post(
attachment_ids=attachments.ids,
body='<p>Test Content</p>',
@@ -47,7 +47,7 @@ class TestMassMailPerformance(TestMassMailPerformanceBase):
})
# runbot needs +101 compared to local (1570)
with self.assertQueryCount(__system__=1672, marketing=1673):
with self.assertQueryCount(__system__=1669, marketing=1670):
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
@@ -87,7 +87,7 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase):
})
# runbot needs +125 compared to local (1836)
with self.assertQueryCount(__system__=1962, marketing=1963):
with self.assertQueryCount(__system__=1959, marketing=1960):
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)