Use authenticated SQL readiness probe for MySQL integration
ABSDEV Framework CI / framework-ci (push) Successful in 23s
ABSDEV Framework CI / framework-ci (push) Successful in 23s
This commit is contained in:
@@ -302,45 +302,7 @@ class MySQLIntegrationTests(unittest.TestCase):
|
|||||||
|
|
||||||
print("PASS: Disposable container started")
|
print("PASS: Disposable container started")
|
||||||
|
|
||||||
deadline = time.monotonic() + 300
|
verify_isolation()
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
# Install credentials inside the disposable
|
# Install credentials inside the disposable
|
||||||
# container without displaying their values.
|
# container without displaying their values.
|
||||||
@@ -362,6 +324,51 @@ class MySQLIntegrationTests(unittest.TestCase):
|
|||||||
input_data=client,
|
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):
|
def sql(statement, database=None):
|
||||||
|
|
||||||
verify_isolation()
|
verify_isolation()
|
||||||
|
|||||||
Reference in New Issue
Block a user