Skip to content
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

Fix pytest plugin #43280

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

o-nikolas
Copy link
Contributor

@o-nikolas o-nikolas commented Oct 22, 2024

pytest plugins cannot be installed by a non-top-level conftest file. Now that provider tests are moved to a nested directory we need to plumb the plugin in a different way.

The plugin is now provided on the command line for breeze testing commands.

Also the config files which contain exceptions for forbidden_warnings were
set in pytest config in the conftest files. Since the plugin is now loaded at
the top-level and before conftest files are loaded. Move the config into the
python module for the plugin itself. There should be no harm in
configuring all exceptions for each test type. Each discovered test is just checked against the set of exceptions.


^ 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.

pytest plugins _cannot_ be installed by a non-top-level conftest file.
Now that provider tests are moved to a nested directory we need to plumb
the plugin in a different way.

The plugin is now provided on the command line for breeze testing
commands.
The config files which contain exceptions for forbidden_warnings were
set in pytest config in the conftest files. The plugin is now loaded at
the top-level and before conftest files are. Move the config into the
python module for the plugin itself. There should be no harm in
configuring all exceptions for each test type
@o-nikolas o-nikolas force-pushed the onikolas/fix_breeze_testing_test_aip_72 branch from 1163a12 to c71472e Compare October 24, 2024 03:27
@potiuk
Copy link
Member

potiuk commented Oct 24, 2024

Nice. I was wondering why we have warnings (yellow tests) back ... I think too much now happens in helm tests simply

@o-nikolas
Copy link
Contributor Author

Nice. I was wondering why we have warnings (yellow tests) back ... I think too much now happens in helm tests simply

@potiuk Yes this is to fix what was broken by Ash's changes to the directory structure (described in this comment). Every one of our system tests are currently failing for this reason.

I think my fix should solve it, but for some reason all the Helm chart tests are failing as a side-effect and I have ZERO ideas why. I cannot see how they are related...

@o-nikolas
Copy link
Contributor Author

Nice. I was wondering why we have warnings (yellow tests) back ... I think too much now happens in helm tests simply

@potiuk Yes this is to fix what was broken by Ash's changes to the directory structure (described in this comment). Every one of our system tests are currently failing for this reason.

I think my fix should solve it, but for some reason all the Helm chart tests are failing as a side-effect and I have ZERO ideas why. I cannot see how they are related...

Actually, when I run the tests locally on main it also fails. Which is a relief but also frustrating. How is main not more broken in the CI of all other PRs and Canary builds?

@potiuk
Copy link
Member

potiuk commented Oct 24, 2024

Actually, when I run the tests locally on main it also fails. Which is a relief but also frustrating. How is main not more broken in the CI of all other PRs and Canary builds?

As discussed in slack - and for posterity. This is another teeting problem after #42505 and later #43173.

It is the result of accidentally triggering database initialization for xdist (parallel) tests - in your PR by plugin initialization, in main runnnig when BACKEND != none.

A solution to that would be to force BACKEND to "none" and _AIRLFOW_SKIP_DB_TESTS to "true" in order to avoid all the DB autouse fixtures. But this is quite tricky as plugins passed with -p wil be initialized before conftest.py that could be used for it, also conftest.py cannot be put at top-level apparently because pytest has problems when several top-level tests folders have conftest.py - it will refuse to load them.

We need to find a better solution - likely use different mechanism of Pytest to do imports - likely https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html or maybe find some other creative ways of loading plugins from common place. Or maybe figure out a better way of sharing common test code.

@potiuk
Copy link
Member

potiuk commented Oct 24, 2024

cc: @ashb -> maybe you will have some ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants