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

Show tracing output only for failed tests #959

Merged
merged 7 commits into from
Mar 19, 2024

Conversation

wprzytula
Copy link
Collaborator

@wprzytula wprzytula commented Mar 14, 2024

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

  • by using tracing_subscriber's TestWriter, tracing's prints are now captured and only shown if a test fails;
  • for all tests to easily employ the captured tracing, a function setup_tracing() is introduced and added to most tests in scylla and scylla-proxy crates.
  • CONTIBUTING.md is updated to mention setup_tracing()'s intended usage.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • [ ] I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • [ ] I have provided docstrings for the public items that I want to introduce.
  • [ ] I have adjusted the documentation in ./docs/source/.
  • [ ] I added appropriate Fixes: annotations to PR description.

@wprzytula wprzytula added the symptom/ci stability Related to continuous integration label Mar 14, 2024
@wprzytula wprzytula requested a review from Lorak-mmk March 14, 2024 19:31
Copy link

github-actions bot commented Mar 14, 2024

cargo semver-checks found no API-breaking changes in this PR! 🎉🥳
Checked commit: 5cec4fa

Copy link
Collaborator

@Lorak-mmk Lorak-mmk left a 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).

scylla/tests/integration/lwt_optimisation.rs Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@wprzytula wprzytula force-pushed the show-tracing-logs-iff-test-failed branch from 261abb5 to 45b8120 Compare March 19, 2024 08:08
wprzytula and others added 7 commits March 19, 2024 10:01
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.
@wprzytula wprzytula force-pushed the show-tracing-logs-iff-test-failed branch from 45b8120 to 5cec4fa Compare March 19, 2024 09:16
@wprzytula wprzytula requested a review from Lorak-mmk March 19, 2024 09:17
@Lorak-mmk Lorak-mmk merged commit cf0b1cd into scylladb:main Mar 19, 2024
11 checks passed
@wprzytula wprzytula deleted the show-tracing-logs-iff-test-failed branch March 19, 2024 09:53
@Lorak-mmk Lorak-mmk mentioned this pull request May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
symptom/ci stability Related to continuous integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants