[IMP] core: don't log cache being nuked during test teardown

Improves on #119813 (595aa24843): 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) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2023-09-01 05:53:42 +00:00
parent c78f54a616
commit 2da41ec07b
+5 -3
View File
@@ -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