Skip to content

Commit

Permalink
Add databricks workflow system to integration tests (#1565)
Browse files Browse the repository at this point in the history
We want to add the Databricks workflow system to our integration tests so that we can be notified in case of any failure during RC testing. This PR copies the Databricks workflow system test from the Airflow repo and integrates it with our integration tests.
  • Loading branch information
vatsrahul1001 authored Aug 27, 2024
1 parent e7e3f68 commit 8234cb7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions .circleci/integration-tests/Dockerfile.astro_cloud
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ RUN mkdir -p ${AIRFLOW_HOME}/dags
COPY . .
RUN cp -r example_* ${AIRFLOW_HOME}/dags
RUN cp master_dag.py ${AIRFLOW_HOME}/dags/
COPY databricks ${AIRFLOW_HOME}/dags/
RUN cp astronomer_migration_dag.py ${AIRFLOW_HOME}/dags/
RUN cp nuke-config.yml ${AIRFLOW_HOME}/dags/
# we have an issue with connexion==3.0.0, so for now pinning previous stable version
Expand Down
5 changes: 4 additions & 1 deletion .circleci/integration-tests/master_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def prepare_dag_dependency(task_info, execution_time):
chain(*kubernetes_trigger_tasks)

# Databricks DAG
databricks_task_info = [{"databricks_dag": "example_async_databricks"}]
databricks_task_info = [
{"databricks_dag": "example_async_databricks"},
{"databricks_workflow_dag": "example_databricks_workflow"},
]
databricks_trigger_tasks, ids = prepare_dag_dependency(databricks_task_info, "{{ ds }}")
dag_run_ids.extend(ids)
chain(*databricks_trigger_tasks)
Expand Down
2 changes: 1 addition & 1 deletion .circleci/integration-tests/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function clean() {
[[ -f ${SCRIPT_PATH}/setup.cfg ]] && rm "${SCRIPT_PATH}"/setup.cfg
[[ -f ${SCRIPT_PATH}/packages.txt ]] && rm "${SCRIPT_PATH}"/packages.txt
[[ -f ${SCRIPT_PATH}/requirements.txt ]] && rm "${SCRIPT_PATH}"/requirements.txt
find . -name "example_*" -exec rm {} \;
find . -name "example_*" ! -name "example_databricks_workflow.py" -exec rm {} \;
}

if [ "$1" == "-h" ]; then
Expand Down
32 changes: 32 additions & 0 deletions .github/scripts/refactor_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

import argparse


def remove_lines_after(file_path, target_line):
"""
Remove all lines in a file after the first occurrence of a specified target line.
This function reads a file and rewrites it, keeping only the lines up to and including
the first occurrence of the target line. All lines following the target line are removed.
Args:
file_path (str): The path to the file to be modified.
target_line (str): The line after which all content in the file should be removed.
"""
with open(file_path) as input_file:
lines = input_file.readlines()

with open(file_path, "w") as output_file:
for line in lines:
if target_line in line:
break
output_file.write(line)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("file_path", help="file path", type=str)
args = parser.parse_args()
target_line = "from tests.system.utils.watcher import watcher"
remove_lines_after(args.file_path, target_line)
9 changes: 9 additions & 0 deletions .github/workflows/reuse-wf-deploy-to-astro-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ jobs:
id: get_git_revision
run: echo "git_rev=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT


- name: Clone airflow and copy system tests
working-directory: .circleci/integration-tests
run: |
git clone https://github.com/apache/airflow.git
cp -r airflow/tests/system/providers/databricks .
python ../../.github/scripts/refactor_dag.py databricks/example_databricks_workflow.py
cat databricks/example_databricks_workflow.py
- name: deploy
working-directory: .circleci/integration-tests
run: |
Expand Down
1 change: 0 additions & 1 deletion dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ RUN apt-get install -y --no-install-recommends \
COPY setup.cfg ${AIRFLOW_HOME}/astronomer_providers/setup.cfg
COPY pyproject.toml ${AIRFLOW_HOME}/astronomer_providers/pyproject.toml


RUN pip install -e "${AIRFLOW_HOME}/astronomer_providers[all,tests,mypy]"
RUN pip install apache-airflow-providers-slack

Expand Down

0 comments on commit 8234cb7

Please sign in to comment.