-
Notifications
You must be signed in to change notification settings - Fork 427
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
Reduce flakiness of CI test runs #4653
Reduce flakiness of CI test runs #4653
Conversation
5d89c95
to
65abf81
Compare
a565200
to
330a777
Compare
330a777
to
8f6bfb4
Compare
Comments copied from gh-4652:
|
(Added description/motivation to the OP.) |
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.
Thank you for working on this @mbargull!
I don't think your approach with rewriting the function defaults for conda_build.api
is a good pattern and could be achieved by a more mundane monkey patching of the conda_build.config.get_or_merge_config
function, to be automatically returning the appropriate test config.
While I enjoy seeing the use of pytestmark
, I agree that it'll likely be forgotten by future contributors when adding new tests, creating rather unpleasant implicit differences in behavior again, increasing the risk of concurrency issues.
I would suggest to indeed use autouse=True
to automatically enable the test config, if you think the majority of test modules need it (as it seems) and instead try to find a way to disable it when needed.
Haha, and that's what I get to only look at level
Okay, I guess |
2ba8bad
to
efe302f
Compare
Oops, conda-build keeps on giving 🤣
Hmm, yeah, let's see what the impact on runtime is for that |
25293a5
to
a29a4be
Compare
a29a4be
to
0f4becf
Compare
Seems like it's only one test failing now! |
msumastro has been updated a couple of days ago and versions >=1.2 now store the metadata in setup.cfg which is not handled by skeletons.pypi. It is easy to fix this if we reuse the code from _load_setup_py_data but we might as well use/advertize newer projects like grayskull instead.
Ha! That was a sneaky PyPI update since Saturday 😁 . |
This is now a much smaller and cleaner change set with which I'm content :). @jezdez, thanks for your thorough and thoughtful review, I appreciate it! |
Remaining failure is the permission error on Windows during |
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.
Reran failed test, seems to be passing now
Looks like @pytest.fixture(scope="function", autouse=True)
def default_testing_config(testing_config, monkeypatch, request): doesn't work (reliably/at all?): #4665 (comment) |
The default_testing_config monkeypatching fixture was added in condagh-4653 but did not consider "from .config import get_or_merge_config" cases in which get_or_merge_config is already bound and thus not patched. Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
The default_testing_config monkeypatching fixture was added in condagh-4653 but did not consider "from .config import get_or_merge_config" cases in which get_or_merge_config is already bound and thus not patched. Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
* Fix testing config monkeypatch for concurrent test flakiness The default_testing_config monkeypatching fixture was added in gh-4653 but did not consider "from .config import get_or_merge_config" cases in which get_or_merge_config is already bound and thus not patched. * main_build: Construct config via get_or_merge_config Helps tests with default_testing_config monkeypatch. * Tests: Don't preset values for get_or_merge_config Otherwise default values set for testing_config before, e.g., environment variable-dependent config can be set in the tests. Example: tests/cli/test_main_build.py::test_conda_py_no_period failed since it sets CONDA_PY=36 but testing_config already had set it before. --------- Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Description
I started to include unrelated test fixes in #4650 to easier inspect failing/passing of relevant tests.
Those started to grow and it's cleaner to have them separated, anyway, so here we go.
What is the main change/result? (See details/motivation below.)
I went back an forth between having a fixture to add
config=testing_config
either completely implicit (autouse=True
) or have it explicitly added to each and every test to make its use obvious.Now I went the middle ground with
pytestmark = pytest.mark.usefixtures("api_default_testing_config")
to explicitly request the fixture for a test module but not on the single test level. If one wants to deactivate it for a single test but still use it for all other tests in a module, they can@pytest.mark.no_api_default_testing_config
such test.What is the overall motivation and why this back and forth, then middle ground, anyway?
The main cause of the tests' flakiness (apart from CRAN connection and occasional
pip
%TEMP%
permission errors on Windows) is that the parallel tests ought to write to separate locations but in reality most don't.The mechanism to have them use separate locations is the
testing_config
fixture which setsConfig.croot
to a temporary directory.So nearly all tests should explicitly run
function(..., config=testing_config)
for allfunction
s that take aconfig
parameter.But actually, many don't, so they can occasionally run into concurrent write conflicts (see #4653 (comment) ).
Hence, the obvious fix is to add
config=testing_config
to all those tests.That results in a large change set with somewhat verbose code, but is also not future-proof (since I expect it'll be forgotten to be added for newer tests again in the future).
The other solution is to have
config=testing_config
always unconditionally, implicitly used.The downside with that is that it adds more hidden/non-obvious behavior.
The proposed change is to not go full explicit- but also not full-implicit mode by adding a fixture that can be
@pytest.mark.usefixtures("api_default_testing_config")
,pytestmark = pytest.mark.usefixtures("api_default_testing_config")
,@pytest.mark.no_api_default_testing_config
.Checklist - did you ...
news
directory (using the template) for the next release's release notes?