Skip to content

Commit 307283e

Browse files
fix(ci): Fix race condition with InnoDB and postgres password
1 parent 6c8b57d commit 307283e

File tree

3 files changed

+63
-13
lines changed

3 files changed

+63
-13
lines changed

.github/workflows/build_and_test.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ jobs:
8787
MARIADB_DATABASE: vendure
8888
MARIADB_USER: vendure
8989
MARIADB_PASSWORD: password
90+
# Ensure InnoDB is used for locking support
91+
MARIADB_MYSQL_LOCALHOST_USER: 1
92+
MARIADB_INITDB_SKIP_TZINFO: 1
9093
ports:
9194
- 3306
92-
options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3
95+
options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3 --command="mysqld --innodb_file_per_table=1 --default-storage-engine=InnoDB"
9396
mysql:
9497
image: vendure/mysql-8-native-auth:latest
9598
env:
@@ -146,39 +149,49 @@ jobs:
146149
- name: Build
147150
run: npx lerna run ci
148151
- name: Wait for services to be ready
152+
env:
153+
E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
154+
E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
155+
E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
156+
E2E_ELASTIC_PORT: ${{ job.services.elastic.ports['9200'] }}
157+
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
158+
DB: ${{ matrix.db }}
149159
run: |
150160
echo "Waiting for required services..."
151161
# Wait for redis
152-
for i in {1..60}; do
153-
if nc -z localhost $E2E_REDIS_PORT; then break; fi
162+
for i in {1..30}; do
163+
if nc -z localhost $E2E_REDIS_PORT; then echo "Redis Ready"; break; fi
164+
if [ $i -eq 30 ]; then echo "Redis Timeout"; exit 1; fi
154165
sleep 1
155166
done
156167
157168
# Wait for DB ports depending on matrix value
158169
if [ "$DB" = "postgres" ]; then
159-
for i in {1..60}; do
160-
if nc -z localhost $E2E_POSTGRES_PORT; then break; fi
170+
for i in {1..30}; do
171+
if nc -z localhost $E2E_POSTGRES_PORT; then echo "Postgres Ready"; break; fi
172+
if [ $i -eq 30 ]; then echo "Postgres Timeout"; exit 1; fi
161173
sleep 1
162174
done
163175
elif [ "$DB" = "mariadb" ]; then
164-
for i in {1..60}; do
165-
if nc -z localhost $E2E_MARIADB_PORT; then break; fi
176+
for i in {1..30}; do
177+
if nc -z localhost $E2E_MARIADB_PORT; then echo "MariaDB Ready"; break; fi
178+
if [ $i -eq 30 ]; then echo "MariaDB Timeout"; exit 1; fi
166179
sleep 1
167180
done
168181
elif [ "$DB" = "mysql" ]; then
169-
for i in {1..60}; do
170-
if nc -z localhost $E2E_MYSQL_PORT; then break; fi
182+
for i in {1..30}; do
183+
if nc -z localhost $E2E_MYSQL_PORT; then echo "MySQL Ready"; break; fi
184+
if [ $i -eq 30 ]; then echo "MySQL Timeout"; exit 1; fi
171185
sleep 1
172186
done
173187
fi
174188
175189
# Wait for Elasticsearch
176-
for i in {1..60}; do
177-
if curl --silent --fail http://localhost:$E2E_ELASTIC_PORT/_cluster/health >/dev/null 2>&1; then break; fi
190+
for i in {1..30}; do
191+
if curl --silent --fail http://localhost:$E2E_ELASTIC_PORT/_cluster/health >/dev/null 2>&1; then echo "Elasticsearch Ready"; break; fi
192+
if [ $i -eq 30 ]; then echo "Elasticsearch Timeout"; exit 1; fi
178193
sleep 1
179194
done
180-
181-
echo "Services appear reachable."
182195
- name: e2e tests
183196
env:
184197
E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
MARIADB_USER: vendure
1212
MARIADB_PASSWORD: password
1313
MARIADB_ROOT_PASSWORD: password
14+
command: ["mysqld", "--innodb_file_per_table=1", "--default-storage-engine=InnoDB"]
1415
volumes:
1516
- 'mariadb_data:/var/lib/mysql'
1617
ports:

e2e-common/test-config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ function getDbConfig(): DataSourceOptions {
9797
port: process.env.CI ? +(process.env.E2E_POSTGRES_PORT || 5432) : 5432,
9898
username: 'vendure',
9999
password: 'password',
100+
// Connection timeouts to prevent aborted connections
101+
connectTimeout: 60000,
102+
// Keep connections alive
103+
keepConnectionAlive: true,
104+
extra: {
105+
// Connection pool settings
106+
max: 10,
107+
idleTimeoutMillis: 30000,
108+
connectionTimeoutMillis: 60000,
109+
},
100110
};
101111
case 'mariadb':
102112
return {
@@ -106,6 +116,19 @@ function getDbConfig(): DataSourceOptions {
106116
port: process.env.CI ? +(process.env.E2E_MARIADB_PORT || 3306) : 3306,
107117
username: 'vendure',
108118
password: 'password',
119+
extra: {
120+
// Ensure tables use InnoDB for locking support
121+
initSql: "SET default_storage_engine=InnoDB;",
122+
// Connection pool settings
123+
connectionLimit: 10,
124+
waitForConnections: true,
125+
queueLimit: 0,
126+
},
127+
// Connection timeouts to prevent aborted connections
128+
connectTimeout: 60000,
129+
acquireTimeout: 60000,
130+
// Keep connections alive
131+
keepConnectionAlive: true,
109132
};
110133
case 'mysql':
111134
return {
@@ -115,6 +138,19 @@ function getDbConfig(): DataSourceOptions {
115138
port: process.env.CI ? +(process.env.E2E_MYSQL_PORT || 3306) : 3306,
116139
username: 'vendure',
117140
password: 'password',
141+
extra: {
142+
// Ensure tables use InnoDB for locking support
143+
initSql: "SET default_storage_engine=InnoDB;",
144+
// Connection pool settings
145+
connectionLimit: 10,
146+
waitForConnections: true,
147+
queueLimit: 0,
148+
},
149+
// Connection timeouts to prevent aborted connections
150+
connectTimeout: 60000,
151+
acquireTimeout: 60000,
152+
// Keep connections alive
153+
keepConnectionAlive: true,
118154
};
119155
case 'sqljs':
120156
default:

0 commit comments

Comments
 (0)