diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 317a22916bad09bef176445ff24de13cdfdf3c08..11ca0c7eea2a5ac4ac83ed38f753aa5177f13e2d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -193,9 +193,8 @@ python tests: NOMAD_KEYCLOAK_PASSWORD: ${CI_KEYCLOAK_ADMIN_PASSWORD} NOMAD_NORMALIZE_SPRINGER_DB_PATH: /nomad/fairdi/db/data/springer.msg before_script: - - sleep 10 - - curl http://elastic:9200/_cat/health - cd /app + - scripts/check_elastic.sh script: - python -m pytest --cov=nomad --cov-report term --cov-report xml:coverage.xml --cov-config=.coveragerc -sv tests after_script: diff --git a/scripts/check_elastic.sh b/scripts/check_elastic.sh new file mode 100755 index 0000000000000000000000000000000000000000..421ab5c22c1c9c52e5b18bc14912afa8c5d04f1c --- /dev/null +++ b/scripts/check_elastic.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +interval=8 + +while true; do + echo "Checking if the cluster is green in $interval seconds..." + sleep $interval + result=$(curl -s http://elastic:9200/_cat/health | awk '{print $4}') + if [ "$result" == "green" ]; then + exit 0 + fi + # double the interval if the cluster is not green + interval=$((interval * 2)) + if [ $interval -gt 120 ]; then + echo "Cluster is not green after 2 minutes." + exit 1 + fi +done