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

Race condition in async tests #2119

Open
Tracked by #765
timobrembeck opened this issue Mar 14, 2023 · 2 comments
Open
Tracked by #765

Race condition in async tests #2119

timobrembeck opened this issue Mar 14, 2023 · 2 comments
Labels
🐛 bug Something isn't working ⁉️ prio: low Not urgent, can be resolved in the distant future. 😱 effort: high Big change, which requires >12h
Milestone

Comments

@timobrembeck
Copy link
Member

Describe the Bug

In some cases there seems to be a race condition in asynchronous tests again.

Steps to Reproduce

No deterministic way of reproducing this, but at least two workflow runs showed this behaviour:

Expected Behavior

Async tests should not influence the sync tests

Actual Behavior

Something goes wrong when specific tests are parallelized together with the async SUMM.AI test

Additional Information

Traceback
============================= test session starts ==============================
platform linux -- Python 3.9.16, pytest-7.2.2, pluggy-1.0.0
django: settings: integreat_cms.core.circleci_settings (from option)
rootdir: /home/circleci/project
plugins: circleci-parallelized-0.1.0, cov-4.0.0, django-4.5.2, icdiff-0.6, testmon-1.4.5, xdist-3.2.0, requests-mock-1.10.0
collecting 2499 items                                                          No timing found for "test_recurrence_rule.TestCreatingIcalRule"
collected 2499 items                                                           
running 69 items due to CircleCI parallelism

tests/summ_ai_api/summ_ai_test.py ......................                 [ 31%]
tests/api/test_api_result.py .....................................       [ 85%]
tests/cms/views/test_public_view_status_code.py ....                     [ 91%]
tests/core/management/commands/test_summ_ai_bulk.py ..

Too long with no output (exceeded 10m0s): context deadline exceeded

This is probably a similar problem like the one fixed in #1787.

@timobrembeck timobrembeck added 🐛 bug Something isn't working ⁉️ prio: low Not urgent, can be resolved in the distant future. 😱 effort: high Big change, which requires >12h labels Mar 14, 2023
@timobrembeck timobrembeck added this to the Backlog milestone Mar 14, 2023
@timobrembeck
Copy link
Member Author

timobrembeck commented Mar 14, 2023

The underlying problem: summ_ai_enabled is set to True in async mode while other sync tests expect the value to be False (like in the test data) and the sync tests start before the test db is reset after the async test is finished.

This is a problem when these two tests are assigned to the same container on CircleCI.

Approaches I tried that all didn't work:

  • Rewrite the async tests as sync (didn't work because aiohttp didn't work with asyncio.run(aiohttp_raw_server(fake_summ_ai_server)))
  • Wrap the async tests in sync wrappers (didn't work as well, not sure why)
  • Wrapping the async code in async.Lock (didn't work because the sync code can't aquire the lock)
  • Wrapping the async tests in asgiref.sync.async_to_sync (the tests were just ignored)

I temporarily disabled the corresponding test case in d912d60 to prevent further CI errors for the moment. Enable them again when you want to reproduce the problem.

@seluianova
Copy link
Contributor

Maybe we should deal with such issues by separating the data?
Let's say: each async test should only use data, that is not used by other tests (separate regions, separate pages, etc.)

If we move our SUMM AI tests to a new region, test_summ_ai_bulk_disabled_region will work.
We could also fix test_summ_ai_bulk_disabled_region by using nurnberg instead of augsburg, but I think it's better to change SUMM AI tests to avoid similar problems in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working ⁉️ prio: low Not urgent, can be resolved in the distant future. 😱 effort: high Big change, which requires >12h
Projects
None yet
Development

No branches or pull requests

2 participants