mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-10-20 01:43:25 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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}"'
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user