Skip to content

Commit

Permalink
Merge pull request #125 from hathitrust/remove-wait-for
Browse files Browse the repository at this point in the history
Use healthcheck instead of wait-for
  • Loading branch information
aelkiss authored May 24, 2024
2 parents e704057 + 4c31aef commit 68ac0de
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- uses: actions/checkout@v4

- name: Build docker image
run: docker compose --file docker-compose.test.yml build
run: docker compose build

- name: Run tests
run: docker compose --file docker-compose.test.yml run sut
run: docker compose run test-and-cover
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
4 changes: 0 additions & 4 deletions bin/test_and_cover.sh

This file was deleted.

118 changes: 0 additions & 118 deletions bin/wait-for

This file was deleted.

50 changes: 0 additions & 50 deletions docker-compose.test.yml

This file was deleted.

65 changes: 57 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
version: '3'
---

x-condition-healthy: &healthy
condition: service_healthy

x-healthcheck-defaults: &healthcheck-defaults
interval: 5s
timeout: 10s
start_period: 10s
retries: 5

services:

Expand All @@ -10,15 +19,43 @@ services:
environment:
- HTFEED_CONFIG=/usr/local/feed/etc/config_test.yml
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
- PUSHGATEWAY=http://pushgateway:9091
- TEST=1
command: prove
depends_on:
mariadb: *healthy
minio: *healthy
pushgateway: *healthy
rabbitmq: *healthy

# Note: for permissions purposes this does NOT bind in the local development
# environment, so local changes after running docker compose build will NOT
# be reflected.
test-and-cover:
build: .
volumes:
- ./clamav:/var/lib/clamav
environment:
- HTFEED_CONFIG=/usr/local/feed/etc/config_test.yml
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
- PUSHGATEWAY=http://pushgateway:9091
command: bin/wait-for --timeout=300 mariadb:3306 minio:9000 pushgateway:9091 rabbitmq:5672 -- prove
- TEST=1
# pass through info needed by coveralls uploader
- GITHUB_TOKEN
- GITHUB_RUN_ID
- GITHUB_EVENT_TOKEN
- GITHUB_EVENT_PATH
- GITHUB_SHA
- GITHUB_REF
- GITHUB_ACTIONS
command: cover -test -report Coveralls -make 'prove; exit $?'
depends_on:
- mariadb
- minio
- pushgateway
- rabbitmq
mariadb: *healthy
minio: *healthy
pushgateway: *healthy
rabbitmq: *healthy

ingest:
build: .
Expand All @@ -40,7 +77,7 @@ services:
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
depends_on:
- mariadb
mariadb: *healthy

validate:
build: .
Expand All @@ -53,7 +90,7 @@ services:
- VERSION=feed-development
command: bash -c "/bin/ls /tmp/stage/toingest/test/*.zip | xargs -n 1 basename | sed s/.zip// | perl -w /usr/local/feed/bin/validate_volume.pl -p simple -n test --no-clean"
depends_on:
- mariadb
mariadb: *healthy

mariadb:
image: ghcr.io/hathitrust/db-image:latest
Expand All @@ -62,6 +99,9 @@ services:
restart: always
environment:
MYSQL_ROOT_PASSWORD: mysqlroot
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized"]

# S3 compatible object storage
minio:
Expand All @@ -71,16 +111,25 @@ services:
MINIO_ACCESS_KEY: TESTINGACCESSKEY
MINIO_SECRET_KEY: testingsecretkey
command: server /data
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "/usr/bin/curl", "-s", "-f", "http://localhost:9000/minio/health/live"]

pushgateway:
image: prom/pushgateway
command:
- --web.enable-admin-api
ports:
- "9091:9091"
healthcheck:
<<: *healthcheck-defaults
test: [ "CMD", "wget", "--quiet", "--tries=1", "-O", "/dev/null", "pushgateway:9091/-/healthy" ]

rabbitmq:
image: rabbitmq
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "rabbitmqctl", "status"]

volumes:
repository_link:
Expand Down

0 comments on commit 68ac0de

Please sign in to comment.