From 948b8347f417c06d5c106b80bf11ad34151eac80 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 17 Oct 2026 23:28:41 +0200 Subject: [PATCH] fix(test): wait for MariaDB with the root password, not the init window The entrypoint installs root@localhost without unix_socket auth and sets its password during init, so the passwordless socket probe only passed when it landed in the window before SET PASSWORD. Missing that window timed the e2e MariaDB suites out at random. The probe now authenticates with the root password it already received and requires @@skip_networking = 0, so the entrypoint's temporary server no longer counts as ready. The anonymous-preemption bootstrap logs in with the root password as well. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/e2e/helpers/process.py | 18 +++++++++++------- .../test_e2e_mariadb_anonymous_preemption.py | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/e2e/helpers/process.py b/tests/e2e/helpers/process.py index 2e8ccf5..80eb929 100644 --- a/tests/e2e/helpers/process.py +++ b/tests/e2e/helpers/process.py @@ -96,12 +96,13 @@ def wait_for_mariadb( container: str, *, root_password: str, timeout_s: int = 90 ) -> None: """ - Liveness probe for MariaDB. + Readiness probe for MariaDB, as root over the socket. - IMPORTANT (MariaDB 11): - Root TCP auth is often restricted (unix_socket auth), so a TCP ping like - `mariadb-admin -uroot -p... -h localhost ping` can fail even though the server is up. - We therefore check readiness via a socket-based query. + The entrypoint drops root@127.0.0.1, so root is socket-only, and it + installs root@localhost without unix_socket auth: a probe without the + password only passes in the init window before the password is set. + `@@skip_networking` must be 0 so the entrypoint's temporary server, + which shuts down right after init, does not count as ready. """ deadline = time.time() + timeout_s while time.time() < deadline: @@ -112,12 +113,15 @@ def wait_for_mariadb( container, "sh", "-lc", - 'mariadb -uroot --protocol=socket -e "SELECT 1;"', + ( + f"mariadb -uroot -p{root_password} --protocol=socket " + '-N -e "SELECT @@skip_networking;"' + ), ], capture=True, check=False, ) - if p.returncode == 0: + if p.returncode == 0 and p.stdout.strip() == "0": return time.sleep(1) raise TimeoutError( diff --git a/tests/e2e/test_e2e_mariadb_anonymous_preemption.py b/tests/e2e/test_e2e_mariadb_anonymous_preemption.py index cfb135b..a183db2 100644 --- a/tests/e2e/test_e2e_mariadb_anonymous_preemption.py +++ b/tests/e2e/test_e2e_mariadb_anonymous_preemption.py @@ -100,7 +100,10 @@ class TestE2EMariaDBAnonymousPreemption(unittest.TestCase): cls.db_container, "sh", "-lc", - f'mariadb -uroot --protocol=socket -e "{bootstrap_sql}"', + ( + f"mariadb -uroot -p{cls.root_password} --protocol=socket " + f'-e "{bootstrap_sql}"' + ), ] )