Commit e2f02f38 authored by Jérome Perrin's avatar Jérome Perrin

software/erp5: fix flappy test_logrotate_and_slow_query_digest test

This test uses the default config of having mariadb log queries taking more
than 1 second, then makes two slow queries and check that these two queries
are logged and included in pt-query-digest report.

Sometimes this test fail because there are more slow queries than the two
expected, in the snapshots, we can see that reports also contain:

    SHOW TABLE STATUS FROM `mysql` LIKE 'time_zone_transition'\G
    SHOW CREATE TABLE `mysql`.`time_zone_transition`\G

but these queries are not made by the test. They are probably made by
mysql_upgrade script. Such queries can take more than 1 second sometimes
and when they do the test fail because there are more slow queries than the
expected.

To prevent this kind of intermitent failures, make our test queries slower
and configure mariadb to log queries after a longer delay (3 seconds).
Hopefully these unrelated queries should not take more than 3 seconds.
parent f1ad7c42
...@@ -63,6 +63,7 @@ class MariaDBTestCase(ERP5InstanceTestCase): ...@@ -63,6 +63,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
return { return {
'tcpv4-port': 3306, 'tcpv4-port': 3306,
'max-connection-count': 5, 'max-connection-count': 5,
'long-query-time': 3,
'max-slowqueries-threshold': 1, 'max-slowqueries-threshold': 1,
'slowest-query-threshold': 0.1, 'slowest-query-threshold': 0.1,
# XXX what is this ? should probably not be needed here # XXX what is this ? should probably not be needed here
...@@ -115,12 +116,13 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin): ...@@ -115,12 +116,13 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin):
# run logrotate a first time so that it create state files # run logrotate a first time so that it create state files
self._executeCrontabAtDate('logrotate', '2000-01-01') self._executeCrontabAtDate('logrotate', '2000-01-01')
# make two slow queries # make two slow queries. We are using long-query-time=3, so the queries
# must take more than 3 seconds to be logged.
cnx = self.getDatabaseConnection() cnx = self.getDatabaseConnection()
with contextlib.closing(cnx): with contextlib.closing(cnx):
cnx.query("SELECT SLEEP(1.1)") cnx.query("SELECT SLEEP(3.1)")
cnx.store_result() cnx.store_result()
cnx.query("SELECT SLEEP(1.2)") cnx.query("SELECT SLEEP(3.2)")
# slow query crontab depends on crontab for log rotation # slow query crontab depends on crontab for log rotation
# to be executed first. # to be executed first.
...@@ -171,7 +173,7 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin): ...@@ -171,7 +173,7 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin):
"""\ """\
Threshold is lower than expected: Threshold is lower than expected:
Expected total queries : 1.0 and current is: 2 Expected total queries : 1.0 and current is: 2
Expected slowest query : 0.1 and current is: 1 Expected slowest query : 0.1 and current is: 3
""") """)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment