Skip to content

test: fix flaky tests caused by multithreaded tests #1334

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

Merged
merged 3 commits into from
Jun 5, 2025

Conversation

Alex-Izquierdo
Copy link
Collaborator

We have sporadic unexpected failures in tests. I think this is caused by test_job_uniqueness which uses multithreading and seems to interfere intermittently with other mocks. Since I could not found a way to avoid it or a better way to do this test (which I think right now is clean and reliable except for the mock interference) I think the best way is to just keep them separately, which is a good and common pattern in general.

It marks the test with a new marker "multithreaded" which is never executed by default. Then CI stuff is updated to execute both, default and multithreaded, separately.

Depends on #1333

Signed-off-by: Alex <aizquier@redhat.com>
@Alex-Izquierdo Alex-Izquierdo requested a review from a team as a code owner June 3, 2025 20:01
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.87%. Comparing base (3f44725) to head (31725db).

@@            Coverage Diff             @@
##             main    #1334      +/-   ##
==========================================
- Coverage   94.11%   93.87%   -0.25%     
==========================================
  Files         318      318              
  Lines       18662    18667       +5     
==========================================
- Hits        17564    17523      -41     
- Misses       1098     1144      +46     
Flag Coverage Δ
unit-int-tests-3.11 93.81% <100.00%> (-0.25%) ⬇️
unit-int-tests-3.12 93.87% <100.00%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/conftest.py 100.00% <100.00%> (ø)
tests/integration/test_advisory_lock.py 32.25% <100.00%> (-61.08%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kaiokmo kaiokmo self-requested a review June 4, 2025 11:13
@kaiokmo
Copy link
Member

kaiokmo commented Jun 5, 2025

@Alex-Izquierdo now that #1333 is merged, should we merge this one too?

@ptoscano
Copy link
Contributor

ptoscano commented Jun 5, 2025

@Alex-Izquierdo now that #1333 is merged, should we merge this one too?

Yeah, although there are conflicts to solve.

Copy link

sonarqubecloud bot commented Jun 5, 2025

@Alex-Izquierdo Alex-Izquierdo merged commit f01fbd6 into ansible:main Jun 5, 2025
7 checks passed
@Alex-Izquierdo Alex-Izquierdo deleted the fix-threading-tests branch June 5, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants