-
Notifications
You must be signed in to change notification settings - Fork 13
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
Pass async to tests, parallelizing them #405
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PragTob
force-pushed
the
async-tests
branch
2 times, most recently
from
October 5, 2024 07:33
11ee3bd
to
707559e
Compare
Ah nice it caught a test that's not fully async safe:
log capturing may capture logs from other processes. Fix is either:
|
Tests run sync by default. But all of Elixir, essentially, is built to run tests in parallel/async. Unless you mess with the global environment there's usually no reason not to run tests in parallel and it's also best practice to always pass either `async: true` or `async: false` and a reason why they can't be run in parallel. Speeds up the test suite, admittedly not by a lot right now but it's nice. I didn't check all the tests for global state, so this may introduce flakies but on a first couple of runs everything seemed fine. async: ``` root@812d17669fe3:/app# mix test *********.................................................................................................................................................... Finished in 0.7 seconds (0.7s async, 0.00s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 325387 root@812d17669fe3:/app# mix test ***.******................................................................................................................................................... Finished in 0.6 seconds (0.6s async, 0.00s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 874856 root@812d17669fe3:/app# mix test *********.................................................................................................................................................... Finished in 0.7 seconds (0.7s async, 0.00s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 194987 root@812d17669fe3:/app# mix test *********.................................................................................................................................................... Finished in 0.6 seconds (0.6s async, 0.00s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 426291 root@812d17669fe3:/app# mix test ***..******.................................................................................................................................................. Finished in 0.7 seconds (0.7s async, 0.00s sync) 157 tests, 0 failures, 9 skipped ``` sync: ``` root@812d17669fe3:/app# mix test Compiling 3 files (.ex) ......................................................................................******............08:54:11.449 [error] Postgrex.Protocol (#PID<0.394.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.2162.0> exited ...............***................................... Finished in 1.6 seconds (0.00s async, 1.6s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 38709 root@812d17669fe3:/app# mix test .................................................................................******.........................08:54:18.537 [error] Postgrex.Protocol (#PID<0.373.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.2293.0> exited .............***............................. Finished in 1.8 seconds (0.00s async, 1.8s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 848590 root@812d17669fe3:/app# mix test ......................................................................................******...........08:54:22.337 [error] Postgrex.Protocol (#PID<0.374.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.2118.0> exited ..............***..................................... Finished in 1.8 seconds (0.00s async, 1.8s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 729972 root@812d17669fe3:/app# mix test ......................................................................................******........................08:54:26.003 [error] Postgrex.Protocol (#PID<0.375.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.2282.0> exited .......***............................... Finished in 1.9 seconds (0.00s async, 1.9s sync) 157 tests, 0 failures, 9 skipped Randomized with seed 249736 root@812d17669fe3:/app# mix test ..........................................................................******..............................08:54:29.869 [error] Postgrex.Protocol (#PID<0.370.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.2196.0> exited .........***................................... Finished in 1.8 seconds (0.00s async, 1.8s sync) 157 tests, 0 failures, 9 skipped ``` Magically it also seems to have gotten rid off that one error, but really don't ask me why.
PragTob
commented
Nov 3, 2024
PragTob
commented
Nov 3, 2024
@PragTob locally, just got this. Maybe you can have a look at it. Its a random fail, does not happen every time:
|
@JannikStreek yup that's a classic, you can't run tests in parallel and assert logs with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tests run sync by default. But all of Elixir, essentially, is built to run tests in parallel/async. Unless you mess with the global environment there's usually no reason not to run tests in parallel and it's also best practice to always pass either
async: true
orasync: false
and a reason why they can't be run in parallel.Speeds up the test suite, admittedly not by a lot right now but it's nice.
Also enables a lint for these.
I didn't check all the tests for global state, so this may introduce flakies but on a first couple of runs everything seemed fine.
async:
sync:
Magically it also seems to have gotten rid off that one error, but really don't ask me why.
Further Notes
New Features / Enhancements
After Merge Checklist