-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Update Dag.test()
to run with an executor if desired
#40205
Conversation
07e8134
to
73cc3a5
Compare
Looks very cool. Apart of getting support for other commands for |
…g non-db-tests` and `breeze shell`
That's a good idea, I added a section about it. Let me know your thoughts :) |
I am currently testing with
Currently investigating, if someone has an idea, please share :) |
The guilty is ... https://github.com/apache/airflow/blob/main/airflow/cli/commands/task_command.py#L470. If I comment it out, it is still failing for the same reason but one task further. The first task succeeds, and then the second one fails for the same reason.
|
Still having this problem? |
Yep, I'll create an issue and work on it separately. I have the issue with Celery as well, I think this is an issue with every executor running locally. They somehow shutdown the DB connection somewhere while executing the task, which then make |
Issue created to track the bug with local executors: #40247 |
Do you think we can still merge the PR @potiuk? It is working only with non local executors. |
Merged. |
* Update `Dag.test()` to run with an executor if desired * Add missing parameter * Fix typo * Move `add_logger_if_needed` to local execution * Add `keep-env-variables` to `breeze testing db-tests`, `breeze testing non-db-tests` and `breeze shell` * Add documentation * Fix tests * Introduce `use-executor` flag * Update `debug` documentation * Fix test
Dag.test()
allows testing a DAG locally. See documentation.Dag.test()
uses no scheduler and no executor to run the task. It runs just all the task instances of the DAG in the current process.This PR extends
Dag.test()
functionality to add capability of testing a DAG with an executor. If a different executor thanLocalExecutor
is configured in config, then it will use this executor to run the DAG. By default,pytest
erases all environment variables before executing tests, thus I introduced a new flag to disable this behavior if desired:--keep-env-variables
.For example, the command below executes successfully the system test
tests/system/providers/amazon/aws/example_sns.py
with a different executor thanLocalExecutor
. Here my Airflow environment was configured to useAwsEcsExecutor
but it could have been another one.breeze testing tests tests/system/providers/amazon/aws/example_sns.py --system amazon --keep-env-variables --test-type System --forward-credentials --test-timeout 500
.^ 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.