Skip to content

Commit f6116aa

Browse files
fix: Made mariadb works better
1 parent c4ab3f2 commit f6116aa

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

integration_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ def _gen_docker_compose(modules, *, diracx_dist_dir=None):
573573
# Load the docker compose configuration and mount the necessary volumes
574574
input_fn = Path(__file__).parent / "tests/CI/docker-compose.yml"
575575
docker_compose = yaml.safe_load(input_fn.read_text())
576-
# diracx-wait-for-db needs the volume to be able to run the witing script
576+
# diracx-wait-for-db needs the volume to be able to run the waiting script
577577
for ctn in ("dirac-server", "dirac-client", "dirac-pilot", "diracx-wait-for-db"):
578578
if "volumes" not in docker_compose["services"][ctn]:
579579
docker_compose["services"][ctn]["volumes"] = []

tests/CI/check_db_initialized.sh

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
#!/bin/bash
2-
dbMissing=true;
3-
allDBs=(AccountingDB FTS3DB JobDB JobLoggingDB PilotAgentsDB ProductionDB ProxyDB ReqDB ResourceManagementDB ResourceStatusDB SandboxMetadataDB StorageManagementDB TaskQueueDB TransformationDB)
4-
while ${dbMissing};
5-
do
6-
dbMissing=false;
7-
allExistingDBs=$(mysql -uDirac -pDirac -h mysql -P 3306 -e "show databases;");
8-
for db in "${allDBs[@]}";
9-
do
10-
if grep -q "${db}" <<< "${allExistingDBs}";
11-
then
12-
echo "${db} OK";
13-
else
14-
echo "${db} not created";
15-
dbMissing=true;
16-
fi;
17-
done;
18-
if ${dbMissing};
19-
then
20-
sleep 1;
2+
DB_USER="Dirac"
3+
DB_PASS="Dirac"
4+
DB_HOST="mysql"
5+
DB_PORT=3306
6+
DB_CMD=""
7+
8+
# Detect available client: maria or mysql
9+
if command -v mariadb >/dev/null 2>&1; then
10+
DB_CMD="mariadb -u${DB_USER} -p${DB_PASS} -h${DB_HOST} -P${DB_PORT}"
11+
elif command -v mysql >/dev/null 2>&1; then
12+
DB_CMD="mysql -u${DB_USER} -p${DB_PASS} -h${DB_HOST} -P${DB_PORT}"
13+
else
14+
echo "❌ Neither mysql nor mariadb client found in PATH."
15+
exit 1
16+
fi
17+
18+
echo "Using client: ${DB_CMD%% *}"
19+
20+
dbMissing=true
21+
allDBs=(
22+
AccountingDB FTS3DB JobDB JobLoggingDB PilotAgentsDB ProductionDB
23+
ProxyDB ReqDB ResourceManagementDB ResourceStatusDB
24+
SandboxMetadataDB StorageManagementDB TaskQueueDB TransformationDB
25+
)
26+
27+
while $dbMissing; do
28+
dbMissing=false
29+
allExistingDBs=$($DB_CMD -e "SHOW DATABASES;" 2>/dev/null)
30+
31+
for db in "${allDBs[@]}"; do
32+
if grep -q "^${db}$" <<<"$allExistingDBs"; then
33+
echo "${db} exists"
34+
else
35+
echo "⚠️ ${db} not created yet"
36+
dbMissing=true
2137
fi
38+
done
39+
40+
$dbMissing && sleep 10
2241
done
42+
43+
echo "🎉 All databases are present."

0 commit comments

Comments
 (0)