Skip to content

Commit

Permalink
Fix flakyness in e2e test setup
Browse files Browse the repository at this point in the history
Docker compose does not care about exit codes of jobs. Migration runner
failed sometimes, perhaps because DB was not ready.

Added a check for migration-runner exit code in e2e start script.

Added a healthcheck for db in compose, and require it to be healthy
before migration runner is run.
  • Loading branch information
solita-antti-mottonen committed Mar 11, 2024
1 parent dfc886a commit 1c7133b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/cypress/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ services:
./db.sh migrate dev
depends_on:
db:
condition: service_started
condition: service_healthy
2 changes: 1 addition & 1 deletion e2e-tests/cypress/start-e2e-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -euxo pipefail
# Start backend and wait for it and frontend to be ready

docker compose up --build -d frontend
docker compose up --build migration-runner
docker compose up --build migration-runner --exit-code-from migration-runner
docker compose exec db dropdb -U postgres cypress_test --if-exists --force
docker compose exec db createdb -U postgres -T etp_dev cypress_test
echo -e "\e[1;33m Waiting for frontend to be healthy. Can take ~20s. \e[0m"
Expand Down
5 changes: 5 additions & 0 deletions etp-core/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ services:
- 127.0.0.1:5432:5432
environment:
POSTGRES_PASSWORD: etp
healthcheck:
test: pg_isready -U postgres
interval: 1s
timeout: 5s
retries: 30

admin:
image: dpage/pgadmin4
Expand Down

0 comments on commit 1c7133b

Please sign in to comment.