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

Fixes flaky test #2798

Merged
merged 2 commits into from
Nov 14, 2023
Merged

Fixes flaky test #2798

merged 2 commits into from
Nov 14, 2023

Conversation

SpeedReach
Copy link
Contributor

@SpeedReach SpeedReach commented Nov 12, 2023

fixes https://github.com/tokio-rs/tracing/actions/runs/6785393202/job/18443641813

cargo test runs tests in the same file in parallel by default, causing race condition,
this can be proven by running
cargo test --test reload -- --test-threads=1 => successes
cargo test --test reload -- --test-threads=2 => flaky
multiple times

This fix runs only the two tests in serial.
We could seperate the tests in different files, but they share the same testing dependencies, so I left them in the same file.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good solution for handling test flakiness, very clever!

in the past, we've generally solved this kind of issue by isolating the tests in their own test files, but the approach of using a single test function with both tests in sequence seems much less annoying.

thank you for the fix!

@hawkw hawkw enabled auto-merge (squash) November 14, 2023 17:19
@hawkw hawkw merged commit 8ba80ae into tokio-rs:master Nov 14, 2023
53 of 55 checks passed
hds pushed a commit that referenced this pull request Nov 19, 2024
fixes https://github.com/tokio-rs/tracing/actions/runs/6785393202/job/18443641813

cargo test runs tests in the same file in parallel by default, causing race condition,
this can be proven by running
`cargo test --test reload -- --test-threads=1` => successes
`cargo test --test reload -- --test-threads=2` => flaky
multiple times

This fix runs only the two tests in serial.
We could seperate the tests in different files, but they share the same testing dependencies, so I left them in the same file.
hds pushed a commit that referenced this pull request Nov 21, 2024
fixes https://github.com/tokio-rs/tracing/actions/runs/6785393202/job/18443641813

cargo test runs tests in the same file in parallel by default, causing race condition,
this can be proven by running
`cargo test --test reload -- --test-threads=1` => successes
`cargo test --test reload -- --test-threads=2` => flaky
multiple times

This fix runs only the two tests in serial.
We could seperate the tests in different files, but they share the same testing dependencies, so I left them in the same file.
hds pushed a commit that referenced this pull request Nov 22, 2024
fixes https://github.com/tokio-rs/tracing/actions/runs/6785393202/job/18443641813

cargo test runs tests in the same file in parallel by default, causing race condition,
this can be proven by running
`cargo test --test reload -- --test-threads=1` => successes
`cargo test --test reload -- --test-threads=2` => flaky
multiple times

This fix runs only the two tests in serial.
We could seperate the tests in different files, but they share the same testing dependencies, so I left them in the same file.
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.

2 participants