From 6cc2c01268c24fdf7b30cfe4b1a8fb5a10922c65 Mon Sep 17 00:00:00 2001 From: moseszane168 <916868287@qq.com> Date: Mon, 4 Aug 2025 12:07:30 +0800 Subject: [PATCH] Update the docker compose file (#7524) * Update the docker compose file to make /Tests/tests_all.sh can run successfully. * Create database gorm in the compose file. * Fix connection failure to local GaussDB instance (127.0.0.1:9950) that resulted in "unexpected EOF" errors during initialization in tests. --- tests/compose.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/compose.yml b/tests/compose.yml index fdce1b88..99c60aa6 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -30,3 +30,37 @@ services: ports: - "127.0.0.1:9940:4000" command: /tidb-server -store unistore -path "" -lease 0s > tidb.log 2>&1 & + gaussdb: + image: 'opengauss/opengauss:7.0.0-RC1.B023' + hostname: opengauss-server + ports: + - "127.0.0.1:9950:5432" + environment: + - TZ=Asia/Shanghai + - GS_PASSWORD=Gaussdb@123 + - GS_CLUSTER_NAME=opengauss_cluster + - PGDATA=/var/lib/opengauss/data + entrypoint: "" + command: |- + /bin/sh -c 'set -euo pipefail; + /usr/local/bin/entrypoint.sh gaussdb & + counter=1; + while [ "$$counter" -le 20 ]; do + if su - omm -c "gsql -U omm -d postgres -c \"SELECT 1;\""; then + echo "Creating database gorm..."; + su - omm -c "gsql -U omm -d postgres -c \"CREATE DATABASE gorm DBCOMPATIBILITY '\'PG\'';\""; + echo "Database initialized successfully"; + break; + fi; + echo "Waiting for database to be ready... ($$counter/12)"; + sleep 5; + counter=$$(($$counter + 1)); + done; + # timeout handling + if [ $$counter -gt 20 ]; then + echo "Error: Database failed to start within timeout"; + exit 1; + fi; + # keep the container running: wait for the database process in the foreground + wait + ' \ No newline at end of file