Files
odoo_source/addons/website_blog/tests/test_performance.py
T
Thibault Delavallée f8e0c92bf4 [FIX] website: add missing digest dependency
Related to digest update in 13.4 (a595ebfca5ab7041224c661f404138612257bdda).

QUERY COUNT IN BLOG

Local installation of blog still makes those tests use 27 or 28 queries. On
runbot it grows until 32.

Due to dependency change, installation order changes. It may have an effect on
query count in website loading some pages in blog. This is worth checking why
queries are added.
Digest module itself has nothing to do with website. It could either be a side
effect of some computed field, either an installation order change adding more
modules before installing blog, with side-effect of adding queries due to
another module.

As without this fix installing website is not possible, let us merge this one
and investigate further soon.

closes odoo/odoo#55835

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-13 08:26:08 +00:00

37 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.website.tests.test_performance import UtilPerf
import random
class TestBlogPerformance(UtilPerf):
def test_10_perf_sql_blog_standard_data(self):
self.assertEqual(self._get_url_hot_query('/blog'), 32)
def test_20_perf_sql_blog_bigger_data_scaling(self):
BlogPost = self.env['blog.post']
BlogTag = self.env['blog.tag']
blogs = self.env['blog.blog'].search([])
blog_tags = BlogTag.create([{'name': 'Blog Tag Test %s' % i} for i in range(1, 20)])
BlogPost.create([{'name': 'Blog Post Test %s' % i, 'is_published': True, 'blog_id': blogs[i % 2].id} for i in range(1, 20)])
blog_posts = BlogPost.search([])
for blog_post in blog_posts:
blog_post.tag_ids += blog_tags
blog_tags = blog_tags[:-1]
self.assertEqual(self._get_url_hot_query('/blog'), 32)
self.assertEqual(self._get_url_hot_query(blog_post[0].website_url), 35)
def test_30_perf_sql_blog_bigger_data_scaling(self):
BlogPost = self.env['blog.post']
BlogTag = self.env['blog.tag']
blogs = self.env['blog.blog'].search([])
blog_tags = BlogTag.create([{'name': 'New Blog Tag Test %s' % i} for i in range(1, 50)])
BlogPost.create([{'name': 'New Blog Post Test %s' % i, 'is_published': True, 'blog_id': blogs[random.randint(0, 1)].id} for i in range(1, 100)])
blog_posts = BlogPost.search([])
for blog_post in blog_posts:
blog_post.write({'tag_ids': [[6, 0, random.choices(blog_tags.ids, k=random.randint(0, len(blog_tags)))]]})
self.assertLessEqual(self._get_url_hot_query('/blog'), 32)
self.assertLessEqual(self._get_url_hot_query(blog_post[0].website_url), 35)