Skip to content

Commit

Permalink
Introduce waits
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet-q committed Apr 17, 2024
1 parent 82188da commit cfcd260
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/manual-all-engines-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
compose-file: "engine/servers/elasticsearch-single-node/docker-compose.yaml"
- name: Execution
run: |
bash -x tools/wait_for_elasticsearch_green_status.sh
source $(poetry env info -p)/bin/activate
poetry run python3 run.py --engines "elasticsearch-default" --datasets "random-100"
Expand Down Expand Up @@ -86,6 +87,7 @@ jobs:
compose-file: "engine/servers/opensearch-single-node/docker-compose.yaml"
- name: Execution
run: |
bash -x tools/wait_for_opensearch.sh
source $(poetry env info -p)/bin/activate
poetry run python3 run.py --engines "opensearch-default" --datasets "random-100"
Expand Down
31 changes: 31 additions & 0 deletions tools/wait_for_elasticsearch_green_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -e

ES_HOST=${1:-"localhost:9200"}

until $(curl --output /dev/null --silent --head --fail "$ES_HOST"); do
printf '.'
sleep 1
done

# Wait for ES to start...
response=$(curl "$ES_HOST")
until [ "$response" = "200" ]; do
response=$(curl --write-out %{http_code} --silent --output /dev/null "$ES_HOST")
>&2 echo "Elastic Search is unavailable - sleeping"
sleep 1
done

# Wait for ES status to turn to Green
health="$(curl -fsSL "$ES_HOST/_cat/health?h=status")"
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")

until [ "$health" = 'green' ]; do
health="$(curl -fsSL "$ES_HOST/_cat/health?h=status")"
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
>&2 echo "Elastic Search is unavailable - sleeping"
sleep 1
done

>&2 echo "Elastic Search is up"
10 changes: 10 additions & 0 deletions tools/wait_for_opensearch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

ES_HOST=${1:-"localhost:9200"}

until $(curl --output /dev/null --silent --head --fail "$ES_HOST"); do
printf '.'
sleep 1
done

0 comments on commit cfcd260

Please sign in to comment.