-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Run system tests using dag.test()
#39176
Conversation
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'm not sure what the solution is, but I believe the reason the test does not pass is because pytest, which is running the test, exits out once it receives an Exception, which is what happens when a task is deferred. We know that when a Task is Deferred, it raises the TaskDeferred Exception. We would need to catch that Exception, and process it differently.
Here's an example that might be useful: #37542
It's because System Tests use Proper way would likely be to change System Tests to use That would even enable to remove DebugExecutor because this is the last thing it is used for. |
I think |
This is how system tests are run currently: https://github.com/apache/airflow/blob/main/tests/system/utils/__init__.py#L34 |
I see! Stupid question: why dont we use the EDIT: nevermind, your solution is even easier. Looking good. |
a4fb824
to
3003562
Compare
The problem I have now (I updated the code) is the DAG always succeed, even though when it should fail. I guess the |
The |
99a8acf
to
cf01df7
Compare
dag.test()
Thanks @potiuk for the information! That helps. I have an implementation working, could you take a look? |
cf01df7
to
5e5c288
Compare
I ran all AWS system tests using this and they all succeeded. I also tested the negative case by "breaking" some system tests. All seems fine |
Looks good then. |
Question on this one though. From the doc it says, |
It's a completely different mechanism - it just runs If you run it with a different executor, what you really need you need to run Airflow Scheduler with the executor and you need to trigger the DAG (via APi or CLI). You should not really use Pytest for that. Previously backfill was used to run the dags (this is how Debug Executor worked) - but that was a feature of Debug Executor - if you have ECS executor, then having scheduler to run the DAG is probably much better. |
Just for testing, I tried to run a system test with the backfill approach with
Edit: nevermind, it does not work. I'll go with the scheduler option |
Thought so :) |
Resolves #31826
Related and continuation of #36236
Deferrable operators cannot be run by
DebugExecutor
.DebugExecutor
is the default executor when running system tests. The purpose of this PR is to no longer useDebugExecutor
for system tests butdag.test()
. See https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/debug.html#testing-dags-with-dag-test^ 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.rst
or{issue_number}.significant.rst
, in newsfragments.