-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Add e2e tests for dag test #59997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add e2e tests for dag test #59997
Conversation
- Add test_dag_test_simple.py: Simple linear DAG with bash and Python tasks - Add test_dag_test_xcom.py: DAG demonstrating XCom passing between tasks - Add test_dag_test_branching.py: DAG with branching logic using BranchPythonOperator - Add test_dag_test_task_groups.py: DAG with nested task groups These DAGs will be used to test dag.test() method in e2e environment.
- Add comprehensive test suite for dag.test() with use_executor=True and False - Test simple DAG, XCom passing, branching, and task groups scenarios - Execute tests inside Airflow scheduler container using exec_in_container - Validate DagRun state and all task instance states after execution Fixes apache#59319
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
| from airflow_e2e_tests.conftest import _E2ETestState | ||
|
|
||
|
|
||
| def _execute_dag_test(dag_id: str, use_executor: bool = False) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to follow the existed e2e test convention as example. So instead of defining explicit ORM session query python code as str, we could take airflow-e2e-tests/tests/airflow_e2e_tests/remote_log_tests/test_remote_logging.py as example then use AirflowClient instead of the python code as string pattern here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for review : new commit 2c8bacf
| from airflow.providers.standard.operators.python import BranchPythonOperator | ||
| from airflow.sdk import DAG, task | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these example dags, not sure would it be a good idea to just add symbolic link for existing example dag (e.g. airflow-core/src/airflow/example_dags/example_xcom.py )
cc @gopidesupavan WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the example dags will be loaded part of airflow e2e tests as we use this file https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/docker-compose/docker-compose.yaml#L65 and it has load_examples set it true.
So its better to use those example dags to test. @Shekharrajak can you please use the existing example dags instead of creating new ones..
closes: #59319
Summary
Adds end-to-end (E2E) tests for
dag.test()method, especially validatinguse_executor=Truemode which was previously untested in E2E environment.What's Changed
airflow-e2e-tests/tests/airflow_e2e_tests/basic_tests/test_dag_test_method.pytest_dag_test_simple.py: Linear DAG executiontest_dag_test_xcom.py: XCom passing between taskstest_dag_test_branching.py: Conditional execution pathstest_dag_test_task_groups.py: Nested task groupsTesting
dag.test()inside Airflow scheduler container viatestcontainersuse_executor=Falseanduse_executor=Truemodesbreeze testing airflow-e2e-tests --python 3.10 -- tests/airflow_e2e_tests/basic_tests/test_dag_test_method.py -vtests passed .^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.