From 53a33295dd4fe587d7b3f2c8c454cb00e4c1351c Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Fri, 27 Nov 2026 08:46:00 +0000 Subject: [PATCH] Use authenticated SQL readiness probe for MySQL integration --- tests/integration/test_mysql.py | 85 ++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/tests/integration/test_mysql.py b/tests/integration/test_mysql.py index 9394abf..40e0be4 100644 --- a/tests/integration/test_mysql.py +++ b/tests/integration/test_mysql.py @@ -302,45 +302,7 @@ class MySQLIntegrationTests(unittest.TestCase): print("PASS: Disposable container started") - deadline = time.monotonic() + 300 - - while time.monotonic() < deadline: - - state = verify_isolation()["State"] - - require( - state["Running"] - and not state["OOMKilled"], - "Test database stopped unexpectedly", - ) - - try: - - result = command( - "docker", "exec", cid, - "mysqladmin", - "--protocol=TCP", - "--host=127.0.0.1", - "--silent", - "ping", - timeout=10, - ) - - if b"mysqld is alive" in result: - break - - except (RuntimeError, subprocess.TimeoutExpired): - pass - - time.sleep(2) - - else: - - raise RuntimeError( - "MySQL readiness timed out" - ) - - print("PASS: MySQL TCP service ready") + verify_isolation() # Install credentials inside the disposable # container without displaying their values. @@ -362,6 +324,51 @@ class MySQLIntegrationTests(unittest.TestCase): input_data=client, ) + deadline = time.monotonic() + 300 + + while time.monotonic() < deadline: + + state = verify_isolation()["State"] + + require( + state["Running"] + and not state["OOMKilled"], + "Test database stopped unexpectedly", + ) + + try: + + result = command( + "docker", "exec", cid, + "mysql", + "--defaults-file=/run/secrets/absdev-client.cnf", + "--protocol=TCP", + "--host=127.0.0.1", + "--connect-timeout=3", + "--batch", + "--skip-column-names", + "--database=" + SOURCE_DATABASE, + "--execute", + "SELECT 1", + timeout=10, + ) + + if result.strip() == b"1": + break + + except (RuntimeError, subprocess.TimeoutExpired): + pass + + time.sleep(2) + + else: + + raise RuntimeError( + "MySQL readiness timed out" + ) + + print("PASS: Authenticated MySQL TCP service ready") + def sql(statement, database=None): verify_isolation()