Skip to content

Commit

Permalink
[AIRFLOW-7054] Breeze has an option now to reset db at entry
Browse files Browse the repository at this point in the history
  • Loading branch information
potiuk committed Mar 13, 2020
1 parent 421e7a2 commit 4ba60f4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3 deletions.
7 changes: 7 additions & 0 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,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 @@ -120,6 +120,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 @@ -552,6 +555,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 @@ -1079,6 +1087,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 @@ -69,7 +69,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 @@ -79,7 +79,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
2 changes: 1 addition & 1 deletion tests/test_utils/system_tests_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def run_dag(self, dag_id: str, dag_folder: str = DEFAULT_DAG_FOLDER) -> None:
:param dag_folder: directory where to look for the specific DAG. Relative to AIRFLOW_HOME.
:type dag_folder: str
"""
if os.environ.get("RUN_AIRFLOW_1_10"):
if os.environ.get("RUN_AIRFLOW_1_10") == "true":
# For system tests purpose we are changing airflow/providers
# to side packages path of the installed providers package
python = f"python{sys.version_info.major}.{sys.version_info.minor}"
Expand Down

0 comments on commit 4ba60f4

Please sign in to comment.