[IMP] *: update query counts

Query counts weren't adapted to recent performance changes.
This commit updates the different query counts to make sure
any commit changing the query counts knows it and does it on purpose.

Some query counts may vary between community and enterprise
and therefore have a higher value than needed in community version.

closes odoo/odoo#43202

Related: odoo/enterprise#7682
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Victor Feyens
2020-01-14 11:59:53 +00:00
parent 2d01930537
commit caf11fade0
5 changed files with 28 additions and 28 deletions
+4 -4
View File
@@ -85,7 +85,7 @@ class TestMailPerformance(BaseMailPerformance):
records = self.env['test_performance.mail'].search([])
self.assertEqual(len(records), 5)
with self.assertQueryCount(__system__=3, demo=3):
with self.assertQueryCount(__system__=2, demo=2):
# without cache
for record in records:
record.partner_id.country_id.name
@@ -364,7 +364,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_one_inbox_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(__system__=23, emp=25):
with self.assertQueryCount(__system__=22, emp=24):
record.message_post(
body='<p>Test Post Performances with an inbox ping</p>',
partner_ids=self.user_test.partner_id.ids,
@@ -680,7 +680,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 | self.user_portal.partner_id)
with self.assertQueryCount(__system__=34, emp=37):
with self.assertQueryCount(__system__=34, emp=35):
rec.write({
'name': 'Test2',
'customer_id': customer_id,
@@ -817,7 +817,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
]
self.attachements = self.env['ir.attachment'].with_user(self.env.user).create(self.vals)
attachement_ids = self.attachements.ids
with self.assertQueryCount(emp=105): # test_mail only: 94
with self.assertQueryCount(emp=92):
self.cr.sql_log = self.warm and self.cr.sql_log_count
record.with_context({}).message_post(
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
@@ -51,7 +51,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.MockSMS):
def test_message_sms_record_1_partner(self):
record = self.test_record.with_user(self.env.user)
pids = self.customer.ids
with self.mockSMSGateway(), self.assertQueryCount(employee=22): # test_mail_enterprise: 22
with self.mockSMSGateway(), self.assertQueryCount(employee=21): # test_mail_enterprise: 21
messages = record._message_sms(
body='Performance Test',
partner_ids=pids,
@@ -66,7 +66,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.MockSMS):
def test_message_sms_record_10_partners(self):
record = self.test_record.with_user(self.env.user)
pids = self.partners.ids
with self.mockSMSGateway(), self.assertQueryCount(employee=40): # test_mail_enterprise: 40
with self.mockSMSGateway(), self.assertQueryCount(employee=39): # test_mail_enterprise: 39
messages = record._message_sms(
body='Performance Test',
partner_ids=pids,
@@ -80,7 +80,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.MockSMS):
@warmup
def test_message_sms_record_default(self):
record = self.test_record.with_user(self.env.user)
with self.mockSMSGateway(), self.assertQueryCount(employee=26): # test_mail_enterprise: 26
with self.mockSMSGateway(), self.assertQueryCount(employee=24): # test_mail_enterprise: 24
messages = record._message_sms(
body='Performance Test',
)
@@ -142,7 +142,7 @@ class TestSMSMassPerformance(BaseMailPerformance, sms_common.MockSMS):
'mass_keep_log': False,
})
with self.mockSMSGateway(), self.assertQueryCount(employee=108):
with self.mockSMSGateway(), self.assertQueryCount(employee=106):
composer.action_send_sms()
@mute_logger('odoo.addons.sms.models.sms_sms')
@@ -159,5 +159,5 @@ class TestSMSMassPerformance(BaseMailPerformance, sms_common.MockSMS):
'mass_keep_log': True,
})
with self.mockSMSGateway(), self.assertQueryCount(employee=159):
with self.mockSMSGateway(), self.assertQueryCount(employee=157):
composer.action_send_sms()
@@ -50,7 +50,7 @@ class TestMassMailPerformance(TestMassMailPerformanceBase):
'mailing_domain': [('id', 'in', self.mm_recs.ids)],
})
with self.assertQueryCount(__system__=2478, marketing=3128):
with self.assertQueryCount(__system__=2261, marketing=2261):
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
@@ -89,7 +89,7 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase):
'mailing_domain': [('id', 'in', self.mm_recs.ids)],
})
with self.assertQueryCount(__system__=2865, marketing=3611):
with self.assertQueryCount(__system__=2636, marketing=2636):
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
@@ -171,7 +171,7 @@ class One2manyCase(TransactionCase):
def test_cache_invalidation(self):
""" Cache invalidation for one2many with integer inverse. """
record0 = self.env['test_new_api.attachment.host'].create({})
with self.assertQueryCount(2):
with self.assertQueryCount(0):
self.assertFalse(record0.attachment_ids, "inconsistent cache")
# creating attachment must compute name and invalidate attachment_ids
@@ -180,7 +180,7 @@ class One2manyCase(TransactionCase):
'res_id': record0.id,
})
attachment.flush()
with self.assertQueryCount(1):
with self.assertQueryCount(0):
self.assertEqual(attachment.name, record0.display_name,
"field should be computed")
with self.assertQueryCount(2):
@@ -192,13 +192,13 @@ class One2manyCase(TransactionCase):
with self.assertQueryCount(0):
# field res_id should not have been invalidated
attachment.res_id
with self.assertQueryCount(2):
with self.assertQueryCount(0):
self.assertFalse(record1.attachment_ids, "inconsistent cache")
# writing on res_id must recompute name and invalidate attachment_ids
attachment.res_id = record1.id
attachment.flush()
with self.assertQueryCount(1):
with self.assertQueryCount(0):
self.assertEqual(attachment.name, record1.display_name,
"field should be recomputed")
with self.assertQueryCount(2):
@@ -50,7 +50,7 @@ class TestPerformance(SavepointCaseWithUserDemo):
records = self.env['test_performance.base'].search([])
self.assertEqual(len(records), 5)
with self.assertQueryCount(__system__=3, demo=3):
with self.assertQueryCount(__system__=2, demo=2):
# without cache
for record in records:
record.partner_id.country_id.name
@@ -94,12 +94,12 @@ class TestPerformance(SavepointCaseWithUserDemo):
# create N lines on rec1: O(N) queries
rec1.invalidate_cache()
with self.assertQueryCount(4):
with self.assertQueryCount(2):
rec1.write({'line_ids': [(0, 0, {'value': 0})]})
self.assertEqual(len(rec1.line_ids), 1)
rec1.invalidate_cache()
with self.assertQueryCount(17):
with self.assertQueryCount(16):
rec1.write({'line_ids': [(0, 0, {'value': val}) for val in range(1, 12)]})
self.assertEqual(len(rec1.line_ids), 12)
@@ -107,12 +107,12 @@ class TestPerformance(SavepointCaseWithUserDemo):
# update N lines: O(N) queries
rec1.invalidate_cache()
with self.assertQueryCount(8):
with self.assertQueryCount(7):
rec1.write({'line_ids': [(1, line.id, {'value': 42}) for line in lines[0]]})
self.assertEqual(rec1.line_ids, lines)
rec1.invalidate_cache()
with self.assertQueryCount(28):
with self.assertQueryCount(27):
rec1.write({'line_ids': [(1, line.id, {'value': 42 + line.id}) for line in lines[1:]]})
self.assertEqual(rec1.line_ids, lines)
@@ -149,24 +149,24 @@ class TestPerformance(SavepointCaseWithUserDemo):
# link N lines from rec1 to rec2: O(1) queries
rec1.invalidate_cache()
with self.assertQueryCount(7):
with self.assertQueryCount(2):
rec2.write({'line_ids': [(4, line.id) for line in lines[0]]})
self.assertEqual(rec1.line_ids, lines[1:])
self.assertEqual(rec2.line_ids, lines[0])
rec1.invalidate_cache()
with self.assertQueryCount(10):
with self.assertQueryCount(8):
rec2.write({'line_ids': [(4, line.id) for line in lines[1:]]})
self.assertFalse(rec1.line_ids)
self.assertEqual(rec2.line_ids, lines)
rec1.invalidate_cache()
with self.assertQueryCount(7):
with self.assertQueryCount(6):
rec2.write({'line_ids': [(4, line.id) for line in lines[0]]})
self.assertEqual(rec2.line_ids, lines)
rec1.invalidate_cache()
with self.assertQueryCount(7):
with self.assertQueryCount(6):
rec2.write({'line_ids': [(4, line.id) for line in lines[1:]]})
self.assertEqual(rec2.line_ids, lines)
@@ -177,7 +177,7 @@ class TestPerformance(SavepointCaseWithUserDemo):
self.assertFalse(rec2.line_ids)
rec1.invalidate_cache()
with self.assertQueryCount(5):
with self.assertQueryCount(4):
rec2.write({'line_ids': [(5,)]})
self.assertFalse(rec2.line_ids)
@@ -186,17 +186,17 @@ class TestPerformance(SavepointCaseWithUserDemo):
# set N lines in rec2: O(1) queries
rec1.invalidate_cache()
with self.assertQueryCount(8):
with self.assertQueryCount(5):
rec2.write({'line_ids': [(6, 0, lines[0].ids)]})
self.assertEqual(rec1.line_ids, lines[1:])
self.assertEqual(rec2.line_ids, lines[0])
with self.assertQueryCount(9):
with self.assertQueryCount(5):
rec2.write({'line_ids': [(6, 0, lines.ids)]})
self.assertFalse(rec1.line_ids)
self.assertEqual(rec2.line_ids, lines)
with self.assertQueryCount(4):
with self.assertQueryCount(3):
rec2.write({'line_ids': [(6, 0, lines.ids)]})
self.assertEqual(rec2.line_ids, lines)