integration: log slow queries and check for them (#4554)

I couldn't get this to work cleanly with
`--log-queries-not-using-indexes` because a couple of queries show up
during integration test runs, seemingly because the tables involved are
small enough that the optimizer finds it faster to skip the index.

Some possible followups:
 - Allow list those queries, or
 - Preload the DB with a certain number of certificates before the start
   of testing.
This commit is contained in:
Jacob Hoffman-Andrews 2019-11-19 10:44:24 -08:00 committed by Daniel McCarney
parent 953885aec1
commit 36e504f21f
2 changed files with 19 additions and 1 deletions

View File

@ -73,7 +73,12 @@ services:
- boulder-mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
command: mysqld --bind-address=0.0.0.0
# Send slow queries to a table so we can check for them in the
# integration tests. For now we ignore queries not using indexes,
# because that seems to trigger based on the optimizer's choice to not
# use an index for certain queries, particularly when tables are still
# small.
command: mysqld --bind-address=0.0.0.0 --slow-query-log --log-output=TABLE --log-queries-not-using-indexes=OFF
logging:
driver: none
netaccess:

View File

@ -308,9 +308,22 @@ def main():
if not startservers.check():
raise Exception("startservers.check failed")
check_slow_queries()
global exit_status
exit_status = 0
def check_slow_queries():
"""Checks that we haven't run any slow queries during the integration test.
This depends on flags set on mysqld in docker-compose.yml.
"""
output = run("mysql -h boulder-mysql -D boulder_sa_integration -e " +
"'select * from mysql.slow_log where user_host not like \"test_setup%\" \G'")
if len(output) > 0:
print(output)
raise Exception("Found slow queries in the slow query log")
def run_chisel(test_case_filter):
for key, value in inspect.getmembers(v1_integration):
if callable(value) and key.startswith('test_') and re.search(test_case_filter, key):