Skip to content

Commit

Permalink
[AIRFLOW-7054] Breeze has an option now to reset db at entry (#7710)
Browse files Browse the repository at this point in the history
(cherry picked from commit a86924f)
  • Loading branch information
potiuk authored and kaxil committed Mar 19, 2020
1 parent aaf1cc9 commit 46b8966
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,13 @@ This is the current syntax for `./breeze <./breeze>`_:
Default: sqlite
-d, --db-reset
Resets the database at entry to the envvironment. It will drop all the tables
and data and recreate the DB from scratch even if 'restart' command was not used.
Combined with 'restart' command it enters the environment in the state that is
ready to start airflow webserver/scheduler/worker. Without the switch, the database
does not have any tables and you need to run reset db manually.
-i, --integration <INTEGRATION>
Integration to start during tests - it determines which integrations are started
for integration tests. There can be more than one integration started, or all to
Expand Down
15 changes: 15 additions & 0 deletions breeze
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function setup_default_breeze_variables() {
# Forward credentials to docker
export FORWARD_CREDENTIALS="false"

# Reset DB at entry
export DB_RESET="false"

# If install released airflow is set to specified version, then the source version of airflow
# is removed and the specified version of airflow is installed from pypi
export INSTALL_AIRFLOW_VERSION=${INSTALL_AIRFLOW_VERSION:="current"}
Expand Down Expand Up @@ -553,6 +556,11 @@ function parse_arguments() {
echo "Installs version of Airflow: ${INSTALL_AIRFLOW_VERSION}"
echo
shift 2 ;;
-d|--db-reset)
echo "Resetting the DB!"
echo
export DB_RESET="true"
shift 1 ;;
-v|--verbose)
export VERBOSE="true"
echo "Verbose output"
Expand Down Expand Up @@ -1080,6 +1088,13 @@ ${ALLOWED_BACKENDS}
Default: ${_BREEZE_DEFAULT_BACKEND:=}
-d, --db-reset
Resets the database at entry to the envvironment. It will drop all the tables
and data and recreate the DB from scratch even if 'restart' command was not used.
Combined with 'restart' command it enters the environment in the state that is
ready to start airflow webserver/scheduler/worker. Without the switch, the database
does not have any tables and you need to run reset db manually.
-i, --integration <INTEGRATION>
Integration to start during tests - it determines which integrations are started
for integration tests. There can be more than one integration started, or all to
Expand Down
4 changes: 2 additions & 2 deletions breeze-complete
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ _BREEZE_SHORT_OPTIONS="
h p: b: i:
K: V:
s x r
l a:
l a: d:
v y n q f
F P C L
D: R: -u
Expand All @@ -61,7 +61,7 @@ _BREEZE_LONG_OPTIONS="
help python: backend: integration:
kubernetes-mode: kubernetes-version:
kind-cluster-start kind-cluster-stop kind-cluster-recreate
skip-mounting-local-sources install-airflow-version:
skip-mounting-local-sources install-airflow-version: db-reset
verbose assume-yes assume-no assume-quit forward-credentials
force-build-images force-pull-images force-clean-images use-local-cache
dockerhub-user: dockerhub-repo: push-images
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/docker-compose/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ services:
- RUN_INTEGRATION_TESTS
- BREEZE
- INSTALL_AIRFLOW_VERSION
- DB_RESET
- ENABLED_SYSTEMS
- RUN_SYSTEM_TESTS
volumes:
Expand Down
13 changes: 13 additions & 0 deletions scripts/ci/in_container/check_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ function check_mysql_logs {
done
}

function resetdb() {
if [[ ${DB_RESET:="false"} == "true" ]]; then
if [[ ${RUN_AIRFLOW_1_10} == "true" ]]; then
airflow resetdb -y
else
airflow db reset -y
fi
fi
}

if [[ -n ${BACKEND:=} ]]; then
echo "==============================================================================================="
echo " Checking backend: ${BACKEND}"
Expand Down Expand Up @@ -200,13 +210,16 @@ 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


if [[ ${DISABLED_INTEGRATIONS} != "" ]]; then
echo
echo "Disabled integrations:${DISABLED_INTEGRATIONS}"
Expand Down
3 changes: 3 additions & 0 deletions scripts/ci/in_container/entrypoint_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ else
install_released_airflow_version "${INSTALL_AIRFLOW_VERSION}"
fi


export RUN_AIRFLOW_1_10=${RUN_AIRFLOW_1_10:="false"}

export HADOOP_DISTRO="${HADOOP_DISTRO:="cdh"}"
export HADOOP_HOME="${HADOOP_HOME:="/opt/hadoop-cdh"}"

Expand Down

0 comments on commit 46b8966

Please sign in to comment.