From 2da41ec07bc8ac558ea5e66b954d3d2d1038543f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 14 Aug 2023 12:29:39 +0200 Subject: [PATCH] [IMP] core: don't log cache being nuked during test teardown Improves on #119813 (595aa248433246959a5fa9288e477091701c6a35): the commit splits the ORM cache into several, and adds a log entry when invalidating caches (both individual and all). To keep tests isolated and coherent (and also make performance tests usable), the test framework has to clear all caches between tests to ensure they don't affect one another. This adds a line of log to *every* test, pointing into the guts of the test framework. Since the clearing is willful, unconditional, and not bypassable, the log line has essentially no value, it just adds tremendous amounts of noise to the logs. Fix by muting the registry logger specifically when clearing the cache in the test suite (there is currently no dedicated cache logger, if there ever is mute that instead). closes odoo/odoo#133811 X-original-commit: 52371bac7d4fadbeab139e4cd044cdc6b1005299 Signed-off-by: Xavier Morel (xmo) --- odoo/tests/common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index c3fd9ad65e3..c19b1099d49 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -53,7 +53,7 @@ from odoo.modules.registry import Registry from odoo.service import security from odoo.sql_db import BaseCursor, Cursor from odoo.tools import float_compare, single_email_re, profiler, lower_logging -from odoo.tools.misc import find_in_path +from odoo.tools.misc import find_in_path, mute_logger from . import case @@ -726,6 +726,7 @@ class TransactionCase(BaseCase): registry: Registry = None env: api.Environment = None cr: Cursor = None + muted_registry_logger = mute_logger(odoo.modules.registry._logger.name) @classmethod @@ -751,7 +752,8 @@ class TransactionCase(BaseCase): cls.registry.setup_models(cr) cls.registry.registry_invalidated = False cls.registry.registry_sequence = cls.registry_start_sequence - cls.registry.clear_all_caches() + with cls.muted_registry_logger: + cls.registry.clear_all_caches() cls.registry.cache_invalidated.clear() cls.addClassCleanup(reset_changes) @@ -772,7 +774,7 @@ class TransactionCase(BaseCase): self.addCleanup(envs.update, list(envs)) self.addCleanup(envs.clear) - self.addCleanup(self.registry.clear_all_caches) + self.addCleanup(self.muted_registry_logger(self.registry.clear_all_caches)) # This prevents precommit functions and data from piling up # until cr.flush is called in 'assertRaises' clauses