[REVERT] "[IMP] core: tolerate a 10% deviation for number of queries"
This reverts commit d565596868. Indeed whole purpose of having tests
based on query counters is to fail every time query count is greater than
expected. Query count could be greater than expected because
* either it is required by a bug fix or a feature and tests should be
updated accordingly in the same commit;
* either implementation can be improved to avoid or lessen query count
impact and code should be updated accordingly;
* either we have some random queries due to nondeterministic behavior;
It seems purpose of the commit was to solve the third case. However we think
hiding first two cases can be dangerous compared to solving third case.
Moreover having a threshold of 10% does not make sense. It means some complex
test case could take 30 queries more without being noticed. Some tests could
fail after several commits adding queries and finding them afterwards could
be complicated.
Another solution based on flagging some tests that have a small random
behavior will come soon.
This commit is contained in:
@@ -207,16 +207,15 @@ class BaseCase(TreeCase, MetaCase('DummyCase', (object,), {})):
|
||||
if self.warm:
|
||||
login = self.env.user.login
|
||||
expected = counters.get(login, default)
|
||||
tolerance = expected + round(expected * 0.1) # allow a 10% tolerance
|
||||
count0 = self.cr.sql_log_count
|
||||
yield
|
||||
count = self.cr.sql_log_count - count0
|
||||
if count > tolerance:
|
||||
msg = "Too much queries for user %s: %d > %d queries"
|
||||
if not count <= expected:
|
||||
msg = "Query count for user %s: got %d instead of %d"
|
||||
self.fail(msg % (login, count, expected))
|
||||
elif count < expected:
|
||||
logger = logging.getLogger(type(self).__module__)
|
||||
msg = "Nice job, %s! Got %d queries instead of %d"
|
||||
msg = "Query count for user %s: got %d instead of %d"
|
||||
logger.info(msg, login, count, expected)
|
||||
else:
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user