ansible / ansible-runner

A tool and python library that helps when interfacing with Ansible directly or as part of another system whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible.
Other
969 stars 357 forks source link

Tests hanging indefinitely with 2.4.0 (running fine with 2.3.6)? #1369

Closed johanneskastl closed 6 months ago

johanneskastl commented 6 months ago

Hi,

I am packaging ansible-runner for openSUSE. The update to 2.4.0 leads to failed builds, as the tests never finish.

We are running the tests differently due to the offline requirements in OBS, but this far everything worked fine (we excluded some checks and the builds passed).

This is the last output before the builds hang:

[  224s] SKIPPED [1] test/unit/test_runner.py:165: Writing to stdout can be flaky, probably due to some pexpect bug
[  224s] ========== 2083 passed, 61 skipped, 7 deselected in 184.48s (0:03:04) ==========

Any ideas where I could start looking? Did you experience something like this before?

Kind Regards, Johannes

Shrews commented 6 months ago

We have not experienced this and no idea to tell you where to start looking, especially if you are not running our tests as we have designed them to be run. The biggest change to 2.4 is to move the minimum python to 3.9 and a change to use setuptools_scm instead of pbr.

johanneskastl commented 6 months ago

Thanks for taking the time to answer, it was worth a shot. I'll try to figure out where this comes from.

Thanks for your help!

johanneskastl commented 5 months ago

For the record: A nice packager colleague helped me, apparently the missing bit was to use pytest -n auto ...

AdamWill commented 5 months ago

Hmmm. We just ran into this on Fedora, as well. We did not change our spec file except to bump the ansible-runner version; with both 2.3.6 and 2.4.0 we had BuildRequires: python3dist(pytest-xdist) but were not running the tests with -n auto. This worked fine with 2.3.6 but causes an indefinite hang at the end of the test suite with 2.4.0.

With -n auto added, it still pauses for several seconds after posting the result summary, but eventually exits. This still isn't normal.

In fact, if I drop the build dependency on xdist entirely - so it is not present in the build environment, and running with -n auto causes a pytest error - the hang still happens. It seems like using xdist and -n auto is only really working around the issue somehow, not fixing it.

The hang is specifically caused by test_prepare_env_sshkey from test/unit/config/test__base.py . Without that one test, pytest exits immediately after printing the result summary.

I don't know exactly why this happens, though :/