From 1377058c8c8215eb71cb57ed9d99866364ba3dd9 Mon Sep 17 00:00:00 2001 From: Zhuoyun Wei Date: Sun, 9 Jul 2023 00:34:32 -0700 Subject: [PATCH] test: docker compose wait until healthy --- .github/workflows/pytest.yaml | 4 +--- tests/elasticsearch/docker-compose.yaml | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index c6d0fd7..a93b49f 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -22,9 +22,7 @@ jobs: - name: Setup Elasticsearch run: | pushd tests/elasticsearch - docker compose up -d - # wait until up - docker inspect --format '{{ .NetworkSettings.IPAddress }}:9200' es01 | xargs wget --retry-connrefused --tries=5 -q --wait=3 --spider + docker compose up -d --wait popd - name: Run pytest diff --git a/tests/elasticsearch/docker-compose.yaml b/tests/elasticsearch/docker-compose.yaml index c6e4c2d..d0efacb 100644 --- a/tests/elasticsearch/docker-compose.yaml +++ b/tests/elasticsearch/docker-compose.yaml @@ -1,4 +1,4 @@ -version: '2.2' +version: '3' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3 @@ -9,3 +9,9 @@ services: - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ports: - 9200:9200 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9200"] + interval: 10s + timeout: 1s + retries: 6 + start_period: 20s