[FIX] sprurious error in log during javascript unit tests
During some tests, the runner performs sequences of DUPLICATE and DROP
on databases. Each DUPLICATE is followed by some operations then a
DROP.
Problem is, after a DROP the next DUPLICATE RPC query will attempt a
connection to the just-dropped database, openerp.sql_db will log an
OperationalError ("Connection to the database failed" since the db it
tries to connect to was removed) then the HTTP dispatcher will just
switch to "nodb" and continue on its merry way.
Mute the sql_db logger while attempting to fetch the ir.http object.
Also assert that the logger name is a string in mute_logger, as
`mute_logger(openerp.sql_db)` is syntactically valid, but will not do
anything.
bzr revid: xmo@openerp.com-20140123115413-ax5patcomdfp3ue3
This commit is contained in:
+6
-3
@@ -35,6 +35,7 @@ import werkzeug.wsgi
|
||||
|
||||
import openerp
|
||||
from openerp.service import security, model as service_model
|
||||
import openerp.tools
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1027,10 +1028,12 @@ class Root(object):
|
||||
if db:
|
||||
openerp.modules.registry.RegistryManager.check_registry_signaling(db)
|
||||
try:
|
||||
ir_http = request.registry['ir.http']
|
||||
with openerp.tools.mute_logger('openerp.sql_db'):
|
||||
ir_http = request.registry['ir.http']
|
||||
except psycopg2.OperationalError:
|
||||
# psycopg2 error. At this point, that's mean the database does not exists
|
||||
# anymore. We unlog the user and failback in nodb mode
|
||||
# psycopg2 error. At this point, that means the
|
||||
# database probably does not exists anymore. Log the
|
||||
# user out and fall back to nodb
|
||||
request.session.logout()
|
||||
result = _dispatch_nodb()
|
||||
else:
|
||||
|
||||
@@ -1075,6 +1075,8 @@ class mute_logger(object):
|
||||
|
||||
def __enter__(self):
|
||||
for logger in self.loggers:
|
||||
assert isinstance(logger, basestring),\
|
||||
"A logger name must be a string, got %s" % type(logger)
|
||||
logging.getLogger(logger).addFilter(self)
|
||||
|
||||
def __exit__(self, exc_type=None, exc_val=None, exc_tb=None):
|
||||
|
||||
Reference in New Issue
Block a user