Skip to content

Commit

Permalink
Test script tries to reset db regardless of db check (#8403)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 33229f9188cce81fb3b5c34834b8ea1f9138603b
  • Loading branch information
potiuk authored and Cloud Composer Team committed Sep 11, 2024
1 parent f042656 commit 4230187
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions scripts/ci/in_container/check_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
# shellcheck source=scripts/ci/in_container/_in_container_script_init.sh
. "$( dirname "${BASH_SOURCE[0]}" )/_in_container_script_init.sh"

export EXIT_CODE=0
export DISABLED_INTEGRATIONS=""
EXIT_CODE=0
DB_EXIT_CODE=0

DISABLED_INTEGRATIONS=""

function check_integration {
INTEGRATION_NAME=$1
Expand Down Expand Up @@ -65,7 +67,7 @@ function check_integration {
echo
echo "${LAST_CHECK_RESULT}"
echo
export EXIT_CODE=${RES}
EXIT_CODE=${RES}
fi
echo "-----------------------------------------------------------------------------------------------"
}
Expand Down Expand Up @@ -114,7 +116,7 @@ function check_db_connection {
echo
echo "${LAST_CHECK_RESULT}"
echo
export EXIT_CODE=${RES}
DB_EXIT_CODE=${RES}
fi
echo "-----------------------------------------------------------------------------------------------"
}
Expand Down Expand Up @@ -182,6 +184,7 @@ function resetdb() {
airflow db reset -y
fi
fi
return $?
}

if [[ -n ${BACKEND:=} ]]; then
Expand Down Expand Up @@ -217,15 +220,21 @@ check_integration rabbitmq "nc -zvv rabbitmq 5672" 20
check_integration cassandra "nc -zvv cassandra 9042" 20
check_integration openldap "nc -zvv openldap 389" 20

resetdb

if [[ ${EXIT_CODE} != 0 ]]; then
echo
echo "Error: some of the CI environment failed to initialize!"
echo
exit ${EXIT_CODE}
fi

# Try to reset the database regardless of DB_EXIT_CODE. If this fails, the whole script will fail
resetdb

if [[ ${DB_EXIT_CODE} != "0" ]]; then
echo
echo "Test of DB connectivity failed, but then managed to connect and reset the DB. Proceeding.".
echo
fi

if [[ ${DISABLED_INTEGRATIONS} != "" ]]; then
echo
Expand Down

0 comments on commit 4230187

Please sign in to comment.