-
Notifications
You must be signed in to change notification settings - Fork 111
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
Show tracing output only for failed tests #959
Show tracing output only for failed tests #959
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you use tracing_subscriber::EnvFilter::from_default_env()
, but we don't set RUST_LOG
var in CI. That means only ERROR
traces will be printed. Please add RUST_LOG
to all CI cargo test
calls so that all traces are printed (as we discussed).
261abb5
to
45b8120
Compare
Before, tracing crate's prints weren't captured during tests. Those with error level used to bloat tests' output, which was especially painful in CI. OTOH, we wanted to have traces visible in failed tests in order to easier spot the cause of a failure. By using tracing_subscriber's TestWriter, tracing's prints are now captured and only shown if a test fails. This enables efficient troubleshooting especially in case of flaky tests, as those are common in CI only and hard to be reproduced locally. For all tests to easily use the captured tracing, a function setup_tracing() is introduced. This commit adds it to scylla crate unit tests. Integration tests and proxy tests are covered in next commits.
As described in the previous commit, setup_tracing() enables captured trace output for tests. Not to make scylla crate depend on tracing_subscriber (now it's only a dev-dependency), the function is simply copied to integration/utils.rs. Integration tests are made call that function at the beginning.
As explained in previous commits, setup_tracing() enables captured tracing outputs in tests.
...so that new tests have setup_tracing() added. Co-authored-by: Karol Baryła <[email protected]>
Now, iff a test fails in the CI, all its logs are preserved and available for further investigation.
It sometimes happens that a test with a random seed fails (especially in the CI). With this debug print and previous commits enabling tracing capturing, debugging such a case should be easier now.
The test was originally created for round-robin default load balancing policy. As the current default policy randomly picks a replica instead, the test became flaky. To mitigate this and still check that various replicas are queried in the non-LWT case: - number of iterations is increased from 15 to 30; - asserted condition is weakened: so far we asserted that all replicas were queried; now more-than-one replica suffice.
45b8120
to
5cec4fa
Compare
Motivation
Flaky tests keep disrupting our CI. Those test failures are often difficult to reproduce locally. A way is needed to debug tests that failed in CI.
On the other hand, error traces bloat outputs.
What's done
tracing_subscriber
'sTestWriter,
tracing's prints are now captured and only shown if a test fails;setup_tracing()
is introduced and added to most tests inscylla
andscylla-proxy
crates.CONTIBUTING.md
is updated to mentionsetup_tracing()
's intended usage.Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have provided docstrings for the public items that I want to introduce.[ ] I have adjusted the documentation in./docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.