Skip to content

Commit 6cc2c01

Browse files
authored
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.
1 parent eb90a02 commit 6cc2c01

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,37 @@ services:
3030
ports:
3131
- "127.0.0.1:9940:4000"
3232
command: /tidb-server -store unistore -path "" -lease 0s > tidb.log 2>&1 &
33+
gaussdb:
34+
image: 'opengauss/opengauss:7.0.0-RC1.B023'
35+
hostname: opengauss-server
36+
ports:
37+
- "127.0.0.1:9950:5432"
38+
environment:
39+
- TZ=Asia/Shanghai
40+
- GS_PASSWORD=Gaussdb@123
41+
- GS_CLUSTER_NAME=opengauss_cluster
42+
- PGDATA=/var/lib/opengauss/data
43+
entrypoint: ""
44+
command: |-
45+
/bin/sh -c 'set -euo pipefail;
46+
/usr/local/bin/entrypoint.sh gaussdb &
47+
counter=1;
48+
while [ "$$counter" -le 20 ]; do
49+
if su - omm -c "gsql -U omm -d postgres -c \"SELECT 1;\""; then
50+
echo "Creating database gorm...";
51+
su - omm -c "gsql -U omm -d postgres -c \"CREATE DATABASE gorm DBCOMPATIBILITY '\'PG\'';\"";
52+
echo "Database initialized successfully";
53+
break;
54+
fi;
55+
echo "Waiting for database to be ready... ($$counter/12)";
56+
sleep 5;
57+
counter=$$(($$counter + 1));
58+
done;
59+
# timeout handling
60+
if [ $$counter -gt 20 ]; then
61+
echo "Error: Database failed to start within timeout";
62+
exit 1;
63+
fi;
64+
# keep the container running: wait for the database process in the foreground
65+
wait
66+
'

0 commit comments

Comments
 (0)