diff --git a/.github/workflows/manual-all-engines-benchmark.yaml b/.github/workflows/manual-all-engines-benchmark.yaml index 994d6e49..4c9ebad6 100644 --- a/.github/workflows/manual-all-engines-benchmark.yaml +++ b/.github/workflows/manual-all-engines-benchmark.yaml @@ -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" @@ -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" diff --git a/tools/wait_for_elasticsearch_green_status.sh b/tools/wait_for_elasticsearch_green_status.sh new file mode 100755 index 00000000..e028eee7 --- /dev/null +++ b/tools/wait_for_elasticsearch_green_status.sh @@ -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" \ No newline at end of file diff --git a/tools/wait_for_opensearch.sh b/tools/wait_for_opensearch.sh new file mode 100755 index 00000000..f531b74e --- /dev/null +++ b/tools/wait_for_opensearch.sh @@ -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 \ No newline at end of file