From 7a248f5933948bf39eafbc672ea2d33d2a6d9a5b Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 6 Sep 2022 12:07:11 +0000 Subject: [PATCH] [IMP] base: add test to measure the installation of a language on a database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main purpose of the test is to provide statistics for the runbot, in order to detect unexpected variations in the loading of translations. closes odoo/odoo#99636 Signed-off-by: Xavier Dollé (xdo) --- odoo/addons/base/tests/test_translate.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/tests/test_translate.py b/odoo/addons/base/tests/test_translate.py index 77593a53168..96151c05580 100644 --- a/odoo/addons/base/tests/test_translate.py +++ b/odoo/addons/base/tests/test_translate.py @@ -1,13 +1,17 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from unittest.mock import patch +import logging +import time from psycopg2 import IntegrityError from odoo.exceptions import AccessError, ValidationError from odoo.tools import mute_logger from odoo.tools.translate import quote, unquote, xml_translate, html_translate -from odoo.tests.common import TransactionCase, BaseCase, new_test_user +from odoo.tests.common import TransactionCase, BaseCase, new_test_user, tagged + +_stats_logger = logging.getLogger('odoo.tests.stats') class TranslationToolsTestCase(BaseCase): @@ -945,3 +949,16 @@ class TestXMLTranslation(TransactionCase): view.write({"arch_db": "
content
"}) self.assertIn("", view.arch_db) self.assertIn("", view_fr.arch_db) + + +@tagged('post_install', '-at_install') +class TestLanguageInstallPerformance(TransactionCase): + def test_language_install(self): + """ Install a language on a complete database. """ + fr_BE = self.env.ref('base.lang_fr_BE') + self.assertFalse(fr_BE.active) + + t0 = time.time() + fr_BE.toggle_active() + t1 = time.time() + _stats_logger.info("installed language fr_BE in %.3fs", t1 - t0)